From 75f29bffae96ccfc64cd83334d265f9a1a36586e Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Tue, 10 Feb 2026 11:01:02 +0100 Subject: [PATCH 01/25] Pretty printer generator --- Makefile | 26 +- .../src/lqp/generated_pretty_printer.py | 3487 +++++++++++++++++ python-tools/src/meta/cli.py | 39 +- python-tools/src/meta/codegen_base.py | 83 +- python-tools/src/meta/codegen_julia.py | 37 + python-tools/src/meta/codegen_python.py | 63 + python-tools/src/meta/codegen_templates.py | 41 + python-tools/src/meta/grammar.py | 14 +- python-tools/src/meta/grammar.y | 660 +++- python-tools/src/meta/grammar_utils.py | 1 + python-tools/src/meta/pretty_gen.py | 503 +++ python-tools/src/meta/pretty_gen_python.py | 139 + python-tools/src/meta/target.py | 45 +- python-tools/src/meta/target_builtins.py | 25 + python-tools/src/meta/target_utils.py | 32 +- python-tools/src/meta/yacc_action_parser.py | 281 +- python-tools/src/meta/yacc_parser.py | 64 +- python-tools/tests/meta/test_analysis.py | 206 +- .../tests/meta/test_cli_integration.py | 6 +- .../tests/meta/test_end_to_end_validation.py | 44 +- python-tools/tests/meta/test_grammar.py | 36 +- python-tools/tests/meta/test_grammar_utils.py | 18 +- .../tests/meta/test_grammar_validator.py | 40 +- python-tools/tests/meta/test_parser_gen.py | 46 +- .../tests/meta/test_terminal_sequence_set.py | 16 +- 25 files changed, 5540 insertions(+), 412 deletions(-) create mode 100644 python-tools/src/lqp/generated_pretty_printer.py create mode 100644 python-tools/src/meta/pretty_gen.py create mode 100644 python-tools/src/meta/pretty_gen_python.py diff --git a/Makefile b/Makefile index 8b418a51..c516460f 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ # Makefile for the Logical Query Protocol (LQP) # # Usage: -# make Build protobuf bindings and regenerate all parsers. +# make Build protobuf bindings and regenerate all parsers and printers. # make build Lint, check breaking changes, and generate protobuf code. # make parsers Regenerate Python and Julia parsers from the grammar. # make parser-X Regenerate a single parser (X = python, julia). # make force-parsers Force-regenerate both parsers. # make force-parser-X Force-regenerate a single parser. +# make printers Regenerate pretty printers from the grammar. +# make printer-X Regenerate a single printer (X = python, go, julia). # make test Run tests for all languages. # make test-X Run tests for one language (X = python, julia). # make clean Remove temporary generated files. @@ -29,6 +31,11 @@ JL_PROTO_DIR := julia/LQPParser/src/relationalai/lqp/v1 PY_PARSER := python-tools/src/lqp/generated_parser.py JL_PARSER := julia/LQPParser/src/parser.jl +# Generated pretty printer outputs +PY_PRINTER := python-tools/src/lqp/generated_pretty_printer.py +JL_PRINTER := julia/LQPParser/src/pretty_printer.jl +GO_PRINTER := go/src/pretty_printer.go + # Parser templates PY_TEMPLATE := python-tools/src/meta/templates/parser.py.template JL_TEMPLATE := python-tools/src/meta/templates/parser.jl.template @@ -44,10 +51,11 @@ META_PROTO_ARGS := \ .PHONY: all build lint breaking protobuf protobuf-py protobuf-julia parsers \ parser-python parser-julia \ force-parsers force-parser-python force-parser-julia \ + printers printer-python printer-julia printer-go \ test test-python test-julia check-python \ clean -all: build parsers +all: build parsers printers # ---------- protobuf build (replaces ./build script) ---------- @@ -96,6 +104,20 @@ force-parser-python: force-parser-julia: $(META_CLI) $(META_PROTO_ARGS) --parser julia -o ../julia/LQPParser/src/parser.jl +# ---------- pretty printer generation ---------- + +printers: printer-python printer-julia printer-go + +printer-python: $(PY_PRINTER) +$(PY_PRINTER): $(PROTO_FILES) $(GRAMMAR) + $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/generated_pretty_printer.py + +printer-julia: + @echo "Pretty printer generation for Julia is not yet implemented." + +printer-go: + @echo "Pretty printer generation for Go is not yet implemented." + # ---------- testing ---------- test: test-python test-julia diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py new file mode 100644 index 00000000..cb810da0 --- /dev/null +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -0,0 +1,3487 @@ +""" +Auto-generated pretty printer. + +Generated from protobuf specifications. +Do not modify this file! If you need to modify the pretty printer, edit the generator code +in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. + + +Command: python -m meta.cli ../proto/relationalai/lqp/v1/fragments.proto ../proto/relationalai/lqp/v1/logic.proto ../proto/relationalai/lqp/v1/transactions.proto --grammar src/meta/grammar.y --printer python +""" + +from io import StringIO +from typing import Any, IO + +from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 + + +class PrettyPrinter: + """Pretty printer for protobuf messages.""" + + def __init__(self, io: IO[str] = None): + self.io = io if io is not None else StringIO() + self.indent_level = 0 + self.at_line_start = True + + def write(self, s: str) -> None: + """Write a string to the output, with indentation at line start.""" + if self.at_line_start and s.strip(): + self.io.write(' ' * self.indent_level) + self.at_line_start = False + self.io.write(s) + + def newline(self) -> None: + """Write a newline to the output.""" + self.io.write('\n') + self.at_line_start = True + + def indent(self, delta: int = 1) -> None: + """Increase indentation level.""" + self.indent_level += delta + + def dedent(self, delta: int = 1) -> None: + """Decrease indentation level.""" + self.indent_level = max(0, self.indent_level - delta) + + def get_output(self) -> str: + """Get the accumulated output as a string.""" + if isinstance(self.io, StringIO): + return self.io.getvalue() + return "" + + def format_decimal(self, msg) -> str: + """Format a DecimalValue protobuf message as a string.""" + # DecimalValue has 'value' field as string + return str(msg.value) if msg.value else "0" + + def format_int128(self, msg) -> str: + """Format an Int128Value protobuf message as a string.""" + value = (msg.high << 64) | msg.low + if msg.high & (1 << 63): + value -= (1 << 128) + return str(value) + + def format_uint128(self, msg) -> str: + """Format a UInt128Value protobuf message as a hex string.""" + value = (msg.high << 64) | msg.low + return f"0x{value:032x}" + + def fragment_id_to_string(self, msg) -> str: + """Convert FragmentId to string representation.""" + return msg.id.decode('utf-8') if msg.id else "" + + def relation_id_to_string(self, msg): + """Convert RelationId to string representation if it has symbol.""" + if msg.symbol: + return msg.symbol + return None + + def relation_id_to_int(self, msg): + """Convert RelationId to int representation if it has id.""" + if msg.id_low or msg.id_high: + return (msg.id_high << 64) | msg.id_low + return None + + def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: + def _t493(_dollar_dollar): + _t494 = Parser.is_default_configure(_dollar_dollar.configure) + + if not _t494: + _t495 = (_dollar_dollar.configure, _dollar_dollar.sync, _dollar_dollar.epochs,) + else: + _t495 = None + return _t495 + _t496 = _t493(msg) + fields0 = _t496 + unwrapped_fields1 = fields0 + self.write('(') + self.write('transaction') + self.newline() + self.indent() + field2 = unwrapped_fields1[0] + + if field2 is not None: + opt_val3 = field2 + _t498 = self.pretty_configure(opt_val3) + _t497 = _t498 + else: + _t497 = None + self.newline() + field4 = unwrapped_fields1[1] + + if field4 is not None: + opt_val5 = field4 + _t500 = self.pretty_sync(opt_val5) + _t499 = _t500 + else: + _t499 = None + self.newline() + field6 = unwrapped_fields1[2] + for i8, elem7 in enumerate(field6): + + if (i8 > 0): + self.newline() + _t501 = None + else: + _t501 = None + _t502 = self.pretty_epoch(elem7) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: + def _t503(_dollar_dollar): + _t504 = Parser.deconstruct_configure(_dollar_dollar) + return _t504 + _t505 = _t503(msg) + fields9 = _t505 + unwrapped_fields10 = fields9 + self.write('(') + self.write('configure') + self.newline() + self.indent() + _t506 = self.pretty_config_dict(unwrapped_fields10) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: + def _t507(_dollar_dollar): + return _dollar_dollar + _t508 = _t507(msg) + fields11 = _t508 + unwrapped_fields12 = fields11 + self.write('{') + for i14, elem13 in enumerate(unwrapped_fields12): + + if (i14 > 0): + self.newline() + _t509 = None + else: + _t509 = None + _t510 = self.pretty_config_key_value(elem13) + self.write('}') + return None + + def pretty_config_key_value(self, msg: tuple[str, logic_pb2.Value]) -> Optional[Never]: + def _t511(_dollar_dollar): + return (_dollar_dollar[0], _dollar_dollar[1],) + _t512 = _t511(msg) + fields15 = _t512 + unwrapped_fields16 = fields15 + self.write(':') + field17 = unwrapped_fields16[0] + self.write(field17) + field18 = unwrapped_fields16[1] + _t513 = self.pretty_value(field18) + return _t513 + + def pretty_value(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t514(_dollar_dollar): + + if _dollar_dollar.HasField('date_value'): + _t515 = _dollar_dollar.date_value + else: + _t515 = None + return _t515 + _t516 = _t514(msg) + deconstruct_result29 = _t516 + + if deconstruct_result29 is not None: + _t518 = self.pretty_date(deconstruct_result29) + _t517 = _t518 + else: + def _t519(_dollar_dollar): + + if _dollar_dollar.HasField('datetime_value'): + _t520 = _dollar_dollar.datetime_value + else: + _t520 = None + return _t520 + _t521 = _t519(msg) + deconstruct_result28 = _t521 + + if deconstruct_result28 is not None: + _t523 = self.pretty_datetime(deconstruct_result28) + _t522 = _t523 + else: + def _t524(_dollar_dollar): + + if _dollar_dollar.HasField('string_value'): + _t525 = _dollar_dollar.string_value + else: + _t525 = None + return _t525 + _t526 = _t524(msg) + deconstruct_result27 = _t526 + + if deconstruct_result27 is not None: + self.write(repr(deconstruct_result27)) + _t527 = None + else: + def _t528(_dollar_dollar): + + if _dollar_dollar.HasField('int_value'): + _t529 = _dollar_dollar.int_value + else: + _t529 = None + return _t529 + _t530 = _t528(msg) + deconstruct_result26 = _t530 + + if deconstruct_result26 is not None: + self.write(str(deconstruct_result26)) + _t531 = None + else: + def _t532(_dollar_dollar): + + if _dollar_dollar.HasField('float_value'): + _t533 = _dollar_dollar.float_value + else: + _t533 = None + return _t533 + _t534 = _t532(msg) + deconstruct_result25 = _t534 + + if deconstruct_result25 is not None: + self.write(str(deconstruct_result25)) + _t535 = None + else: + def _t536(_dollar_dollar): + + if _dollar_dollar.HasField('uint128_value'): + _t537 = _dollar_dollar.uint128_value + else: + _t537 = None + return _t537 + _t538 = _t536(msg) + deconstruct_result24 = _t538 + + if deconstruct_result24 is not None: + self.write(str(deconstruct_result24)) + _t539 = None + else: + def _t540(_dollar_dollar): + + if _dollar_dollar.HasField('int128_value'): + _t541 = _dollar_dollar.int128_value + else: + _t541 = None + return _t541 + _t542 = _t540(msg) + deconstruct_result23 = _t542 + + if deconstruct_result23 is not None: + self.write(str(deconstruct_result23)) + _t543 = None + else: + def _t544(_dollar_dollar): + + if _dollar_dollar.HasField('decimal_value'): + _t545 = _dollar_dollar.decimal_value + else: + _t545 = None + return _t545 + _t546 = _t544(msg) + deconstruct_result22 = _t546 + + if deconstruct_result22 is not None: + self.write(str(deconstruct_result22)) + _t547 = None + else: + def _t548(_dollar_dollar): + + if _dollar_dollar.HasField('boolean_value'): + _t549 = _dollar_dollar.boolean_value + else: + _t549 = None + return _t549 + _t550 = _t548(msg) + deconstruct_result21 = _t550 + + if deconstruct_result21 is not None: + _t552 = self.pretty_boolean_value(deconstruct_result21) + _t551 = _t552 + else: + def _t553(_dollar_dollar): + return _dollar_dollar + _t554 = _t553(msg) + fields19 = _t554 + unwrapped_fields20 = fields19 + self.write('missing') + _t551 = None + _t547 = _t551 + _t543 = _t547 + _t539 = _t543 + _t535 = _t539 + _t531 = _t535 + _t527 = _t531 + _t522 = _t527 + _t517 = _t522 + return _t517 + + def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: + def _t555(_dollar_dollar): + _t556 = self.int32_to_int64(_dollar_dollar.year) + _t557 = self.int32_to_int64(_dollar_dollar.month) + _t558 = self.int32_to_int64(_dollar_dollar.day) + return (_t556, _t557, _t558,) + _t559 = _t555(msg) + fields30 = _t559 + unwrapped_fields31 = fields30 + self.write('(') + self.write('date') + self.newline() + self.indent() + field32 = unwrapped_fields31[0] + self.write(str(field32)) + self.newline() + field33 = unwrapped_fields31[1] + self.write(str(field33)) + self.newline() + field34 = unwrapped_fields31[2] + self.write(str(field34)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: + def _t560(_dollar_dollar): + _t561 = self.int32_to_int64(_dollar_dollar.year) + _t562 = self.int32_to_int64(_dollar_dollar.month) + _t563 = self.int32_to_int64(_dollar_dollar.day) + _t564 = self.int32_to_int64(_dollar_dollar.hour) + _t565 = self.int32_to_int64(_dollar_dollar.minute) + _t566 = self.int32_to_int64(_dollar_dollar.second) + _t567 = self.int32_to_int64(_dollar_dollar.microsecond) + return (_t561, _t562, _t563, _t564, _t565, _t566, _t567,) + _t568 = _t560(msg) + fields35 = _t568 + unwrapped_fields36 = fields35 + self.write('(') + self.write('datetime') + self.newline() + self.indent() + field37 = unwrapped_fields36[0] + self.write(str(field37)) + self.newline() + field38 = unwrapped_fields36[1] + self.write(str(field38)) + self.newline() + field39 = unwrapped_fields36[2] + self.write(str(field39)) + self.newline() + field40 = unwrapped_fields36[3] + self.write(str(field40)) + self.newline() + field41 = unwrapped_fields36[4] + self.write(str(field41)) + self.newline() + field42 = unwrapped_fields36[5] + self.write(str(field42)) + self.newline() + field43 = unwrapped_fields36[6] + + if field43 is not None: + opt_val44 = field43 + self.write(str(opt_val44)) + _t569 = None + else: + _t569 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_boolean_value(self, msg: bool) -> Optional[Never]: + def _t570(_dollar_dollar): + return _dollar_dollar + _t571 = _t570(msg) + fields47 = _t571 + unwrapped_fields48 = fields47 + self.write('true') + return None + + def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: + def _t572(_dollar_dollar): + return _dollar_dollar.fragments + _t573 = _t572(msg) + fields49 = _t573 + unwrapped_fields50 = fields49 + self.write('(') + self.write('sync') + self.newline() + self.indent() + for i52, elem51 in enumerate(unwrapped_fields50): + + if (i52 > 0): + self.newline() + _t574 = None + else: + _t574 = None + _t575 = self.pretty_fragment_id(elem51) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: + def _t576(_dollar_dollar): + _t577 = self.fragment_id_to_string(_dollar_dollar) + return _t577 + _t578 = _t576(msg) + fields53 = _t578 + unwrapped_fields54 = fields53 + self.write(':') + self.write(unwrapped_fields54) + return None + + def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: + def _t579(_dollar_dollar): + _t580 = self.is_empty(_dollar_dollar.writes) + _t581 = self.is_empty(_dollar_dollar.reads) + + if (not _t580 and not _t581): + _t582 = (_dollar_dollar.writes, _dollar_dollar.reads,) + else: + _t582 = None + return _t582 + _t583 = _t579(msg) + fields55 = _t583 + unwrapped_fields56 = fields55 + self.write('(') + self.write('epoch') + self.newline() + self.indent() + field57 = unwrapped_fields56[0] + + if field57 is not None: + opt_val58 = field57 + _t585 = self.pretty_epoch_writes(opt_val58) + _t584 = _t585 + else: + _t584 = None + self.newline() + field59 = unwrapped_fields56[1] + + if field59 is not None: + opt_val60 = field59 + _t587 = self.pretty_epoch_reads(opt_val60) + _t586 = _t587 + else: + _t586 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: + def _t588(_dollar_dollar): + return _dollar_dollar + _t589 = _t588(msg) + fields61 = _t589 + unwrapped_fields62 = fields61 + self.write('(') + self.write('writes') + self.newline() + self.indent() + for i64, elem63 in enumerate(unwrapped_fields62): + + if (i64 > 0): + self.newline() + _t590 = None + else: + _t590 = None + _t591 = self.pretty_write(elem63) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: + def _t592(_dollar_dollar): + + if _dollar_dollar.HasField('define'): + _t593 = _dollar_dollar.define + else: + _t593 = None + return _t593 + _t594 = _t592(msg) + deconstruct_result67 = _t594 + + if deconstruct_result67 is not None: + _t596 = self.pretty_define(deconstruct_result67) + _t595 = _t596 + else: + def _t597(_dollar_dollar): + + if _dollar_dollar.HasField('undefine'): + _t598 = _dollar_dollar.undefine + else: + _t598 = None + return _t598 + _t599 = _t597(msg) + deconstruct_result66 = _t599 + + if deconstruct_result66 is not None: + _t601 = self.pretty_undefine(deconstruct_result66) + _t600 = _t601 + else: + def _t602(_dollar_dollar): + + if _dollar_dollar.HasField('context'): + _t603 = _dollar_dollar.context + else: + _t603 = None + return _t603 + _t604 = _t602(msg) + deconstruct_result65 = _t604 + + if deconstruct_result65 is not None: + _t606 = self.pretty_context(deconstruct_result65) + _t605 = _t606 + else: + raise ParseError('No matching rule for write') + _t600 = _t605 + _t595 = _t600 + return _t595 + + def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: + def _t607(_dollar_dollar): + return _dollar_dollar.fragment + _t608 = _t607(msg) + fields68 = _t608 + unwrapped_fields69 = fields68 + self.write('(') + self.write('define') + self.newline() + self.indent() + _t609 = self.pretty_fragment(unwrapped_fields69) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: + def _t610(_dollar_dollar): + return (_dollar_dollar.id, _dollar_dollar.declarations,) + _t611 = _t610(msg) + fields70 = _t611 + unwrapped_fields71 = fields70 + self.write('(') + self.write('fragment') + self.newline() + self.indent() + field72 = unwrapped_fields71[0] + _t612 = self.pretty_new_fragment_id(field72) + self.newline() + field73 = unwrapped_fields71[1] + for i75, elem74 in enumerate(field73): + + if (i75 > 0): + self.newline() + _t613 = None + else: + _t613 = None + _t614 = self.pretty_declaration(elem74) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: + def _t615(_dollar_dollar): + return _dollar_dollar + _t616 = _t615(msg) + fields76 = _t616 + unwrapped_fields77 = fields76 + _t617 = self.pretty_fragment_id(unwrapped_fields77) + return _t617 + + def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: + def _t618(_dollar_dollar): + _t619 = self.is_empty(_dollar_dollar.attrs) + + if not _t619: + _t620 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t620 = None + return _t620 + _t621 = _t618(msg) + guard_result81 = _t621 + + if guard_result81 is not None: + _t623 = self.pretty_def(msg) + _t622 = _t623 + else: + def _t624(_dollar_dollar): + + if _dollar_dollar.HasField('algorithm'): + _t625 = _dollar_dollar.algorithm + else: + _t625 = None + return _t625 + _t626 = _t624(msg) + deconstruct_result80 = _t626 + + if deconstruct_result80 is not None: + _t628 = self.pretty_algorithm(deconstruct_result80) + _t627 = _t628 + else: + def _t629(_dollar_dollar): + + if _dollar_dollar.HasField('constraint'): + _t630 = _dollar_dollar.constraint + else: + _t630 = None + return _t630 + _t631 = _t629(msg) + deconstruct_result79 = _t631 + + if deconstruct_result79 is not None: + _t633 = self.pretty_constraint(deconstruct_result79) + _t632 = _t633 + else: + def _t634(_dollar_dollar): + + if _dollar_dollar.HasField('rel_edb'): + _t635 = _dollar_dollar.rel_edb + else: + _t635 = None + return _t635 + _t636 = _t634(msg) + guard_result78 = _t636 + + if guard_result78 is not None: + _t638 = self.pretty_data(msg) + _t637 = _t638 + else: + raise ParseError('No matching rule for declaration') + _t632 = _t637 + _t627 = _t632 + _t622 = _t627 + return _t622 + + def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: + def _t639(_dollar_dollar): + _t640 = self.is_empty(_dollar_dollar.attrs) + + if not _t640: + _t641 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t641 = None + return _t641 + _t642 = _t639(msg) + fields82 = _t642 + unwrapped_fields83 = fields82 + self.write('(') + self.write('def') + self.newline() + self.indent() + field84 = unwrapped_fields83[0] + _t643 = self.pretty_relation_id(field84) + self.newline() + field85 = unwrapped_fields83[1] + _t644 = self.pretty_abstraction(field85) + self.newline() + field86 = unwrapped_fields83[2] + + if field86 is not None: + opt_val87 = field86 + _t646 = self.pretty_attrs(opt_val87) + _t645 = _t646 + else: + _t645 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: + def _t647(_dollar_dollar): + _t648 = Parser.deconstruct_relation_id_string(_dollar_dollar) + return _t648 + _t649 = _t647(msg) + deconstruct_result89 = _t649 + + if deconstruct_result89 is not None: + self.write(':') + self.write(deconstruct_result89) + _t650 = None + else: + def _t651(_dollar_dollar): + _t652 = Parser.deconstruct_relation_id_uint128(_dollar_dollar) + return _t652 + _t653 = _t651(msg) + deconstruct_result88 = _t653 + + if deconstruct_result88 is not None: + self.write(str(deconstruct_result88)) + _t654 = None + else: + raise ParseError('No matching rule for relation_id') + _t650 = _t654 + return _t650 + + def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: + def _t655(_dollar_dollar): + _t656 = Parser.deconstruct_bindings(_dollar_dollar) + return (_t656, _dollar_dollar.value,) + _t657 = _t655(msg) + fields90 = _t657 + unwrapped_fields91 = fields90 + self.write('(') + field92 = unwrapped_fields91[0] + _t658 = self.pretty_bindings(field92) + field93 = unwrapped_fields91[1] + _t659 = self.pretty_formula(field93) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: + def _t660(_dollar_dollar): + _t661 = self.is_empty(_dollar_dollar[1]) + + if not _t661: + _t662 = (_dollar_dollar[0], _dollar_dollar[1],) + else: + _t662 = None + return _t662 + _t663 = _t660(msg) + fields94 = _t663 + unwrapped_fields95 = fields94 + self.write('[') + field96 = unwrapped_fields95[0] + for i98, elem97 in enumerate(field96): + + if (i98 > 0): + self.newline() + _t664 = None + else: + _t664 = None + _t665 = self.pretty_binding(elem97) + field99 = unwrapped_fields95[1] + + if field99 is not None: + opt_val100 = field99 + _t667 = self.pretty_value_bindings(opt_val100) + _t666 = _t667 + else: + _t666 = None + self.write(']') + return None + + def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: + def _t668(_dollar_dollar): + return (_dollar_dollar.var.name, _dollar_dollar.type,) + _t669 = _t668(msg) + fields101 = _t669 + unwrapped_fields102 = fields101 + field103 = unwrapped_fields102[0] + self.write(field103) + self.write('::') + field104 = unwrapped_fields102[1] + _t670 = self.pretty_type(field104) + return _t670 + + def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: + def _t671(_dollar_dollar): + + if _dollar_dollar.HasField('unspecified_type'): + _t672 = _dollar_dollar.unspecified_type + else: + _t672 = None + return _t672 + _t673 = _t671(msg) + deconstruct_result115 = _t673 + + if deconstruct_result115 is not None: + _t675 = self.pretty_unspecified_type(deconstruct_result115) + _t674 = _t675 + else: + def _t676(_dollar_dollar): + + if _dollar_dollar.HasField('string_type'): + _t677 = _dollar_dollar.string_type + else: + _t677 = None + return _t677 + _t678 = _t676(msg) + deconstruct_result114 = _t678 + + if deconstruct_result114 is not None: + _t680 = self.pretty_string_type(deconstruct_result114) + _t679 = _t680 + else: + def _t681(_dollar_dollar): + + if _dollar_dollar.HasField('int_type'): + _t682 = _dollar_dollar.int_type + else: + _t682 = None + return _t682 + _t683 = _t681(msg) + deconstruct_result113 = _t683 + + if deconstruct_result113 is not None: + _t685 = self.pretty_int_type(deconstruct_result113) + _t684 = _t685 + else: + def _t686(_dollar_dollar): + + if _dollar_dollar.HasField('float_type'): + _t687 = _dollar_dollar.float_type + else: + _t687 = None + return _t687 + _t688 = _t686(msg) + deconstruct_result112 = _t688 + + if deconstruct_result112 is not None: + _t690 = self.pretty_float_type(deconstruct_result112) + _t689 = _t690 + else: + def _t691(_dollar_dollar): + + if _dollar_dollar.HasField('uint128_type'): + _t692 = _dollar_dollar.uint128_type + else: + _t692 = None + return _t692 + _t693 = _t691(msg) + deconstruct_result111 = _t693 + + if deconstruct_result111 is not None: + _t695 = self.pretty_uint128_type(deconstruct_result111) + _t694 = _t695 + else: + def _t696(_dollar_dollar): + + if _dollar_dollar.HasField('int128_type'): + _t697 = _dollar_dollar.int128_type + else: + _t697 = None + return _t697 + _t698 = _t696(msg) + deconstruct_result110 = _t698 + + if deconstruct_result110 is not None: + _t700 = self.pretty_int128_type(deconstruct_result110) + _t699 = _t700 + else: + def _t701(_dollar_dollar): + + if _dollar_dollar.HasField('date_type'): + _t702 = _dollar_dollar.date_type + else: + _t702 = None + return _t702 + _t703 = _t701(msg) + deconstruct_result109 = _t703 + + if deconstruct_result109 is not None: + _t705 = self.pretty_date_type(deconstruct_result109) + _t704 = _t705 + else: + def _t706(_dollar_dollar): + + if _dollar_dollar.HasField('datetime_type'): + _t707 = _dollar_dollar.datetime_type + else: + _t707 = None + return _t707 + _t708 = _t706(msg) + deconstruct_result108 = _t708 + + if deconstruct_result108 is not None: + _t710 = self.pretty_datetime_type(deconstruct_result108) + _t709 = _t710 + else: + def _t711(_dollar_dollar): + + if _dollar_dollar.HasField('missing_type'): + _t712 = _dollar_dollar.missing_type + else: + _t712 = None + return _t712 + _t713 = _t711(msg) + deconstruct_result107 = _t713 + + if deconstruct_result107 is not None: + _t715 = self.pretty_missing_type(deconstruct_result107) + _t714 = _t715 + else: + def _t716(_dollar_dollar): + + if _dollar_dollar.HasField('decimal_type'): + _t717 = _dollar_dollar.decimal_type + else: + _t717 = None + return _t717 + _t718 = _t716(msg) + deconstruct_result106 = _t718 + + if deconstruct_result106 is not None: + _t720 = self.pretty_decimal_type(deconstruct_result106) + _t719 = _t720 + else: + def _t721(_dollar_dollar): + + if _dollar_dollar.HasField('boolean_type'): + _t722 = _dollar_dollar.boolean_type + else: + _t722 = None + return _t722 + _t723 = _t721(msg) + deconstruct_result105 = _t723 + + if deconstruct_result105 is not None: + _t725 = self.pretty_boolean_type(deconstruct_result105) + _t724 = _t725 + else: + raise ParseError('No matching rule for type') + _t719 = _t724 + _t714 = _t719 + _t709 = _t714 + _t704 = _t709 + _t699 = _t704 + _t694 = _t699 + _t689 = _t694 + _t684 = _t689 + _t679 = _t684 + _t674 = _t679 + return _t674 + + def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: + def _t726(_dollar_dollar): + return _dollar_dollar + _t727 = _t726(msg) + fields116 = _t727 + unwrapped_fields117 = fields116 + self.write('UNKNOWN') + return None + + def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: + def _t728(_dollar_dollar): + return _dollar_dollar + _t729 = _t728(msg) + fields118 = _t729 + unwrapped_fields119 = fields118 + self.write('STRING') + return None + + def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: + def _t730(_dollar_dollar): + return _dollar_dollar + _t731 = _t730(msg) + fields120 = _t731 + unwrapped_fields121 = fields120 + self.write('INT') + return None + + def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: + def _t732(_dollar_dollar): + return _dollar_dollar + _t733 = _t732(msg) + fields122 = _t733 + unwrapped_fields123 = fields122 + self.write('FLOAT') + return None + + def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: + def _t734(_dollar_dollar): + return _dollar_dollar + _t735 = _t734(msg) + fields124 = _t735 + unwrapped_fields125 = fields124 + self.write('UINT128') + return None + + def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: + def _t736(_dollar_dollar): + return _dollar_dollar + _t737 = _t736(msg) + fields126 = _t737 + unwrapped_fields127 = fields126 + self.write('INT128') + return None + + def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: + def _t738(_dollar_dollar): + return _dollar_dollar + _t739 = _t738(msg) + fields128 = _t739 + unwrapped_fields129 = fields128 + self.write('DATE') + return None + + def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: + def _t740(_dollar_dollar): + return _dollar_dollar + _t741 = _t740(msg) + fields130 = _t741 + unwrapped_fields131 = fields130 + self.write('DATETIME') + return None + + def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: + def _t742(_dollar_dollar): + return _dollar_dollar + _t743 = _t742(msg) + fields132 = _t743 + unwrapped_fields133 = fields132 + self.write('MISSING') + return None + + def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: + def _t744(_dollar_dollar): + _t745 = self.int32_to_int64(_dollar_dollar.precision) + _t746 = self.int32_to_int64(_dollar_dollar.scale) + return (_t745, _t746,) + _t747 = _t744(msg) + fields134 = _t747 + unwrapped_fields135 = fields134 + self.write('(') + self.write('DECIMAL') + self.newline() + self.indent() + field136 = unwrapped_fields135[0] + self.write(str(field136)) + self.newline() + field137 = unwrapped_fields135[1] + self.write(str(field137)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: + def _t748(_dollar_dollar): + return _dollar_dollar + _t749 = _t748(msg) + fields138 = _t749 + unwrapped_fields139 = fields138 + self.write('BOOLEAN') + return None + + def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: + def _t750(_dollar_dollar): + return _dollar_dollar + _t751 = _t750(msg) + fields140 = _t751 + unwrapped_fields141 = fields140 + self.write('|') + for i143, elem142 in enumerate(unwrapped_fields141): + + if (i143 > 0): + self.newline() + _t752 = None + else: + _t752 = None + _t753 = self.pretty_binding(elem142) + return None + + def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: + def _t754(_dollar_dollar): + _t755 = self.is_empty(_dollar_dollar.conjunction.args) + + if (_dollar_dollar.HasField('conjunction') and _t755): + _t756 = _dollar_dollar.conjunction + else: + _t756 = None + return _t756 + _t757 = _t754(msg) + deconstruct_result156 = _t757 + + if deconstruct_result156 is not None: + _t759 = self.pretty_true(deconstruct_result156) + _t758 = _t759 + else: + def _t760(_dollar_dollar): + _t761 = self.is_empty(_dollar_dollar.disjunction.args) + + if (_dollar_dollar.HasField('disjunction') and _t761): + _t762 = _dollar_dollar.disjunction + else: + _t762 = None + return _t762 + _t763 = _t760(msg) + deconstruct_result155 = _t763 + + if deconstruct_result155 is not None: + _t765 = self.pretty_false(deconstruct_result155) + _t764 = _t765 + else: + def _t766(_dollar_dollar): + + if _dollar_dollar.HasField('exists'): + _t767 = _dollar_dollar.exists + else: + _t767 = None + return _t767 + _t768 = _t766(msg) + deconstruct_result154 = _t768 + + if deconstruct_result154 is not None: + _t770 = self.pretty_exists(deconstruct_result154) + _t769 = _t770 + else: + def _t771(_dollar_dollar): + + if _dollar_dollar.HasField('reduce'): + _t772 = _dollar_dollar.reduce + else: + _t772 = None + return _t772 + _t773 = _t771(msg) + deconstruct_result153 = _t773 + + if deconstruct_result153 is not None: + _t775 = self.pretty_reduce(deconstruct_result153) + _t774 = _t775 + else: + def _t776(_dollar_dollar): + _t777 = self.is_empty(_dollar_dollar.conjunction.args) + + if (_dollar_dollar.HasField('conjunction') and not _t777): + _t778 = _dollar_dollar.conjunction + else: + _t778 = None + return _t778 + _t779 = _t776(msg) + deconstruct_result152 = _t779 + + if deconstruct_result152 is not None: + _t781 = self.pretty_conjunction(deconstruct_result152) + _t780 = _t781 + else: + def _t782(_dollar_dollar): + _t783 = self.is_empty(_dollar_dollar.disjunction.args) + + if (_dollar_dollar.HasField('disjunction') and not _t783): + _t784 = _dollar_dollar.disjunction + else: + _t784 = None + return _t784 + _t785 = _t782(msg) + deconstruct_result151 = _t785 + + if deconstruct_result151 is not None: + _t787 = self.pretty_disjunction(deconstruct_result151) + _t786 = _t787 + else: + def _t788(_dollar_dollar): + + if _dollar_dollar.HasField('not'): + _t789 = getattr(_dollar_dollar, 'not') + else: + _t789 = None + return _t789 + _t790 = _t788(msg) + deconstruct_result150 = _t790 + + if deconstruct_result150 is not None: + _t792 = self.pretty_not(deconstruct_result150) + _t791 = _t792 + else: + def _t793(_dollar_dollar): + + if _dollar_dollar.HasField('ffi'): + _t794 = _dollar_dollar.ffi + else: + _t794 = None + return _t794 + _t795 = _t793(msg) + deconstruct_result149 = _t795 + + if deconstruct_result149 is not None: + _t797 = self.pretty_ffi(deconstruct_result149) + _t796 = _t797 + else: + def _t798(_dollar_dollar): + + if _dollar_dollar.HasField('atom'): + _t799 = _dollar_dollar.atom + else: + _t799 = None + return _t799 + _t800 = _t798(msg) + deconstruct_result148 = _t800 + + if deconstruct_result148 is not None: + _t802 = self.pretty_atom(deconstruct_result148) + _t801 = _t802 + else: + def _t803(_dollar_dollar): + + if _dollar_dollar.HasField('pragma'): + _t804 = _dollar_dollar.pragma + else: + _t804 = None + return _t804 + _t805 = _t803(msg) + deconstruct_result147 = _t805 + + if deconstruct_result147 is not None: + _t807 = self.pretty_pragma(deconstruct_result147) + _t806 = _t807 + else: + def _t808(_dollar_dollar): + + if _dollar_dollar.HasField('primitive'): + _t809 = _dollar_dollar.primitive + else: + _t809 = None + return _t809 + _t810 = _t808(msg) + deconstruct_result146 = _t810 + + if deconstruct_result146 is not None: + _t812 = self.pretty_primitive(deconstruct_result146) + _t811 = _t812 + else: + def _t813(_dollar_dollar): + + if _dollar_dollar.HasField('rel_atom'): + _t814 = _dollar_dollar.rel_atom + else: + _t814 = None + return _t814 + _t815 = _t813(msg) + deconstruct_result145 = _t815 + + if deconstruct_result145 is not None: + _t817 = self.pretty_rel_atom(deconstruct_result145) + _t816 = _t817 + else: + def _t818(_dollar_dollar): + + if _dollar_dollar.HasField('cast'): + _t819 = _dollar_dollar.cast + else: + _t819 = None + return _t819 + _t820 = _t818(msg) + deconstruct_result144 = _t820 + + if deconstruct_result144 is not None: + _t822 = self.pretty_cast(deconstruct_result144) + _t821 = _t822 + else: + raise ParseError('No matching rule for formula') + _t816 = _t821 + _t811 = _t816 + _t806 = _t811 + _t801 = _t806 + _t796 = _t801 + _t791 = _t796 + _t786 = _t791 + _t780 = _t786 + _t774 = _t780 + _t769 = _t774 + _t764 = _t769 + _t758 = _t764 + return _t758 + + def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: + def _t823(_dollar_dollar): + return _dollar_dollar + _t824 = _t823(msg) + fields157 = _t824 + unwrapped_fields158 = fields157 + self.write('(') + self.write('true') + self.newline() + self.indent() + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: + def _t825(_dollar_dollar): + return _dollar_dollar + _t826 = _t825(msg) + fields159 = _t826 + unwrapped_fields160 = fields159 + self.write('(') + self.write('false') + self.newline() + self.indent() + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: + def _t827(_dollar_dollar): + _t828 = Parser.deconstruct_bindings(_dollar_dollar.body) + return (_t828, _dollar_dollar.body.value,) + _t829 = _t827(msg) + fields161 = _t829 + unwrapped_fields162 = fields161 + self.write('(') + self.write('exists') + self.newline() + self.indent() + field163 = unwrapped_fields162[0] + _t830 = self.pretty_bindings(field163) + self.newline() + field164 = unwrapped_fields162[1] + _t831 = self.pretty_formula(field164) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: + def _t832(_dollar_dollar): + return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) + _t833 = _t832(msg) + fields165 = _t833 + unwrapped_fields166 = fields165 + self.write('(') + self.write('reduce') + self.newline() + self.indent() + field167 = unwrapped_fields166[0] + _t834 = self.pretty_abstraction(field167) + self.newline() + field168 = unwrapped_fields166[1] + _t835 = self.pretty_abstraction(field168) + self.newline() + field169 = unwrapped_fields166[2] + _t836 = self.pretty_terms(field169) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: + def _t837(_dollar_dollar): + return _dollar_dollar + _t838 = _t837(msg) + fields170 = _t838 + unwrapped_fields171 = fields170 + self.write('(') + self.write('terms') + self.newline() + self.indent() + for i173, elem172 in enumerate(unwrapped_fields171): + + if (i173 > 0): + self.newline() + _t839 = None + else: + _t839 = None + _t840 = self.pretty_term(elem172) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: + def _t841(_dollar_dollar): + + if _dollar_dollar.HasField('var'): + _t842 = _dollar_dollar.var + else: + _t842 = None + return _t842 + _t843 = _t841(msg) + deconstruct_result175 = _t843 + + if deconstruct_result175 is not None: + _t845 = self.pretty_var(deconstruct_result175) + _t844 = _t845 + else: + def _t846(_dollar_dollar): + + if _dollar_dollar.HasField('constant'): + _t847 = _dollar_dollar.constant + else: + _t847 = None + return _t847 + _t848 = _t846(msg) + deconstruct_result174 = _t848 + + if deconstruct_result174 is not None: + _t850 = self.pretty_constant(deconstruct_result174) + _t849 = _t850 + else: + raise ParseError('No matching rule for term') + _t844 = _t849 + return _t844 + + def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: + def _t851(_dollar_dollar): + return _dollar_dollar.name + _t852 = _t851(msg) + fields176 = _t852 + unwrapped_fields177 = fields176 + self.write(unwrapped_fields177) + return None + + def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t853(_dollar_dollar): + return _dollar_dollar + _t854 = _t853(msg) + fields178 = _t854 + unwrapped_fields179 = fields178 + _t855 = self.pretty_value(unwrapped_fields179) + return _t855 + + def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: + def _t856(_dollar_dollar): + return _dollar_dollar.args + _t857 = _t856(msg) + fields180 = _t857 + unwrapped_fields181 = fields180 + self.write('(') + self.write('and') + self.newline() + self.indent() + for i183, elem182 in enumerate(unwrapped_fields181): + + if (i183 > 0): + self.newline() + _t858 = None + else: + _t858 = None + _t859 = self.pretty_formula(elem182) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: + def _t860(_dollar_dollar): + return _dollar_dollar.args + _t861 = _t860(msg) + fields184 = _t861 + unwrapped_fields185 = fields184 + self.write('(') + self.write('or') + self.newline() + self.indent() + for i187, elem186 in enumerate(unwrapped_fields185): + + if (i187 > 0): + self.newline() + _t862 = None + else: + _t862 = None + _t863 = self.pretty_formula(elem186) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: + def _t864(_dollar_dollar): + return _dollar_dollar.arg + _t865 = _t864(msg) + fields188 = _t865 + unwrapped_fields189 = fields188 + self.write('(') + self.write('not') + self.newline() + self.indent() + _t866 = self.pretty_formula(unwrapped_fields189) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: + def _t867(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) + _t868 = _t867(msg) + fields190 = _t868 + unwrapped_fields191 = fields190 + self.write('(') + self.write('ffi') + self.newline() + self.indent() + field192 = unwrapped_fields191[0] + _t869 = self.pretty_name(field192) + self.newline() + field193 = unwrapped_fields191[1] + _t870 = self.pretty_ffi_args(field193) + self.newline() + field194 = unwrapped_fields191[2] + _t871 = self.pretty_terms(field194) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_name(self, msg: str) -> Optional[Never]: + def _t872(_dollar_dollar): + return _dollar_dollar + _t873 = _t872(msg) + fields195 = _t873 + unwrapped_fields196 = fields195 + self.write(':') + self.write(unwrapped_fields196) + return None + + def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: + def _t874(_dollar_dollar): + return _dollar_dollar + _t875 = _t874(msg) + fields197 = _t875 + unwrapped_fields198 = fields197 + self.write('(') + self.write('args') + self.newline() + self.indent() + for i200, elem199 in enumerate(unwrapped_fields198): + + if (i200 > 0): + self.newline() + _t876 = None + else: + _t876 = None + _t877 = self.pretty_abstraction(elem199) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: + def _t878(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t879 = _t878(msg) + fields201 = _t879 + unwrapped_fields202 = fields201 + self.write('(') + self.write('atom') + self.newline() + self.indent() + field203 = unwrapped_fields202[0] + _t880 = self.pretty_relation_id(field203) + self.newline() + field204 = unwrapped_fields202[1] + for i206, elem205 in enumerate(field204): + + if (i206 > 0): + self.newline() + _t881 = None + else: + _t881 = None + _t882 = self.pretty_term(elem205) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: + def _t883(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t884 = _t883(msg) + fields207 = _t884 + unwrapped_fields208 = fields207 + self.write('(') + self.write('pragma') + self.newline() + self.indent() + field209 = unwrapped_fields208[0] + _t885 = self.pretty_name(field209) + self.newline() + field210 = unwrapped_fields208[1] + for i212, elem211 in enumerate(field210): + + if (i212 > 0): + self.newline() + _t886 = None + else: + _t886 = None + _t887 = self.pretty_term(elem211) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t888(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_eq': + _t889 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t889 = None + return _t889 + _t890 = _t888(msg) + guard_result227 = _t890 + + if guard_result227 is not None: + _t892 = self.pretty_eq(msg) + _t891 = _t892 + else: + def _t893(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_monotype': + _t894 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t894 = None + return _t894 + _t895 = _t893(msg) + guard_result226 = _t895 + + if guard_result226 is not None: + _t897 = self.pretty_lt(msg) + _t896 = _t897 + else: + def _t898(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': + _t899 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t899 = None + return _t899 + _t900 = _t898(msg) + guard_result225 = _t900 + + if guard_result225 is not None: + _t902 = self.pretty_lt_eq(msg) + _t901 = _t902 + else: + def _t903(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_monotype': + _t904 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t904 = None + return _t904 + _t905 = _t903(msg) + guard_result224 = _t905 + + if guard_result224 is not None: + _t907 = self.pretty_gt(msg) + _t906 = _t907 + else: + def _t908(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': + _t909 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t909 = None + return _t909 + _t910 = _t908(msg) + guard_result223 = _t910 + + if guard_result223 is not None: + _t912 = self.pretty_gt_eq(msg) + _t911 = _t912 + else: + def _t913(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_add_monotype': + _t914 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t914 = None + return _t914 + _t915 = _t913(msg) + guard_result222 = _t915 + + if guard_result222 is not None: + _t917 = self.pretty_add(msg) + _t916 = _t917 + else: + def _t918(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_subtract_monotype': + _t919 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t919 = None + return _t919 + _t920 = _t918(msg) + guard_result221 = _t920 + + if guard_result221 is not None: + _t922 = self.pretty_minus(msg) + _t921 = _t922 + else: + def _t923(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_multiply_monotype': + _t924 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t924 = None + return _t924 + _t925 = _t923(msg) + guard_result220 = _t925 + + if guard_result220 is not None: + _t927 = self.pretty_multiply(msg) + _t926 = _t927 + else: + def _t928(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_divide_monotype': + _t929 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t929 = None + return _t929 + _t930 = _t928(msg) + guard_result219 = _t930 + + if guard_result219 is not None: + _t932 = self.pretty_divide(msg) + _t931 = _t932 + else: + def _t933(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t934 = _t933(msg) + fields213 = _t934 + unwrapped_fields214 = fields213 + self.write('(') + self.write('primitive') + self.newline() + self.indent() + field215 = unwrapped_fields214[0] + _t935 = self.pretty_name(field215) + self.newline() + field216 = unwrapped_fields214[1] + for i218, elem217 in enumerate(field216): + + if (i218 > 0): + self.newline() + _t936 = None + else: + _t936 = None + _t937 = self.pretty_rel_term(elem217) + self.dedent() + self.write(')') + self.newline() + _t931 = None + _t926 = _t931 + _t921 = _t926 + _t916 = _t921 + _t911 = _t916 + _t906 = _t911 + _t901 = _t906 + _t896 = _t901 + _t891 = _t896 + return _t891 + + def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t938(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_eq': + _t939 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t939 = None + return _t939 + _t940 = _t938(msg) + fields228 = _t940 + unwrapped_fields229 = fields228 + self.write('(') + self.write('=') + self.newline() + self.indent() + field230 = unwrapped_fields229[0] + _t941 = self.pretty_term(field230) + self.newline() + field231 = unwrapped_fields229[1] + _t942 = self.pretty_term(field231) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t943(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_monotype': + _t944 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t944 = None + return _t944 + _t945 = _t943(msg) + fields232 = _t945 + unwrapped_fields233 = fields232 + self.write('(') + self.write('<') + self.newline() + self.indent() + field234 = unwrapped_fields233[0] + _t946 = self.pretty_term(field234) + self.newline() + field235 = unwrapped_fields233[1] + _t947 = self.pretty_term(field235) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t948(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': + _t949 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t949 = None + return _t949 + _t950 = _t948(msg) + fields236 = _t950 + unwrapped_fields237 = fields236 + self.write('(') + self.write('<=') + self.newline() + self.indent() + field238 = unwrapped_fields237[0] + _t951 = self.pretty_term(field238) + self.newline() + field239 = unwrapped_fields237[1] + _t952 = self.pretty_term(field239) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t953(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_monotype': + _t954 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t954 = None + return _t954 + _t955 = _t953(msg) + fields240 = _t955 + unwrapped_fields241 = fields240 + self.write('(') + self.write('>') + self.newline() + self.indent() + field242 = unwrapped_fields241[0] + _t956 = self.pretty_term(field242) + self.newline() + field243 = unwrapped_fields241[1] + _t957 = self.pretty_term(field243) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t958(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': + _t959 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t959 = None + return _t959 + _t960 = _t958(msg) + fields244 = _t960 + unwrapped_fields245 = fields244 + self.write('(') + self.write('>=') + self.newline() + self.indent() + field246 = unwrapped_fields245[0] + _t961 = self.pretty_term(field246) + self.newline() + field247 = unwrapped_fields245[1] + _t962 = self.pretty_term(field247) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t963(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_add_monotype': + _t964 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t964 = None + return _t964 + _t965 = _t963(msg) + fields248 = _t965 + unwrapped_fields249 = fields248 + self.write('(') + self.write('+') + self.newline() + self.indent() + field250 = unwrapped_fields249[0] + _t966 = self.pretty_term(field250) + self.newline() + field251 = unwrapped_fields249[1] + _t967 = self.pretty_term(field251) + self.newline() + field252 = unwrapped_fields249[2] + _t968 = self.pretty_term(field252) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t969(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_subtract_monotype': + _t970 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t970 = None + return _t970 + _t971 = _t969(msg) + fields253 = _t971 + unwrapped_fields254 = fields253 + self.write('(') + self.write('-') + self.newline() + self.indent() + field255 = unwrapped_fields254[0] + _t972 = self.pretty_term(field255) + self.newline() + field256 = unwrapped_fields254[1] + _t973 = self.pretty_term(field256) + self.newline() + field257 = unwrapped_fields254[2] + _t974 = self.pretty_term(field257) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t975(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_multiply_monotype': + _t976 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t976 = None + return _t976 + _t977 = _t975(msg) + fields258 = _t977 + unwrapped_fields259 = fields258 + self.write('(') + self.write('*') + self.newline() + self.indent() + field260 = unwrapped_fields259[0] + _t978 = self.pretty_term(field260) + self.newline() + field261 = unwrapped_fields259[1] + _t979 = self.pretty_term(field261) + self.newline() + field262 = unwrapped_fields259[2] + _t980 = self.pretty_term(field262) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t981(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_divide_monotype': + _t982 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t982 = None + return _t982 + _t983 = _t981(msg) + fields263 = _t983 + unwrapped_fields264 = fields263 + self.write('(') + self.write('/') + self.newline() + self.indent() + field265 = unwrapped_fields264[0] + _t984 = self.pretty_term(field265) + self.newline() + field266 = unwrapped_fields264[1] + _t985 = self.pretty_term(field266) + self.newline() + field267 = unwrapped_fields264[2] + _t986 = self.pretty_term(field267) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: + def _t987(_dollar_dollar): + + if _dollar_dollar.HasField('specialized_value'): + _t988 = _dollar_dollar.specialized_value + else: + _t988 = None + return _t988 + _t989 = _t987(msg) + deconstruct_result269 = _t989 + + if deconstruct_result269 is not None: + _t991 = self.pretty_specialized_value(deconstruct_result269) + _t990 = _t991 + else: + def _t992(_dollar_dollar): + + if _dollar_dollar.HasField('var'): + _t993 = _dollar_dollar.var + else: + _t993 = None + return _t993 + _t994 = _t992(msg) + guard_result268 = _t994 + + if guard_result268 is not None: + _t996 = self.pretty_term(msg) + _t995 = _t996 + else: + raise ParseError('No matching rule for rel_term') + _t990 = _t995 + return _t990 + + def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t997(_dollar_dollar): + return _dollar_dollar + _t998 = _t997(msg) + fields270 = _t998 + unwrapped_fields271 = fields270 + self.write('#') + _t999 = self.pretty_value(unwrapped_fields271) + return _t999 + + def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: + def _t1000(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t1001 = _t1000(msg) + fields272 = _t1001 + unwrapped_fields273 = fields272 + self.write('(') + self.write('relatom') + self.newline() + self.indent() + field274 = unwrapped_fields273[0] + _t1002 = self.pretty_name(field274) + self.newline() + field275 = unwrapped_fields273[1] + for i277, elem276 in enumerate(field275): + + if (i277 > 0): + self.newline() + _t1003 = None + else: + _t1003 = None + _t1004 = self.pretty_rel_term(elem276) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: + def _t1005(_dollar_dollar): + return (_dollar_dollar.input, _dollar_dollar.result,) + _t1006 = _t1005(msg) + fields278 = _t1006 + unwrapped_fields279 = fields278 + self.write('(') + self.write('cast') + self.newline() + self.indent() + field280 = unwrapped_fields279[0] + _t1007 = self.pretty_term(field280) + self.newline() + field281 = unwrapped_fields279[1] + _t1008 = self.pretty_term(field281) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: + def _t1009(_dollar_dollar): + return _dollar_dollar + _t1010 = _t1009(msg) + fields282 = _t1010 + unwrapped_fields283 = fields282 + self.write('(') + self.write('attrs') + self.newline() + self.indent() + for i285, elem284 in enumerate(unwrapped_fields283): + + if (i285 > 0): + self.newline() + _t1011 = None + else: + _t1011 = None + _t1012 = self.pretty_attribute(elem284) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: + def _t1013(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.args,) + _t1014 = _t1013(msg) + fields286 = _t1014 + unwrapped_fields287 = fields286 + self.write('(') + self.write('attribute') + self.newline() + self.indent() + field288 = unwrapped_fields287[0] + _t1015 = self.pretty_name(field288) + self.newline() + field289 = unwrapped_fields287[1] + for i291, elem290 in enumerate(field289): + + if (i291 > 0): + self.newline() + _t1016 = None + else: + _t1016 = None + _t1017 = self.pretty_value(elem290) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: + def _t1018(_dollar_dollar): + return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) + _t1019 = _t1018(msg) + fields292 = _t1019 + unwrapped_fields293 = fields292 + self.write('(') + self.write('algorithm') + self.newline() + self.indent() + field294 = unwrapped_fields293[0] + for i296, elem295 in enumerate(field294): + + if (i296 > 0): + self.newline() + _t1020 = None + else: + _t1020 = None + _t1021 = self.pretty_relation_id(elem295) + self.newline() + field297 = unwrapped_fields293[1] + _t1022 = self.pretty_script(field297) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: + def _t1023(_dollar_dollar): + return _dollar_dollar.constructs + _t1024 = _t1023(msg) + fields298 = _t1024 + unwrapped_fields299 = fields298 + self.write('(') + self.write('script') + self.newline() + self.indent() + for i301, elem300 in enumerate(unwrapped_fields299): + + if (i301 > 0): + self.newline() + _t1025 = None + else: + _t1025 = None + _t1026 = self.pretty_construct(elem300) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: + def _t1027(_dollar_dollar): + + if _dollar_dollar.HasField('loop'): + _t1028 = _dollar_dollar.loop + else: + _t1028 = None + return _t1028 + _t1029 = _t1027(msg) + deconstruct_result303 = _t1029 + + if deconstruct_result303 is not None: + _t1031 = self.pretty_loop(deconstruct_result303) + _t1030 = _t1031 + else: + def _t1032(_dollar_dollar): + + if _dollar_dollar.HasField('assign'): + _t1033 = _dollar_dollar.assign + else: + _t1033 = None + return _t1033 + _t1034 = _t1032(msg) + guard_result302 = _t1034 + + if guard_result302 is not None: + _t1036 = self.pretty_instruction(msg) + _t1035 = _t1036 + else: + raise ParseError('No matching rule for construct') + _t1030 = _t1035 + return _t1030 + + def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: + def _t1037(_dollar_dollar): + return (_dollar_dollar.init, _dollar_dollar.body,) + _t1038 = _t1037(msg) + fields304 = _t1038 + unwrapped_fields305 = fields304 + self.write('(') + self.write('loop') + self.newline() + self.indent() + field306 = unwrapped_fields305[0] + _t1039 = self.pretty_init(field306) + self.newline() + field307 = unwrapped_fields305[1] + _t1040 = self.pretty_script(field307) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: + def _t1041(_dollar_dollar): + return _dollar_dollar + _t1042 = _t1041(msg) + fields308 = _t1042 + unwrapped_fields309 = fields308 + self.write('(') + self.write('init') + self.newline() + self.indent() + for i311, elem310 in enumerate(unwrapped_fields309): + + if (i311 > 0): + self.newline() + _t1043 = None + else: + _t1043 = None + _t1044 = self.pretty_instruction(elem310) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: + def _t1045(_dollar_dollar): + _t1046 = self.is_empty(_dollar_dollar.attrs) + + if not _t1046: + _t1047 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t1047 = None + return _t1047 + _t1048 = _t1045(msg) + guard_result316 = _t1048 + + if guard_result316 is not None: + _t1050 = self.pretty_assign(msg) + _t1049 = _t1050 + else: + def _t1051(_dollar_dollar): + _t1052 = self.is_empty(_dollar_dollar.attrs) + + if not _t1052: + _t1053 = (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1053 = None + return _t1053 + _t1054 = _t1051(msg) + guard_result315 = _t1054 + + if guard_result315 is not None: + _t1056 = self.pretty_upsert(msg) + _t1055 = _t1056 + else: + def _t1057(_dollar_dollar): + _t1058 = self.is_empty(_dollar_dollar.attrs) + + if not _t1058: + _t1059 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t1059 = None + return _t1059 + _t1060 = _t1057(msg) + guard_result314 = _t1060 + + if guard_result314 is not None: + _t1062 = self.pretty_break(msg) + _t1061 = _t1062 + else: + def _t1063(_dollar_dollar): + _t1064 = self.is_empty(_dollar_dollar.attrs) + + if not _t1064: + _t1065 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1065 = None + return _t1065 + _t1066 = _t1063(msg) + guard_result313 = _t1066 + + if guard_result313 is not None: + _t1068 = self.pretty_monoid_def(msg) + _t1067 = _t1068 + else: + def _t1069(_dollar_dollar): + _t1070 = self.is_empty(_dollar_dollar.attrs) + + if not _t1070: + _t1071 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1071 = None + return _t1071 + _t1072 = _t1069(msg) + guard_result312 = _t1072 + + if guard_result312 is not None: + _t1074 = self.pretty_monus_def(msg) + _t1073 = _t1074 + else: + raise ParseError('No matching rule for instruction') + _t1067 = _t1073 + _t1061 = _t1067 + _t1055 = _t1061 + _t1049 = _t1055 + return _t1049 + + def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: + def _t1075(_dollar_dollar): + _t1076 = self.is_empty(_dollar_dollar.attrs) + + if not _t1076: + _t1077 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t1077 = None + return _t1077 + _t1078 = _t1075(msg) + fields317 = _t1078 + unwrapped_fields318 = fields317 + self.write('(') + self.write('assign') + self.newline() + self.indent() + field319 = unwrapped_fields318[0] + _t1079 = self.pretty_relation_id(field319) + self.newline() + field320 = unwrapped_fields318[1] + _t1080 = self.pretty_abstraction(field320) + self.newline() + field321 = unwrapped_fields318[2] + + if field321 is not None: + opt_val322 = field321 + _t1082 = self.pretty_attrs(opt_val322) + _t1081 = _t1082 + else: + _t1081 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: + def _t1083(_dollar_dollar): + _t1084 = self.is_empty(_dollar_dollar.attrs) + + if not _t1084: + _t1085 = (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1085 = None + return _t1085 + _t1086 = _t1083(msg) + fields323 = _t1086 + unwrapped_fields324 = fields323 + self.write('(') + self.write('upsert') + self.newline() + self.indent() + field325 = unwrapped_fields324[0] + _t1087 = self.pretty_relation_id(field325) + self.newline() + field326 = unwrapped_fields324[1] + _t1088 = self.pretty_abstraction_with_arity(field326) + self.newline() + field327 = unwrapped_fields324[2] + + if field327 is not None: + opt_val328 = field327 + _t1090 = self.pretty_attrs(opt_val328) + _t1089 = _t1090 + else: + _t1089 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: + def _t1091(_dollar_dollar): + _t1092 = Parser.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) + return (_t1092, _dollar_dollar[0].value,) + _t1093 = _t1091(msg) + fields329 = _t1093 + unwrapped_fields330 = fields329 + self.write('(') + field331 = unwrapped_fields330[0] + _t1094 = self.pretty_bindings(field331) + field332 = unwrapped_fields330[1] + _t1095 = self.pretty_formula(field332) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: + def _t1096(_dollar_dollar): + _t1097 = self.is_empty(_dollar_dollar.attrs) + + if not _t1097: + _t1098 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + else: + _t1098 = None + return _t1098 + _t1099 = _t1096(msg) + fields333 = _t1099 + unwrapped_fields334 = fields333 + self.write('(') + self.write('break') + self.newline() + self.indent() + field335 = unwrapped_fields334[0] + _t1100 = self.pretty_relation_id(field335) + self.newline() + field336 = unwrapped_fields334[1] + _t1101 = self.pretty_abstraction(field336) + self.newline() + field337 = unwrapped_fields334[2] + + if field337 is not None: + opt_val338 = field337 + _t1103 = self.pretty_attrs(opt_val338) + _t1102 = _t1103 + else: + _t1102 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: + def _t1104(_dollar_dollar): + _t1105 = self.is_empty(_dollar_dollar.attrs) + + if not _t1105: + _t1106 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1106 = None + return _t1106 + _t1107 = _t1104(msg) + fields339 = _t1107 + unwrapped_fields340 = fields339 + self.write('(') + self.write('monoid') + self.newline() + self.indent() + field341 = unwrapped_fields340[0] + _t1108 = self.pretty_monoid(field341) + self.newline() + field342 = unwrapped_fields340[1] + _t1109 = self.pretty_relation_id(field342) + self.newline() + field343 = unwrapped_fields340[2] + _t1110 = self.pretty_abstraction_with_arity(field343) + self.newline() + field344 = unwrapped_fields340[3] + + if field344 is not None: + opt_val345 = field344 + _t1112 = self.pretty_attrs(opt_val345) + _t1111 = _t1112 + else: + _t1111 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: + def _t1113(_dollar_dollar): + + if _dollar_dollar.HasField('or_monoid'): + _t1114 = _dollar_dollar.or_monoid + else: + _t1114 = None + return _t1114 + _t1115 = _t1113(msg) + deconstruct_result349 = _t1115 + + if deconstruct_result349 is not None: + _t1117 = self.pretty_or_monoid(deconstruct_result349) + _t1116 = _t1117 + else: + def _t1118(_dollar_dollar): + + if _dollar_dollar.HasField('min_monoid'): + _t1119 = _dollar_dollar.min_monoid + else: + _t1119 = None + return _t1119 + _t1120 = _t1118(msg) + deconstruct_result348 = _t1120 + + if deconstruct_result348 is not None: + _t1122 = self.pretty_min_monoid(deconstruct_result348) + _t1121 = _t1122 + else: + def _t1123(_dollar_dollar): + + if _dollar_dollar.HasField('max_monoid'): + _t1124 = _dollar_dollar.max_monoid + else: + _t1124 = None + return _t1124 + _t1125 = _t1123(msg) + deconstruct_result347 = _t1125 + + if deconstruct_result347 is not None: + _t1127 = self.pretty_max_monoid(deconstruct_result347) + _t1126 = _t1127 + else: + def _t1128(_dollar_dollar): + + if _dollar_dollar.HasField('sum_monoid'): + _t1129 = _dollar_dollar.sum_monoid + else: + _t1129 = None + return _t1129 + _t1130 = _t1128(msg) + deconstruct_result346 = _t1130 + + if deconstruct_result346 is not None: + _t1132 = self.pretty_sum_monoid(deconstruct_result346) + _t1131 = _t1132 + else: + raise ParseError('No matching rule for monoid') + _t1126 = _t1131 + _t1121 = _t1126 + _t1116 = _t1121 + return _t1116 + + def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: + def _t1133(_dollar_dollar): + return _dollar_dollar + _t1134 = _t1133(msg) + fields350 = _t1134 + unwrapped_fields351 = fields350 + self.write('(') + self.write('or') + self.newline() + self.indent() + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: + def _t1135(_dollar_dollar): + return _dollar_dollar.type + _t1136 = _t1135(msg) + fields352 = _t1136 + unwrapped_fields353 = fields352 + self.write('(') + self.write('min') + self.newline() + self.indent() + _t1137 = self.pretty_type(unwrapped_fields353) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: + def _t1138(_dollar_dollar): + return _dollar_dollar.type + _t1139 = _t1138(msg) + fields354 = _t1139 + unwrapped_fields355 = fields354 + self.write('(') + self.write('max') + self.newline() + self.indent() + _t1140 = self.pretty_type(unwrapped_fields355) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: + def _t1141(_dollar_dollar): + return _dollar_dollar.type + _t1142 = _t1141(msg) + fields356 = _t1142 + unwrapped_fields357 = fields356 + self.write('(') + self.write('sum') + self.newline() + self.indent() + _t1143 = self.pretty_type(unwrapped_fields357) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: + def _t1144(_dollar_dollar): + _t1145 = self.is_empty(_dollar_dollar.attrs) + + if not _t1145: + _t1146 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + else: + _t1146 = None + return _t1146 + _t1147 = _t1144(msg) + fields358 = _t1147 + unwrapped_fields359 = fields358 + self.write('(') + self.write('monus') + self.newline() + self.indent() + field360 = unwrapped_fields359[0] + _t1148 = self.pretty_monoid(field360) + self.newline() + field361 = unwrapped_fields359[1] + _t1149 = self.pretty_relation_id(field361) + self.newline() + field362 = unwrapped_fields359[2] + _t1150 = self.pretty_abstraction_with_arity(field362) + self.newline() + field363 = unwrapped_fields359[3] + + if field363 is not None: + opt_val364 = field363 + _t1152 = self.pretty_attrs(opt_val364) + _t1151 = _t1152 + else: + _t1151 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: + def _t1153(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) + _t1154 = _t1153(msg) + fields365 = _t1154 + unwrapped_fields366 = fields365 + self.write('(') + self.write('functional_dependency') + self.newline() + self.indent() + field367 = unwrapped_fields366[0] + _t1155 = self.pretty_relation_id(field367) + self.newline() + field368 = unwrapped_fields366[1] + _t1156 = self.pretty_abstraction(field368) + self.newline() + field369 = unwrapped_fields366[2] + _t1157 = self.pretty_functional_dependency_keys(field369) + self.newline() + field370 = unwrapped_fields366[3] + _t1158 = self.pretty_functional_dependency_values(field370) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def _t1159(_dollar_dollar): + return _dollar_dollar + _t1160 = _t1159(msg) + fields371 = _t1160 + unwrapped_fields372 = fields371 + self.write('(') + self.write('keys') + self.newline() + self.indent() + for i374, elem373 in enumerate(unwrapped_fields372): + + if (i374 > 0): + self.newline() + _t1161 = None + else: + _t1161 = None + _t1162 = self.pretty_var(elem373) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def _t1163(_dollar_dollar): + return _dollar_dollar + _t1164 = _t1163(msg) + fields375 = _t1164 + unwrapped_fields376 = fields375 + self.write('(') + self.write('values') + self.newline() + self.indent() + for i378, elem377 in enumerate(unwrapped_fields376): + + if (i378 > 0): + self.newline() + _t1165 = None + else: + _t1165 = None + _t1166 = self.pretty_var(elem377) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: + def _t1167(_dollar_dollar): + + if _dollar_dollar.HasField('rel_edb'): + _t1168 = _dollar_dollar.rel_edb + else: + _t1168 = None + return _t1168 + _t1169 = _t1167(msg) + deconstruct_result381 = _t1169 + + if deconstruct_result381 is not None: + _t1171 = self.pretty_rel_edb(deconstruct_result381) + _t1170 = _t1171 + else: + def _t1172(_dollar_dollar): + + if _dollar_dollar.HasField('betree_relation'): + _t1173 = _dollar_dollar.betree_relation + else: + _t1173 = None + return _t1173 + _t1174 = _t1172(msg) + deconstruct_result380 = _t1174 + + if deconstruct_result380 is not None: + _t1176 = self.pretty_betree_relation(deconstruct_result380) + _t1175 = _t1176 + else: + def _t1177(_dollar_dollar): + + if _dollar_dollar.HasField('csv_data'): + _t1178 = _dollar_dollar.csv_data + else: + _t1178 = None + return _t1178 + _t1179 = _t1177(msg) + deconstruct_result379 = _t1179 + + if deconstruct_result379 is not None: + _t1181 = self.pretty_csv_data(deconstruct_result379) + _t1180 = _t1181 + else: + raise ParseError('No matching rule for data') + _t1175 = _t1180 + _t1170 = _t1175 + return _t1170 + + def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: + def _t1182(_dollar_dollar): + return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) + _t1183 = _t1182(msg) + fields382 = _t1183 + unwrapped_fields383 = fields382 + self.write('(') + self.write('rel_edb') + self.newline() + self.indent() + field384 = unwrapped_fields383[0] + _t1184 = self.pretty_relation_id(field384) + self.newline() + field385 = unwrapped_fields383[1] + _t1185 = self.pretty_rel_edb_path(field385) + self.newline() + field386 = unwrapped_fields383[2] + _t1186 = self.pretty_rel_edb_types(field386) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: + def _t1187(_dollar_dollar): + return _dollar_dollar + _t1188 = _t1187(msg) + fields387 = _t1188 + unwrapped_fields388 = fields387 + self.write('[') + for i390, elem389 in enumerate(unwrapped_fields388): + + if (i390 > 0): + self.newline() + _t1189 = None + else: + _t1189 = None + self.write(repr(elem389)) + self.write(']') + return None + + def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1190(_dollar_dollar): + return _dollar_dollar + _t1191 = _t1190(msg) + fields391 = _t1191 + unwrapped_fields392 = fields391 + self.write('[') + for i394, elem393 in enumerate(unwrapped_fields392): + + if (i394 > 0): + self.newline() + _t1192 = None + else: + _t1192 = None + _t1193 = self.pretty_type(elem393) + self.write(']') + return None + + def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: + def _t1194(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.relation_info,) + _t1195 = _t1194(msg) + fields395 = _t1195 + unwrapped_fields396 = fields395 + self.write('(') + self.write('betree_relation') + self.newline() + self.indent() + field397 = unwrapped_fields396[0] + _t1196 = self.pretty_relation_id(field397) + self.newline() + field398 = unwrapped_fields396[1] + _t1197 = self.pretty_betree_info(field398) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: + def _t1198(_dollar_dollar): + _t1199 = Parser.deconstruct_betree_info_config(_dollar_dollar) + return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1199,) + _t1200 = _t1198(msg) + fields399 = _t1200 + unwrapped_fields400 = fields399 + self.write('(') + self.write('betree_info') + self.newline() + self.indent() + field401 = unwrapped_fields400[0] + _t1201 = self.pretty_betree_info_key_types(field401) + self.newline() + field402 = unwrapped_fields400[1] + _t1202 = self.pretty_betree_info_value_types(field402) + self.newline() + field403 = unwrapped_fields400[2] + _t1203 = self.pretty_config_dict(field403) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1204(_dollar_dollar): + return _dollar_dollar + _t1205 = _t1204(msg) + fields404 = _t1205 + unwrapped_fields405 = fields404 + self.write('(') + self.write('key_types') + self.newline() + self.indent() + for i407, elem406 in enumerate(unwrapped_fields405): + + if (i407 > 0): + self.newline() + _t1206 = None + else: + _t1206 = None + _t1207 = self.pretty_type(elem406) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1208(_dollar_dollar): + return _dollar_dollar + _t1209 = _t1208(msg) + fields408 = _t1209 + unwrapped_fields409 = fields408 + self.write('(') + self.write('value_types') + self.newline() + self.indent() + for i411, elem410 in enumerate(unwrapped_fields409): + + if (i411 > 0): + self.newline() + _t1210 = None + else: + _t1210 = None + _t1211 = self.pretty_type(elem410) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: + def _t1212(_dollar_dollar): + return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) + _t1213 = _t1212(msg) + fields412 = _t1213 + unwrapped_fields413 = fields412 + self.write('(') + self.write('csv_data') + self.newline() + self.indent() + field414 = unwrapped_fields413[0] + _t1214 = self.pretty_csvlocator(field414) + self.newline() + field415 = unwrapped_fields413[1] + _t1215 = self.pretty_csv_config(field415) + self.newline() + field416 = unwrapped_fields413[2] + _t1216 = self.pretty_csv_columns(field416) + self.newline() + field417 = unwrapped_fields413[3] + _t1217 = self.pretty_csv_asof(field417) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: + def _t1218(_dollar_dollar): + _t1219 = self.is_empty(_dollar_dollar.paths) + _t1220 = self.decode_string(_dollar_dollar.inline_data) + + if (not _t1219 and _t1220 != ''): + _t1222 = self.decode_string(_dollar_dollar.inline_data) + _t1221 = (_dollar_dollar.paths, _t1222,) + else: + _t1221 = None + return _t1221 + _t1223 = _t1218(msg) + fields418 = _t1223 + unwrapped_fields419 = fields418 + self.write('(') + self.write('csv_locator') + self.newline() + self.indent() + field420 = unwrapped_fields419[0] + + if field420 is not None: + opt_val421 = field420 + _t1225 = self.pretty_csv_locator_paths(opt_val421) + _t1224 = _t1225 + else: + _t1224 = None + self.newline() + field422 = unwrapped_fields419[1] + + if field422 is not None: + opt_val423 = field422 + _t1227 = self.pretty_csv_locator_inline_data(opt_val423) + _t1226 = _t1227 + else: + _t1226 = None + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: + def _t1228(_dollar_dollar): + return _dollar_dollar + _t1229 = _t1228(msg) + fields424 = _t1229 + unwrapped_fields425 = fields424 + self.write('(') + self.write('paths') + self.newline() + self.indent() + for i427, elem426 in enumerate(unwrapped_fields425): + + if (i427 > 0): + self.newline() + _t1230 = None + else: + _t1230 = None + self.write(repr(elem426)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: + def _t1231(_dollar_dollar): + return _dollar_dollar + _t1232 = _t1231(msg) + fields428 = _t1232 + unwrapped_fields429 = fields428 + self.write('(') + self.write('inline_data') + self.newline() + self.indent() + self.write(repr(unwrapped_fields429)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: + def _t1233(_dollar_dollar): + _t1234 = Parser.deconstruct_csv_config(_dollar_dollar) + return _t1234 + _t1235 = _t1233(msg) + fields430 = _t1235 + unwrapped_fields431 = fields430 + self.write('(') + self.write('csv_config') + self.newline() + self.indent() + _t1236 = self.pretty_config_dict(unwrapped_fields431) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: + def _t1237(_dollar_dollar): + return _dollar_dollar + _t1238 = _t1237(msg) + fields432 = _t1238 + unwrapped_fields433 = fields432 + self.write('(') + self.write('columns') + self.newline() + self.indent() + for i435, elem434 in enumerate(unwrapped_fields433): + + if (i435 > 0): + self.newline() + _t1239 = None + else: + _t1239 = None + _t1240 = self.pretty_csv_column(elem434) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: + def _t1241(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) + _t1242 = _t1241(msg) + fields436 = _t1242 + unwrapped_fields437 = fields436 + self.write('(') + self.write('column') + self.newline() + self.indent() + field438 = unwrapped_fields437[0] + self.write(repr(field438)) + self.newline() + field439 = unwrapped_fields437[1] + _t1243 = self.pretty_relation_id(field439) + self.write('[') + self.newline() + field440 = unwrapped_fields437[2] + for i442, elem441 in enumerate(field440): + + if (i442 > 0): + self.newline() + _t1244 = None + else: + _t1244 = None + _t1245 = self.pretty_type(elem441) + self.write(']') + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_csv_asof(self, msg: str) -> Optional[Never]: + def _t1246(_dollar_dollar): + return _dollar_dollar + _t1247 = _t1246(msg) + fields443 = _t1247 + unwrapped_fields444 = fields443 + self.write('(') + self.write('asof') + self.newline() + self.indent() + self.write(repr(unwrapped_fields444)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: + def _t1248(_dollar_dollar): + return _dollar_dollar.fragment_id + _t1249 = _t1248(msg) + fields445 = _t1249 + unwrapped_fields446 = fields445 + self.write('(') + self.write('undefine') + self.newline() + self.indent() + _t1250 = self.pretty_fragment_id(unwrapped_fields446) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: + def _t1251(_dollar_dollar): + return _dollar_dollar.relations + _t1252 = _t1251(msg) + fields447 = _t1252 + unwrapped_fields448 = fields447 + self.write('(') + self.write('context') + self.newline() + self.indent() + for i450, elem449 in enumerate(unwrapped_fields448): + + if (i450 > 0): + self.newline() + _t1253 = None + else: + _t1253 = None + _t1254 = self.pretty_relation_id(elem449) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: + def _t1255(_dollar_dollar): + return _dollar_dollar + _t1256 = _t1255(msg) + fields451 = _t1256 + unwrapped_fields452 = fields451 + self.write('(') + self.write('reads') + self.newline() + self.indent() + for i454, elem453 in enumerate(unwrapped_fields452): + + if (i454 > 0): + self.newline() + _t1257 = None + else: + _t1257 = None + _t1258 = self.pretty_read(elem453) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: + def _t1259(_dollar_dollar): + + if _dollar_dollar.HasField('demand'): + _t1260 = _dollar_dollar.demand + else: + _t1260 = None + return _t1260 + _t1261 = _t1259(msg) + deconstruct_result459 = _t1261 + + if deconstruct_result459 is not None: + _t1263 = self.pretty_demand(deconstruct_result459) + _t1262 = _t1263 + else: + def _t1264(_dollar_dollar): + + if _dollar_dollar.name != 'output': + _t1265 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + else: + _t1265 = None + return _t1265 + _t1266 = _t1264(msg) + guard_result458 = _t1266 + + if guard_result458 is not None: + _t1268 = self.pretty_output(msg) + _t1267 = _t1268 + else: + def _t1269(_dollar_dollar): + + if _dollar_dollar.HasField('what_if'): + _t1270 = _dollar_dollar.what_if + else: + _t1270 = None + return _t1270 + _t1271 = _t1269(msg) + deconstruct_result457 = _t1271 + + if deconstruct_result457 is not None: + _t1273 = self.pretty_what_if(deconstruct_result457) + _t1272 = _t1273 + else: + def _t1274(_dollar_dollar): + + if _dollar_dollar.name != 'abort': + _t1275 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + else: + _t1275 = None + return _t1275 + _t1276 = _t1274(msg) + guard_result456 = _t1276 + + if guard_result456 is not None: + _t1278 = self.pretty_abort(msg) + _t1277 = _t1278 + else: + def _t1279(_dollar_dollar): + + if _dollar_dollar.HasField('export'): + _t1280 = _dollar_dollar.export + else: + _t1280 = None + return _t1280 + _t1281 = _t1279(msg) + deconstruct_result455 = _t1281 + + if deconstruct_result455 is not None: + _t1283 = self.pretty_export(deconstruct_result455) + _t1282 = _t1283 + else: + raise ParseError('No matching rule for read') + _t1277 = _t1282 + _t1272 = _t1277 + _t1267 = _t1272 + _t1262 = _t1267 + return _t1262 + + def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: + def _t1284(_dollar_dollar): + return _dollar_dollar.relation_id + _t1285 = _t1284(msg) + fields460 = _t1285 + unwrapped_fields461 = fields460 + self.write('(') + self.write('demand') + self.newline() + self.indent() + _t1286 = self.pretty_relation_id(unwrapped_fields461) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: + def _t1287(_dollar_dollar): + + if _dollar_dollar.name != 'output': + _t1288 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + else: + _t1288 = None + return _t1288 + _t1289 = _t1287(msg) + fields462 = _t1289 + unwrapped_fields463 = fields462 + self.write('(') + self.write('output') + self.newline() + self.indent() + field464 = unwrapped_fields463[0] + + if field464 is not None: + opt_val465 = field464 + _t1291 = self.pretty_name(opt_val465) + _t1290 = _t1291 + else: + _t1290 = None + self.newline() + field466 = unwrapped_fields463[1] + _t1292 = self.pretty_relation_id(field466) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: + def _t1293(_dollar_dollar): + return (_dollar_dollar.branch, _dollar_dollar.epoch,) + _t1294 = _t1293(msg) + fields467 = _t1294 + unwrapped_fields468 = fields467 + self.write('(') + self.write('what_if') + self.newline() + self.indent() + field469 = unwrapped_fields468[0] + _t1295 = self.pretty_name(field469) + self.newline() + field470 = unwrapped_fields468[1] + _t1296 = self.pretty_epoch(field470) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: + def _t1297(_dollar_dollar): + + if _dollar_dollar.name != 'abort': + _t1298 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + else: + _t1298 = None + return _t1298 + _t1299 = _t1297(msg) + fields471 = _t1299 + unwrapped_fields472 = fields471 + self.write('(') + self.write('abort') + self.newline() + self.indent() + field473 = unwrapped_fields472[0] + + if field473 is not None: + opt_val474 = field473 + _t1301 = self.pretty_name(opt_val474) + _t1300 = _t1301 + else: + _t1300 = None + self.newline() + field475 = unwrapped_fields472[1] + _t1302 = self.pretty_relation_id(field475) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: + def _t1303(_dollar_dollar): + return _dollar_dollar.csv_config + _t1304 = _t1303(msg) + fields476 = _t1304 + unwrapped_fields477 = fields476 + self.write('(') + self.write('export') + self.newline() + self.indent() + _t1305 = self.pretty_export_csv_config(unwrapped_fields477) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: + def _t1306(_dollar_dollar): + _t1307 = Parser.deconstruct_export_csv_config(_dollar_dollar) + return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1307,) + _t1308 = _t1306(msg) + fields478 = _t1308 + unwrapped_fields479 = fields478 + self.write('(') + self.write('export_csv_config') + self.newline() + self.indent() + field480 = unwrapped_fields479[0] + _t1309 = self.pretty_export_csv_path(field480) + self.newline() + field481 = unwrapped_fields479[1] + _t1310 = self.pretty_export_csv_columns(field481) + self.newline() + field482 = unwrapped_fields479[2] + _t1311 = self.pretty_config_dict(field482) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_export_csv_path(self, msg: str) -> Optional[Never]: + def _t1312(_dollar_dollar): + return _dollar_dollar + _t1313 = _t1312(msg) + fields483 = _t1313 + unwrapped_fields484 = fields483 + self.write('(') + self.write('path') + self.newline() + self.indent() + self.write(repr(unwrapped_fields484)) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: + def _t1314(_dollar_dollar): + return _dollar_dollar + _t1315 = _t1314(msg) + fields485 = _t1315 + unwrapped_fields486 = fields485 + self.write('(') + self.write('columns') + self.newline() + self.indent() + for i488, elem487 in enumerate(unwrapped_fields486): + + if (i488 > 0): + self.newline() + _t1316 = None + else: + _t1316 = None + _t1317 = self.pretty_export_csv_column(elem487) + self.dedent() + self.write(')') + self.newline() + return None + + def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: + def _t1318(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.column_data,) + _t1319 = _t1318(msg) + fields489 = _t1319 + unwrapped_fields490 = fields489 + self.write('(') + self.write('column') + self.newline() + self.indent() + field491 = unwrapped_fields490[0] + self.write(repr(field491)) + self.newline() + field492 = unwrapped_fields490[1] + _t1320 = self.pretty_relation_id(field492) + self.dedent() + self.write(')') + self.newline() + return None + + +def pretty(msg: Any, io: IO[str] = None) -> str: + """Pretty print a protobuf message and return the string representation.""" + printer = PrettyPrinter(io) + printer.pretty_transaction(msg) + return printer.get_output() diff --git a/python-tools/src/meta/cli.py b/python-tools/src/meta/cli.py index d3939919..1413008a 100644 --- a/python-tools/src/meta/cli.py +++ b/python-tools/src/meta/cli.py @@ -71,12 +71,20 @@ def parse_args(): choices=["ir", "python", "julia"], help="Output the generated parser (ir, python, or julia)" ) + output_group.add_argument( + "--printer", + type=str, + choices=["ir", "python", "julia"], + help="Output the generated pretty printer (ir, python, or julia)" + ) args = parser.parse_args() - # --grammar is required for --parser + # --grammar is required for --parser and --printer if args.parser and not args.grammar: parser.error("--grammar is required when using --parser") + if args.printer and not args.grammar: + parser.error("--grammar is required when using --printer") return args @@ -178,8 +186,8 @@ def run(args) -> int: return 1 - # Output grammar if -o is specified and not generating parser - if args.output and not args.parser: + # Output grammar if -o is specified and not generating parser or printer + if args.output and not args.parser and not args.printer: output_text = grammar.print_grammar_yacc() args.output.write_text(output_text) print(f"Grammar written to {args.output}") @@ -211,6 +219,31 @@ def run(args) -> int: output_text = generate_parser_julia(grammar, command_line, proto_messages) write_output(output_text, args.output, f"Generated parser written to {args.output}") + if args.printer: + if args.printer == "ir": + from .pretty_gen import generate_pretty_functions + pretty_functions = generate_pretty_functions(grammar, proto_messages) + output_lines = [] + for defn in pretty_functions: + output_lines.append(str(defn)) + output_lines.append("") + output_text = "\n".join(output_lines) + write_output(output_text, args.output, f"Generated printer IR written to {args.output}") + elif args.printer == "python": + proto_messages = {(msg.module, name): msg for name, msg in proto_parser.messages.items()} + command_line = " ".join( + ["python -m meta.cli"] + + [str(f) for f in args.proto_files] + + ["--grammar", str(args.grammar)] + + ["--printer", args.printer] + ) + from .pretty_gen_python import generate_pretty_printer_python + output_text = generate_pretty_printer_python(grammar, command_line, proto_messages) + write_output(output_text, args.output, f"Generated pretty printer written to {args.output}") + else: + print(f"Error: Pretty printer generation for '{args.printer}' is not yet implemented", file=sys.stderr) + return 1 + return 0 diff --git a/python-tools/src/meta/codegen_base.py b/python-tools/src/meta/codegen_base.py index 8d9b7cd9..6f74fc99 100644 --- a/python-tools/src/meta/codegen_base.py +++ b/python-tools/src/meta/codegen_base.py @@ -14,9 +14,9 @@ from .target import ( TargetExpr, Var, Lit, Symbol, Builtin, NamedFun, NewMessage, EnumValue, OneOf, ListExpr, Call, Lambda, Let, - IfElse, Seq, While, Assign, Return, FunDef, VisitNonterminalDef, + IfElse, Seq, While, Foreach, ForeachEnumerated, Assign, Return, FunDef, VisitNonterminalDef, VisitNonterminal, TargetType, BaseType, TupleType, ListType, DictType, OptionType, - MessageType, EnumType, FunctionType, GetField, GetElement + MessageType, EnumType, FunctionType, VarType, GetField, GetElement ) from .target_builtins import get_builtin from .gensym import gensym @@ -77,6 +77,12 @@ def escape_identifier(self, name: str) -> str: return self.escape_keyword(name) return name + # --- Field access --- + + def gen_field_access(self, obj_code: str, field_name: str) -> str: + """Generate field access expression: obj.field_name.""" + return f"{obj_code}.{field_name}" + # --- Literal generation --- @abstractmethod @@ -141,6 +147,11 @@ def gen_parse_nonterminal_ref(self, name: str) -> str: """Generate a reference to a parse method for a nonterminal.""" pass + @abstractmethod + def gen_pretty_nonterminal_ref(self, name: str) -> str: + """Generate a reference to a pretty-print method for a nonterminal.""" + pass + # --- Type generation --- @abstractmethod @@ -204,6 +215,8 @@ def gen_type(self, typ: TargetType) -> str: param_types = [self.gen_type(pt) for pt in typ.param_types] return_type = self.gen_type(typ.return_type) return self.gen_function_type(param_types, return_type) + elif isinstance(typ, VarType): + return self.base_type_map.get("Any", "Any") else: raise ValueError(f"Unknown type: {type(typ)}") @@ -234,6 +247,21 @@ def gen_while_end(self) -> str: """Generate end of while loop.""" pass + @abstractmethod + def gen_foreach_start(self, var: str, collection: str) -> str: + """Generate start of foreach loop.""" + pass + + @abstractmethod + def gen_foreach_enumerated_start(self, index_var: str, var: str, collection: str) -> str: + """Generate start of foreach enumerated loop.""" + pass + + @abstractmethod + def gen_foreach_end(self) -> str: + """Generate end of foreach loop.""" + pass + @abstractmethod def gen_empty_body(self) -> str: """Generate placeholder for empty body (e.g., 'pass' or '// empty').""" @@ -389,6 +417,8 @@ def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") - return self.gen_named_fun_ref(expr.name) elif isinstance(expr, VisitNonterminal): + if expr.visitor_name == 'pretty': + return self.gen_pretty_nonterminal_ref(expr.nonterminal.name) return self.gen_parse_nonterminal_ref(expr.nonterminal.name) elif isinstance(expr, OneOf): @@ -398,9 +428,8 @@ def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") - return self._generate_list_expr(expr, lines, indent) elif isinstance(expr, GetField): - # GetField(object, field_name) -> object.field_name obj_code = self.generate_lines(expr.object, lines, indent) - return f"{obj_code}.{expr.field_name}" + return self.gen_field_access(obj_code, expr.field_name) elif isinstance(expr, GetElement): return self._generate_get_element(expr, lines, indent) @@ -423,6 +452,12 @@ def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") - elif isinstance(expr, While): return self._generate_while(expr, lines, indent) + elif isinstance(expr, Foreach): + return self._generate_foreach(expr, lines, indent) + + elif isinstance(expr, ForeachEnumerated): + return self._generate_foreach_enumerated(expr, lines, indent) + elif isinstance(expr, Assign): return self._generate_assign(expr, lines, indent) @@ -703,6 +738,39 @@ def _generate_while(self, expr: While, lines: List[str], indent: str) -> str: return self.gen_none() + def _generate_foreach(self, expr: Foreach, lines: List[str], indent: str) -> str: + """Generate code for a foreach loop.""" + collection_code = self.generate_lines(expr.collection, lines, indent) + assert collection_code is not None, "Foreach collection should not contain a return" + var_name = self.escape_identifier(expr.var.name) + + lines.append(f"{indent}{self.gen_foreach_start(var_name, collection_code)}") + body_indent = indent + self.indent_str + self.generate_lines(expr.body, lines, body_indent) + + end = self.gen_foreach_end() + if end: + lines.append(f"{indent}{end}") + + return self.gen_none() + + def _generate_foreach_enumerated(self, expr: ForeachEnumerated, lines: List[str], indent: str) -> str: + """Generate code for a foreach enumerated loop.""" + collection_code = self.generate_lines(expr.collection, lines, indent) + assert collection_code is not None, "ForeachEnumerated collection should not contain a return" + index_name = self.escape_identifier(expr.index_var.name) + var_name = self.escape_identifier(expr.var.name) + + lines.append(f"{indent}{self.gen_foreach_enumerated_start(index_name, var_name, collection_code)}") + body_indent = indent + self.indent_str + self.generate_lines(expr.body, lines, body_indent) + + end = self.gen_foreach_end() + if end: + lines.append(f"{indent}{end}") + + return self.gen_none() + def _generate_assign(self, expr: Assign, lines: List[str], indent: str) -> str: """Generate code for an assignment.""" var_name = self.escape_identifier(expr.var.name) @@ -729,6 +797,8 @@ def generate_def(self, expr: Union[FunDef, VisitNonterminalDef], indent: str = " if isinstance(expr, FunDef): return self._generate_fun_def(expr, indent) elif isinstance(expr, VisitNonterminalDef): + if expr.visitor_name == 'pretty': + return self._generate_pretty_def(expr, indent) return self._generate_parse_def(expr, indent) else: raise ValueError(f"Unknown definition type: {type(expr)}") @@ -766,6 +836,11 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: """Generate a parse method definition. Language-specific due to method syntax.""" pass + @abstractmethod + def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + """Generate a pretty-print method definition. Language-specific due to method syntax.""" + pass + # --- Token spec formatting for parser generation --- @abstractmethod diff --git a/python-tools/src/meta/codegen_julia.py b/python-tools/src/meta/codegen_julia.py index 3445dd23..a797b309 100644 --- a/python-tools/src/meta/codegen_julia.py +++ b/python-tools/src/meta/codegen_julia.py @@ -128,6 +128,9 @@ def gen_named_fun_ref(self, name: str) -> str: def gen_parse_nonterminal_ref(self, name: str) -> str: return f"parse_{name}" + def gen_pretty_nonterminal_ref(self, name: str) -> str: + return f"pretty_{name}" + # --- Type generation --- def gen_message_type(self, module: str, name: str) -> str: @@ -192,6 +195,15 @@ def gen_while_start(self, cond: str) -> str: def gen_while_end(self) -> str: return "end" + def gen_foreach_start(self, var: str, collection: str) -> str: + return f"for {var} in {collection}" + + def gen_foreach_enumerated_start(self, index_var: str, var: str, collection: str) -> str: + return f"for ({index_var}, {var}) in enumerate({collection})" + + def gen_foreach_end(self) -> str: + return "end" + def gen_empty_body(self) -> str: return "nothing" @@ -420,6 +432,31 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: return f"{indent}function {func_name}({params_str}){ret_hint}\n{body_code}\n{indent}end" + def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + """Generate a pretty-print function definition.""" + func_name = f"pretty_{expr.nonterminal.name}" + + params = ["pp::PrettyPrinter"] + for param in expr.params: + escaped_name = self.escape_identifier(param.name) + type_hint = self.gen_type(param.type) + params.append(f"{escaped_name}::{type_hint}") + + params_str = ', '.join(params) + + ret_hint = f"::{self.gen_type(expr.return_type)}" if expr.return_type else "" + + if expr.body is None: + body_code = f"{indent} nothing" + else: + body_lines: List[str] = [] + body_inner = self.generate_lines(expr.body, body_lines, indent + " ") + if body_inner is not None: + body_lines.append(f"{indent} return {body_inner}") + body_code = "\n".join(body_lines) + + return f"{indent}function {func_name}({params_str}){ret_hint}\n{body_code}\n{indent}end" + def format_literal_token_spec(self, escaped_literal: str) -> str: return f' ("LITERAL", r"{escaped_literal}", identity),' diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index 071df454..5705f96d 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -49,10 +49,37 @@ def __init__(self, proto_messages=None): def _register_builtins(self) -> None: """Register builtin generators from templates.""" self.register_builtins_from_templates(PYTHON_TEMPLATES) + # Override tuple to handle empty and single-element cases correctly + self.register_builtin("tuple", self._gen_tuple_builtin) + + @staticmethod + def _gen_tuple_builtin(args, lines, indent): + from .codegen_base import BuiltinResult + if len(args) == 0: + return BuiltinResult("()", []) + elif len(args) == 1: + return BuiltinResult(f"({args[0]},)", []) + else: + return BuiltinResult(f"({', '.join(args)},)", []) def escape_keyword(self, name: str) -> str: return f"{name}_" + # --- Field access --- + + _PYTHON_KEYWORDS = frozenset({ + 'False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', + 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', + 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', + 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', + 'try', 'while', 'with', 'yield', + }) + + def gen_field_access(self, obj_code: str, field_name: str) -> str: + if field_name in self._PYTHON_KEYWORDS: + return f"getattr({obj_code}, {field_name!r})" + return f"{obj_code}.{field_name}" + # --- Literal generation --- def gen_none(self) -> str: @@ -81,6 +108,9 @@ def gen_named_fun_ref(self, name: str) -> str: def gen_parse_nonterminal_ref(self, name: str) -> str: return f"self.parse_{name}" + def gen_pretty_nonterminal_ref(self, name: str) -> str: + return f"self.pretty_{name}" + # --- Type generation --- def gen_message_type(self, module: str, name: str) -> str: @@ -129,6 +159,15 @@ def gen_while_start(self, cond: str) -> str: def gen_while_end(self) -> str: return "" # Python uses indentation + def gen_foreach_start(self, var: str, collection: str) -> str: + return f"for {var} in {collection}:" + + def gen_foreach_enumerated_start(self, index_var: str, var: str, collection: str) -> str: + return f"for {index_var}, {var} in enumerate({collection}):" + + def gen_foreach_end(self) -> str: + return "" # Python uses indentation + def gen_empty_body(self) -> str: return "pass" @@ -280,6 +319,30 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" + def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + """Generate a pretty-print method definition.""" + func_name = f"pretty_{expr.nonterminal.name}" + + params = [] + for param in expr.params: + escaped_name = self.escape_identifier(param.name) + type_hint = self.gen_type(param.type) + params.append(f"{escaped_name}: {type_hint}") + + params_str = ', '.join(params) if params else '' + if params_str: + params_str = ', ' + params_str + + ret_hint = f" -> {self.gen_type(expr.return_type)}" if expr.return_type else "" + + body_lines: List[str] = [] + body_inner = self.generate_lines(expr.body, body_lines, indent + " ") + if body_inner is not None: + body_lines.append(f"{indent} return {body_inner}") + body_code = "\n".join(body_lines) + + return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" + # Parser generation settings parse_def_indent = " " diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index b8984a31..7a32052f 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -120,8 +120,49 @@ class BuiltinTemplate: +# Python pretty-printing builtin templates +PYTHON_PRETTY_TEMPLATES: Dict[str, BuiltinTemplate] = { + "write_io": BuiltinTemplate("None", ["self.write({0})"]), + "newline_io": BuiltinTemplate("None", ["self.newline()"]), + "indent_io": BuiltinTemplate("None", ["self.indent()"]), + "dedent_io": BuiltinTemplate("None", ["self.dedent()"]), + "format_int64": BuiltinTemplate("str({0})"), + "format_int32": BuiltinTemplate("str({0})"), + "format_float64": BuiltinTemplate("str({0})"), + "format_string": BuiltinTemplate("repr({0})"), + "format_symbol": BuiltinTemplate("{0}"), + "format_bool": BuiltinTemplate("('true' if {0} else 'false')"), + "format_decimal": BuiltinTemplate("self.format_decimal({0})"), + "format_int128": BuiltinTemplate("self.format_int128({0})"), + "format_uint128": BuiltinTemplate("self.format_uint128({0})"), + "greater": BuiltinTemplate("({0} > {1})"), + "to_string": BuiltinTemplate("str({0})"), +} + +# Julia pretty-printing builtin templates +JULIA_PRETTY_TEMPLATES: Dict[str, BuiltinTemplate] = { + "write_io": BuiltinTemplate("nothing", ["write(pp, {0})"]), + "newline_io": BuiltinTemplate("nothing", ["newline(pp)"]), + "indent_io": BuiltinTemplate("nothing", ["indent!(pp)"]), + "dedent_io": BuiltinTemplate("nothing", ["dedent!(pp)"]), + "format_int64": BuiltinTemplate("string({0})"), + "format_int32": BuiltinTemplate("string({0})"), + "format_float64": BuiltinTemplate("string({0})"), + "format_string": BuiltinTemplate("repr({0})"), + "format_symbol": BuiltinTemplate("{0}"), + "format_bool": BuiltinTemplate("({0} ? \"true\" : \"false\")"), + "format_decimal": BuiltinTemplate("format_decimal(pp, {0})"), + "format_int128": BuiltinTemplate("format_int128(pp, {0})"), + "format_uint128": BuiltinTemplate("format_uint128(pp, {0})"), + "greater": BuiltinTemplate("({0} > {1})"), + "to_string": BuiltinTemplate("string({0})"), +} + + __all__ = [ 'BuiltinTemplate', 'PYTHON_TEMPLATES', 'JULIA_TEMPLATES', + 'PYTHON_PRETTY_TEMPLATES', + 'JULIA_PRETTY_TEMPLATES', ] diff --git a/python-tools/src/meta/grammar.py b/python-tools/src/meta/grammar.py index d6b78076..61205ec3 100644 --- a/python-tools/src/meta/grammar.py +++ b/python-tools/src/meta/grammar.py @@ -8,7 +8,7 @@ from typing import Dict, List, Optional, Tuple, TYPE_CHECKING # Import action AST types -from .target import TargetExpr, Var, Symbol, Call, Lambda, Lit, TargetType, ListType, OptionType, TupleType, FunDef +from .target import TargetExpr, Call, Lambda, TargetType, ListType, OptionType, TupleType, FunDef # Use TYPE_CHECKING to avoid circular import: GrammarAnalysis imports Grammar, # but we need GrammarAnalysis type hints here. These imports only exist during @@ -208,6 +208,7 @@ class Rule: lhs: Nonterminal rhs: Rhs constructor: 'Lambda' + deconstructor: Optional['Lambda'] = None # Pretty-printer deconstruction action source_type: Optional[str] = None # Track the protobuf type this rule came from def __str__(self): @@ -228,6 +229,10 @@ def __post_init__(self): f"but RHS has {rhs_len} non-literal element(s): {self.rhs}" ) +# Backwards-compatible alias for tests +make_rule = Rule + + @dataclass(frozen=True) class Token: """Token definition (terminal with regex pattern). @@ -323,6 +328,8 @@ def print_grammar(self, reachable_only: bool = True) -> str: if rule.constructor: lines.append(f" +{{{{ {rule.constructor} }}}}") + if rule.deconstructor: + lines.append(f" -{{{{ {rule.deconstructor} }}}}") lines.append("") @@ -389,7 +396,10 @@ def print_grammar_yacc(self, reachable_only: bool = True) -> str: rhs_str = self._rhs_to_str(rule.rhs) action_str = expr_to_str(rule.constructor.body) lines.append(f"{prefix}{rhs_str}") - lines.append(f" {{ {action_str} }}") + lines.append(f" construct: {action_str}") + if rule.deconstructor is not None: + decon_str = expr_to_str(rule.deconstructor.body) + lines.append(f" deconstruct: {decon_str}") lines.append("") diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index f11e5594..a23fd0ae 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -12,6 +12,22 @@ # Not all expression forms are supported. Indeed, one can only call helper # functions declared below and builtin functions via `builtin.func(...)`. # We translate this restricted Python into actual Python, Julia, and Go. +# +# Each rule has a construct action and a deconstruct action. +# +# Construct actions use `$$ = expr` to build the LHS value from the RHS +# elements ($1, $2, ...). If omitted, the default is `$$ = $N` when there +# is exactly one non-literal RHS element. +# +# Deconstruct actions use `$N = expr` assignments to extract RHS element +# values from the LHS value ($$). If omitted, the default is the identity +# deconstruct. If any assignment uses a conditional guard of the form +# `$N = expr if COND else None`, the deconstructor returns None when the +# condition fails, signaling that this rule does not match. +# +# The pretty printer uses the deconstruct actions. For nonterminals with +# multiple alternatives, it tries the rules in declaration order, choosing +# the first whose deconstructor returns a non-None value. # Start symbol @@ -164,267 +180,350 @@ transaction : "(" "transaction" configure? sync? epoch* ")" - construct: transactions.Transaction(epochs=$5, configure=builtin.unwrap_option_or($3, default_configure()), sync=$4) + construct: $$ = transactions.Transaction(epochs=$5, configure=builtin.unwrap_option_or($3, default_configure()), sync=$4) + deconstruct: + $3 = $$.configure if not is_default_configure($$.configure) else None + $4 = $$.sync + $5 = $$.epochs configure : "(" "configure" config_dict ")" - construct: construct_configure($3) + construct: $$ = construct_configure($3) + deconstruct: $3 = deconstruct_configure($$) config_dict : "{" config_key_value* "}" config_key_value : ":" SYMBOL value - construct: builtin.tuple($2, $3) + construct: $$ = builtin.tuple($2, $3) + deconstruct: + $2 = $$[0] + $3 = $$[1] value : date - construct: logic.Value(date_value=$1) + construct: $$ = logic.Value(date_value=$1) + deconstruct: $1 = $$.date_value if builtin.has_proto_field($$, 'date_value') else None | datetime - construct: logic.Value(datetime_value=$1) + construct: $$ = logic.Value(datetime_value=$1) + deconstruct: $1 = $$.datetime_value if builtin.has_proto_field($$, 'datetime_value') else None | STRING - construct: logic.Value(string_value=$1) + construct: $$ = logic.Value(string_value=$1) + deconstruct: $1 = $$.string_value if builtin.has_proto_field($$, 'string_value') else None | INT - construct: logic.Value(int_value=$1) + construct: $$ = logic.Value(int_value=$1) + deconstruct: $1 = $$.int_value if builtin.has_proto_field($$, 'int_value') else None | FLOAT - construct: logic.Value(float_value=$1) + construct: $$ = logic.Value(float_value=$1) + deconstruct: $1 = $$.float_value if builtin.has_proto_field($$, 'float_value') else None | UINT128 - construct: logic.Value(uint128_value=$1) + construct: $$ = logic.Value(uint128_value=$1) + deconstruct: $1 = $$.uint128_value if builtin.has_proto_field($$, 'uint128_value') else None | INT128 - construct: logic.Value(int128_value=$1) + construct: $$ = logic.Value(int128_value=$1) + deconstruct: $1 = $$.int128_value if builtin.has_proto_field($$, 'int128_value') else None | DECIMAL - construct: logic.Value(decimal_value=$1) + construct: $$ = logic.Value(decimal_value=$1) + deconstruct: $1 = $$.decimal_value if builtin.has_proto_field($$, 'decimal_value') else None | "missing" - construct: logic.Value(missing_value=logic.MissingValue()) + construct: $$ = logic.Value(missing_value=logic.MissingValue()) | boolean_value - construct: logic.Value(boolean_value=$1) + construct: $$ = logic.Value(boolean_value=$1) + deconstruct: $1 = $$.boolean_value if builtin.has_proto_field($$, 'boolean_value') else None date : "(" "date" INT INT INT ")" - construct: logic.DateValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5)) + construct: $$ = logic.DateValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5)) + deconstruct: $3 = builtin.int32_to_int64($$.year); $4 = builtin.int32_to_int64($$.month); $5 = builtin.int32_to_int64($$.day) datetime : "(" "datetime" INT INT INT INT INT INT INT? ")" - construct: logic.DateTimeValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5), hour=builtin.int64_to_int32($6), minute=builtin.int64_to_int32($7), second=builtin.int64_to_int32($8), microsecond=builtin.int64_to_int32(builtin.unwrap_option_or($9, 0))) + construct: $$ = logic.DateTimeValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5), hour=builtin.int64_to_int32($6), minute=builtin.int64_to_int32($7), second=builtin.int64_to_int32($8), microsecond=builtin.int64_to_int32(builtin.unwrap_option_or($9, 0))) + deconstruct: + $3 = builtin.int32_to_int64($$.year) + $4 = builtin.int32_to_int64($$.month) + $5 = builtin.int32_to_int64($$.day) + $6 = builtin.int32_to_int64($$.hour) + $7 = builtin.int32_to_int64($$.minute) + $8 = builtin.int32_to_int64($$.second) + $9 = builtin.int32_to_int64($$.microsecond) boolean_value : "true" - construct: True + construct: $$ = True | "false" - construct: False + construct: $$ = False sync : "(" "sync" fragment_id* ")" - construct: transactions.Sync(fragments=$3) + construct: $$ = transactions.Sync(fragments=$3) + deconstruct: $3 = $$.fragments fragment_id : ":" SYMBOL - construct: builtin.fragment_id_from_string($2) + construct: $$ = builtin.fragment_id_from_string($2) + deconstruct: $2 = builtin.fragment_id_to_string($$) epoch : "(" "epoch" epoch_writes? epoch_reads? ")" - construct: transactions.Epoch(writes=builtin.unwrap_option_or($3, list[transactions.Write]()), reads=builtin.unwrap_option_or($4, list[transactions.Read]())) + construct: $$ = transactions.Epoch(writes=builtin.unwrap_option_or($3, list[transactions.Write]()), reads=builtin.unwrap_option_or($4, list[transactions.Read]())) + deconstruct: + $3 = $$.writes if not builtin.is_empty($$.writes) else None + $4 = $$.reads if not builtin.is_empty($$.reads) else None epoch_writes : "(" "writes" write* ")" write : define - construct: transactions.Write(define=$1) + construct: $$ = transactions.Write(define=$1) + deconstruct: $1 = $$.define if builtin.has_proto_field($$, 'define') else None | undefine - construct: transactions.Write(undefine=$1) + construct: $$ = transactions.Write(undefine=$1) + deconstruct: $1 = $$.undefine if builtin.has_proto_field($$, 'undefine') else None | context - construct: transactions.Write(context=$1) + construct: $$ = transactions.Write(context=$1) + deconstruct: $1 = $$.context if builtin.has_proto_field($$, 'context') else None define : "(" "define" fragment ")" - construct: transactions.Define(fragment=$3) + construct: $$ = transactions.Define(fragment=$3) + deconstruct: $3 = $$.fragment fragment : "(" "fragment" new_fragment_id declaration* ")" - construct: builtin.construct_fragment($3, $4) + construct: $$ = builtin.construct_fragment($3, $4) + deconstruct: $3 = $$.id; $4 = $$.declarations new_fragment_id : fragment_id construct: builtin.start_fragment($1) - $1 + $$ = $1 declaration : def - construct: logic.Declaration(def=$1) + construct: $$ = logic.Declaration(def=$1) + deconstruct: $1 = $$.def if builtin.has_proto_field($$, 'def') else None | algorithm - construct: logic.Declaration(algorithm=$1) + construct: $$ = logic.Declaration(algorithm=$1) + deconstruct: $1 = $$.algorithm if builtin.has_proto_field($$, 'algorithm') else None | constraint - construct: logic.Declaration(constraint=$1) + construct: $$ = logic.Declaration(constraint=$1) + deconstruct: $1 = $$.constraint if builtin.has_proto_field($$, 'constraint') else None | data - construct: logic.Declaration(data=$1) + construct: $$ = logic.Declaration(data=$1) + deconstruct: $1 = $$.data if builtin.has_proto_field($$, 'data') else None def : "(" "def" relation_id abstraction attrs? ")" - construct: logic.Def(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + construct: $$ = logic.Def(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + deconstruct: + $3 = $$.name + $4 = $$.body + $5 = $$.attrs if not builtin.is_empty($$.attrs) else None relation_id : ":" SYMBOL - construct: builtin.relation_id_from_string($2) + construct: $$ = builtin.relation_id_from_string($2) + deconstruct: $2 = deconstruct_relation_id_string($$) | UINT128 - construct: builtin.relation_id_from_uint128($1) + construct: $$ = builtin.relation_id_from_uint128($1) + deconstruct: $1 = deconstruct_relation_id_uint128($$) abstraction : "(" bindings formula ")" - construct: logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3) + construct: $$ = logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3) + deconstruct: $2 = deconstruct_bindings($$); $3 = $$.value bindings : "[" binding* value_bindings? "]" - construct: builtin.tuple($2, builtin.unwrap_option_or($3, list[logic.Binding]())) + construct: $$ = builtin.tuple($2, builtin.unwrap_option_or($3, list[logic.Binding]())) + deconstruct: $2 = $$[0]; $3 = $$[1] if not builtin.is_empty($$[1]) else None binding : SYMBOL "::" type - construct: logic.Binding(var=logic.Var(name=$1), type=$3) + construct: $$ = logic.Binding(var=logic.Var(name=$1), type=$3) + deconstruct: $1 = $$.var.name; $3 = $$.type type : unspecified_type - construct: logic.Type(unspecified_type=$1) + construct: $$ = logic.Type(unspecified_type=$1) + deconstruct: $1 = $$.unspecified_type if builtin.has_proto_field($$, 'unspecified_type') else None | string_type - construct: logic.Type(string_type=$1) + construct: $$ = logic.Type(string_type=$1) + deconstruct: $1 = $$.string_type if builtin.has_proto_field($$, 'string_type') else None | int_type - construct: logic.Type(int_type=$1) + construct: $$ = logic.Type(int_type=$1) + deconstruct: $1 = $$.int_type if builtin.has_proto_field($$, 'int_type') else None | float_type - construct: logic.Type(float_type=$1) + construct: $$ = logic.Type(float_type=$1) + deconstruct: $1 = $$.float_type if builtin.has_proto_field($$, 'float_type') else None | uint128_type - construct: logic.Type(uint128_type=$1) + construct: $$ = logic.Type(uint128_type=$1) + deconstruct: $1 = $$.uint128_type if builtin.has_proto_field($$, 'uint128_type') else None | int128_type - construct: logic.Type(int128_type=$1) + construct: $$ = logic.Type(int128_type=$1) + deconstruct: $1 = $$.int128_type if builtin.has_proto_field($$, 'int128_type') else None | date_type - construct: logic.Type(date_type=$1) + construct: $$ = logic.Type(date_type=$1) + deconstruct: $1 = $$.date_type if builtin.has_proto_field($$, 'date_type') else None | datetime_type - construct: logic.Type(datetime_type=$1) + construct: $$ = logic.Type(datetime_type=$1) + deconstruct: $1 = $$.datetime_type if builtin.has_proto_field($$, 'datetime_type') else None | missing_type - construct: logic.Type(missing_type=$1) + construct: $$ = logic.Type(missing_type=$1) + deconstruct: $1 = $$.missing_type if builtin.has_proto_field($$, 'missing_type') else None | decimal_type - construct: logic.Type(decimal_type=$1) + construct: $$ = logic.Type(decimal_type=$1) + deconstruct: $1 = $$.decimal_type if builtin.has_proto_field($$, 'decimal_type') else None | boolean_type - construct: logic.Type(boolean_type=$1) + construct: $$ = logic.Type(boolean_type=$1) + deconstruct: $1 = $$.boolean_type if builtin.has_proto_field($$, 'boolean_type') else None unspecified_type : "UNKNOWN" - construct: logic.UnspecifiedType() + construct: $$ = logic.UnspecifiedType() string_type : "STRING" - construct: logic.StringType() + construct: $$ = logic.StringType() int_type : "INT" - construct: logic.IntType() + construct: $$ = logic.IntType() float_type : "FLOAT" - construct: logic.FloatType() + construct: $$ = logic.FloatType() uint128_type : "UINT128" - construct: logic.UInt128Type() + construct: $$ = logic.UInt128Type() int128_type : "INT128" - construct: logic.Int128Type() + construct: $$ = logic.Int128Type() date_type : "DATE" - construct: logic.DateType() + construct: $$ = logic.DateType() datetime_type : "DATETIME" - construct: logic.DateTimeType() + construct: $$ = logic.DateTimeType() missing_type : "MISSING" - construct: logic.MissingType() + construct: $$ = logic.MissingType() decimal_type : "(" "DECIMAL" INT INT ")" - construct: logic.DecimalType(precision=builtin.int64_to_int32($3), scale=builtin.int64_to_int32($4)) + construct: $$ = logic.DecimalType(precision=builtin.int64_to_int32($3), scale=builtin.int64_to_int32($4)) + deconstruct: $3 = builtin.int32_to_int64($$.precision); $4 = builtin.int32_to_int64($$.scale) boolean_type : "BOOLEAN" - construct: logic.BooleanType() + construct: $$ = logic.BooleanType() value_bindings : "|" binding* formula : true - construct: logic.Formula(conjunction=$1) + construct: $$ = logic.Formula(conjunction=$1) + deconstruct: $1 = $$.conjunction if builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args) else None | false - construct: logic.Formula(disjunction=$1) + construct: $$ = logic.Formula(disjunction=$1) + deconstruct: $1 = $$.disjunction if builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args) else None | exists - construct: logic.Formula(exists=$1) + construct: $$ = logic.Formula(exists=$1) + deconstruct: $1 = $$.exists if builtin.has_proto_field($$, 'exists') else None | reduce - construct: logic.Formula(reduce=$1) + construct: $$ = logic.Formula(reduce=$1) + deconstruct: $1 = $$.reduce if builtin.has_proto_field($$, 'reduce') else None | conjunction - construct: logic.Formula(conjunction=$1) + construct: $$ = logic.Formula(conjunction=$1) + deconstruct: $1 = $$.conjunction if builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args) else None | disjunction - construct: logic.Formula(disjunction=$1) + construct: $$ = logic.Formula(disjunction=$1) + deconstruct: $1 = $$.disjunction if builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args) else None | not - construct: logic.Formula(not=$1) + construct: $$ = logic.Formula(not=$1) + deconstruct: $1 = $$.not if builtin.has_proto_field($$, 'not') else None | ffi - construct: logic.Formula(ffi=$1) + construct: $$ = logic.Formula(ffi=$1) + deconstruct: $1 = $$.ffi if builtin.has_proto_field($$, 'ffi') else None | atom - construct: logic.Formula(atom=$1) + construct: $$ = logic.Formula(atom=$1) + deconstruct: $1 = $$.atom if builtin.has_proto_field($$, 'atom') else None | pragma - construct: logic.Formula(pragma=$1) + construct: $$ = logic.Formula(pragma=$1) + deconstruct: $1 = $$.pragma if builtin.has_proto_field($$, 'pragma') else None | primitive - construct: logic.Formula(primitive=$1) + construct: $$ = logic.Formula(primitive=$1) + deconstruct: $1 = $$.primitive if builtin.has_proto_field($$, 'primitive') else None | rel_atom - construct: logic.Formula(rel_atom=$1) + construct: $$ = logic.Formula(rel_atom=$1) + deconstruct: $1 = $$.rel_atom if builtin.has_proto_field($$, 'rel_atom') else None | cast - construct: logic.Formula(cast=$1) + construct: $$ = logic.Formula(cast=$1) + deconstruct: $1 = $$.cast if builtin.has_proto_field($$, 'cast') else None true : "(" "true" ")" - construct: logic.Conjunction(args=list[logic.Formula]()) + construct: $$ = logic.Conjunction(args=list[logic.Formula]()) false : "(" "false" ")" - construct: logic.Disjunction(args=list[logic.Formula]()) + construct: $$ = logic.Disjunction(args=list[logic.Formula]()) exists : "(" "exists" bindings formula ")" - construct: logic.Exists(body=logic.Abstraction(vars=builtin.list_concat($3[0], $3[1]), value=$4)) + construct: $$ = logic.Exists(body=logic.Abstraction(vars=builtin.list_concat($3[0], $3[1]), value=$4)) + deconstruct: $3 = deconstruct_bindings($$.body); $4 = $$.body.value reduce : "(" "reduce" abstraction abstraction terms ")" - construct: logic.Reduce(op=$3, body=$4, terms=$5) + construct: $$ = logic.Reduce(op=$3, body=$4, terms=$5) + deconstruct: $3 = $$.op; $4 = $$.body; $5 = $$.terms term : var - construct: logic.Term(var=$1) + construct: $$ = logic.Term(var=$1) + deconstruct: $1 = $$.var if builtin.has_proto_field($$, 'var') else None | constant - construct: logic.Term(constant=$1) + construct: $$ = logic.Term(constant=$1) + deconstruct: $1 = $$.constant if builtin.has_proto_field($$, 'constant') else None var : SYMBOL - construct: logic.Var(name=$1) + construct: $$ = logic.Var(name=$1) + deconstruct: $1 = $$.name constant : value conjunction : "(" "and" formula* ")" - construct: logic.Conjunction(args=$3) + construct: $$ = logic.Conjunction(args=$3) + deconstruct: $3 = $$.args disjunction : "(" "or" formula* ")" - construct: logic.Disjunction(args=$3) + construct: $$ = logic.Disjunction(args=$3) + deconstruct: $3 = $$.args not : "(" "not" formula ")" - construct: logic.Not(arg=$3) + construct: $$ = logic.Not(arg=$3) + deconstruct: $3 = $$.arg ffi : "(" "ffi" name ffi_args terms ")" - construct: logic.FFI(name=$3, args=$4, terms=$5) + construct: $$ = logic.FFI(name=$3, args=$4, terms=$5) + deconstruct: $3 = $$.name; $4 = $$.args; $5 = $$.terms ffi_args : "(" "args" abstraction* ")" @@ -437,11 +536,13 @@ name atom : "(" "atom" relation_id term* ")" - construct: logic.Atom(name=$3, terms=$4) + construct: $$ = logic.Atom(name=$3, terms=$4) + deconstruct: $3 = $$.name; $4 = $$.terms pragma : "(" "pragma" name term* ")" - construct: logic.Pragma(name=$3, terms=$4) + construct: $$ = logic.Pragma(name=$3, terms=$4) + deconstruct: $3 = $$.name; $4 = $$.terms primitive : eq @@ -454,153 +555,236 @@ primitive | multiply | divide | "(" "primitive" name rel_term* ")" - construct: logic.Primitive(name=$3, terms=$4) + construct: $$ = logic.Primitive(name=$3, terms=$4) + deconstruct: $3 = $$.name; $4 = $$.terms eq : "(" "=" term term ")" - construct: logic.Primitive(name="rel_primitive_eq", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + construct: $$ = logic.Primitive(name="rel_primitive_eq", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_eq" else None + $4 = $$.terms[1].term lt : "(" "<" term term ")" - construct: logic.Primitive(name="rel_primitive_lt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + construct: $$ = logic.Primitive(name="rel_primitive_lt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_lt_monotype" else None + $4 = $$.terms[1].term lt_eq : "(" "<=" term term ")" - construct: logic.Primitive(name="rel_primitive_lt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + construct: $$ = logic.Primitive(name="rel_primitive_lt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_lt_eq_monotype" else None + $4 = $$.terms[1].term gt : "(" ">" term term ")" - construct: logic.Primitive(name="rel_primitive_gt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + construct: $$ = logic.Primitive(name="rel_primitive_gt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_gt_monotype" else None + $4 = $$.terms[1].term gt_eq : "(" ">=" term term ")" - construct: logic.Primitive(name="rel_primitive_gt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + construct: $$ = logic.Primitive(name="rel_primitive_gt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_gt_eq_monotype" else None + $4 = $$.terms[1].term add : "(" "+" term term term ")" - construct: logic.Primitive(name="rel_primitive_add_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + construct: $$ = logic.Primitive(name="rel_primitive_add_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_add_monotype" else None + $4 = $$.terms[1].term + $5 = $$.terms[2].term minus : "(" "-" term term term ")" - construct: logic.Primitive(name="rel_primitive_subtract_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + construct: $$ = logic.Primitive(name="rel_primitive_subtract_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_subtract_monotype" else None + $4 = $$.terms[1].term + $5 = $$.terms[2].term multiply : "(" "*" term term term ")" - construct: logic.Primitive(name="rel_primitive_multiply_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + construct: $$ = logic.Primitive(name="rel_primitive_multiply_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_multiply_monotype" else None + $4 = $$.terms[1].term + $5 = $$.terms[2].term divide : "(" "/" term term term ")" - construct: logic.Primitive(name="rel_primitive_divide_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + construct: $$ = logic.Primitive(name="rel_primitive_divide_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) + deconstruct: + $3 = $$.terms[0].term if $$.name == "rel_primitive_divide_monotype" else None + $4 = $$.terms[1].term + $5 = $$.terms[2].term rel_term : specialized_value - construct: logic.RelTerm(specialized_value=$1) + construct: $$ = logic.RelTerm(specialized_value=$1) + deconstruct: $1 = $$.specialized_value if builtin.has_proto_field($$, 'specialized_value') else None | term - construct: logic.RelTerm(term=$1) + construct: $$ = logic.RelTerm(term=$1) + deconstruct: $1 = $$.term if builtin.has_proto_field($$, 'term') else None specialized_value : "#" value rel_atom : "(" "relatom" name rel_term* ")" - construct: logic.RelAtom(name=$3, terms=$4) + construct: $$ = logic.RelAtom(name=$3, terms=$4) + deconstruct: $3 = $$.name; $4 = $$.terms cast : "(" "cast" term term ")" - construct: logic.Cast(input=$3, result=$4) + construct: $$ = logic.Cast(input=$3, result=$4) + deconstruct: $3 = $$.input; $4 = $$.result attrs : "(" "attrs" attribute* ")" attribute : "(" "attribute" name value* ")" - construct: logic.Attribute(name=$3, args=$4) + construct: $$ = logic.Attribute(name=$3, args=$4) + deconstruct: $3 = $$.name; $4 = $$.args algorithm : "(" "algorithm" relation_id* script ")" - construct: logic.Algorithm(global=$3, body=$4) + construct: $$ = logic.Algorithm(global=$3, body=$4) + deconstruct: $3 = $$.global; $4 = $$.body script : "(" "script" construct* ")" - construct: logic.Script(constructs=$3) + construct: $$ = logic.Script(constructs=$3) + deconstruct: $3 = $$.constructs construct : loop - construct: logic.Construct(loop=$1) + construct: $$ = logic.Construct(loop=$1) + deconstruct: $1 = $$.loop if builtin.has_proto_field($$, 'loop') else None | instruction - construct: logic.Construct(instruction=$1) + construct: $$ = logic.Construct(instruction=$1) + deconstruct: $1 = $$.instruction if builtin.has_proto_field($$, 'instruction') else None loop : "(" "loop" init script ")" - construct: logic.Loop(init=$3, body=$4) + construct: $$ = logic.Loop(init=$3, body=$4) + deconstruct: $3 = $$.init; $4 = $$.body init : "(" "init" instruction* ")" instruction : assign - construct: logic.Instruction(assign=$1) + construct: $$ = logic.Instruction(assign=$1) + deconstruct: $1 = $$.assign if builtin.has_proto_field($$, 'assign') else None | upsert - construct: logic.Instruction(upsert=$1) + construct: $$ = logic.Instruction(upsert=$1) + deconstruct: $1 = $$.upsert if builtin.has_proto_field($$, 'upsert') else None | break - construct: logic.Instruction(break=$1) + construct: $$ = logic.Instruction(break=$1) + deconstruct: $1 = $$.break if builtin.has_proto_field($$, 'break') else None | monoid_def - construct: logic.Instruction(monoid_def=$1) + construct: $$ = logic.Instruction(monoid_def=$1) + deconstruct: $1 = $$.monoid_def if builtin.has_proto_field($$, 'monoid_def') else None | monus_def - construct: logic.Instruction(monus_def=$1) + construct: $$ = logic.Instruction(monus_def=$1) + deconstruct: $1 = $$.monus_def if builtin.has_proto_field($$, 'monus_def') else None assign : "(" "assign" relation_id abstraction attrs? ")" - construct: logic.Assign(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + construct: $$ = logic.Assign(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + deconstruct: + $3 = $$.name + $4 = $$.body + $5 = $$.attrs if not builtin.is_empty($$.attrs) else None upsert : "(" "upsert" relation_id abstraction_with_arity attrs? ")" - construct: logic.Upsert(name=$3, body=$4[0], attrs=builtin.unwrap_option_or($5, list[logic.Attribute]()), value_arity=$4[1]) + construct: $$ = logic.Upsert(name=$3, body=$4[0], attrs=builtin.unwrap_option_or($5, list[logic.Attribute]()), value_arity=$4[1]) + deconstruct: + $3 = $$.name + $4 = builtin.tuple($$.body, $$.value_arity) + $5 = $$.attrs if not builtin.is_empty($$.attrs) else None abstraction_with_arity : "(" bindings formula ")" - construct: builtin.tuple(logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3), builtin.length($2[1])) + construct: $$ = builtin.tuple(logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3), builtin.length($2[1])) + deconstruct: $2 = deconstruct_bindings_with_arity($$[0], $$[1]); $3 = $$[0].value break : "(" "break" relation_id abstraction attrs? ")" - construct: logic.Break(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + construct: $$ = logic.Break(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) + deconstruct: + $3 = $$.name + $4 = $$.body + $5 = $$.attrs if not builtin.is_empty($$.attrs) else None monoid_def : "(" "monoid" monoid relation_id abstraction_with_arity attrs? ")" - construct: logic.MonoidDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) + construct: $$ = logic.MonoidDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) + deconstruct: + $3 = $$.monoid + $4 = $$.name + $5 = builtin.tuple($$.body, $$.value_arity) + $6 = $$.attrs if not builtin.is_empty($$.attrs) else None monoid : or_monoid - construct: logic.Monoid(or_monoid=$1) + construct: $$ = logic.Monoid(or_monoid=$1) + deconstruct: $1 = $$.or_monoid if builtin.has_proto_field($$, 'or_monoid') else None | min_monoid - construct: logic.Monoid(min_monoid=$1) + construct: $$ = logic.Monoid(min_monoid=$1) + deconstruct: $1 = $$.min_monoid if builtin.has_proto_field($$, 'min_monoid') else None | max_monoid - construct: logic.Monoid(max_monoid=$1) + construct: $$ = logic.Monoid(max_monoid=$1) + deconstruct: $1 = $$.max_monoid if builtin.has_proto_field($$, 'max_monoid') else None | sum_monoid - construct: logic.Monoid(sum_monoid=$1) + construct: $$ = logic.Monoid(sum_monoid=$1) + deconstruct: $1 = $$.sum_monoid if builtin.has_proto_field($$, 'sum_monoid') else None or_monoid : "(" "or" ")" - construct: logic.OrMonoid() + construct: $$ = logic.OrMonoid() min_monoid : "(" "min" type ")" - construct: logic.MinMonoid(type=$3) + construct: $$ = logic.MinMonoid(type=$3) + deconstruct: $3 = $$.type + max_monoid : "(" "max" type ")" - construct: logic.MaxMonoid(type=$3) + construct: $$ = logic.MaxMonoid(type=$3) + deconstruct: $3 = $$.type sum_monoid : "(" "sum" type ")" - construct: logic.SumMonoid(type=$3) + construct: $$ = logic.SumMonoid(type=$3) + deconstruct: $3 = $$.type monus_def : "(" "monus" monoid relation_id abstraction_with_arity attrs? ")" - construct: logic.MonusDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) + construct: $$ = logic.MonusDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) + deconstruct: + $3 = $$.monoid + $4 = $$.name + $5 = builtin.tuple($$.body, $$.value_arity) + $6 = $$.attrs if not builtin.is_empty($$.attrs) else None constraint : "(" "functional_dependency" relation_id abstraction functional_dependency_keys functional_dependency_values ")" - construct: logic.Constraint(name=$3, functional_dependency=logic.FunctionalDependency(guard=$4, keys=$5, values=$6)) + construct: $$ = logic.Constraint(name=$3, functional_dependency=logic.FunctionalDependency(guard=$4, keys=$5, values=$6)) + deconstruct: + $3 = $$.name + $4 = $$.functional_dependency.guard + $5 = $$.functional_dependency.keys + $6 = $$.functional_dependency.values functional_dependency_keys : "(" "keys" var* ")" @@ -610,11 +794,14 @@ functional_dependency_values data : rel_edb - construct: logic.Data(rel_edb=$1) + construct: $$ = logic.Data(rel_edb=$1) + deconstruct: $1 = $$.rel_edb if builtin.has_proto_field($$, 'rel_edb') else None | betree_relation - construct: logic.Data(betree_relation=$1) + construct: $$ = logic.Data(betree_relation=$1) + deconstruct: $1 = $$.betree_relation if builtin.has_proto_field($$, 'betree_relation') else None | csv_data - construct: logic.Data(csv_data=$1) + construct: $$ = logic.Data(csv_data=$1) + deconstruct: $1 = $$.csv_data if builtin.has_proto_field($$, 'csv_data') else None rel_edb_path : "[" STRING* "]" @@ -624,15 +811,21 @@ rel_edb_types rel_edb : "(" "rel_edb" relation_id rel_edb_path rel_edb_types ")" - construct: logic.RelEDB(target_id=$3, path=$4, types=$5) + construct: $$ = logic.RelEDB(target_id=$3, path=$4, types=$5) + deconstruct: $3 = $$.target_id; $4 = $$.path; $5 = $$.types betree_relation : "(" "betree_relation" relation_id betree_info ")" - construct: logic.BeTreeRelation(name=$3, relation_info=$4) + construct: $$ = logic.BeTreeRelation(name=$3, relation_info=$4) + deconstruct: $3 = $$.name; $4 = $$.relation_info betree_info : "(" "betree_info" betree_info_key_types betree_info_value_types config_dict ")" - construct: construct_betree_info($3, $4, $5) + construct: $$ = construct_betree_info($3, $4, $5) + deconstruct: + $3 = $$.key_types + $4 = $$.value_types + $5 = deconstruct_betree_info_config($$) betree_info_key_types : "(" "key_types" type* ")" @@ -648,7 +841,8 @@ csv_asof csv_data : "(" "csv_data" csvlocator csv_config csv_columns csv_asof ")" - construct: logic.CSVData(locator=$3, config=$4, columns=$5, asof=$6) + construct: $$ = logic.CSVData(locator=$3, config=$4, columns=$5, asof=$6) + deconstruct: $3 = $$.locator; $4 = $$.config; $5 = $$.columns; $6 = $$.asof csv_locator_paths : "(" "paths" STRING* ")" @@ -658,62 +852,83 @@ csv_locator_inline_data csvlocator : "(" "csv_locator" csv_locator_paths? csv_locator_inline_data? ")" - construct: logic.CSVLocator(paths=builtin.unwrap_option_or($3, list[str]()), inline_data=builtin.encode_string(builtin.unwrap_option_or($4, ""))) + construct: $$ = logic.CSVLocator(paths=builtin.unwrap_option_or($3, list[str]()), inline_data=builtin.encode_string(builtin.unwrap_option_or($4, ""))) + deconstruct: + $3 = $$.paths if not builtin.is_empty($$.paths) else None + $4 = builtin.decode_string($$.inline_data) if builtin.decode_string($$.inline_data) != "" else None csv_config : "(" "csv_config" config_dict ")" - construct: construct_csv_config($3) + construct: $$ = construct_csv_config($3) + deconstruct: $3 = deconstruct_csv_config($$) csv_column : "(" "column" STRING relation_id "[" type* "]" ")" - construct: logic.CSVColumn(column_name=$3, target_id=$4, types=$6) + construct: $$ = logic.CSVColumn(column_name=$3, target_id=$4, types=$6) + deconstruct: $3 = $$.column_name; $4 = $$.target_id; $6 = $$.types undefine : "(" "undefine" fragment_id ")" - construct: transactions.Undefine(fragment_id=$3) + construct: $$ = transactions.Undefine(fragment_id=$3) + deconstruct: $3 = $$.fragment_id context : "(" "context" relation_id* ")" - construct: transactions.Context(relations=$3) + construct: $$ = transactions.Context(relations=$3) + deconstruct: $3 = $$.relations epoch_reads : "(" "reads" read* ")" read : demand - construct: transactions.Read(demand=$1) + construct: $$ = transactions.Read(demand=$1) + deconstruct: $1 = $$.demand if builtin.has_proto_field($$, 'demand') else None | output - construct: transactions.Read(output=$1) + construct: $$ = transactions.Read(output=$1) + deconstruct: $1 = $$.output if builtin.has_proto_field($$, 'output') else None | what_if - construct: transactions.Read(what_if=$1) + construct: $$ = transactions.Read(what_if=$1) + deconstruct: $1 = $$.what_if if builtin.has_proto_field($$, 'what_if') else None | abort - construct: transactions.Read(abort=$1) + construct: $$ = transactions.Read(abort=$1) + deconstruct: $1 = $$.abort if builtin.has_proto_field($$, 'abort') else None | export - construct: transactions.Read(export=$1) + construct: $$ = transactions.Read(export=$1) + deconstruct: $1 = $$.export if builtin.has_proto_field($$, 'export') else None demand : "(" "demand" relation_id ")" - construct: transactions.Demand(relation_id=$3) + construct: $$ = transactions.Demand(relation_id=$3) + deconstruct: $3 = $$.relation_id output : "(" "output" name? relation_id ")" - construct: transactions.Output(name=builtin.unwrap_option_or($3, "output"), relation_id=$4) + construct: $$ = transactions.Output(name=builtin.unwrap_option_or($3, "output"), relation_id=$4) + deconstruct: $3 = $$.name if $$.name != "output" else None; $4 = $$.relation_id what_if : "(" "what_if" name epoch ")" - construct: transactions.WhatIf(branch=$3, epoch=$4) + construct: $$ = transactions.WhatIf(branch=$3, epoch=$4) + deconstruct: $3 = $$.branch; $4 = $$.epoch abort : "(" "abort" name? relation_id ")" - construct: transactions.Abort(name=builtin.unwrap_option_or($3, "abort"), relation_id=$4) + construct: $$ = transactions.Abort(name=builtin.unwrap_option_or($3, "abort"), relation_id=$4) + deconstruct: $3 = $$.name if $$.name != "abort" else None; $4 = $$.relation_id export : "(" "export" export_csv_config ")" - construct: transactions.Export(csv_config=$3) + construct: $$ = transactions.Export(csv_config=$3) + deconstruct: $3 = $$.csv_config export_csv_config : "(" "export_csv_config" export_csv_path export_csv_columns config_dict ")" - construct: export_csv_config($3, $4, $5) + construct: $$ = export_csv_config($3, $4, $5) + deconstruct: + $3 = $$.path + $4 = $$.data_columns + $5 = deconstruct_export_csv_config($$) export_csv_path : "(" "path" STRING ")" @@ -723,7 +938,8 @@ export_csv_columns export_csv_column : "(" "column" STRING relation_id ")" - construct: transactions.ExportCSVColumn(column_name=$3, column_data=$4) + construct: $$ = transactions.ExportCSVColumn(column_name=$3, column_data=$4) + deconstruct: $3 = $$.column_name; $4 = $$.column_data %% @@ -920,3 +1136,151 @@ def export_csv_config( syntax_quotechar=builtin.to_ptr_string(syntax_quotechar), syntax_escapechar=builtin.to_ptr_string(syntax_escapechar), ) + + +def _make_value_int64(v: int) -> logic.Value: + return logic.Value(int_value=v) + + +def _make_value_float64(v: float) -> logic.Value: + return logic.Value(float_value=v) + + +def _make_value_string(v: str) -> logic.Value: + return logic.Value(string_value=v) + + +def _make_value_boolean(v: bool) -> logic.Value: + return logic.Value(boolean_value=v) + + +def _make_value_uint128(v: logic.UInt128Value) -> logic.Value: + return logic.Value(uint128_value=v) + + +def is_default_configure(cfg: transactions.Configure) -> bool: + if cfg.semantics_version != 0: + return False + if cfg.ivm_config.level != transactions.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + return False + return True + + +def deconstruct_configure(msg: transactions.Configure) -> List[Tuple[String, logic.Value]]: + result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() + if msg.semantics_version != 0: + builtin.list_push(result, builtin.tuple("semantics_version", _make_value_int64(msg.semantics_version))) + if msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: + builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("auto"))) + elif msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: + builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("all"))) + elif msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("off"))) + return result + + +def deconstruct_csv_config(msg: logic.CSVConfig) -> List[Tuple[String, logic.Value]]: + result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() + if msg.header_row != 1: + builtin.list_push(result, builtin.tuple("csv_header_row", _make_value_int64(builtin.int32_to_int64(msg.header_row)))) + if msg.skip != 0: + builtin.list_push(result, builtin.tuple("csv_skip", _make_value_int64(msg.skip))) + if msg.new_line != "": + builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) + if msg.delimiter != ",": + builtin.list_push(result, builtin.tuple("csv_delimiter", _make_value_string(msg.delimiter))) + if msg.quotechar != "\"": + builtin.list_push(result, builtin.tuple("csv_quotechar", _make_value_string(msg.quotechar))) + if msg.escapechar != "\"": + builtin.list_push(result, builtin.tuple("csv_escapechar", _make_value_string(msg.escapechar))) + if msg.comment != "": + builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) + if not builtin.is_empty(msg.missing_strings): + builtin.list_push(result, builtin.tuple("csv_missing_strings", _make_value_string(msg.missing_strings[0]))) + if msg.decimal_separator != ".": + builtin.list_push(result, builtin.tuple("csv_decimal_separator", _make_value_string(msg.decimal_separator))) + if msg.encoding != "utf-8": + builtin.list_push(result, builtin.tuple("csv_encoding", _make_value_string(msg.encoding))) + if msg.compression != "auto": + builtin.list_push(result, builtin.tuple("csv_compression", _make_value_string(msg.compression))) + return result + + +def _maybe_push_float64(result: List[Tuple[String, logic.Value]], key: String, val: Optional[float]) -> None: + if val is not None: + builtin.list_push(result, builtin.tuple(key, _make_value_float64(builtin.unwrap_option(val)))) + return None + + +def _maybe_push_int64(result: List[Tuple[String, logic.Value]], key: String, val: Optional[int]) -> None: + if val is not None: + builtin.list_push(result, builtin.tuple(key, _make_value_int64(builtin.unwrap_option(val)))) + return None + + +def _maybe_push_uint128(result: List[Tuple[String, logic.Value]], key: String, val: Optional[logic.UInt128Value]) -> None: + if val is not None: + builtin.list_push(result, builtin.tuple(key, _make_value_uint128(builtin.unwrap_option(val)))) + return None + + +def _maybe_push_bytes_as_string(result: List[Tuple[String, logic.Value]], key: String, val: Optional[bytes]) -> None: + if val is not None: + builtin.list_push(result, builtin.tuple(key, _make_value_string(builtin.decode_string(builtin.unwrap_option(val))))) + return None + + +def deconstruct_betree_info_config(msg: logic.BeTreeInfo) -> List[Tuple[String, logic.Value]]: + result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() + _maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.epsilon) + _maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.max_pivots) + _maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.max_deltas) + _maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.max_leaf) + _maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.root_pageid) + _maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.inline_data) + _maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.element_count) + _maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.tree_height) + return result + + +def deconstruct_export_csv_config(msg: transactions.ExportCSVConfig) -> List[Tuple[String, logic.Value]]: + result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() + if msg.partition_size is not None and builtin.unwrap_option(msg.partition_size) != 0: + builtin.list_push(result, builtin.tuple("partition_size", _make_value_int64(builtin.unwrap_option(msg.partition_size)))) + if msg.compression is not None and builtin.unwrap_option(msg.compression) != "": + builtin.list_push(result, builtin.tuple("compression", _make_value_string(builtin.unwrap_option(msg.compression)))) + if msg.syntax_header_row is not None: + builtin.list_push(result, builtin.tuple("syntax_header_row", _make_value_boolean(builtin.unwrap_option(msg.syntax_header_row)))) + if msg.syntax_missing_string is not None and builtin.unwrap_option(msg.syntax_missing_string) != "": + builtin.list_push(result, builtin.tuple("syntax_missing_string", _make_value_string(builtin.unwrap_option(msg.syntax_missing_string)))) + if msg.syntax_delim is not None and builtin.unwrap_option(msg.syntax_delim) != ",": + builtin.list_push(result, builtin.tuple("syntax_delim", _make_value_string(builtin.unwrap_option(msg.syntax_delim)))) + if msg.syntax_quotechar is not None and builtin.unwrap_option(msg.syntax_quotechar) != '"': + builtin.list_push(result, builtin.tuple("syntax_quotechar", _make_value_string(builtin.unwrap_option(msg.syntax_quotechar)))) + if msg.syntax_escapechar is not None and builtin.unwrap_option(msg.syntax_escapechar) != "\\": + builtin.list_push(result, builtin.tuple("syntax_escapechar", _make_value_string(builtin.unwrap_option(msg.syntax_escapechar)))) + return result + + +def deconstruct_relation_id_string(msg: logic.RelationId) -> Optional[String]: + name: String = builtin.relation_id_to_string(msg) + if name != "": + return name + return None + + +def deconstruct_relation_id_uint128(msg: logic.RelationId) -> Optional[logic.UInt128Value]: + name: String = builtin.relation_id_to_string(msg) + if name == "": + return builtin.relation_id_to_uint128(msg) + return None + + +def deconstruct_bindings(abs: logic.Abstraction) -> Tuple[List[logic.Binding], List[logic.Binding]]: + return builtin.tuple(abs.vars, list[logic.Binding]()) + + +def deconstruct_bindings_with_arity(abs: logic.Abstraction, value_arity: int) -> Tuple[List[logic.Binding], List[logic.Binding]]: + n: int = builtin.length(abs.vars) + key_end: int = n - value_arity + return builtin.tuple(builtin.list_slice(abs.vars, 0, key_end), builtin.list_slice(abs.vars, key_end, n)) diff --git a/python-tools/src/meta/grammar_utils.py b/python-tools/src/meta/grammar_utils.py index 4deff6b1..5e0513dd 100644 --- a/python-tools/src/meta/grammar_utils.py +++ b/python-tools/src/meta/grammar_utils.py @@ -81,6 +81,7 @@ def rewrite_rule(rule: Rule, replacements: Dict[Rhs, Rhs]) -> Rule: lhs=rule.lhs, rhs=new_rhs, constructor=rule.constructor, + deconstructor=rule.deconstructor, source_type=rule.source_type ) return rule diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py new file mode 100644 index 00000000..137bc9fb --- /dev/null +++ b/python-tools/src/meta/pretty_gen.py @@ -0,0 +1,503 @@ +"""Pretty printer generator. + +Generates pretty-printer visitor methods from grammar rules. Each nonterminal +gets a pretty_X method that deconstructs a protobuf message according to the +rule's deconstruct action, then prints the RHS elements. + +For nonterminals with multiple rules, rules are tried in specificity order +(most specific first), using the deconstructor to determine which rule matches. +""" + +from typing import Dict, List, Optional, Union +from .grammar import Grammar, GrammarConfig, Rule, Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence +from .grammar_utils import is_epsilon, rhs_elements +from .target import ( + Lambda, Call, VisitNonterminalDef, Var, Lit, Builtin, Let, IfElse, + BaseType, ListType, TupleType, TargetExpr, Seq, VisitNonterminal, gensym, + OptionType, ForeachEnumerated, GetElement +) +from .target_builtins import make_builtin + +# Type alias for grammar parameter (both Grammar and GrammarConfig have .rules) +GrammarLike = Union[Grammar, GrammarConfig] + + +def _get_rules_dict(grammar: GrammarLike) -> Dict[Nonterminal, List[Rule]]: + """Get the rules dictionary from either Grammar or GrammarConfig.""" + return grammar.rules + + +def generate_pretty_functions(grammar: GrammarLike, + proto_messages: Optional[Dict] = None) -> List[VisitNonterminalDef]: + """Generate pretty printer functions for all nonterminals.""" + pretty_methods = [] + + if isinstance(grammar, GrammarConfig): + nonterminals = sorted(grammar.rules.keys(), key=lambda nt: nt.name) + else: + rule_order, _ = grammar.analysis.partition_nonterminals_by_reachability() + reachable = grammar.analysis.reachability + nonterminals = [nt for nt in rule_order if reachable is None or nt in reachable] + + rules_dict = _get_rules_dict(grammar) + for nt in nonterminals: + rules = rules_dict[nt] + method_code = _generate_pretty_method(nt, rules, grammar, proto_messages) + pretty_methods.append(method_code) + return pretty_methods + + +def _generate_pretty_method(lhs: Nonterminal, rules: List[Rule], + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> VisitNonterminalDef: + """Generate a pretty-print visitor method for a nonterminal.""" + nt = rules[0].lhs + msg_param = Var("msg", nt.type) + + if len(rules) == 1: + body = _generate_pretty_with_deconstruct(rules[0], msg_param, grammar, proto_messages) + else: + body = _generate_pretty_alternatives(rules, msg_param, grammar, proto_messages) + + return VisitNonterminalDef( + visitor_name='pretty', + nonterminal=nt, + params=[msg_param], + return_type=OptionType(BaseType("Never")), + body=body + ) + + +def _generate_pretty_alternatives(rules: List[Rule], msg_param: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate if-else chain trying rules in declaration order. + + Rules are tried in the order they appear in the grammar. For each rule, + the deconstructor is called; if it returns non-None, that rule is used. + The last rule with a trivial (always-matching) deconstructor serves as + the fallback. + """ + # Find the last rule with a trivial deconstructor to use as fallback. + # All other rules are tried in declaration order before it. + fallback_idx: Optional[int] = None + for i in range(len(rules) - 1, -1, -1): + rule = rules[i] + if is_epsilon(rule.rhs): + fallback_idx = i + break + if rule.deconstructor is None or _is_trivial_deconstruct(rule.deconstructor): + fallback_idx = i + break + if not (_is_guarded_rule(rule, grammar)): + fallback_idx = i + break + + if fallback_idx is not None: + result: TargetExpr = _generate_pretty_with_deconstruct( + rules[fallback_idx], msg_param, grammar, proto_messages) + else: + result = Call(make_builtin('error'), [Lit(f"No matching rule for {rules[0].lhs.name}")]) + + # Build if-else chain in reverse declaration order (so first-declared ends up outermost) + guarded_indices = [i for i in range(len(rules)) if i != fallback_idx] + for i in reversed(guarded_indices): + rule = rules[i] + if _is_nonterminal_ref(rule) and _has_guarded_deconstruct(rule.rhs, grammar): + result = _generate_nonterminal_ref_dispatch(rule, msg_param, grammar, proto_messages, result) + elif rule.deconstructor is not None and isinstance(rule.deconstructor.return_type, OptionType): + deconstruct_result_var = Var(gensym('deconstruct_result'), rule.deconstructor.return_type) + deconstruct_call = Call(rule.deconstructor, [msg_param]) + pretty_body = _generate_pretty_from_fields( + rule.rhs, deconstruct_result_var, grammar, proto_messages) + result = Let( + deconstruct_result_var, + deconstruct_call, + IfElse( + Call(make_builtin('is_some'), [deconstruct_result_var]), + pretty_body, + result + ) + ) + else: + # Unguarded non-fallback rule — treat as always matching at this position + result = _generate_pretty_with_deconstruct(rule, msg_param, grammar, proto_messages) + + return result + + +def _is_guarded_rule(rule: Rule, grammar: GrammarLike) -> bool: + """Check if a rule has a guard (Optional deconstructor or guarded nonterminal ref).""" + if _is_nonterminal_ref(rule) and _has_guarded_deconstruct(rule.rhs, grammar): + return True + if rule.deconstructor is not None and isinstance(rule.deconstructor.return_type, OptionType): + return True + return False + + +def _is_nonterminal_ref(rule: Rule) -> bool: + """Check if a rule's RHS is a single nonterminal reference.""" + return isinstance(rule.rhs, Nonterminal) + + +def _has_guarded_deconstruct(nt_ref: Rhs, grammar: GrammarLike) -> bool: + """Check if a referenced nonterminal has a guarded (Optional) deconstructor.""" + if not isinstance(nt_ref, Nonterminal): + return False + rules_dict = _get_rules_dict(grammar) + for nt, rules in rules_dict.items(): + if nt.name == nt_ref.name: + return any( + r.deconstructor is not None + and isinstance(r.deconstructor.return_type, OptionType) + for r in rules + ) + return False + + +def _generate_nonterminal_ref_dispatch(rule: Rule, msg_param: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict], + fallback: TargetExpr) -> TargetExpr: + """Generate dispatch for a nonterminal-reference alternative. + + Uses the referenced nonterminal's deconstructor as the guard condition, + then calls the referenced nonterminal's pretty printer if matched. + """ + nt_ref = rule.rhs + assert isinstance(nt_ref, Nonterminal) + + rules_dict = _get_rules_dict(grammar) + subrule_rules = None + for nt, rules in rules_dict.items(): + if nt.name == nt_ref.name: + subrule_rules = rules + break + + if subrule_rules is None: + return fallback + + # Find the first rule with an Optional deconstructor (guard) + guard_deconstructor = None + for r in subrule_rules: + if r.deconstructor is not None and isinstance(r.deconstructor.return_type, OptionType): + guard_deconstructor = r.deconstructor + break + + if guard_deconstructor is None: + return Call(VisitNonterminal('pretty', nt_ref), [msg_param]) + + deconstruct_result_var = Var(gensym('guard_result'), guard_deconstructor.return_type) + deconstruct_call = Call(guard_deconstructor, [msg_param]) + pretty_call = Call(VisitNonterminal('pretty', nt_ref), [msg_param]) + + return Let( + deconstruct_result_var, + deconstruct_call, + IfElse( + Call(make_builtin('is_some'), [deconstruct_result_var]), + pretty_call, + fallback + ) + ) + + +def _generate_pretty_with_deconstruct(rule: Rule, msg_param: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate pretty printing using the deconstructor to extract fields.""" + if rule.deconstructor is None or _is_trivial_deconstruct(rule.deconstructor): + deconstructor = rule.deconstructor + if deconstructor is not None: + fields_expr = _extract_trivial_deconstruct_result(deconstructor, msg_param) + if isinstance(deconstructor.return_type, OptionType): + unwrapped_type = deconstructor.return_type.element_type + else: + unwrapped_type = deconstructor.return_type + else: + fields_expr = msg_param + unwrapped_type = msg_param.type + + fields_var = Var(gensym('fields'), unwrapped_type) + pretty_body = _generate_pretty_from_fields(rule.rhs, fields_var, grammar, proto_messages) + return Let(fields_var, fields_expr, pretty_body) + + # Non-trivial deconstruct — call the lambda + deconstructor = rule.deconstructor + deconstruct_result_var = Var(gensym('fields'), deconstructor.return_type) + deconstruct_call = Call(deconstructor, [msg_param]) + + if isinstance(deconstructor.return_type, OptionType): + unwrapped_type = deconstructor.return_type.element_type + else: + unwrapped_type = deconstructor.return_type + + unwrapped_var = Var(gensym('unwrapped_fields'), unwrapped_type) + unwrap_expr = Call(make_builtin('unwrap_option'), [deconstruct_result_var]) + + pretty_body = _generate_pretty_from_fields(rule.rhs, unwrapped_var, grammar, proto_messages) + + return Let(deconstruct_result_var, deconstruct_call, + Let(unwrapped_var, unwrap_expr, pretty_body)) + + +def _generate_pretty_from_fields(rhs: Rhs, fields_var: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate pretty printing code given extracted field values.""" + if isinstance(rhs, Sequence): + return _generate_pretty_sequence_from_fields(rhs, fields_var, grammar, proto_messages) + elif isinstance(rhs, LitTerminal): + return _format_literal(rhs) + elif isinstance(rhs, NamedTerminal): + formatted = _format_terminal(rhs, fields_var) + return Call(make_builtin('write_io'), [formatted]) + elif isinstance(rhs, Nonterminal): + return Call(VisitNonterminal('pretty', rhs), [fields_var]) + elif isinstance(rhs, Option): + return _generate_pretty_option_from_field(rhs, fields_var, grammar, proto_messages) + elif isinstance(rhs, Star): + return _generate_pretty_star_from_field(rhs, fields_var, grammar, proto_messages) + else: + assert False, f'Unsupported Rhs type: {type(rhs)}' + + +def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate pretty printing for a sequence using extracted field values.""" + if is_epsilon(rhs): + return Lit(None) + + elems = list(rhs_elements(rhs)) + stmts: List[TargetExpr] = [] + field_idx = 0 + + # Detect S-expression pattern: first element is "(", second is a keyword literal + is_sexp = (len(elems) >= 2 + and isinstance(elems[0], LitTerminal) and elems[0].name == '(' + and isinstance(elems[1], LitTerminal) and elems[1].name != '(') + + # Count non-literal elements to determine if fields_var is a tuple or single value + non_lit_count = sum(1 for e in elems if not isinstance(e, LitTerminal)) + + for i, elem in enumerate(elems): + if isinstance(elem, LitTerminal): + is_keyword = is_sexp and i == 1 + stmts.append(_format_literal(elem, is_sexp_keyword=is_keyword)) + else: + # Insert newline between consecutive non-literal elements + if stmts and field_idx > 0 and is_sexp: + stmts.append(Call(make_builtin('newline_io'), [])) + + # Extract field from tuple or use directly + if non_lit_count > 1 and isinstance(fields_var.type, TupleType): + elem_type = fields_var.type.elements[field_idx] + elem_var = Var(gensym('field'), elem_type) + elem_expr = GetElement(fields_var, field_idx) + pretty_elem = _pretty_print_element(elem, elem_var, grammar, proto_messages) + stmts.append(Let(elem_var, elem_expr, pretty_elem)) + else: + stmts.append(_pretty_print_element(elem, fields_var, grammar, proto_messages)) + field_idx += 1 + + if not stmts: + return Lit(None) + elif len(stmts) == 1: + return stmts[0] + else: + return Seq(stmts) + + +def _pretty_print_element(elem: Rhs, var: Var, grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Pretty print a single RHS element given its value.""" + if isinstance(elem, NamedTerminal): + formatted = _format_terminal(elem, var) + return Call(make_builtin('write_io'), [formatted]) + elif isinstance(elem, Nonterminal): + return Call(VisitNonterminal('pretty', elem), [var]) + elif isinstance(elem, Option): + return _generate_pretty_option_from_field(elem, var, grammar, proto_messages) + elif isinstance(elem, Star): + return _generate_pretty_star_from_field(elem, var, grammar, proto_messages) + else: + return Call(make_builtin('write_io'), [Lit(f'<{type(elem).__name__}>')]) + + +def _generate_pretty_option_from_field(rhs: Option, field_var: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate pretty printing for an optional field.""" + has_value = Call(make_builtin('is_some'), [field_var]) + + inner_type = field_var.type + if isinstance(inner_type, OptionType): + inner_type = inner_type.element_type + + value_var = Var(gensym('opt_val'), inner_type) + value_expr = Call(make_builtin('unwrap_option'), [field_var]) + + if isinstance(rhs.rhs, NamedTerminal): + formatted = _format_terminal(rhs.rhs, value_var) + pretty_inner = Call(make_builtin('write_io'), [formatted]) + elif isinstance(rhs.rhs, Nonterminal): + pretty_inner = Call(VisitNonterminal('pretty', rhs.rhs), [value_var]) + elif isinstance(rhs.rhs, Sequence): + pretty_inner = _generate_pretty_from_fields(rhs.rhs, value_var, grammar, proto_messages) + else: + pretty_inner = Call(make_builtin('write_io'), [Call(make_builtin('to_string'), [value_var])]) + + return IfElse( + has_value, + Let(value_var, value_expr, pretty_inner), + Lit(None) + ) + + +def _generate_pretty_star_from_field(rhs: Star, field_var: Var, + grammar: GrammarLike, + proto_messages: Optional[Dict]) -> TargetExpr: + """Generate pretty printing for a repeated field.""" + list_type = field_var.type + if isinstance(list_type, ListType): + elem_type = list_type.element_type + else: + elem_type = BaseType('Any') + + elem_var = Var(gensym('elem'), elem_type) + index_var = Var(gensym('i'), BaseType('Int64')) + + if isinstance(rhs.rhs, NamedTerminal): + formatted = _format_terminal(rhs.rhs, elem_var) + pretty_elem = Call(make_builtin('write_io'), [formatted]) + elif isinstance(rhs.rhs, Nonterminal): + pretty_elem = Call(VisitNonterminal('pretty', rhs.rhs), [elem_var]) + elif isinstance(rhs.rhs, Sequence): + pretty_elem = _generate_pretty_from_fields(rhs.rhs, elem_var, grammar, proto_messages) + else: + pretty_elem = Call(make_builtin('write_io'), [Call(make_builtin('to_string'), [elem_var])]) + + # Add newline between elements (except before first) + pretty_with_spacing = IfElse( + Call(make_builtin('greater'), [index_var, Lit(0)]), + Seq([Call(make_builtin('newline_io'), []), pretty_elem]), + pretty_elem + ) + + pretty_with_spacing = _optimize_if_else_with_common_tail(pretty_with_spacing) + + return ForeachEnumerated(index_var, elem_var, field_var, pretty_with_spacing) + + +def _format_literal(lit: LitTerminal, is_sexp_keyword: bool = False) -> TargetExpr: + """Format a literal terminal for output. + + is_sexp_keyword: True if this literal is the keyword in an S-expression + (i.e., appears at position 1 in a "(keyword ...)" sequence). + """ + if lit.name == '(': + return Call(make_builtin('write_io'), [Lit('(')]) + elif lit.name == ')': + return Seq([ + Call(make_builtin('dedent_io'), []), + Call(make_builtin('write_io'), [Lit(')')]), + Call(make_builtin('newline_io'), []), + ]) + elif is_sexp_keyword: + return Seq([ + Call(make_builtin('write_io'), [Lit(lit.name)]), + Call(make_builtin('newline_io'), []), + Call(make_builtin('indent_io'), []), + ]) + else: + return Call(make_builtin('write_io'), [Lit(lit.name)]) + + +def _format_terminal(terminal: NamedTerminal, value_var: Var) -> TargetExpr: + """Format a terminal value for pretty printing.""" + if terminal.name in ['SYMBOL', 'IDENTIFIER']: + return Call(make_builtin('format_symbol'), [value_var]) + elif terminal.name == 'STRING': + return Call(make_builtin('format_string'), [value_var]) + elif terminal.name in ['INT', 'NUMBER']: + return Call(make_builtin('format_int64'), [value_var]) + elif terminal.name == 'FLOAT': + return Call(make_builtin('format_float64'), [value_var]) + elif terminal.name == 'BOOL': + return Call(make_builtin('format_bool'), [value_var]) + elif terminal.name == 'HEX_UINT128': + return Call(make_builtin('format_uint128'), [value_var]) + else: + return Call(make_builtin('to_string'), [value_var]) + + +# --- Utility functions --- + +def _is_trivial_deconstruct(deconstructor: Lambda) -> bool: + """Check if a deconstructor is trivial (just returns msg or msg.field).""" + body = deconstructor.body + if isinstance(body, Var) and body.name == 'msg': + return True + if (isinstance(body, Call) and isinstance(body.func, Builtin) and + body.func.name == 'some' and len(body.args) == 1 and + isinstance(body.args[0], Var) and body.args[0].name == 'msg'): + return True + return False + + +def _extract_trivial_deconstruct_result(deconstructor: Lambda, msg_param: Var) -> TargetExpr: + """Extract the result expression from a trivial deconstructor.""" + body = deconstructor.body + if isinstance(body, Var) and body.name == 'msg': + return msg_param + if (isinstance(body, Call) and isinstance(body.func, Builtin) and + body.func.name == 'some' and len(body.args) == 1): + return msg_param + return msg_param + + +def _optimize_if_else_with_common_tail(expr: IfElse) -> TargetExpr: + """Optimize IfElse where both branches end with the same expression. + + Transforms: IfElse(cond, Seq([a, b, c]), Seq([x, c])) + Into: Seq([IfElse(cond, Seq([a, b]), x), c]) + """ + then_branch = expr.then_branch + else_branch = expr.else_branch + + if not isinstance(then_branch, Seq): + return expr + + if not isinstance(else_branch, Seq): + if len(then_branch.exprs) > 1 and then_branch.exprs[-1] == else_branch: + new_then = Seq(then_branch.exprs[:-1]) if len(then_branch.exprs) > 2 else then_branch.exprs[0] + return Seq([IfElse(expr.condition, new_then, Lit(None)), else_branch]) + return expr + + then_exprs = list(then_branch.exprs) + else_exprs = list(else_branch.exprs) + + common_len = 0 + min_len = min(len(then_exprs), len(else_exprs)) + for i in range(1, min_len + 1): + if then_exprs[-i] == else_exprs[-i]: + common_len = i + else: + break + + if common_len == 0: + return expr + + then_prefix = then_exprs[:-common_len] + else_prefix = else_exprs[:-common_len] + common_suffix = then_exprs[-common_len:] + + if len(then_prefix) == 0 and len(else_prefix) == 0: + return Seq(common_suffix) if len(common_suffix) > 1 else common_suffix[0] + + new_then = Seq(then_prefix) if len(then_prefix) > 1 else (then_prefix[0] if then_prefix else Lit(None)) + new_else = Seq(else_prefix) if len(else_prefix) > 1 else (else_prefix[0] if else_prefix else Lit(None)) + + result_parts = [IfElse(expr.condition, new_then, new_else)] + common_suffix + return Seq(result_parts) if len(result_parts) > 1 else result_parts[0] diff --git a/python-tools/src/meta/pretty_gen_python.py b/python-tools/src/meta/pretty_gen_python.py new file mode 100644 index 00000000..ba596e0d --- /dev/null +++ b/python-tools/src/meta/pretty_gen_python.py @@ -0,0 +1,139 @@ +"""Python-specific pretty printer code generation. + +Generates pretty printers in Python from grammars. Handles Python-specific +code generation including prologue (imports, PrettyPrinter class), pretty +print method generation, and epilogue. +""" + +from typing import Optional, Set + +from .grammar import Grammar, Nonterminal +from .codegen_python import PythonCodeGenerator +from .codegen_templates import PYTHON_TEMPLATES, PYTHON_PRETTY_TEMPLATES +from .pretty_gen import generate_pretty_functions + + +PROLOGUE_TEMPLATE = '''\ +""" +Auto-generated pretty printer. + +Generated from protobuf specifications. +Do not modify this file! If you need to modify the pretty printer, edit the generator code +in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. + +{command_line_comment}""" + +from io import StringIO +from typing import Any, IO + +from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 + + +class PrettyPrinter: + """Pretty printer for protobuf messages.""" + + def __init__(self, io: IO[str] = None): + self.io = io if io is not None else StringIO() + self.indent_level = 0 + self.at_line_start = True + + def write(self, s: str) -> None: + """Write a string to the output, with indentation at line start.""" + if self.at_line_start and s.strip(): + self.io.write(' ' * self.indent_level) + self.at_line_start = False + self.io.write(s) + + def newline(self) -> None: + """Write a newline to the output.""" + self.io.write('\\n') + self.at_line_start = True + + def indent(self, delta: int = 1) -> None: + """Increase indentation level.""" + self.indent_level += delta + + def dedent(self, delta: int = 1) -> None: + """Decrease indentation level.""" + self.indent_level = max(0, self.indent_level - delta) + + def get_output(self) -> str: + """Get the accumulated output as a string.""" + if isinstance(self.io, StringIO): + return self.io.getvalue() + return "" + + def format_decimal(self, msg) -> str: + """Format a DecimalValue protobuf message as a string.""" + # DecimalValue has 'value' field as string + return str(msg.value) if msg.value else "0" + + def format_int128(self, msg) -> str: + """Format an Int128Value protobuf message as a string.""" + value = (msg.high << 64) | msg.low + if msg.high & (1 << 63): + value -= (1 << 128) + return str(value) + + def format_uint128(self, msg) -> str: + """Format a UInt128Value protobuf message as a hex string.""" + value = (msg.high << 64) | msg.low + return f"0x{{value:032x}}" + + def fragment_id_to_string(self, msg) -> str: + """Convert FragmentId to string representation.""" + return msg.id.decode('utf-8') if msg.id else "" + + def relation_id_to_string(self, msg): + """Convert RelationId to string representation if it has symbol.""" + if msg.symbol: + return msg.symbol + return None + + def relation_id_to_int(self, msg): + """Convert RelationId to int representation if it has id.""" + if msg.id_low or msg.id_high: + return (msg.id_high << 64) | msg.id_low + return None +''' + +EPILOGUE_TEMPLATE = ''' + +def pretty(msg: Any, io: IO[str] = None) -> str: + """Pretty print a protobuf message and return the string representation.""" + printer = PrettyPrinter(io) + printer.pretty_{start_name}(msg) + return printer.get_output() +''' + + +def generate_pretty_printer_python(grammar: Grammar, command_line: Optional[str] = None, + proto_messages=None) -> str: + """Generate pretty printer in Python.""" + prologue = _generate_prologue(command_line) + + codegen = PythonCodeGenerator(proto_messages=proto_messages) + # Register pretty-printing templates (on top of the default parser templates) + codegen.register_builtins_from_templates(PYTHON_PRETTY_TEMPLATES) + + defns = generate_pretty_functions(grammar, proto_messages) + lines = [] + for defn in defns: + lines.append("") + lines.append(codegen.generate_def(defn, " ")) + lines.append("") + + epilogue = _generate_epilogue(grammar.start) + + return prologue + "\n".join(lines) + epilogue + + +def _generate_prologue(command_line: Optional[str] = None) -> str: + """Generate pretty printer prologue with imports and class start.""" + command_line_comment = f"\nCommand: {command_line}\n" if command_line else "" + return PROLOGUE_TEMPLATE.format(command_line_comment=command_line_comment) + + +def _generate_epilogue(start: Nonterminal) -> str: + """Generate pretty function.""" + return EPILOGUE_TEMPLATE.format(start_name=start.name.lower()) diff --git a/python-tools/src/meta/target.py b/python-tools/src/meta/target.py index b9abd99a..b273d27f 100644 --- a/python-tools/src/meta/target.py +++ b/python-tools/src/meta/target.py @@ -381,12 +381,16 @@ def __post_init__(self): assert isinstance(self.index, int) and self.index >= 0, f"GetElement index must be non-negative integer: {self.index}" def target_type(self) -> 'TargetType': - tuple_type = self.tuple_expr.target_type() - if isinstance(tuple_type, TupleType): - if 0 <= self.index < len(tuple_type.elements): - return tuple_type.elements[self.index] - raise ValueError(f"Tuple index {self.index} out of range for {tuple_type}") - raise ValueError(f"Cannot get element from non-tuple type: {tuple_type}") + expr_type = self.tuple_expr.target_type() + if isinstance(expr_type, TupleType): + if 0 <= self.index < len(expr_type.elements): + return expr_type.elements[self.index] + raise ValueError(f"Tuple index {self.index} out of range for {expr_type}") + if isinstance(expr_type, ListType): + return expr_type.element_type + if isinstance(expr_type, BaseType) and expr_type.name == "Unknown": + return BaseType("Unknown") + raise ValueError(f"Cannot get element from non-tuple type: {expr_type}") @dataclass(frozen=True) @@ -501,6 +505,33 @@ def __str__(self) -> str: def target_type(self) -> 'TargetType': return OptionType(BaseType("Never")) +@dataclass(frozen=True) +class Foreach(TargetExpr): + """Foreach loop: for var in collection do body.""" + var: 'Var' + collection: TargetExpr + body: TargetExpr + + def __str__(self) -> str: + return f"for {self.var.name} in {self.collection} do {self.body}" + + def target_type(self) -> 'TargetType': + return OptionType(BaseType("Never")) + +@dataclass(frozen=True) +class ForeachEnumerated(TargetExpr): + """Foreach loop with index: for (index_var, var) in enumerate(collection) do body.""" + index_var: 'Var' + var: 'Var' + collection: TargetExpr + body: TargetExpr + + def __str__(self) -> str: + return f"for ({self.index_var.name}, {self.var.name}) in enumerate({self.collection}) do {self.body}" + + def target_type(self) -> 'TargetType': + return OptionType(BaseType("Never")) + @dataclass(frozen=True) class Assign(TargetExpr): """Assignment statement: var = expr. @@ -784,6 +815,8 @@ def function_type(self) -> 'FunctionType': 'IfElse', 'Seq', 'While', + 'Foreach', + 'ForeachEnumerated', 'Assign', 'Return', 'TargetType', diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index 5bd8f86f..5bc602ec 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -112,6 +112,7 @@ def is_builtin(name: str) -> bool: # === List operations === register_builtin("list_concat", [ListType(T), ListType(T)], ListType(T)) register_builtin("list_push", [ListType(T), T], VOID) # Mutating push: list.append(item) / push!(list, item) +register_builtin("list_slice", [ListType(T), INT64, INT64], ListType(T)) # list[start:end] register_builtin("length", [ListType(T)], INT64) register_builtin("map", [FunctionType([T1], T2), ListType(T1)], ListType(T2)) register_builtin("append", [ListType(T), T], ListType(T)) # list.append(item) @@ -128,6 +129,8 @@ def is_builtin(name: str) -> bool: # === Type conversions === register_builtin("int64_to_int32", [INT64], INT32) +register_builtin("int32_to_int64", [INT32], INT64) +register_builtin("decode_string", [BYTES], STRING) register_builtin("to_ptr_int64", [INT64], OptionType(INT64)) register_builtin("to_ptr_string", [STRING], OptionType(STRING)) register_builtin("to_ptr_bool", [BOOLEAN], OptionType(BOOLEAN)) @@ -146,8 +149,11 @@ def is_builtin(name: str) -> bool: # === Protobuf-specific === register_builtin("fragment_id_from_string", [STRING], MessageType("fragments", "FragmentId")) +register_builtin("fragment_id_to_string", [MessageType("fragments", "FragmentId")], STRING) register_builtin("relation_id_from_string", [STRING], MessageType("logic", "RelationId")) register_builtin("relation_id_from_uint128", [MessageType("logic", "UInt128Value")], MessageType("logic", "RelationId")) +register_builtin("relation_id_to_string", [MessageType("logic", "RelationId")], STRING) +register_builtin("relation_id_to_uint128", [MessageType("logic", "RelationId")], MessageType("logic", "UInt128Value")) register_builtin("construct_fragment", [MessageType("fragments", "FragmentId"), ListType(MessageType("logic", "Declaration"))], @@ -165,6 +171,25 @@ def is_builtin(name: str) -> bool: # === General helpers === register_builtin("is_empty", [ListType(T)], BOOLEAN) # len(list) == 0 register_builtin("enum_value", [STRING, STRING], T) # enum_value(EnumType, ValueName) +register_builtin("greater", [INT64, INT64], BOOLEAN) +register_builtin("to_string", [T], STRING) + +# === Pretty-printing IO operations === +register_builtin("write_io", [STRING], VOID) +register_builtin("newline_io", [], VOID) +register_builtin("indent_io", [], VOID) +register_builtin("dedent_io", [], VOID) + +# === Formatting for terminal types === +register_builtin("format_int64", [INT64], STRING) +register_builtin("format_int32", [INT32], STRING) +register_builtin("format_float64", [FLOAT64], STRING) +register_builtin("format_string", [STRING], STRING) +register_builtin("format_symbol", [STRING], STRING) +register_builtin("format_bool", [BOOLEAN], STRING) +register_builtin("format_decimal", [MessageType("logic", "DecimalValue")], STRING) +register_builtin("format_int128", [MessageType("logic", "Int128Value")], STRING) +register_builtin("format_uint128", [MessageType("logic", "UInt128Value")], STRING) # === Validation functions === diff --git a/python-tools/src/meta/target_utils.py b/python-tools/src/meta/target_utils.py index 5b962e7c..910a201e 100644 --- a/python-tools/src/meta/target_utils.py +++ b/python-tools/src/meta/target_utils.py @@ -142,7 +142,7 @@ def _is_simple_expr(expr: TargetExpr) -> bool: def _count_var_occurrences(expr: TargetExpr, var: str) -> int: """Count occurrences of a variable in an expression.""" - from .target import Let, Assign, Seq, IfElse, While, Return, NewMessage, GetField, GetElement, ListExpr + from .target import Let, Assign, Seq, IfElse, While, Foreach, ForeachEnumerated, Return, NewMessage, GetField, GetElement, ListExpr if isinstance(expr, Var) and expr.name == var: return 1 elif isinstance(expr, Lambda): @@ -171,6 +171,16 @@ def _count_var_occurrences(expr: TargetExpr, var: str) -> int: _count_var_occurrences(expr.else_branch, var)) elif isinstance(expr, While): return _count_var_occurrences(expr.condition, var) + _count_var_occurrences(expr.body, var) + elif isinstance(expr, Foreach): + count = _count_var_occurrences(expr.collection, var) + if expr.var.name != var: + count += _count_var_occurrences(expr.body, var) + return count + elif isinstance(expr, ForeachEnumerated): + count = _count_var_occurrences(expr.collection, var) + if expr.index_var.name != var and expr.var.name != var: + count += _count_var_occurrences(expr.body, var) + return count elif isinstance(expr, Return): return _count_var_occurrences(expr.expr, var) elif isinstance(expr, NewMessage): @@ -198,7 +208,7 @@ def _new_mapping(mapping: Mapping[str, TargetExpr], shadowed: list[str]): def _subst_inner(expr: TargetExpr, mapping: Mapping[str, TargetExpr]) -> TargetExpr: """Inner substitution helper - performs actual substitution.""" - from .target import Let, Assign, Seq, IfElse, While, Return, NewMessage, GetField, GetElement, ListExpr + from .target import Let, Assign, Seq, IfElse, While, Foreach, ForeachEnumerated, Return, NewMessage, GetField, GetElement, ListExpr if isinstance(expr, Var) and expr.name in mapping: return mapping[expr.name] elif isinstance(expr, Lambda): @@ -218,6 +228,12 @@ def _subst_inner(expr: TargetExpr, mapping: Mapping[str, TargetExpr]) -> TargetE return IfElse(_subst_inner(expr.condition, mapping), _subst_inner(expr.then_branch, mapping), _subst_inner(expr.else_branch, mapping)) elif isinstance(expr, While): return While(_subst_inner(expr.condition, mapping), _subst_inner(expr.body, mapping)) + elif isinstance(expr, Foreach): + new_mapping = _new_mapping(mapping, [expr.var.name]) + return Foreach(expr.var, _subst_inner(expr.collection, mapping), _subst_inner(expr.body, new_mapping)) + elif isinstance(expr, ForeachEnumerated): + new_mapping = _new_mapping(mapping, [expr.index_var.name, expr.var.name]) + return ForeachEnumerated(expr.index_var, expr.var, _subst_inner(expr.collection, mapping), _subst_inner(expr.body, new_mapping)) elif isinstance(expr, Return): return Return(_subst_inner(expr.expr, mapping)) elif isinstance(expr, NewMessage): @@ -236,7 +252,7 @@ def _subst_inner(expr: TargetExpr, mapping: Mapping[str, TargetExpr]) -> TargetE def _validate_subst_types(expr: TargetExpr, mapping: Mapping[str, TargetExpr]) -> None: """Check that substitution values have compatible types with their target variables.""" - from .target import Let, Assign, Seq, IfElse, While, Return + from .target import Let, Assign, Seq, IfElse, While, Foreach, ForeachEnumerated, Return if isinstance(expr, Var) and expr.name in mapping: val = mapping[expr.name] assert is_subtype(val.target_type(), expr.type), \ @@ -265,6 +281,16 @@ def _validate_subst_types(expr: TargetExpr, mapping: Mapping[str, TargetExpr]) - elif isinstance(expr, While): _validate_subst_types(expr.condition, mapping) _validate_subst_types(expr.body, mapping) + elif isinstance(expr, Foreach): + _validate_subst_types(expr.collection, mapping) + filtered = {k: v for k, v in mapping.items() if k != expr.var.name} + if filtered: + _validate_subst_types(expr.body, filtered) + elif isinstance(expr, ForeachEnumerated): + _validate_subst_types(expr.collection, mapping) + filtered = {k: v for k, v in mapping.items() if k not in {expr.index_var.name, expr.var.name}} + if filtered: + _validate_subst_types(expr.body, filtered) elif isinstance(expr, Assign): _validate_subst_types(expr.expr, mapping) elif isinstance(expr, Return): diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 1b970149..7e588fb6 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -179,14 +179,27 @@ def preprocess_action(text: str) -> str: $1, $2, ... -> _dollar_1, _dollar_2, ... keyword=expr -> _kw_keyword_=expr (for Python keywords used as field names) """ - # Replace $N with _dollar_N - result = re.sub(r'\$(\d+)', r'_dollar_\1', text) + # Replace $$ with _dollar_dollar, then $N with _dollar_N + result = text.replace('$$', '_dollar_dollar') + result = re.sub(r'\$(\d+)', r'_dollar_\1', result) # Replace keyword= with _kw_keyword_= for Python keywords used as kwargs + # Replace .keyword with ._kw_keyword_ for field access on Python keywords for kw in PYTHON_KEYWORDS: result = re.sub(rf'\b{kw}=', f'_kw_{kw}_=', result) + result = re.sub(rf'\.{kw}\b', f'._kw_{kw}_', result) return result +def _unescape_keyword(name: str) -> str: + """Unescape a preprocessed keyword field name back to its original form. + + _kw_def_ -> def, _kw_class_ -> class, etc. + """ + if name.startswith('_kw_') and name.endswith('_'): + return name[4:-1] + return name + + def _unsupported_node_error(node: ast.AST, line: Optional[int], reason: str = "") -> YaccGrammarError: """Create an error for unsupported Python syntax with helpful diagnostics.""" node_type = type(node).__name__ @@ -221,8 +234,7 @@ def _unsupported_node_error(node: ast.AST, line: Optional[int], reason: str = "" 'Slice': "Slice expressions (x[a:b]) are not supported. " "Only constant integer indexing is allowed.", 'NamedExpr': "Walrus operator (:=) is not supported.", - 'Tuple': "Tuple literals are not directly supported. " - "Use tuple(a, b, ...) builtin instead.", + 'Tuple': "Tuple literals (a, b, ...) are supported and map to builtin.tuple().", } base_msg = f"Cannot convert Python '{node_type}' to target IR" @@ -271,7 +283,9 @@ def convert(n: ast.AST) -> TargetExpr: return Lit(True) elif name == 'False': return Lit(False) - elif name.startswith('_dollar_'): + elif name in extra_vars: + return Var(name, extra_vars[name]) + elif name.startswith('_dollar_') and name[8:].isdigit(): # $N reference - map to the corresponding parameter idx = int(name[8:]) - 1 # Convert 1-indexed to 0-indexed if idx < 0 or idx >= len(param_info): @@ -282,8 +296,6 @@ def convert(n: ast.AST) -> TargetExpr: # Find the parameter for this position (skipping literals) param_idx = sum(1 for _, t in param_info[:idx] if t is not None) return params[param_idx] - elif name in extra_vars: - return Var(name, extra_vars[name]) elif name in ctx.functions: return _make_named_fun(name, ctx.functions[name]) else: @@ -306,14 +318,18 @@ def convert(n: ast.AST) -> TargetExpr: line) elif isinstance(node, ast.Attribute): + attr_name = _unescape_keyword(node.attr) if isinstance(node.value, ast.Name): + name = node.value.id + # Field access on a variable in scope + if name in extra_vars: + obj = Var(name, extra_vars[name]) + return _make_get_field(obj, attr_name, ctx, line) # module.Message reference - return NewMessage(node.value.id, node.attr, ()) - raise YaccGrammarError( - f"Field access on expressions is not supported.\n" - f" Only 'module.MessageName' for message constructors is allowed.\n" - f" Use GetField in target IR for field access on messages.", - line) + return NewMessage(name, attr_name, ()) + # Field access on a more complex expression + obj = convert(node.value) + return _make_get_field(obj, attr_name, ctx, line) elif isinstance(node, ast.Call): func = node.func @@ -393,6 +409,10 @@ def convert(n: ast.AST) -> TargetExpr: line) return _make_list_expr(elements, line, ctx) + elif isinstance(node, ast.Tuple): + elements = [convert(e) for e in node.elts] + return Call(make_builtin('tuple'), elements) + elif isinstance(node, ast.IfExp): cond = convert(node.test) then_branch = convert(node.body) @@ -400,20 +420,48 @@ def convert(n: ast.AST) -> TargetExpr: return IfElse(cond, then_branch, else_branch) elif isinstance(node, ast.Compare): - # Handle comparisons: x is None, x is not None if len(node.ops) == 1 and len(node.comparators) == 1: left = convert(node.left) + right = convert(node.comparators[0]) op = node.ops[0] if isinstance(op, ast.Is): if isinstance(node.comparators[0], ast.Constant) and node.comparators[0].value is None: return Call(make_builtin("is_none"), [left]) + return Call(make_builtin("equal"), [left, right]) elif isinstance(op, ast.IsNot): if isinstance(node.comparators[0], ast.Constant) and node.comparators[0].value is None: return Call(make_builtin("is_some"), [left]) + return Call(make_builtin("not_equal"), [left, right]) + elif isinstance(op, ast.Eq): + return Call(make_builtin("equal"), [left, right]) + elif isinstance(op, ast.NotEq): + return Call(make_builtin("not_equal"), [left, right]) + elif isinstance(op, ast.In): + return Call(make_builtin("string_in_list"), [left, right]) + elif isinstance(op, ast.NotIn): + return Call(make_builtin("not"), [Call(make_builtin("string_in_list"), [left, right])]) raise YaccGrammarError( - f"Unsupported comparison. Only 'x is None' and 'x is not None' are supported in actions.", + f"Unsupported comparison operator in action.", line) + elif isinstance(node, ast.BoolOp): + if isinstance(node.op, ast.And): + result = convert(node.values[0]) + for val in node.values[1:]: + result = Call(make_builtin("and"), [result, convert(val)]) + return result + elif isinstance(node.op, ast.Or): + result = convert(node.values[0]) + for val in node.values[1:]: + result = Call(make_builtin("or"), [result, convert(val)]) + return result + raise YaccGrammarError(f"Unsupported boolean operation", line) + + elif isinstance(node, ast.UnaryOp): + if isinstance(node.op, ast.Not): + return Call(make_builtin("not"), [convert(node.operand)]) + raise _unsupported_node_error(node, line) + else: raise _unsupported_node_error(node, line) @@ -446,8 +494,14 @@ def parse_action(text: str, rhs: Rhs, ctx: 'TypeContext', line: Optional[int] = expected_return_type: Optional[TargetType] = None) -> Lambda: """Parse a semantic action and return a Lambda. + Construct actions must assign to $$ (the result). For example: + $$ = module.Message(field=$1) + or multi-statement: + builtin.start_fragment($1) + $$ = $1 + Args: - text: Action text (Python expression) + text: Action text with $$ = expr assignment rhs: The RHS of the rule ctx: Type context line: Line number for error messages @@ -461,17 +515,181 @@ def parse_action(text: str, rhs: Rhs, ctx: 'TypeContext', line: Optional[int] = # Build parameter list with names from RHS symbols params = _build_params(rhs) - - # Parse the expression - # Pass param info so $N references can be resolved to named parameters param_info = _get_rhs_param_info(rhs) - body = parse_action_expr(preprocessed, param_info, params, ctx, line) + + # Parse as exec mode to handle $$ = expr assignments and multi-statement actions + try: + tree = ast.parse(preprocessed, mode='exec') + except SyntaxError as e: + raise YaccGrammarError(f"Syntax error in construct action: {e}", line) + + # Find the $$ assignment and any side-effect statements + dollar_dollar_value: Optional[ast.expr] = None + side_effects: List[TargetExpr] = [] + + for stmt in tree.body: + if isinstance(stmt, ast.Assign) and len(stmt.targets) == 1: + target = stmt.targets[0] + if isinstance(target, ast.Name) and target.id == '_dollar_dollar': + if dollar_dollar_value is not None: + raise YaccGrammarError("Multiple assignments to $$ in construct action", line) + dollar_dollar_value = stmt.value + continue + # Side-effect statement (e.g., builtin.start_fragment($1)) + if isinstance(stmt, ast.Expr): + expr = _convert_node_with_vars(stmt.value, param_info, params, ctx, line, {}) + side_effects.append(expr) + else: + raise YaccGrammarError( + f"Construct actions must contain $$ = expr and optional side-effect expressions. " + f"Got: {type(stmt).__name__}", + line) + + if dollar_dollar_value is None: + raise YaccGrammarError("Construct action must assign to $$", line) + + # Convert the $$ value expression + body = _convert_node_with_vars(dollar_dollar_value, param_info, params, ctx, line, {}) + + # If there are side effects, wrap in a Seq with the $$ value last + if side_effects: + body = Seq(tuple(side_effects) + (body,)) # Use expected return type from %type declaration if provided, otherwise infer return_type = expected_return_type if expected_return_type is not None else _infer_type(body, line, ctx) return Lambda(params, return_type, body) +def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', + ctx: 'TypeContext', line: Optional[int] = None) -> Lambda: + """Parse a deconstruct action and return a Lambda. + + Deconstruct actions assign to $1, $2, ... for each non-literal RHS element, + extracting values from $$ (the LHS message). For example: + + $1 = $$.name; $2 = $$.body + + The parser validates that all non-literal RHS elements are assigned. + + The resulting Lambda takes one parameter ($$) and returns a tuple of the + assigned values, in RHS order. + + If no text is provided (default identity), the Lambda returns $$ directly. + + Args: + text: Deconstruct action text with $N = expr assignments + lhs_type: Type of the LHS nonterminal (type of $$ parameter) + rhs: The RHS of the rule (used for validation) + ctx: Type context + line: Line number for error messages + + Returns: + Lambda expression with one parameter of lhs_type + """ + from .target_builtins import make_builtin as _make_builtin + + text = text.strip() + + # Default identity: deconstruct returns $$ unchanged + if text == '$$': + msg_param = Var("_dollar_dollar", lhs_type) + return Lambda([msg_param], lhs_type, msg_param) + + preprocessed = preprocess_action(text) + + # The $$ parameter + msg_param = Var("_dollar_dollar", lhs_type) + + # Get the non-literal RHS element info for validation + rhs_param_info = _get_rhs_param_info(rhs) + non_literal_indices = [i for i, (_, t) in enumerate(rhs_param_info) if t is not None] + + # Parse as statements (exec mode) to handle $N = expr assignments + try: + tree = ast.parse(preprocessed, mode='exec') + except SyntaxError as e: + raise YaccGrammarError(f"Syntax error in deconstruct action: {e}", line) + + # Extract $N assignments from the AST + # assignments maps 1-indexed $N to the expression AST node + assignments: Dict[int, ast.expr] = {} + extra_vars: Dict[str, TargetType] = {"_dollar_dollar": lhs_type} + + for stmt in tree.body: + if isinstance(stmt, ast.Assign) and len(stmt.targets) == 1: + target = stmt.targets[0] + if isinstance(target, ast.Name) and target.id.startswith('_dollar_') and target.id[8:].isdigit(): + dollar_idx = int(target.id[8:]) # 1-indexed + assignments[dollar_idx] = stmt.value + continue + raise YaccGrammarError( + f"Deconstruct actions must be $N = expr assignments. Got: {ast.dump(stmt)}", + line) + + # Validate all non-literal RHS elements are assigned + expected_indices = set(i + 1 for i in non_literal_indices) # 1-indexed + assigned_indices = set(assignments.keys()) + missing = expected_indices - assigned_indices + if missing: + raise YaccGrammarError( + f"Deconstruct action missing assignments for: {', '.join(f'${i}' for i in sorted(missing))}", + line) + extra = assigned_indices - expected_indices + if extra: + raise YaccGrammarError( + f"Deconstruct action has assignments for non-existent RHS elements: " + f"{', '.join(f'${i}' for i in sorted(extra))}", + line) + + # Convert each assignment's value expression to target IR + param_info: List[Tuple[Optional[str], Optional[TargetType]]] = [] + empty_params: List[Var] = [] + converted: List[TargetExpr] = [] + for idx in sorted(assignments.keys()): + expr = _convert_node_with_vars(assignments[idx], param_info, empty_params, ctx, line, extra_vars) + converted.append(expr) + + # Detect conditional assignments: IfElse(cond, then_val, None) + # These are guards — if any condition fails, the deconstruct should return None. + conditions: List[TargetExpr] = [] + unconditional: List[TargetExpr] = [] + for expr in converted: + if (isinstance(expr, IfElse) and isinstance(expr.else_branch, Lit) + and expr.else_branch.value is None): + conditions.append(expr.condition) + unconditional.append(expr.then_branch) + else: + unconditional.append(expr) + + if conditions: + # Build guarded body: if all conditions met, return Some(tuple); else None + if len(unconditional) == 1: + success_body: TargetExpr = Call(_make_builtin('some'), [unconditional[0]]) + inner_type = _infer_type(unconditional[0], line, ctx) + else: + tuple_expr = Call(_make_builtin('tuple'), unconditional) + success_body = Call(_make_builtin('some'), [tuple_expr]) + element_types = [_infer_type(c, line, ctx) for c in unconditional] + inner_type = TupleType(tuple(element_types)) + + # Combine conditions with 'and' + combined_cond = conditions[0] + for c in conditions[1:]: + combined_cond = Call(_make_builtin('and'), [combined_cond, c]) + + body: TargetExpr = IfElse(combined_cond, success_body, Lit(None)) + return_type: TargetType = OptionType(inner_type) + elif len(converted) == 1: + body = converted[0] + return_type = _infer_type(body, line, ctx) + else: + body = Call(_make_builtin('tuple'), converted) + element_types = [_infer_type(c, line, ctx) for c in converted] + return_type = TupleType(tuple(element_types)) + + return Lambda([msg_param], return_type, body) + + def parse_action_expr(text: str, param_info: List[Tuple[Optional[str], Optional[TargetType]]], params: List[Var], ctx: 'TypeContext', line: Optional[int], extra_vars: Optional[Dict[str, TargetType]] = None) -> TargetExpr: @@ -715,7 +933,8 @@ def _make_get_field(obj: TargetExpr, field_name: str, ctx: 'TypeContext', line: if isinstance(obj_type, OptionType): obj_type = obj_type.element_type if not isinstance(obj_type, MessageType): - raise YaccGrammarError(f"Cannot access field '{field_name}' on non-message type {obj_type}", line) + # Allow field access on Unknown types — return GetField with Unknown type + return GetField(obj, field_name, MessageType("unknown", "Unknown"), BaseType("Unknown")) message_type = obj_type # Try to look up field type field_type: TargetType = BaseType("Unknown") @@ -921,12 +1140,23 @@ def _convert_func_expr(node: ast.expr, ctx: 'TypeContext', line: int, left = _convert_func_expr(node.left, ctx, line, local_vars) right = _convert_func_expr(node.right, ctx, line, local_vars) if isinstance(node.op, ast.Add): - # Could be numeric add or string concat - use string_concat for strings - return Call(make_builtin("string_concat"), [left, right]) + return Call(make_builtin("add"), [left, right]) + elif isinstance(node.op, ast.Sub): + return Call(make_builtin("subtract"), [left, right]) + elif isinstance(node.op, ast.Mult): + return Call(make_builtin("multiply"), [left, right]) raise YaccGrammarError(f"Unsupported binary operation: {type(node.op).__name__}", line) + elif isinstance(node, ast.Tuple): + elements = [_convert_func_expr(e, ctx, line, local_vars) for e in node.elts] + return Call(make_builtin('tuple'), elements) + + elif isinstance(node, ast.UnaryOp): + if isinstance(node.op, ast.Not): + return Call(make_builtin("not"), [_convert_func_expr(node.operand, ctx, line, local_vars)]) + raise YaccGrammarError(f"Unsupported unary operation: {type(node.op).__name__}", line) + elif isinstance(node, ast.Subscript): - # Handle dict.get() result or tuple indexing value = _convert_func_expr(node.value, ctx, line, local_vars) if isinstance(node.slice, ast.Constant) and isinstance(node.slice.value, int): return GetElement(value, node.slice.value) @@ -948,6 +1178,8 @@ def _convert_func_expr(node: ast.expr, ctx: 'TypeContext', line: int, def _annotation_to_type(node: ast.AST, line: int) -> TargetType: """Convert a Python type annotation AST to TargetType.""" + if isinstance(node, ast.Constant) and node.value is None: + return BaseType("Void") if isinstance(node, ast.Name): # Normalize Python type names to canonical IR names type_name = _PYTHON_TYPE_MAP.get(node.id, node.id) @@ -1019,6 +1251,7 @@ class TerminalInfo: 'TypeContext', 'TerminalInfo', 'parse_action', + 'parse_deconstruct_action', 'parse_action_expr', 'parse_helper_functions', 'prescan_helper_function_names', diff --git a/python-tools/src/meta/yacc_parser.py b/python-tools/src/meta/yacc_parser.py index 6e262d61..714346e6 100644 --- a/python-tools/src/meta/yacc_parser.py +++ b/python-tools/src/meta/yacc_parser.py @@ -57,7 +57,7 @@ from .grammar import ( Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence, Rule, - GrammarConfig, TerminalDef + GrammarConfig, TerminalDef, ) from .target import TargetType, BaseType, MessageType, ListType, OptionType, TupleType @@ -356,16 +356,20 @@ def _get_indent(line: str) -> int: def parse_rules(lines: List[str], start_line: int, ctx: TypeContext) -> Tuple[List[Rule], int]: """Parse rules section until %%. - Rules use 'construct:' to introduce semantic actions: + Rules use 'construct:' and 'deconstruct:' to introduce semantic actions: rule : rhs construct: single_line_expression + deconstruct: single_line_expression rule : rhs construct: multi_line action_code + deconstruct: + multi_line + action_code Returns: (rules, end_line_index) @@ -376,21 +380,26 @@ def parse_rules(lines: List[str], start_line: int, ctx: TypeContext) -> Tuple[Li current_lhs_type: Optional[TargetType] = None current_rhs_lines: List[str] = [] # Accumulate RHS lines current_action_lines: List[str] = [] # Accumulate action lines + current_deconstruct_lines: List[str] = [] # Accumulate deconstruct lines current_alt_start_line: int = 0 in_action: bool = False - action_base_indent: int = 0 # Indentation level of the 'construct:' line + in_deconstruct: bool = False + action_base_indent: int = 0 # Indentation level of the 'construct:'/'deconstruct:' line def flush_alternative(): """Process accumulated alternative.""" - nonlocal current_rhs_lines, current_action_lines, in_action + nonlocal current_rhs_lines, current_action_lines, current_deconstruct_lines, in_action, in_deconstruct if current_rhs_lines and current_lhs is not None and current_lhs_type is not None: rhs_text = '\n'.join(current_rhs_lines) action_text = '\n'.join(current_action_lines) - rule = _parse_alternative(current_lhs, current_lhs_type, rhs_text, action_text, ctx, current_alt_start_line) + deconstruct_text = '\n'.join(current_deconstruct_lines) + rule = _parse_alternative(current_lhs, current_lhs_type, rhs_text, action_text, deconstruct_text, ctx, current_alt_start_line) rules.append(rule) current_rhs_lines = [] current_action_lines = [] + current_deconstruct_lines = [] in_action = False + in_deconstruct = False while i < len(lines): line = lines[i] @@ -402,8 +411,9 @@ def flush_alternative(): # Skip empty lines and comments (but preserve them in action blocks) if not stripped or stripped.startswith('#'): if in_action and current_action_lines: - # Preserve empty lines within action blocks current_action_lines.append('') + if in_deconstruct and current_deconstruct_lines: + current_deconstruct_lines.append('') continue # Check for section separator @@ -414,14 +424,21 @@ def flush_alternative(): # If we're in an action block, check if we should exit if in_action: if indent <= action_base_indent and not stripped.startswith('construct:'): - # Indentation decreased - end of action block in_action = False # Don't consume this line, process it below else: - # Continue action block current_action_lines.append(stripped) continue + # If we're in a deconstruct block, check if we should exit + if in_deconstruct: + if indent <= action_base_indent and not stripped.startswith('deconstruct:'): + in_deconstruct = False + # Don't consume this line, process it below + else: + current_deconstruct_lines.append(stripped) + continue + # Check for new rule (name at start of line, not indented) if line and (line[0].isalpha() or line[0] == '_'): flush_alternative() @@ -466,13 +483,21 @@ def flush_alternative(): action_base_indent = indent rest = stripped[len('construct:'):].strip() if rest: - # Single-line action current_action_lines = [rest] else: - # Multi-line action follows in_action = True current_action_lines = [] + elif stripped.startswith('deconstruct:'): + # Start of deconstruct action + action_base_indent = indent + rest = stripped[len('deconstruct:'):].strip() + if rest: + current_deconstruct_lines = [rest] + else: + in_deconstruct = True + current_deconstruct_lines = [] + elif line and line[0].isspace() and current_rhs_lines: # Continuation of RHS (indented line, not yet in action) current_rhs_lines.append(stripped) @@ -503,7 +528,8 @@ def _find_non_literal_indices(rhs: Rhs) -> List[int]: def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, - action_text: str, ctx: TypeContext, line: int) -> Rule: + action_text: str, deconstruct_text: str, + ctx: TypeContext, line: int) -> Rule: """Parse a single rule alternative. Args: @@ -511,9 +537,12 @@ def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, lhs_type: Type of the left-hand side rhs_text: The right-hand side pattern text action_text: The semantic action text (from construct: block), or empty for default + deconstruct_text: The deconstruct action text (from deconstruct: block) ctx: Type context line: Line number for error messages """ + from .yacc_action_parser import parse_deconstruct_action + # Parse RHS first so we can check for default action rhs = parse_rhs(rhs_text, ctx) @@ -530,14 +559,21 @@ def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, f"(at positions {non_literal_indices}): {rhs_text}", line) else: - # Exactly one non-literal - default to $n - action_text = f"${non_literal_indices[0]}" + # Exactly one non-literal - default to $$ = $n + action_text = f"$$ = ${non_literal_indices[0]}" # Parse action, using LHS type as expected return type constructor = parse_action(action_text, rhs, ctx, line, expected_return_type=lhs_type) lhs = Nonterminal(lhs_name, lhs_type) - return Rule(lhs=lhs, rhs=rhs, constructor=constructor) + + # Parse deconstruct action: explicit if provided, otherwise default to identity ($$) + if deconstruct_text: + deconstructor = parse_deconstruct_action(deconstruct_text, lhs_type, rhs, ctx, line) + else: + deconstructor = parse_deconstruct_action("$$", lhs_type, rhs, ctx, line) + + return Rule(lhs=lhs, rhs=rhs, constructor=constructor, deconstructor=deconstructor) def _make_field_type_lookup( diff --git a/python-tools/tests/meta/test_analysis.py b/python-tools/tests/meta/test_analysis.py index 2c352613..86d0971e 100644 --- a/python-tools/tests/meta/test_analysis.py +++ b/python-tools/tests/meta/test_analysis.py @@ -12,7 +12,7 @@ from meta.grammar import ( LitTerminal, NamedTerminal, Nonterminal, Terminal, Star, Option, Sequence, - Rule, Grammar, + Rule, Grammar, make_rule, ) from meta.grammar_analysis import GrammarAnalysis from meta.target import BaseType, MessageType, Lambda, Var, OptionType, TupleType, Lit, Call @@ -38,15 +38,15 @@ def make_simple_grammar(): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) constructor_s = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), constructor_s)) + grammar.add_rule(make_rule(s, Sequence((a, b)), constructor_s)) # A -> "a" constructor_a = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, constructor_a)) + grammar.add_rule(make_rule(a, lit_a, constructor_a)) # B -> "b" constructor_b = Lambda([], MessageType("proto", "B"), Var("y", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, constructor_b)) + grammar.add_rule(make_rule(b, lit_b, constructor_b)) return grammar, s, a, b, lit_a, lit_b @@ -70,19 +70,19 @@ def make_nullable_grammar(): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) constructor_s = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), constructor_s)) + grammar.add_rule(make_rule(s, Sequence((a, b)), constructor_s)) # A -> "a" constructor_a1 = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, constructor_a1)) + grammar.add_rule(make_rule(a, lit_a, constructor_a1)) # A -> epsilon constructor_a2 = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, Sequence(()), constructor_a2)) + grammar.add_rule(make_rule(a, Sequence(()), constructor_a2)) # B -> "b" constructor_b = Lambda([], MessageType("proto", "B"), Var("y", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, constructor_b)) + grammar.add_rule(make_rule(b, lit_b, constructor_b)) return grammar, s, a, b @@ -104,17 +104,17 @@ def make_left_recursive_grammar(): param_s = Var("x", MessageType("proto", "S")) param_t1 = Var("y", MessageType("proto", "T")) constructor_s1 = Lambda([param_s, param_t1], MessageType("proto", "S"), param_s) - grammar.add_rule(Rule(s, Sequence((s, plus, t)), constructor_s1)) + grammar.add_rule(make_rule(s, Sequence((s, plus, t)), constructor_s1)) # S -> T param_t2 = Var("z", MessageType("proto", "T")) constructor_s2 = Lambda([param_t2], MessageType("proto", "S"), param_t2) - grammar.add_rule(Rule(s, t, constructor_s2)) + grammar.add_rule(make_rule(s, t, constructor_s2)) # T -> NUM param_num = Var("n", BaseType("Int64")) constructor_t = Lambda([param_num], MessageType("proto", "T"), param_num) - grammar.add_rule(Rule(t, num, constructor_t)) + grammar.add_rule(make_rule(t, num, constructor_t)) return grammar, s, t, num @@ -137,15 +137,15 @@ def make_unreachable_grammar(): # S -> A param_a = Var("x", MessageType("proto", "A")) constructor_s = Lambda([param_a], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, a, constructor_s)) + grammar.add_rule(make_rule(s, a, constructor_s)) # A -> "a" constructor_a = Lambda([], MessageType("proto", "A"), Var("y", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, constructor_a)) + grammar.add_rule(make_rule(a, lit_a, constructor_a)) # B -> "b" (unreachable) constructor_b = Lambda([], MessageType("proto", "B"), Var("z", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, constructor_b)) + grammar.add_rule(make_rule(b, lit_b, constructor_b)) return grammar, s, a, b @@ -186,7 +186,7 @@ def test_single_rule(self): lit = LitTerminal("a") grammar = Grammar(s) constructor= Lambda([], MessageType("proto", "S"), Var("x", MessageType("proto", "S"))) - grammar.add_rule(Rule(s, lit, constructor)) + grammar.add_rule(make_rule(s, lit, constructor)) reachable = grammar.analysis.reachability assert s in reachable assert len(reachable) == 1 @@ -209,10 +209,10 @@ def test_indirect_reachability(self): constructor_b = Lambda([param_c], MessageType("proto", "B"), param_c) constructor_c = Lambda([param_c], MessageType("proto", "C"), param_c) - grammar.add_rule(Rule(s, a, constructor_s)) - grammar.add_rule(Rule(a, b, constructor_a)) - grammar.add_rule(Rule(b, c, constructor_b)) - grammar.add_rule(Rule(c, c, constructor_c)) + grammar.add_rule(make_rule(s, a, constructor_s)) + grammar.add_rule(make_rule(a, b, constructor_a)) + grammar.add_rule(make_rule(b, c, constructor_b)) + grammar.add_rule(make_rule(c, c, constructor_c)) reachable = grammar.analysis.reachability assert len(reachable) == 4 @@ -250,7 +250,7 @@ def test_star_makes_nullable(self): grammar = Grammar(s) param = Var("x", MessageType("proto", "S")) constructor= Lambda([param], MessageType("proto", "S"), param) - grammar.add_rule(Rule(s, star_a, constructor)) + grammar.add_rule(make_rule(s, star_a, constructor)) nullable = grammar.analysis.nullable assert nullable[s] @@ -264,7 +264,7 @@ def test_option_makes_nullable(self): grammar = Grammar(s) param = Var("x", MessageType("proto", "S")) constructor= Lambda([param], MessageType("proto", "S"), param) - grammar.add_rule(Rule(s, opt_a, constructor)) + grammar.add_rule(make_rule(s, opt_a, constructor)) nullable = grammar.analysis.nullable assert nullable[s] @@ -274,7 +274,7 @@ def test_empty_sequence_makes_nullable(self): s = Nonterminal("S", MessageType("proto", "S")) grammar = Grammar(s) constructor= Lambda([], MessageType("proto", "S"), Var("x", MessageType("proto", "S"))) - grammar.add_rule(Rule(s, Sequence(()), constructor)) + grammar.add_rule(make_rule(s, Sequence(()), constructor)) nullable = grammar.analysis.nullable assert nullable[s] @@ -294,9 +294,9 @@ def test_transitive_nullable(self): constructor_a = Lambda([param_b], MessageType("proto", "A"), param_b) constructor_b = Lambda([], MessageType("proto", "B"), Var("z", MessageType("proto", "B"))) - grammar.add_rule(Rule(s, a, constructor_s)) - grammar.add_rule(Rule(a, b, constructor_a)) - grammar.add_rule(Rule(b, Sequence(()), constructor_b)) + grammar.add_rule(make_rule(s, a, constructor_s)) + grammar.add_rule(make_rule(a, b, constructor_a)) + grammar.add_rule(make_rule(b, Sequence(()), constructor_b)) nullable = grammar.analysis.nullable assert nullable[s] @@ -489,7 +489,7 @@ def test_empty_sequence_gives_empty_tuple(self): s = Nonterminal("S", MessageType("proto", "S")) grammar = Grammar(s) constructor= Lambda([], MessageType("proto", "S"), Var("x", MessageType("proto", "S"))) - grammar.add_rule(Rule(s, Sequence(()), constructor)) + grammar.add_rule(make_rule(s, Sequence(()), constructor)) first_k = grammar.analysis.compute_first_k(k=2) assert () in first_k[s] @@ -612,15 +612,15 @@ def test_nullable_propagates_follow(self): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) constructor_s = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), constructor_s)) + grammar.add_rule(make_rule(s, Sequence((a, b)), constructor_s)) # A -> epsilon constructor_a = Lambda([], MessageType("proto", "A"), Var("z", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, Sequence(()), constructor_a)) + grammar.add_rule(make_rule(a, Sequence(()), constructor_a)) # B -> "b" constructor_b = Lambda([], MessageType("proto", "B"), Var("w", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, constructor_b)) + grammar.add_rule(make_rule(b, lit_b, constructor_b)) follow = grammar.analysis.follow @@ -784,47 +784,47 @@ def test_dragon_book_example_4_28(self): # E -> T E' param_t = Var("t", exp_type) param_ep = Var("ep", OptionType(exp_type)) - grammar.add_rule(Rule(e, Sequence((t, e_prime)), + grammar.add_rule(make_rule(e, Sequence((t, e_prime)), Lambda([param_t, param_ep], exp_type, param_t))) # E' -> + T E' param_t2 = Var("t2", exp_type) param_ep2 = Var("ep2", OptionType(exp_type)) - grammar.add_rule(Rule(e_prime, Sequence((plus, t, e_prime)), + grammar.add_rule(make_rule(e_prime, Sequence((plus, t, e_prime)), Lambda([param_t2, param_ep2], OptionType(exp_type), Call(make_builtin('some'), [param_t2])))) # E' -> epsilon - grammar.add_rule(Rule(e_prime, Sequence(()), + grammar.add_rule(make_rule(e_prime, Sequence(()), Lambda([], OptionType(exp_type), Call(make_builtin('none'), [])))) # T -> F T' param_f = Var("f", exp_type) param_tp = Var("tp", OptionType(exp_type)) - grammar.add_rule(Rule(t, Sequence((f, t_prime)), + grammar.add_rule(make_rule(t, Sequence((f, t_prime)), Lambda([param_f, param_tp], exp_type, param_f))) # T' -> * F T' param_f2 = Var("f2", exp_type) param_tp2 = Var("tp2", OptionType(exp_type)) - grammar.add_rule(Rule(t_prime, Sequence((star, f, t_prime)), + grammar.add_rule(make_rule(t_prime, Sequence((star, f, t_prime)), Lambda([param_f2, param_tp2], OptionType(exp_type), Call(make_builtin('some'), [param_f2])))) # T' -> epsilon - grammar.add_rule(Rule(t_prime, Sequence(()), + grammar.add_rule(make_rule(t_prime, Sequence(()), Lambda([], OptionType(exp_type), Call(make_builtin('none'), [])))) # F -> ( E ) param_e = Var("e", exp_type) - grammar.add_rule(Rule(f, Sequence((lparen, e, rparen)), + grammar.add_rule(make_rule(f, Sequence((lparen, e, rparen)), Lambda([param_e], exp_type, param_e))) # F -> id param_id = Var("i", exp_type) - grammar.add_rule(Rule(f, id_tok, + grammar.add_rule(make_rule(f, id_tok, Lambda([param_id], exp_type, param_id))) # Compute nullable @@ -898,24 +898,24 @@ def test_dragon_book_example_4_31(self): param_e = Var("e", MessageType("proto", "E")) param_s1 = Var("s1", MessageType("proto", "S")) param_sp = Var("sp", MessageType("proto", "SPrime")) - grammar.add_rule(Rule(s, Sequence((if_tok, e, then_tok, s, s_prime)), + grammar.add_rule(make_rule(s, Sequence((if_tok, e, then_tok, s, s_prime)), Lambda([param_e, param_s1, param_sp], MessageType("proto", "S"), param_e))) # S -> a - grammar.add_rule(Rule(s, a_tok, + grammar.add_rule(make_rule(s, a_tok, Lambda([], MessageType("proto", "S"), Var("x", MessageType("proto", "S"))))) # S' -> else S param_s2 = Var("s2", MessageType("proto", "S")) - grammar.add_rule(Rule(s_prime, Sequence((else_tok, s)), + grammar.add_rule(make_rule(s_prime, Sequence((else_tok, s)), Lambda([param_s2], MessageType("proto", "SPrime"), param_s2))) # S' -> epsilon - grammar.add_rule(Rule(s_prime, Sequence(()), + grammar.add_rule(make_rule(s_prime, Sequence(()), Lambda([], MessageType("proto", "SPrime"), Var("y", MessageType("proto", "SPrime"))))) # E -> b - grammar.add_rule(Rule(e, b_tok, + grammar.add_rule(make_rule(e, b_tok, Lambda([], MessageType("proto", "E"), Var("z", MessageType("proto", "E"))))) # Compute nullable @@ -959,20 +959,20 @@ def test_dragon_book_list_grammar(self): # list -> list + digit param_list = Var("l", MessageType("proto", "List")) param_digit = Var("d", MessageType("proto", "Digit")) - grammar.add_rule(Rule(list_nt, Sequence((list_nt, plus, digit)), + grammar.add_rule(make_rule(list_nt, Sequence((list_nt, plus, digit)), Lambda([param_list, param_digit], MessageType("proto", "List"), param_list))) # list -> digit param_digit2 = Var("d2", MessageType("proto", "Digit")) - grammar.add_rule(Rule(list_nt, digit, + grammar.add_rule(make_rule(list_nt, digit, Lambda([param_digit2], MessageType("proto", "List"), param_digit2))) # digit -> 0 - grammar.add_rule(Rule(digit, zero, + grammar.add_rule(make_rule(digit, zero, Lambda([], MessageType("proto", "Digit"), Var("x", MessageType("proto", "Digit"))))) # digit -> 1 - grammar.add_rule(Rule(digit, one, + grammar.add_rule(make_rule(digit, one, Lambda([], MessageType("proto", "Digit"), Var("y", MessageType("proto", "Digit"))))) # Compute nullable @@ -1019,27 +1019,27 @@ def test_dragon_book_nullable_propagation(self): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) param_c = Var("z", MessageType("proto", "C")) - grammar.add_rule(Rule(s, Sequence((a, b, c)), + grammar.add_rule(make_rule(s, Sequence((a, b, c)), Lambda([param_a, param_b, param_c], MessageType("proto", "S"), param_a))) # A -> a - grammar.add_rule(Rule(a, lit_a, + grammar.add_rule(make_rule(a, lit_a, Lambda([], MessageType("proto", "A"), Var("v", MessageType("proto", "A"))))) # A -> epsilon - grammar.add_rule(Rule(a, Sequence(()), + grammar.add_rule(make_rule(a, Sequence(()), Lambda([], MessageType("proto", "A"), Var("w", MessageType("proto", "A"))))) # B -> b - grammar.add_rule(Rule(b, lit_b, + grammar.add_rule(make_rule(b, lit_b, Lambda([], MessageType("proto", "B"), Var("u", MessageType("proto", "B"))))) # B -> epsilon - grammar.add_rule(Rule(b, Sequence(()), + grammar.add_rule(make_rule(b, Sequence(()), Lambda([], MessageType("proto", "B"), Var("t", MessageType("proto", "B"))))) # C -> c - grammar.add_rule(Rule(c, lit_c, + grammar.add_rule(make_rule(c, lit_c, Lambda([], MessageType("proto", "C"), Var("s", MessageType("proto", "C"))))) # Compute nullable @@ -1077,20 +1077,20 @@ def test_dragon_book_first_k_example(self): # S -> a A a param_a1 = Var("x", MessageType("proto", "A")) - grammar.add_rule(Rule(s, Sequence((lit_a, a_nt, lit_a)), + grammar.add_rule(make_rule(s, Sequence((lit_a, a_nt, lit_a)), Lambda([param_a1], MessageType("proto", "S"), param_a1))) # S -> b A b param_a2 = Var("y", MessageType("proto", "A")) - grammar.add_rule(Rule(s, Sequence((lit_b, a_nt, lit_b)), + grammar.add_rule(make_rule(s, Sequence((lit_b, a_nt, lit_b)), Lambda([param_a2], MessageType("proto", "S"), param_a2))) # A -> a - grammar.add_rule(Rule(a_nt, lit_a, + grammar.add_rule(make_rule(a_nt, lit_a, Lambda([], MessageType("proto", "A"), Var("v", MessageType("proto", "A"))))) # A -> b - grammar.add_rule(Rule(a_nt, lit_b, + grammar.add_rule(make_rule(a_nt, lit_b, Lambda([], MessageType("proto", "A"), Var("w", MessageType("proto", "A"))))) # With k=1, FIRST(S) = {a, b} - ambiguous @@ -1130,24 +1130,24 @@ def test_dragon_book_dangling_else_with_follow_k(self): param_e = Var("e", MessageType("proto", "E")) param_s = Var("s", MessageType("proto", "S")) param_sp = Var("sp", MessageType("proto", "SPrime")) - grammar.add_rule(Rule(s, Sequence((if_tok, e, then_tok, s, s_prime)), + grammar.add_rule(make_rule(s, Sequence((if_tok, e, then_tok, s, s_prime)), Lambda([param_e, param_s, param_sp], MessageType("proto", "S"), param_e))) # S -> other - grammar.add_rule(Rule(s, other_tok, + grammar.add_rule(make_rule(s, other_tok, Lambda([], MessageType("proto", "S"), Var("x", MessageType("proto", "S"))))) # S' -> else S param_s2 = Var("s2", MessageType("proto", "S")) - grammar.add_rule(Rule(s_prime, Sequence((else_tok, s)), + grammar.add_rule(make_rule(s_prime, Sequence((else_tok, s)), Lambda([param_s2], MessageType("proto", "SPrime"), param_s2))) # S' -> epsilon - grammar.add_rule(Rule(s_prime, Sequence(()), + grammar.add_rule(make_rule(s_prime, Sequence(()), Lambda([], MessageType("proto", "SPrime"), Var("y", MessageType("proto", "SPrime"))))) # E -> expr - grammar.add_rule(Rule(e, expr_tok, + grammar.add_rule(make_rule(e, expr_tok, Lambda([], MessageType("proto", "E"), Var("z", MessageType("proto", "E"))))) nullable = GrammarAnalysis.compute_nullable_static(grammar) @@ -1218,19 +1218,19 @@ def test_complex_grammar_analysis(self): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) constructor1 = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), constructor1)) + grammar.add_rule(make_rule(s, Sequence((a, b)), constructor1)) param_b2 = Var("z", MessageType("proto", "B")) constructor2 = Lambda([param_b2], MessageType("proto", "S"), param_b2) - grammar.add_rule(Rule(s, b, constructor2)) + grammar.add_rule(make_rule(s, b, constructor2)) # A -> "a" constructor3 = Lambda([], MessageType("proto", "A"), Var("w", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, constructor3)) + grammar.add_rule(make_rule(a, lit_a, constructor3)) # B -> "b" constructor4 = Lambda([], MessageType("proto", "B"), Var("v", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, constructor4)) + grammar.add_rule(make_rule(b, lit_b, constructor4)) # Check everything works together reachable = grammar.analysis.reachability @@ -1270,31 +1270,31 @@ def test_grammar_3_12_nullable_first_follow(self): grammar = Grammar(z) # Z -> d - grammar.add_rule(Rule(z, lit_d, + grammar.add_rule(make_rule(z, lit_d, Lambda([], MessageType("proto", "Z"), Var("v", MessageType("proto", "Z"))))) # Z -> X Y Z param_x = Var("x", MessageType("proto", "X")) param_y = Var("y", MessageType("proto", "Y")) param_z = Var("z", MessageType("proto", "Z")) - grammar.add_rule(Rule(z, Sequence((x, y, z)), + grammar.add_rule(make_rule(z, Sequence((x, y, z)), Lambda([param_x, param_y, param_z], MessageType("proto", "Z"), param_x))) # Y -> epsilon - grammar.add_rule(Rule(y, Sequence(()), + grammar.add_rule(make_rule(y, Sequence(()), Lambda([], MessageType("proto", "Y"), Var("w", MessageType("proto", "Y"))))) # Y -> c - grammar.add_rule(Rule(y, lit_c, + grammar.add_rule(make_rule(y, lit_c, Lambda([], MessageType("proto", "Y"), Var("u", MessageType("proto", "Y"))))) # X -> Y param_y2 = Var("y2", MessageType("proto", "Y")) - grammar.add_rule(Rule(x, y, + grammar.add_rule(make_rule(x, y, Lambda([param_y2], MessageType("proto", "X"), param_y2))) # X -> a - grammar.add_rule(Rule(x, lit_a, + grammar.add_rule(make_rule(x, lit_a, Lambda([], MessageType("proto", "X"), Var("t", MessageType("proto", "X"))))) # Compute nullable - from page 50 @@ -1376,59 +1376,59 @@ def test_grammar_3_1_straight_line(self): p1 = Var("p1", BaseType("String")) p2 = Var("p2", MessageType("proto", "E")) p3 = Var("p3", MessageType("proto", "SPrime")) - grammar.add_rule(Rule(s, Sequence((id_tok, assign, e, s_prime)), + grammar.add_rule(make_rule(s, Sequence((id_tok, assign, e, s_prime)), Lambda([p1, p2, p3], MessageType("proto", "S"), p2))) # S -> print ( L ) S' (2 non-literal elements: L, S') p4 = Var("p4", MessageType("proto", "L")) p5 = Var("p5", MessageType("proto", "SPrime")) - grammar.add_rule(Rule(s, Sequence((print_tok, lparen, l_nt, rparen, s_prime)), + grammar.add_rule(make_rule(s, Sequence((print_tok, lparen, l_nt, rparen, s_prime)), Lambda([p4, p5], MessageType("proto", "S"), p4))) # S' -> ; S (1 non-literal element: S) p6 = Var("p6", MessageType("proto", "S")) - grammar.add_rule(Rule(s_prime, Sequence((semi, s)), + grammar.add_rule(make_rule(s_prime, Sequence((semi, s)), Lambda([p6], MessageType("proto", "SPrime"), p6))) # S' -> epsilon - grammar.add_rule(Rule(s_prime, Sequence(()), + grammar.add_rule(make_rule(s_prime, Sequence(()), Lambda([], MessageType("proto", "SPrime"), Var("w", MessageType("proto", "SPrime"))))) # E -> id E' (2 non-literal elements: id, E') p7 = Var("p7", BaseType("String")) p8 = Var("p8", MessageType("proto", "EPrime")) - grammar.add_rule(Rule(e, Sequence((id_tok, e_prime)), + grammar.add_rule(make_rule(e, Sequence((id_tok, e_prime)), Lambda([p7, p8], MessageType("proto", "E"), p7))) # E -> num E' (2 non-literal elements: num, E') p9 = Var("p9", BaseType("Int64")) p10 = Var("p10", MessageType("proto", "EPrime")) - grammar.add_rule(Rule(e, Sequence((num_tok, e_prime)), + grammar.add_rule(make_rule(e, Sequence((num_tok, e_prime)), Lambda([p9, p10], MessageType("proto", "E"), p9))) # E' -> + E (1 non-literal element: E) p11 = Var("p11", MessageType("proto", "E")) - grammar.add_rule(Rule(e_prime, Sequence((plus, e)), + grammar.add_rule(make_rule(e_prime, Sequence((plus, e)), Lambda([p11], MessageType("proto", "EPrime"), p11))) # E' -> epsilon - grammar.add_rule(Rule(e_prime, Sequence(()), + grammar.add_rule(make_rule(e_prime, Sequence(()), Lambda([], MessageType("proto", "EPrime"), Var("s", MessageType("proto", "EPrime"))))) # L -> E L' (2 non-literal elements: E, L') p12 = Var("p12", MessageType("proto", "E")) p13 = Var("p13", MessageType("proto", "LPrime")) - grammar.add_rule(Rule(l_nt, Sequence((e, l_prime)), + grammar.add_rule(make_rule(l_nt, Sequence((e, l_prime)), Lambda([p12, p13], MessageType("proto", "L"), p12))) # L' -> , E L' (2 non-literal elements: E, L') p14 = Var("p14", MessageType("proto", "E")) p15 = Var("p15", MessageType("proto", "LPrime")) - grammar.add_rule(Rule(l_prime, Sequence((comma, e, l_prime)), + grammar.add_rule(make_rule(l_prime, Sequence((comma, e, l_prime)), Lambda([p14, p15], MessageType("proto", "LPrime"), p14))) # L' -> epsilon - grammar.add_rule(Rule(l_prime, Sequence(()), + grammar.add_rule(make_rule(l_prime, Sequence(()), Lambda([], MessageType("proto", "LPrime"), Var("p", MessageType("proto", "LPrime"))))) # Compute nullable @@ -1492,43 +1492,43 @@ def test_grammar_3_8_expression_precedence(self): # E -> T E' (2 non-literal elements) p_t = Var("t", MessageType("proto", "T")) p_ep = Var("ep", MessageType("proto", "EPrime")) - grammar.add_rule(Rule(e, Sequence((t, e_prime)), + grammar.add_rule(make_rule(e, Sequence((t, e_prime)), Lambda([p_t, p_ep], MessageType("proto", "E"), p_t))) # E' -> + T E' (2 non-literal elements) p_t2 = Var("t2", MessageType("proto", "T")) p_ep2 = Var("ep2", MessageType("proto", "EPrime")) - grammar.add_rule(Rule(e_prime, Sequence((plus, t, e_prime)), + grammar.add_rule(make_rule(e_prime, Sequence((plus, t, e_prime)), Lambda([p_t2, p_ep2], MessageType("proto", "EPrime"), p_t2))) # E' -> epsilon - grammar.add_rule(Rule(e_prime, Sequence(()), + grammar.add_rule(make_rule(e_prime, Sequence(()), Lambda([], MessageType("proto", "EPrime"), Var("z", MessageType("proto", "EPrime"))))) # T -> F T' (2 non-literal elements) p_f = Var("f", MessageType("proto", "F")) p_tp = Var("tp", MessageType("proto", "TPrime")) - grammar.add_rule(Rule(t, Sequence((f, t_prime)), + grammar.add_rule(make_rule(t, Sequence((f, t_prime)), Lambda([p_f, p_tp], MessageType("proto", "T"), p_f))) # T' -> * F T' (2 non-literal elements) p_f2 = Var("f2", MessageType("proto", "F")) p_tp2 = Var("tp2", MessageType("proto", "TPrime")) - grammar.add_rule(Rule(t_prime, Sequence((star, f, t_prime)), + grammar.add_rule(make_rule(t_prime, Sequence((star, f, t_prime)), Lambda([p_f2, p_tp2], MessageType("proto", "TPrime"), p_f2))) # T' -> epsilon - grammar.add_rule(Rule(t_prime, Sequence(()), + grammar.add_rule(make_rule(t_prime, Sequence(()), Lambda([], MessageType("proto", "TPrime"), Var("u", MessageType("proto", "TPrime"))))) # F -> id (1 non-literal element) p_id = Var("id", BaseType("String")) - grammar.add_rule(Rule(f, id_tok, + grammar.add_rule(make_rule(f, id_tok, Lambda([p_id], MessageType("proto", "F"), p_id))) # F -> ( E ) (1 non-literal element) p_e = Var("e", MessageType("proto", "E")) - grammar.add_rule(Rule(f, Sequence((lparen, e, rparen)), + grammar.add_rule(make_rule(f, Sequence((lparen, e, rparen)), Lambda([p_e], MessageType("proto", "F"), p_e))) # Compute nullable @@ -1606,27 +1606,27 @@ def test_grammar_3_20_sexp(self): # S -> ( L ) (1 non-literal element) p_l = Var("l", MessageType("proto", "L")) - grammar.add_rule(Rule(s, Sequence((lparen, l_nt, rparen)), + grammar.add_rule(make_rule(s, Sequence((lparen, l_nt, rparen)), Lambda([p_l], MessageType("proto", "S"), p_l))) # S -> x (0 non-literal elements - x is a LitTerminal) - grammar.add_rule(Rule(s, x_tok, + grammar.add_rule(make_rule(s, x_tok, Lambda([], MessageType("proto", "S"), Var("b", MessageType("proto", "S"))))) # L -> S L' (2 non-literal elements) p_s = Var("s", MessageType("proto", "S")) p_lp = Var("lp", MessageType("proto", "LPrime")) - grammar.add_rule(Rule(l_nt, Sequence((s, l_prime)), + grammar.add_rule(make_rule(l_nt, Sequence((s, l_prime)), Lambda([p_s, p_lp], MessageType("proto", "L"), p_s))) # L' -> S L' (2 non-literal elements) p_s2 = Var("s2", MessageType("proto", "S")) p_lp2 = Var("lp2", MessageType("proto", "LPrime")) - grammar.add_rule(Rule(l_prime, Sequence((s, l_prime)), + grammar.add_rule(make_rule(l_prime, Sequence((s, l_prime)), Lambda([p_s2, p_lp2], MessageType("proto", "LPrime"), p_s2))) # L' -> epsilon - grammar.add_rule(Rule(l_prime, Sequence(()), + grammar.add_rule(make_rule(l_prime, Sequence(()), Lambda([], MessageType("proto", "LPrime"), Var("e", MessageType("proto", "LPrime"))))) nullable = GrammarAnalysis.compute_nullable_static(grammar) @@ -1678,11 +1678,11 @@ def test_exercise_3_5_grammar(self): # S -> a S a (1 non-literal element) p_s = Var("s", MessageType("proto", "S")) - grammar.add_rule(Rule(s, Sequence((lit_a, s, lit_a)), + grammar.add_rule(make_rule(s, Sequence((lit_a, s, lit_a)), Lambda([p_s], MessageType("proto", "S"), p_s))) # S -> a a (0 non-literal elements - both are LitTerminals) - grammar.add_rule(Rule(s, Sequence((lit_a, lit_a)), + grammar.add_rule(make_rule(s, Sequence((lit_a, lit_a)), Lambda([], MessageType("proto", "S"), Var("y", MessageType("proto", "S"))))) nullable = GrammarAnalysis.compute_nullable_static(grammar) @@ -1716,31 +1716,31 @@ def test_first_k_grammar_3_12(self): grammar = Grammar(z) # Z -> d (0 non-literal elements) - grammar.add_rule(Rule(z, lit_d, + grammar.add_rule(make_rule(z, lit_d, Lambda([], MessageType("proto", "Z"), Var("v", MessageType("proto", "Z"))))) # Z -> X Y Z (3 non-literal elements) p_x = Var("x", MessageType("proto", "X")) p_y = Var("y", MessageType("proto", "Y")) p_z = Var("z", MessageType("proto", "Z")) - grammar.add_rule(Rule(z, Sequence((x, y, z)), + grammar.add_rule(make_rule(z, Sequence((x, y, z)), Lambda([p_x, p_y, p_z], MessageType("proto", "Z"), p_x))) # Y -> epsilon - grammar.add_rule(Rule(y, Sequence(()), + grammar.add_rule(make_rule(y, Sequence(()), Lambda([], MessageType("proto", "Y"), Var("u", MessageType("proto", "Y"))))) # Y -> c (0 non-literal elements) - grammar.add_rule(Rule(y, lit_c, + grammar.add_rule(make_rule(y, lit_c, Lambda([], MessageType("proto", "Y"), Var("t", MessageType("proto", "Y"))))) # X -> Y (1 non-literal element) p_y2 = Var("y2", MessageType("proto", "Y")) - grammar.add_rule(Rule(x, y, + grammar.add_rule(make_rule(x, y, Lambda([p_y2], MessageType("proto", "X"), p_y2))) # X -> a (0 non-literal elements) - grammar.add_rule(Rule(x, lit_a, + grammar.add_rule(make_rule(x, lit_a, Lambda([], MessageType("proto", "X"), Var("r", MessageType("proto", "X"))))) nullable = GrammarAnalysis.compute_nullable_static(grammar) diff --git a/python-tools/tests/meta/test_cli_integration.py b/python-tools/tests/meta/test_cli_integration.py index 9894940c..d1f37e9b 100644 --- a/python-tools/tests/meta/test_cli_integration.py +++ b/python-tools/tests/meta/test_cli_integration.py @@ -47,7 +47,7 @@ def create_test_files(): transaction : "(" "transaction" STRING INT ")" - construct: test.Transaction(name=$3, value=$4) + construct: $$ = test.Transaction(name=$3, value=$4) %% """) @@ -103,11 +103,11 @@ def create_invalid_grammar(): transaction : "(" "person" STRING ")" - construct: test.Transaction(person=test.Person(name=$3)) + construct: $$ = test.Transaction(person=test.Person(name=$3)) person : "(" "person" STRING ")" - construct: test.Person(name=$3) + construct: $$ = test.Person(name=$3) %% """) diff --git a/python-tools/tests/meta/test_end_to_end_validation.py b/python-tools/tests/meta/test_end_to_end_validation.py index e20199bf..2edb0f07 100644 --- a/python-tools/tests/meta/test_end_to_end_validation.py +++ b/python-tools/tests/meta/test_end_to_end_validation.py @@ -96,7 +96,7 @@ def test_missing_message_rule(self): person : STRING - construct: test.Person(name=$1) + construct: $$ = test.Person(name=$1) %% """ @@ -127,7 +127,7 @@ def test_rule_name_can_be_anything(self): my_custom_person_rule : STRING - construct: test.Person(name=$1) + construct: $$ = test.Person(name=$1) %% """ @@ -162,7 +162,7 @@ def test_return_type_mismatch(self): record : STRING - construct: $1 + construct: $$ = $1 %% """ @@ -193,7 +193,7 @@ def test_getelement_out_of_bounds(self): pair : STRING STRING - construct: test.Pair(first=builtin.tuple($1, $2)[5], second=$2) + construct: $$ = test.Pair(first=builtin.tuple($1, $2)[5], second=$2) %% """ @@ -224,7 +224,7 @@ def test_getelement_non_tuple_type(self): record : STRING - construct: test.Record(value=$1[0]) + construct: $$ = test.Record(value=$1[0]) %% """ @@ -256,7 +256,7 @@ def test_message_constructor_arity_error(self): person : STRING - construct: test.Person(name=$1) + construct: $$ = test.Person(name=$1) %% """ @@ -288,7 +288,7 @@ def test_builtin_unwrap_option_or_non_option_arg(self): record : STRING - construct: test.Record(value=builtin.unwrap_option_or($1, "default")) + construct: $$ = test.Record(value=builtin.unwrap_option_or($1, "default")) %% """ @@ -319,7 +319,7 @@ def test_builtin_length_non_list_arg(self): record : STRING - construct: test.Record(count=builtin.length($1)) + construct: $$ = test.Record(count=builtin.length($1)) %% """ @@ -357,7 +357,7 @@ def test_missing_oneof_variant(self): value : STRING - construct: test.Value(kind=oneof_text($1)) + construct: $$ = test.Value(kind=oneof_text($1)) %% """ @@ -393,11 +393,11 @@ def test_rule_without_proto_backing(self): person : STRING - construct: test.Person(name=$1) + construct: $$ = test.Person(name=$1) unknown_rule : STRING - construct: test.NonExistentMessage(name=$1) + construct: $$ = test.NonExistentMessage(name=$1) %% """ @@ -436,11 +436,11 @@ def test_unreachable_rule_error(self): start : STRING - construct: test.Start(value=$1) + construct: $$ = test.Start(value=$1) orphan : STRING - construct: test.Orphan(data=$1) + construct: $$ = test.Orphan(data=$1) %% """ @@ -476,7 +476,7 @@ def test_simple_valid_grammar(self): person : STRING INT - construct: test.Person(name=$1, age=builtin.int64_to_int32($2)) + construct: $$ = test.Person(name=$1, age=builtin.int64_to_int32($2)) %% """ @@ -510,9 +510,9 @@ def test_valid_grammar_with_oneof(self): value : STRING - construct: test.Value(kind=oneof_text($1)) + construct: $$ = test.Value(kind=oneof_text($1)) | INT - construct: test.Value(kind=oneof_number($1)) + construct: $$ = test.Value(kind=oneof_number($1)) %% """ @@ -542,7 +542,7 @@ def test_valid_grammar_with_repeated_fields(self): record : STRING* - construct: test.Record(values=$1) + construct: $$ = test.Record(values=$1) %% """ @@ -572,7 +572,7 @@ def test_valid_grammar_with_optional_fields(self): record : STRING? - construct: test.Record(value=$1) + construct: $$ = test.Record(value=$1) %% """ @@ -608,11 +608,11 @@ def test_valid_grammar_with_nested_messages(self): person : STRING address - construct: test.Person(name=$1, address=$2) + construct: $$ = test.Person(name=$1, address=$2) address : STRING - construct: test.Address(street=$1) + construct: $$ = test.Address(street=$1) %% """ @@ -652,7 +652,7 @@ def test_multiple_errors_in_single_grammar(self): person : STRING INT - construct: $1 + construct: $$ = $1 %% """ @@ -686,7 +686,7 @@ def test_grammar_with_getelement_operations(self): pair : STRING STRING - construct: test.Pair(first=builtin.tuple($1, $2)[0], second=builtin.tuple($1, $2)[1]) + construct: $$ = test.Pair(first=builtin.tuple($1, $2)[0], second=builtin.tuple($1, $2)[1]) %% """ diff --git a/python-tools/tests/meta/test_grammar.py b/python-tools/tests/meta/test_grammar.py index 7ee5527a..f067c60a 100644 --- a/python-tools/tests/meta/test_grammar.py +++ b/python-tools/tests/meta/test_grammar.py @@ -6,7 +6,7 @@ from meta.grammar import ( LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence, - Rule, Token, Grammar, + Rule, Token, Grammar, make_rule, ) from meta.grammar_utils import ( get_nonterminals, get_literals, is_epsilon, rhs_elements, @@ -256,7 +256,7 @@ def test_construction_simple(self): rhs = nt param = Var("x", MessageType("proto", "B")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(lhs, rhs, constructor) + rule = make_rule(lhs, rhs, constructor) assert rule.lhs == lhs assert rule.rhs == rhs assert rule.constructor == constructor @@ -270,7 +270,7 @@ def test_construction_with_sequence(self): param1 = Var("x", MessageType("proto", "B")) param2 = Var("y", MessageType("proto", "C")) constructor = Lambda([param1, param2], MessageType("proto", "A"), param1) - rule = Rule(lhs, rhs, constructor) + rule = make_rule(lhs, rhs, constructor) assert len(rule.constructor.params) == 2 def test_construction_filters_literals(self): @@ -281,7 +281,7 @@ def test_construction_filters_literals(self): rhs = Sequence((nt, lit)) param = Var("x", MessageType("proto", "B")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(lhs, rhs, constructor) + rule = make_rule(lhs, rhs, constructor) assert len(rule.constructor.params) == 1 def test_construction_fails_with_wrong_param_count(self): @@ -293,7 +293,7 @@ def test_construction_fails_with_wrong_param_count(self): param = Var("x", MessageType("proto", "B")) constructor = Lambda([param], MessageType("proto", "A"), param) with pytest.raises(AssertionError, match="Action for A has 1 parameter"): - Rule(lhs, rhs, constructor) + make_rule(lhs, rhs, constructor) def test_str(self): """Test Rule string representation.""" @@ -301,7 +301,7 @@ def test_str(self): nt = Nonterminal("B", MessageType("proto", "B")) param = Var("x", MessageType("proto", "B")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(lhs, nt, constructor) + rule = make_rule(lhs, nt, constructor) result = str(rule) assert "A ->" in result assert "B" in result @@ -312,7 +312,7 @@ def test_source_type(self): nt = Nonterminal("B", MessageType("proto", "B")) param = Var("x", MessageType("proto", "B")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(lhs, nt, constructor, source_type="SomeProtoType") + rule = make_rule(lhs, nt, constructor, source_type="SomeProtoType") assert rule.source_type == "SomeProtoType" @@ -344,7 +344,7 @@ def test_add_rule(self): nt = Nonterminal("A", MessageType("proto", "A")) param = Var("x", MessageType("proto", "A")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(nt, nt, constructor) + rule = make_rule(nt, nt, constructor) grammar.add_rule(rule) assert nt in grammar.rules assert len(grammar.rules[nt]) == 1 @@ -360,8 +360,8 @@ def test_add_multiple_rules_same_lhs(self): param_c = Var("y", MessageType("proto", "C")) constructor_b = Lambda([param_b], MessageType("proto", "A"), param_b) constructor_c = Lambda([param_c], MessageType("proto", "A"), param_c) - rule1 = Rule(nt, nt_b, constructor_b) - rule2 = Rule(nt, nt_c, constructor_c) + rule1 = make_rule(nt, nt_b, constructor_b) + rule2 = make_rule(nt, nt_c, constructor_c) grammar.add_rule(rule1) grammar.add_rule(rule2) assert len(grammar.rules[nt]) == 2 @@ -373,7 +373,7 @@ def test_get_rules(self): nt = Nonterminal("A", MessageType("proto", "A")) param = Var("x", MessageType("proto", "A")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(nt, nt, constructor) + rule = make_rule(nt, nt, constructor) grammar.add_rule(rule) rules = grammar.get_rules(nt) assert len(rules) == 1 @@ -394,7 +394,7 @@ def test_has_rule(self): nt = Nonterminal("A", MessageType("proto", "A")) param = Var("x", MessageType("proto", "A")) constructor = Lambda([param], MessageType("proto", "A"), param) - rule = Rule(nt, nt, constructor) + rule = make_rule(nt, nt, constructor) grammar.add_rule(rule) assert grammar.has_rule(nt) other = Nonterminal("B", MessageType("proto", "B")) @@ -420,11 +420,11 @@ def test_partition_nonterminals(self): constructor_c = Lambda([param_c], MessageType("proto", "C"), param_c) constructor_d = Lambda([param_d], MessageType("proto", "D"), param_d) - grammar.add_rule(Rule(start, a, constructor_start)) - grammar.add_rule(Rule(a, b, constructor_a)) - grammar.add_rule(Rule(b, c, constructor_b)) - grammar.add_rule(Rule(c, c, constructor_c)) - grammar.add_rule(Rule(d, d, constructor_d)) # unreachable rule + grammar.add_rule(make_rule(start, a, constructor_start)) + grammar.add_rule(make_rule(a, b, constructor_a)) + grammar.add_rule(make_rule(b, c, constructor_b)) + grammar.add_rule(make_rule(c, c, constructor_c)) + grammar.add_rule(make_rule(d, d, constructor_d)) # unreachable rule reachable, unreachable = grammar.analysis.partition_nonterminals_by_reachability() assert reachable[0] == start @@ -443,7 +443,7 @@ def test_print_grammar(self): a = Nonterminal("A", MessageType("proto", "A")) param = Var("x", MessageType("proto", "A")) constructor = Lambda([param], MessageType("proto", "A"), param) - grammar.add_rule(Rule(start, a, constructor)) + grammar.add_rule(make_rule(start, a, constructor)) output = grammar.print_grammar() assert "Start" in output assert ": A" in output diff --git a/python-tools/tests/meta/test_grammar_utils.py b/python-tools/tests/meta/test_grammar_utils.py index 09c5b14c..5849c3f4 100644 --- a/python-tools/tests/meta/test_grammar_utils.py +++ b/python-tools/tests/meta/test_grammar_utils.py @@ -1,7 +1,7 @@ """Tests for grammar_utils module.""" from meta.grammar import ( - Nonterminal, LitTerminal, NamedTerminal, Sequence, Star, Option, Rule + Nonterminal, LitTerminal, NamedTerminal, Sequence, Star, Option, Rule, make_rule, ) from meta.grammar_utils import collect, get_nonterminals, get_literals, rewrite_rule from meta.target import MessageType, BaseType, Lambda, Var, OptionType, ListType @@ -138,7 +138,7 @@ def test_rewrite_nonterminal(self): nt_old = Nonterminal('Foo', MessageType('test', 'Foo')) nt_new = Nonterminal('Bar', MessageType('test', 'Foo')) param = Var('x', MessageType('test', 'Foo')) - rule = Rule( + rule = make_rule( lhs=nt_old, rhs=nt_old, constructor=Lambda([param], MessageType('test', 'Foo'), param), @@ -156,7 +156,7 @@ def test_rewrite_in_sequence(self): # Constructor needs 2 params since RHS has 2 non-literals param1 = Var('x', MessageType('test', 'Foo')) param2 = Var('y', MessageType('test', 'Keep')) - rule = Rule( + rule = make_rule( lhs=Nonterminal('Result', MessageType('test', 'Result')), rhs=seq, constructor=Lambda([param1, param2], MessageType('test', 'Result'), param1), @@ -173,7 +173,7 @@ def test_rewrite_in_star(self): nt_new = Nonterminal('Bar', MessageType('test', 'Foo')) star = Star(nt_old) param = Var('x', MessageType('test', 'Foo')) - rule = Rule( + rule = make_rule( lhs=Nonterminal('Result', MessageType('test', 'Result')), rhs=star, constructor=Lambda([param], MessageType('test', 'Result'), param), @@ -189,7 +189,7 @@ def test_rewrite_in_option(self): nt_new = Nonterminal('Bar', MessageType('test', 'Foo')) opt = Option(nt_old) param = Var('x', MessageType('test', 'Foo')) - rule = Rule( + rule = make_rule( lhs=Nonterminal('Result', MessageType('test', 'Result')), rhs=opt, constructor=Lambda([param], MessageType('test', 'Result'), param), @@ -203,7 +203,7 @@ def test_rewrite_no_match_returns_original(self): """Rewrite with no matches returns original rule.""" nt = Nonterminal('Foo', MessageType('test', 'Foo')) param = Var('x', MessageType('test', 'Foo')) - rule = Rule( + rule = make_rule( lhs=nt, rhs=nt, constructor=Lambda([param], MessageType('test', 'Foo'), param), @@ -225,7 +225,7 @@ def test_rewrite_nested_structure(self): # Constructor needs 2 params - one for Keep, one for Option containing Star param1 = Var('x', MessageType('test', 'Keep')) param2 = Var('y', OptionType(ListType(MessageType('test', 'Foo')))) - rule = Rule( + rule = make_rule( lhs=Nonterminal('Result', MessageType('test', 'Result')), rhs=outer, constructor=Lambda([param1, param2], MessageType('test', 'Result'), param1), @@ -248,7 +248,7 @@ def test_rewrite_multiple_replacements(self): # Constructor needs 2 params since RHS has 2 non-literals param1 = Var('x', MessageType('test', 'Foo')) param2 = Var('y', MessageType('test', 'Bar')) - rule = Rule( + rule = make_rule( lhs=Nonterminal('Result', MessageType('test', 'Result')), rhs=seq, constructor=Lambda([param1, param2], MessageType('test', 'Result'), param1), @@ -266,7 +266,7 @@ def test_rewrite_preserves_lhs_and_constructor(self): lhs = Nonterminal('Result', MessageType('test', 'Result')) param = Var('x', MessageType('test', 'Foo')) constructor = Lambda([param], MessageType('test', 'Result'), param) - rule = Rule( + rule = make_rule( lhs=lhs, rhs=nt_old, constructor=constructor, diff --git a/python-tools/tests/meta/test_grammar_validator.py b/python-tools/tests/meta/test_grammar_validator.py index faa2cdf4..15ad7c23 100644 --- a/python-tools/tests/meta/test_grammar_validator.py +++ b/python-tools/tests/meta/test_grammar_validator.py @@ -11,7 +11,7 @@ from meta.target_builtins import make_builtin from meta.grammar import ( Grammar, Nonterminal, Rule, LitTerminal, NamedTerminal, - Star, Option, Sequence + Star, Option, Sequence, make_rule, ) from meta.grammar_validator import GrammarValidator from meta.proto_parser import ProtoParser @@ -271,7 +271,7 @@ def test_star_with_nonterminal(self): rhs = Star(nt) param = Var('items', ListType(BaseType('String'))) constructor = Lambda([param], BaseType('Unit'), Lit(None)) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -288,7 +288,7 @@ def test_star_with_terminal(self): rhs = Star(terminal) param = Var('items', ListType(BaseType('String'))) constructor = Lambda([param], BaseType('Unit'), Lit(None)) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -312,7 +312,7 @@ def test_option_with_nonterminal(self): rhs = Option(nt) param = Var('opt', OptionType(BaseType('String'))) constructor = Lambda([param], BaseType('Unit'), Lit(None)) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -339,7 +339,7 @@ def test_message_with_rule(self): start = Nonterminal('test_message', MessageType('proto', 'TestMessage')) grammar = Grammar(start=start) constructor = Lambda([], MessageType('proto', 'TestMessage'), Call(NewMessage('proto', 'TestMessage', ()), [])) - rule = Rule(start, LitTerminal('test'), constructor) + rule = make_rule(start, LitTerminal('test'), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -381,7 +381,7 @@ def test_message_with_correct_field_count(self): age_var = Var('age', BaseType('Int32')) body = NewMessage('proto', 'Person', (('name', name_var), ('age', age_var))) constructor = Lambda([name_var, age_var], MessageType('proto', 'Person'), body) - rule = Rule(start, Sequence((NamedTerminal('STRING', BaseType('String')), NamedTerminal('INT', BaseType('Int32')))), constructor) + rule = make_rule(start, Sequence((NamedTerminal('STRING', BaseType('String')), NamedTerminal('INT', BaseType('Int32')))), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -404,7 +404,7 @@ def test_message_with_wrong_field_count(self): name_var = Var('name', BaseType('String')) body = NewMessage('proto', 'Person', (('name', name_var),)) # Missing age field constructor = Lambda([name_var], MessageType('proto', 'Person'), body) - rule = Rule(start, NamedTerminal('STRING', BaseType('String')), constructor) + rule = make_rule(start, NamedTerminal('STRING', BaseType('String')), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -504,7 +504,7 @@ def test_rule_arity_match(self): param2 = Var('y', BaseType('Int64')) rhs = Sequence((NamedTerminal('STRING', BaseType('String')), NamedTerminal('INT', BaseType('Int64')))) constructor = Lambda([param1, param2], BaseType('String'), param1) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) validator = GrammarValidator(grammar, parser) validator._check_rule_types(rule) @@ -538,7 +538,7 @@ def test_rule_param_type_match(self): rhs = NamedTerminal('STRING', BaseType('String')) body = NewMessage('proto', 'TestMsg', (('s', param),)) constructor = Lambda([param], msg_type, body) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -554,7 +554,7 @@ def test_rule_return_type_match(self): param = Var('s', BaseType('String')) rhs = NamedTerminal('STRING', BaseType('String')) constructor = Lambda([param], BaseType('String'), param) # Returns the string - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -576,7 +576,7 @@ def test_nested_expressions_checked(self): bad_elem = GetElement(tuple_var, 5) # Out of bounds body = IfElse(condition, bad_elem, param) constructor = Lambda([param], BaseType('String'), body) - rule = Rule(start, rhs, constructor) + rule = make_rule(start, rhs, constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -598,12 +598,12 @@ def test_reachable_rule(self): # Start rule references child - need parameter for child nonterminal child_param = Var('c', BaseType('String')) constructor1 = Lambda([child_param], BaseType('Unit'), Lit(None)) - rule1 = Rule(start, child, constructor1) + rule1 = make_rule(start, child, constructor1) grammar.rules[start] = [rule1] # Child rule constructor2 = Lambda([], BaseType('String'), Lit("test")) - rule2 = Rule(child, LitTerminal('test'), constructor2) + rule2 = make_rule(child, LitTerminal('test'), constructor2) grammar.rules[child] = [rule2] validator = GrammarValidator(grammar, parser) @@ -619,12 +619,12 @@ def test_unreachable_rule(self): # Start rule doesn't reference orphan constructor1 = Lambda([], BaseType('Unit'), Lit(None)) - rule1 = Rule(start, LitTerminal('test'), constructor1) + rule1 = make_rule(start, LitTerminal('test'), constructor1) grammar.rules[start] = [rule1] # Orphan rule not referenced constructor2 = Lambda([], BaseType('String'), Lit("orphan")) - rule2 = Rule(orphan, LitTerminal('orphan'), constructor2) + rule2 = make_rule(orphan, LitTerminal('orphan'), constructor2) grammar.rules[orphan] = [rule2] validator = GrammarValidator(grammar, parser) @@ -645,7 +645,7 @@ def test_rule_with_proto_backing(self): start = Nonterminal('test_message', MessageType('proto', 'TestMessage')) grammar = Grammar(start=start) constructor = Lambda([], MessageType('proto', 'TestMessage'), Call(NewMessage('proto', 'TestMessage', ()), [])) - rule = Rule(start, LitTerminal('test'), constructor) + rule = make_rule(start, LitTerminal('test'), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -661,7 +661,7 @@ def test_rule_without_proto_backing(self): start = Nonterminal('unknown_rule', invalid_type) grammar = Grammar(start=start) constructor = Lambda([], invalid_type, Call(NewMessage('proto', 'NonExistentMessage', ()), [])) - rule = Rule(start, LitTerminal('test'), constructor) + rule = make_rule(start, LitTerminal('test'), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -763,7 +763,7 @@ def test_call_helper_function(self): helper_type = FunctionType([BaseType('String')], BaseType('String')) body = Call(NamedFun('my_helper', helper_type), [param]) constructor = Lambda([param], BaseType('String'), body) - rule = Rule(start, NamedTerminal('STRING', BaseType('String')), constructor) + rule = make_rule(start, NamedTerminal('STRING', BaseType('String')), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -796,7 +796,7 @@ def test_helper_function_as_argument(self): helper_call = Call(NamedFun('wrap', wrap_type), [param]) body = ListExpr([helper_call], BaseType('String')) constructor = Lambda([param], ListType(BaseType('String')), body) - rule = Rule(start, NamedTerminal('STRING', BaseType('String')), constructor) + rule = make_rule(start, NamedTerminal('STRING', BaseType('String')), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) @@ -825,7 +825,7 @@ def test_nested_helper_function_calls(self): param = Var('s', BaseType('String')) body = Call(NamedFun('outer', str_to_str), [param]) constructor = Lambda([param], BaseType('String'), body) - rule = Rule(start, NamedTerminal('STRING', BaseType('String')), constructor) + rule = make_rule(start, NamedTerminal('STRING', BaseType('String')), constructor) grammar.rules[start] = [rule] validator = GrammarValidator(grammar, parser) diff --git a/python-tools/tests/meta/test_parser_gen.py b/python-tools/tests/meta/test_parser_gen.py index 162606c9..315d0b08 100644 --- a/python-tools/tests/meta/test_parser_gen.py +++ b/python-tools/tests/meta/test_parser_gen.py @@ -8,7 +8,7 @@ # Add src to path sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src")) -from meta.grammar import Grammar, Rule, Nonterminal, LitTerminal, NamedTerminal, Option, Star, Sequence +from meta.grammar import make_rule, Grammar, Rule, Nonterminal, LitTerminal, NamedTerminal, Option, Star, Sequence from meta.target import Lambda, Var, MessageType, VisitNonterminalDef, BaseType, ListType from meta.parser_gen import generate_parse_functions, GrammarConflictError, AmbiguousGrammarError @@ -22,7 +22,7 @@ def test_generate_parse_functions_simple(): grammar = Grammar(start=s) action = Lambda([], s_type, Var("result", s_type)) - grammar.add_rule(Rule(s, lit_a, action)) + grammar.add_rule(make_rule(s, lit_a, action)) # Generate parse functions defs = generate_parse_functions(grammar) @@ -43,8 +43,8 @@ def test_generate_parse_functions_multiple_alternatives(): grammar = Grammar(start=s) action = Lambda([], s_type, Var("result", s_type)) - grammar.add_rule(Rule(s, lit_a, action)) - grammar.add_rule(Rule(s, lit_b, action)) + grammar.add_rule(make_rule(s, lit_a, action)) + grammar.add_rule(make_rule(s, lit_b, action)) defs = generate_parse_functions(grammar) @@ -64,8 +64,8 @@ def test_generate_parse_functions_with_nonterminal(): grammar = Grammar(start=s) action_s = Lambda([Var("x", a_type)], s_type, Var("x", a_type)) action_a = Lambda([], a_type, Var("result", a_type)) - grammar.add_rule(Rule(s, a, action_s)) - grammar.add_rule(Rule(a, lit_a, action_a)) + grammar.add_rule(make_rule(s, a, action_s)) + grammar.add_rule(make_rule(a, lit_a, action_a)) defs = generate_parse_functions(grammar) @@ -89,12 +89,12 @@ def test_generate_parse_functions_with_option(): grammar = Grammar(start=s) action_a = Lambda([], a_type, Var("result", a_type)) - grammar.add_rule(Rule(a, lit_b, action_a)) + grammar.add_rule(make_rule(a, lit_b, action_a)) # S -> "a" A? rhs = Sequence((lit_a, Option(a))) action_s = Lambda([Var("opt", a_type)], s_type, Var("opt", a_type)) - grammar.add_rule(Rule(s, rhs, action_s)) + grammar.add_rule(make_rule(s, rhs, action_s)) defs = generate_parse_functions(grammar) @@ -114,13 +114,13 @@ def test_generate_parse_functions_with_star(): grammar = Grammar(start=s) action_a = Lambda([], a_type, Var("result", a_type)) - grammar.add_rule(Rule(a, lit_a, action_a)) + grammar.add_rule(make_rule(a, lit_a, action_a)) # S -> A* rhs = Star(a) list_type = ListType(a_type) action_s = Lambda([Var("list", list_type)], s_type, Var("list", list_type)) - grammar.add_rule(Rule(s, rhs, action_s)) + grammar.add_rule(make_rule(s, rhs, action_s)) defs = generate_parse_functions(grammar) @@ -144,11 +144,11 @@ def test_generate_parse_functions_ll2(): # S -> "a" "b" rhs1 = Sequence((lit_a, lit_b)) - grammar.add_rule(Rule(s, rhs1, action)) + grammar.add_rule(make_rule(s, rhs1, action)) # S -> "a" "c" rhs2 = Sequence((lit_a, lit_c)) - grammar.add_rule(Rule(s, rhs2, action)) + grammar.add_rule(make_rule(s, rhs2, action)) defs = generate_parse_functions(grammar) @@ -172,11 +172,11 @@ def test_generate_parse_functions_ll3(): # S -> "a" "b" "c" rhs1 = Sequence((lit_a, lit_b, lit_c)) - grammar.add_rule(Rule(s, rhs1, action)) + grammar.add_rule(make_rule(s, rhs1, action)) # S -> "a" "b" "d" rhs2 = Sequence((lit_a, lit_b, lit_d)) - grammar.add_rule(Rule(s, rhs2, action)) + grammar.add_rule(make_rule(s, rhs2, action)) defs = generate_parse_functions(grammar) @@ -195,11 +195,11 @@ def test_generate_parse_functions_with_epsilon(): action = Lambda([], s_type, Var("result", s_type)) # S -> "a" - grammar.add_rule(Rule(s, lit_a, action)) + grammar.add_rule(make_rule(s, lit_a, action)) # S -> ε epsilon = Sequence(()) - grammar.add_rule(Rule(s, epsilon, action)) + grammar.add_rule(make_rule(s, epsilon, action)) defs = generate_parse_functions(grammar) @@ -216,7 +216,7 @@ def test_generate_parse_functions_with_named_terminal(): grammar = Grammar(start=s) action = Lambda([Var("id", BaseType("String"))], s_type, Var("id", BaseType("String"))) - grammar.add_rule(Rule(s, id_terminal, action)) + grammar.add_rule(make_rule(s, id_terminal, action)) defs = generate_parse_functions(grammar) @@ -237,8 +237,8 @@ def test_generate_parse_functions_unreachable_nonterminal(): grammar = Grammar(start=s) action_s = Lambda([], s_type, Var("result", s_type)) action_b = Lambda([], b_type, Var("result", b_type)) - grammar.add_rule(Rule(s, lit_a, action_s)) - grammar.add_rule(Rule(b, lit_b, action_b)) + grammar.add_rule(make_rule(s, lit_a, action_s)) + grammar.add_rule(make_rule(b, lit_b, action_b)) defs = generate_parse_functions(grammar) @@ -262,11 +262,11 @@ def test_ll4_conflict_detection(): # S -> "a" "a" "a" "b" rhs1 = Sequence((lit_a, lit_a, lit_a, lit_b)) - grammar.add_rule(Rule(s, rhs1, action)) + grammar.add_rule(make_rule(s, rhs1, action)) # S -> "a" "a" "a" "c" rhs2 = Sequence((lit_a, lit_a, lit_a, lit_c)) - grammar.add_rule(Rule(s, rhs2, action)) + grammar.add_rule(make_rule(s, rhs2, action)) # This should raise a GrammarConflictError with pytest.raises(GrammarConflictError, match="Grammar conflict"): @@ -286,12 +286,12 @@ def test_complex_star_sequence(): grammar = Grammar(start=s) action_a = Lambda([], a_type, Var("result", a_type)) - grammar.add_rule(Rule(a, lit_a, action_a)) + grammar.add_rule(make_rule(a, lit_a, action_a)) # S -> "(" A* ")" rhs = Sequence((lit_lparen, Star(a), lit_rparen)) action_s = Lambda([Var("list", ListType(a_type))], s_type, Var("list", ListType(a_type))) - grammar.add_rule(Rule(s, rhs, action_s)) + grammar.add_rule(make_rule(s, rhs, action_s)) # Should generate successfully since ")" provides clear boundary defs = generate_parse_functions(grammar) diff --git a/python-tools/tests/meta/test_terminal_sequence_set.py b/python-tools/tests/meta/test_terminal_sequence_set.py index 104e25fd..ef81cbcd 100644 --- a/python-tools/tests/meta/test_terminal_sequence_set.py +++ b/python-tools/tests/meta/test_terminal_sequence_set.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src")) from meta.grammar import ( - LitTerminal, NamedTerminal, Nonterminal, Sequence, Rule, Grammar, + LitTerminal, NamedTerminal, Nonterminal, Sequence, Rule, Grammar, make_rule, ) from meta.target import BaseType, MessageType, Lambda, Var from meta.terminal_sequence_set import ( @@ -33,13 +33,13 @@ def make_simple_grammar(): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) construct_action_s = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), construct_action_s)) + grammar.add_rule(make_rule(s, Sequence((a, b)), construct_action_s)) construct_action_a = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, construct_action_a)) + grammar.add_rule(make_rule(a, lit_a, construct_action_a)) construct_action_b = Lambda([], MessageType("proto", "B"), Var("y", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, construct_action_b)) + grammar.add_rule(make_rule(b, lit_b, construct_action_b)) return grammar, s, a, b, lit_a, lit_b @@ -62,16 +62,16 @@ def make_nullable_grammar(): param_a = Var("x", MessageType("proto", "A")) param_b = Var("y", MessageType("proto", "B")) construct_action_s = Lambda([param_a, param_b], MessageType("proto", "S"), param_a) - grammar.add_rule(Rule(s, Sequence((a, b)), construct_action_s)) + grammar.add_rule(make_rule(s, Sequence((a, b)), construct_action_s)) construct_action_a1 = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, lit_a, construct_action_a1)) + grammar.add_rule(make_rule(a, lit_a, construct_action_a1)) construct_action_a2 = Lambda([], MessageType("proto", "A"), Var("x", MessageType("proto", "A"))) - grammar.add_rule(Rule(a, Sequence(()), construct_action_a2)) + grammar.add_rule(make_rule(a, Sequence(()), construct_action_a2)) construct_action_b = Lambda([], MessageType("proto", "B"), Var("y", MessageType("proto", "B"))) - grammar.add_rule(Rule(b, lit_b, construct_action_b)) + grammar.add_rule(make_rule(b, lit_b, construct_action_b)) return grammar, s, a, b, lit_a, lit_b From d08c68839b76cf84c67c9accc614147e623e0063 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Tue, 10 Feb 2026 17:22:15 +0100 Subject: [PATCH 02/25] WIP on pretty printer generator --- python-tools/src/lqp/cli.py | 59 +- .../src/lqp/generated_pretty_printer.py | 2952 ++++++++++------- python-tools/src/meta/__init__.py | 12 +- python-tools/src/meta/codegen_base.py | 26 +- python-tools/src/meta/codegen_julia.py | 15 +- python-tools/src/meta/codegen_python.py | 38 +- python-tools/src/meta/codegen_templates.py | 64 +- python-tools/src/meta/grammar.y | 399 ++- python-tools/src/meta/parser_gen.py | 12 +- python-tools/src/meta/pretty_gen.py | 25 +- python-tools/src/meta/pretty_gen_python.py | 39 +- python-tools/src/meta/target.py | 69 +- python-tools/src/meta/target_builtins.py | 1 + python-tools/src/meta/target_print.py | 9 +- python-tools/src/meta/yacc_action_parser.py | 56 +- python-tools/tests/meta/test_codegen_julia.py | 10 +- .../tests/meta/test_codegen_python.py | 10 +- python-tools/tests/meta/test_parser_gen.py | 6 +- .../tests/test_generated_pretty_printer.py | 132 + 19 files changed, 2413 insertions(+), 1521 deletions(-) create mode 100644 python-tools/tests/test_generated_pretty_printer.py diff --git a/python-tools/src/lqp/cli.py b/python-tools/src/lqp/cli.py index f65314fa..e8eba848 100644 --- a/python-tools/src/lqp/cli.py +++ b/python-tools/src/lqp/cli.py @@ -17,8 +17,8 @@ import lqp.ir as ir -def process_file(filename, bin, json, validate=True, use_generated=False): - """Process a single LQP file and output binary and/or JSON.""" +def parse_lqp_to_proto(filename, use_generated=False, validate=True): + """Parse an LQP text file and return a protobuf message.""" with open(filename, "r") as f: lqp_text = f.read() @@ -33,6 +33,29 @@ def process_file(filename, bin, json, validate=True, use_generated=False): validate_lqp(lqp) lqp_proto = ir_to_proto(lqp) + return lqp_proto + + +def read_bin_to_proto(filename): + """Read a protobuf binary file and return a Transaction message.""" + from lqp.proto.v1 import transactions_pb2 + with open(filename, "rb") as f: + data = f.read() + msg = transactions_pb2.Transaction() + msg.ParseFromString(data) + return msg + + +def pretty_print_proto(lqp_proto): + """Pretty-print a protobuf message and return the string.""" + from lqp.generated_pretty_printer import pretty + return pretty(lqp_proto) + + +def process_file(filename, bin, json, validate=True, use_generated=False): + """Process a single LQP file and output binary and/or JSON.""" + lqp_proto = parse_lqp_to_proto(filename, use_generated, validate) + # Write binary output to the configured directories, using the same filename. if bin: lqp_bin = lqp_proto.SerializeToString() @@ -115,10 +138,11 @@ def main(): """Main entry point for the lqp CLI.""" arg_parser = argparse.ArgumentParser(description="Parse LQP S-expression into Protobuf binary and JSON files.") arg_parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {get_package_version()}", help="show program's version number and exit") - arg_parser.add_argument("input", help="directory holding .lqp files, or a single .lqp file") + arg_parser.add_argument("input", help="directory holding .lqp files, or a single .lqp or .bin file") arg_parser.add_argument("--no-validation", action="store_true", help="don't validate parsed LQP") arg_parser.add_argument("--bin", action="store_true", help="encode emitted ProtoBuf into binary") arg_parser.add_argument("--json", action="store_true", help="encode emitted ProtoBuf into JSON") + arg_parser.add_argument("--pretty", action="store_true", help="pretty-print the input as LQP S-expression") arg_parser.add_argument("--out", action="store_true", help="write emitted binary or JSON to stdout") # Parser selection options (mutually exclusive) @@ -136,8 +160,33 @@ def main(): if os.path.isfile(args.input): filename = args.input - assert filename.endswith(".lqp") and os.path.isfile(filename), \ - f"The input {filename} does not seem to be an LQP file" + + if filename.endswith(".bin"): + lqp_proto = read_bin_to_proto(filename) + if args.pretty: + sys.stdout.write(pretty_print_proto(lqp_proto)) + if args.json: + lqp_json = MessageToJson(lqp_proto, preserving_proto_field_name=True) + if args.out: + sys.stdout.write(lqp_json) + else: + basename = os.path.splitext(filename)[0] + json_name = basename + ".json" + with open(json_name, "w") as f: + f.write(lqp_json) + print(f"Successfully wrote {filename} to JSON at {json_name}") + if not args.pretty and not args.json: + # Default: pretty-print to stdout + sys.stdout.write(pretty_print_proto(lqp_proto)) + return + + assert filename.endswith(".lqp"), \ + f"The input {filename} does not seem to be an LQP or bin file" + + if args.pretty: + lqp_proto = parse_lqp_to_proto(filename, use_generated, validate) + sys.stdout.write(pretty_print_proto(lqp_proto)) + return if args.out: assert not (args.bin and args.json), "Cannot specify both --bin and --json with --out option" diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py index cb810da0..c322bfb0 100644 --- a/python-tools/src/lqp/generated_pretty_printer.py +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -6,22 +6,27 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. -Command: python -m meta.cli ../proto/relationalai/lqp/v1/fragments.proto ../proto/relationalai/lqp/v1/logic.proto ../proto/relationalai/lqp/v1/transactions.proto --grammar src/meta/grammar.y --printer python +Command: python -m meta.cli proto/relationalai/lqp/v1/fragments.proto proto/relationalai/lqp/v1/logic.proto proto/relationalai/lqp/v1/transactions.proto --grammar python-tools/src/meta/grammar.y --printer python """ from io import StringIO -from typing import Any, IO +from typing import Any, IO, Never, Optional from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 +class ParseError(Exception): + pass + + class PrettyPrinter: """Pretty printer for protobuf messages.""" - def __init__(self, io: IO[str] = None): + def __init__(self, io: Optional[IO[str]] = None): self.io = io if io is not None else StringIO() self.indent_level = 0 self.at_line_start = True + self._debug_info: dict[tuple[int, int], str] = {} def write(self, s: str) -> None: """Write a string to the output, with indentation at line start.""" @@ -70,11 +75,15 @@ def fragment_id_to_string(self, msg) -> str: """Convert FragmentId to string representation.""" return msg.id.decode('utf-8') if msg.id else "" - def relation_id_to_string(self, msg): - """Convert RelationId to string representation if it has symbol.""" - if msg.symbol: - return msg.symbol - return None + def start_pretty_fragment(self, msg) -> None: + """Extract debug info from Fragment for relation ID lookup.""" + debug_info = msg.debug_info + for rid, name in zip(debug_info.ids, debug_info.orig_names): + self._debug_info[(rid.id_low, rid.id_high)] = name + + def relation_id_to_string(self, msg) -> str: + """Convert RelationId to string representation using debug info.""" + return self._debug_info.get((msg.id_low, msg.id_high), "") def relation_id_to_int(self, msg): """Convert RelationId to int representation if it has id.""" @@ -82,15 +91,19 @@ def relation_id_to_int(self, msg): return (msg.id_high << 64) | msg.id_low return None + def relation_id_to_uint128(self, msg): + """Convert RelationId to UInt128Value representation.""" + return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) + def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: def _t493(_dollar_dollar): - _t494 = Parser.is_default_configure(_dollar_dollar.configure) + _t494 = self.is_default_configure(_dollar_dollar.configure) if not _t494: - _t495 = (_dollar_dollar.configure, _dollar_dollar.sync, _dollar_dollar.epochs,) + _t495 = _dollar_dollar.configure else: _t495 = None - return _t495 + return (_t495, _dollar_dollar.sync, _dollar_dollar.epochs,) _t496 = _t493(msg) fields0 = _t496 unwrapped_fields1 = fields0 @@ -132,7 +145,7 @@ def _t493(_dollar_dollar): def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: def _t503(_dollar_dollar): - _t504 = Parser.deconstruct_configure(_dollar_dollar) + _t504 = self.deconstruct_configure(_dollar_dollar) return _t504 _t505 = _t503(msg) fields9 = _t505 @@ -260,7 +273,7 @@ def _t536(_dollar_dollar): deconstruct_result24 = _t538 if deconstruct_result24 is not None: - self.write(str(deconstruct_result24)) + self.write(self.format_uint128(deconstruct_result24)) _t539 = None else: def _t540(_dollar_dollar): @@ -324,12 +337,9 @@ def _t553(_dollar_dollar): def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: def _t555(_dollar_dollar): - _t556 = self.int32_to_int64(_dollar_dollar.year) - _t557 = self.int32_to_int64(_dollar_dollar.month) - _t558 = self.int32_to_int64(_dollar_dollar.day) - return (_t556, _t557, _t558,) - _t559 = _t555(msg) - fields30 = _t559 + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) + _t556 = _t555(msg) + fields30 = _t556 unwrapped_fields31 = fields30 self.write('(') self.write('date') @@ -349,17 +359,10 @@ def _t555(_dollar_dollar): return None def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: - def _t560(_dollar_dollar): - _t561 = self.int32_to_int64(_dollar_dollar.year) - _t562 = self.int32_to_int64(_dollar_dollar.month) - _t563 = self.int32_to_int64(_dollar_dollar.day) - _t564 = self.int32_to_int64(_dollar_dollar.hour) - _t565 = self.int32_to_int64(_dollar_dollar.minute) - _t566 = self.int32_to_int64(_dollar_dollar.second) - _t567 = self.int32_to_int64(_dollar_dollar.microsecond) - return (_t561, _t562, _t563, _t564, _t565, _t566, _t567,) - _t568 = _t560(msg) - fields35 = _t568 + def _t557(_dollar_dollar): + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), int(_dollar_dollar.microsecond),) + _t558 = _t557(msg) + fields35 = _t558 unwrapped_fields36 = fields35 self.write('(') self.write('datetime') @@ -388,28 +391,28 @@ def _t560(_dollar_dollar): if field43 is not None: opt_val44 = field43 self.write(str(opt_val44)) - _t569 = None + _t559 = None else: - _t569 = None + _t559 = None self.dedent() self.write(')') self.newline() return None def pretty_boolean_value(self, msg: bool) -> Optional[Never]: - def _t570(_dollar_dollar): + def _t560(_dollar_dollar): return _dollar_dollar - _t571 = _t570(msg) - fields47 = _t571 + _t561 = _t560(msg) + fields47 = _t561 unwrapped_fields48 = fields47 self.write('true') return None def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: - def _t572(_dollar_dollar): + def _t562(_dollar_dollar): return _dollar_dollar.fragments - _t573 = _t572(msg) - fields49 = _t573 + _t563 = _t562(msg) + fields49 = _t563 unwrapped_fields50 = fields49 self.write('(') self.write('sync') @@ -419,38 +422,40 @@ def _t572(_dollar_dollar): if (i52 > 0): self.newline() - _t574 = None + _t564 = None else: - _t574 = None - _t575 = self.pretty_fragment_id(elem51) + _t564 = None + _t565 = self.pretty_fragment_id(elem51) self.dedent() self.write(')') self.newline() return None def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t576(_dollar_dollar): - _t577 = self.fragment_id_to_string(_dollar_dollar) - return _t577 - _t578 = _t576(msg) - fields53 = _t578 + def _t566(_dollar_dollar): + return self.fragment_id_to_string(_dollar_dollar) + _t567 = _t566(msg) + fields53 = _t567 unwrapped_fields54 = fields53 self.write(':') self.write(unwrapped_fields54) return None def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: - def _t579(_dollar_dollar): - _t580 = self.is_empty(_dollar_dollar.writes) - _t581 = self.is_empty(_dollar_dollar.reads) + def _t568(_dollar_dollar): + + if not len(_dollar_dollar.writes) == 0: + _t569 = _dollar_dollar.writes + else: + _t569 = None - if (not _t580 and not _t581): - _t582 = (_dollar_dollar.writes, _dollar_dollar.reads,) + if not len(_dollar_dollar.reads) == 0: + _t570 = _dollar_dollar.reads else: - _t582 = None - return _t582 - _t583 = _t579(msg) - fields55 = _t583 + _t570 = None + return (_t569, _t570,) + _t571 = _t568(msg) + fields55 = _t571 unwrapped_fields56 = fields55 self.write('(') self.write('epoch') @@ -460,29 +465,29 @@ def _t579(_dollar_dollar): if field57 is not None: opt_val58 = field57 - _t585 = self.pretty_epoch_writes(opt_val58) - _t584 = _t585 + _t573 = self.pretty_epoch_writes(opt_val58) + _t572 = _t573 else: - _t584 = None + _t572 = None self.newline() field59 = unwrapped_fields56[1] if field59 is not None: opt_val60 = field59 - _t587 = self.pretty_epoch_reads(opt_val60) - _t586 = _t587 + _t575 = self.pretty_epoch_reads(opt_val60) + _t574 = _t575 else: - _t586 = None + _t574 = None self.dedent() self.write(')') self.newline() return None def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: - def _t588(_dollar_dollar): + def _t576(_dollar_dollar): return _dollar_dollar - _t589 = _t588(msg) - fields61 = _t589 + _t577 = _t576(msg) + fields61 = _t577 unwrapped_fields62 = fields61 self.write('(') self.write('writes') @@ -492,268 +497,266 @@ def _t588(_dollar_dollar): if (i64 > 0): self.newline() - _t590 = None + _t578 = None else: - _t590 = None - _t591 = self.pretty_write(elem63) + _t578 = None + _t579 = self.pretty_write(elem63) self.dedent() self.write(')') self.newline() return None def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: - def _t592(_dollar_dollar): + def _t580(_dollar_dollar): if _dollar_dollar.HasField('define'): - _t593 = _dollar_dollar.define + _t581 = _dollar_dollar.define else: - _t593 = None - return _t593 - _t594 = _t592(msg) - deconstruct_result67 = _t594 + _t581 = None + return _t581 + _t582 = _t580(msg) + deconstruct_result67 = _t582 if deconstruct_result67 is not None: - _t596 = self.pretty_define(deconstruct_result67) - _t595 = _t596 + _t584 = self.pretty_define(deconstruct_result67) + _t583 = _t584 else: - def _t597(_dollar_dollar): + def _t585(_dollar_dollar): if _dollar_dollar.HasField('undefine'): - _t598 = _dollar_dollar.undefine + _t586 = _dollar_dollar.undefine else: - _t598 = None - return _t598 - _t599 = _t597(msg) - deconstruct_result66 = _t599 + _t586 = None + return _t586 + _t587 = _t585(msg) + deconstruct_result66 = _t587 if deconstruct_result66 is not None: - _t601 = self.pretty_undefine(deconstruct_result66) - _t600 = _t601 + _t589 = self.pretty_undefine(deconstruct_result66) + _t588 = _t589 else: - def _t602(_dollar_dollar): + def _t590(_dollar_dollar): if _dollar_dollar.HasField('context'): - _t603 = _dollar_dollar.context + _t591 = _dollar_dollar.context else: - _t603 = None - return _t603 - _t604 = _t602(msg) - deconstruct_result65 = _t604 + _t591 = None + return _t591 + _t592 = _t590(msg) + deconstruct_result65 = _t592 if deconstruct_result65 is not None: - _t606 = self.pretty_context(deconstruct_result65) - _t605 = _t606 + _t594 = self.pretty_context(deconstruct_result65) + _t593 = _t594 else: raise ParseError('No matching rule for write') - _t600 = _t605 - _t595 = _t600 - return _t595 + _t588 = _t593 + _t583 = _t588 + return _t583 def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: - def _t607(_dollar_dollar): + def _t595(_dollar_dollar): return _dollar_dollar.fragment - _t608 = _t607(msg) - fields68 = _t608 + _t596 = _t595(msg) + fields68 = _t596 unwrapped_fields69 = fields68 self.write('(') self.write('define') self.newline() self.indent() - _t609 = self.pretty_fragment(unwrapped_fields69) + _t597 = self.pretty_fragment(unwrapped_fields69) self.dedent() self.write(')') self.newline() return None def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: - def _t610(_dollar_dollar): + def _t598(_dollar_dollar): + _t599 = self.start_pretty_fragment(_dollar_dollar) return (_dollar_dollar.id, _dollar_dollar.declarations,) - _t611 = _t610(msg) - fields70 = _t611 + _t600 = _t598(msg) + fields70 = _t600 unwrapped_fields71 = fields70 self.write('(') self.write('fragment') self.newline() self.indent() field72 = unwrapped_fields71[0] - _t612 = self.pretty_new_fragment_id(field72) + _t601 = self.pretty_new_fragment_id(field72) self.newline() field73 = unwrapped_fields71[1] for i75, elem74 in enumerate(field73): if (i75 > 0): self.newline() - _t613 = None + _t602 = None else: - _t613 = None - _t614 = self.pretty_declaration(elem74) + _t602 = None + _t603 = self.pretty_declaration(elem74) self.dedent() self.write(')') self.newline() return None def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t615(_dollar_dollar): + def _t604(_dollar_dollar): return _dollar_dollar - _t616 = _t615(msg) - fields76 = _t616 + _t605 = _t604(msg) + fields76 = _t605 unwrapped_fields77 = fields76 - _t617 = self.pretty_fragment_id(unwrapped_fields77) - return _t617 + _t606 = self.pretty_fragment_id(unwrapped_fields77) + return _t606 def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: - def _t618(_dollar_dollar): - _t619 = self.is_empty(_dollar_dollar.attrs) + def _t607(_dollar_dollar): - if not _t619: - _t620 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if _dollar_dollar.HasField('def'): + _t608 = getattr(_dollar_dollar, 'def') else: - _t620 = None - return _t620 - _t621 = _t618(msg) - guard_result81 = _t621 + _t608 = None + return _t608 + _t609 = _t607(msg) + deconstruct_result81 = _t609 - if guard_result81 is not None: - _t623 = self.pretty_def(msg) - _t622 = _t623 + if deconstruct_result81 is not None: + _t611 = self.pretty_def(deconstruct_result81) + _t610 = _t611 else: - def _t624(_dollar_dollar): + def _t612(_dollar_dollar): if _dollar_dollar.HasField('algorithm'): - _t625 = _dollar_dollar.algorithm + _t613 = _dollar_dollar.algorithm else: - _t625 = None - return _t625 - _t626 = _t624(msg) - deconstruct_result80 = _t626 + _t613 = None + return _t613 + _t614 = _t612(msg) + deconstruct_result80 = _t614 if deconstruct_result80 is not None: - _t628 = self.pretty_algorithm(deconstruct_result80) - _t627 = _t628 + _t616 = self.pretty_algorithm(deconstruct_result80) + _t615 = _t616 else: - def _t629(_dollar_dollar): + def _t617(_dollar_dollar): if _dollar_dollar.HasField('constraint'): - _t630 = _dollar_dollar.constraint + _t618 = _dollar_dollar.constraint else: - _t630 = None - return _t630 - _t631 = _t629(msg) - deconstruct_result79 = _t631 + _t618 = None + return _t618 + _t619 = _t617(msg) + deconstruct_result79 = _t619 if deconstruct_result79 is not None: - _t633 = self.pretty_constraint(deconstruct_result79) - _t632 = _t633 + _t621 = self.pretty_constraint(deconstruct_result79) + _t620 = _t621 else: - def _t634(_dollar_dollar): + def _t622(_dollar_dollar): if _dollar_dollar.HasField('rel_edb'): - _t635 = _dollar_dollar.rel_edb + _t623 = _dollar_dollar.rel_edb else: - _t635 = None - return _t635 - _t636 = _t634(msg) - guard_result78 = _t636 + _t623 = None + return _t623 + _t624 = _t622(msg) + guard_result78 = _t624 if guard_result78 is not None: - _t638 = self.pretty_data(msg) - _t637 = _t638 + _t626 = self.pretty_data(msg) + _t625 = _t626 else: raise ParseError('No matching rule for declaration') - _t632 = _t637 - _t627 = _t632 - _t622 = _t627 - return _t622 + _t620 = _t625 + _t615 = _t620 + _t610 = _t615 + return _t610 def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: - def _t639(_dollar_dollar): - _t640 = self.is_empty(_dollar_dollar.attrs) + def _t627(_dollar_dollar): - if not _t640: - _t641 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t628 = _dollar_dollar.attrs else: - _t641 = None - return _t641 - _t642 = _t639(msg) - fields82 = _t642 + _t628 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t628,) + _t629 = _t627(msg) + fields82 = _t629 unwrapped_fields83 = fields82 self.write('(') self.write('def') self.newline() self.indent() field84 = unwrapped_fields83[0] - _t643 = self.pretty_relation_id(field84) + _t630 = self.pretty_relation_id(field84) self.newline() field85 = unwrapped_fields83[1] - _t644 = self.pretty_abstraction(field85) + _t631 = self.pretty_abstraction(field85) self.newline() field86 = unwrapped_fields83[2] if field86 is not None: opt_val87 = field86 - _t646 = self.pretty_attrs(opt_val87) - _t645 = _t646 + _t633 = self.pretty_attrs(opt_val87) + _t632 = _t633 else: - _t645 = None + _t632 = None self.dedent() self.write(')') self.newline() return None def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: - def _t647(_dollar_dollar): - _t648 = Parser.deconstruct_relation_id_string(_dollar_dollar) - return _t648 - _t649 = _t647(msg) - deconstruct_result89 = _t649 + def _t634(_dollar_dollar): + _t635 = self.deconstruct_relation_id_string(_dollar_dollar) + return _t635 + _t636 = _t634(msg) + deconstruct_result89 = _t636 if deconstruct_result89 is not None: self.write(':') self.write(deconstruct_result89) - _t650 = None + _t637 = None else: - def _t651(_dollar_dollar): - _t652 = Parser.deconstruct_relation_id_uint128(_dollar_dollar) - return _t652 - _t653 = _t651(msg) - deconstruct_result88 = _t653 + def _t638(_dollar_dollar): + _t639 = self.deconstruct_relation_id_uint128(_dollar_dollar) + return _t639 + _t640 = _t638(msg) + deconstruct_result88 = _t640 if deconstruct_result88 is not None: - self.write(str(deconstruct_result88)) - _t654 = None + self.write(self.format_uint128(deconstruct_result88)) + _t641 = None else: raise ParseError('No matching rule for relation_id') - _t650 = _t654 - return _t650 + _t637 = _t641 + return _t637 def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: - def _t655(_dollar_dollar): - _t656 = Parser.deconstruct_bindings(_dollar_dollar) - return (_t656, _dollar_dollar.value,) - _t657 = _t655(msg) - fields90 = _t657 + def _t642(_dollar_dollar): + _t643 = self.deconstruct_bindings(_dollar_dollar) + return (_t643, _dollar_dollar.value,) + _t644 = _t642(msg) + fields90 = _t644 unwrapped_fields91 = fields90 self.write('(') field92 = unwrapped_fields91[0] - _t658 = self.pretty_bindings(field92) + _t645 = self.pretty_bindings(field92) field93 = unwrapped_fields91[1] - _t659 = self.pretty_formula(field93) + _t646 = self.pretty_formula(field93) self.dedent() self.write(')') self.newline() return None def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: - def _t660(_dollar_dollar): - _t661 = self.is_empty(_dollar_dollar[1]) + def _t647(_dollar_dollar): - if not _t661: - _t662 = (_dollar_dollar[0], _dollar_dollar[1],) + if not len(_dollar_dollar[1]) == 0: + _t648 = _dollar_dollar[1] else: - _t662 = None - return _t662 - _t663 = _t660(msg) - fields94 = _t663 + _t648 = None + return (_dollar_dollar[0], _t648,) + _t649 = _t647(msg) + fields94 = _t649 unwrapped_fields95 = fields94 self.write('[') field96 = unwrapped_fields95[0] @@ -761,290 +764,288 @@ def _t660(_dollar_dollar): if (i98 > 0): self.newline() - _t664 = None + _t650 = None else: - _t664 = None - _t665 = self.pretty_binding(elem97) + _t650 = None + _t651 = self.pretty_binding(elem97) field99 = unwrapped_fields95[1] if field99 is not None: opt_val100 = field99 - _t667 = self.pretty_value_bindings(opt_val100) - _t666 = _t667 + _t653 = self.pretty_value_bindings(opt_val100) + _t652 = _t653 else: - _t666 = None + _t652 = None self.write(']') return None def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: - def _t668(_dollar_dollar): + def _t654(_dollar_dollar): return (_dollar_dollar.var.name, _dollar_dollar.type,) - _t669 = _t668(msg) - fields101 = _t669 + _t655 = _t654(msg) + fields101 = _t655 unwrapped_fields102 = fields101 field103 = unwrapped_fields102[0] self.write(field103) self.write('::') field104 = unwrapped_fields102[1] - _t670 = self.pretty_type(field104) - return _t670 + _t656 = self.pretty_type(field104) + return _t656 def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: - def _t671(_dollar_dollar): + def _t657(_dollar_dollar): if _dollar_dollar.HasField('unspecified_type'): - _t672 = _dollar_dollar.unspecified_type + _t658 = _dollar_dollar.unspecified_type else: - _t672 = None - return _t672 - _t673 = _t671(msg) - deconstruct_result115 = _t673 + _t658 = None + return _t658 + _t659 = _t657(msg) + deconstruct_result115 = _t659 if deconstruct_result115 is not None: - _t675 = self.pretty_unspecified_type(deconstruct_result115) - _t674 = _t675 + _t661 = self.pretty_unspecified_type(deconstruct_result115) + _t660 = _t661 else: - def _t676(_dollar_dollar): + def _t662(_dollar_dollar): if _dollar_dollar.HasField('string_type'): - _t677 = _dollar_dollar.string_type + _t663 = _dollar_dollar.string_type else: - _t677 = None - return _t677 - _t678 = _t676(msg) - deconstruct_result114 = _t678 + _t663 = None + return _t663 + _t664 = _t662(msg) + deconstruct_result114 = _t664 if deconstruct_result114 is not None: - _t680 = self.pretty_string_type(deconstruct_result114) - _t679 = _t680 + _t666 = self.pretty_string_type(deconstruct_result114) + _t665 = _t666 else: - def _t681(_dollar_dollar): + def _t667(_dollar_dollar): if _dollar_dollar.HasField('int_type'): - _t682 = _dollar_dollar.int_type + _t668 = _dollar_dollar.int_type else: - _t682 = None - return _t682 - _t683 = _t681(msg) - deconstruct_result113 = _t683 + _t668 = None + return _t668 + _t669 = _t667(msg) + deconstruct_result113 = _t669 if deconstruct_result113 is not None: - _t685 = self.pretty_int_type(deconstruct_result113) - _t684 = _t685 + _t671 = self.pretty_int_type(deconstruct_result113) + _t670 = _t671 else: - def _t686(_dollar_dollar): + def _t672(_dollar_dollar): if _dollar_dollar.HasField('float_type'): - _t687 = _dollar_dollar.float_type + _t673 = _dollar_dollar.float_type else: - _t687 = None - return _t687 - _t688 = _t686(msg) - deconstruct_result112 = _t688 + _t673 = None + return _t673 + _t674 = _t672(msg) + deconstruct_result112 = _t674 if deconstruct_result112 is not None: - _t690 = self.pretty_float_type(deconstruct_result112) - _t689 = _t690 + _t676 = self.pretty_float_type(deconstruct_result112) + _t675 = _t676 else: - def _t691(_dollar_dollar): + def _t677(_dollar_dollar): if _dollar_dollar.HasField('uint128_type'): - _t692 = _dollar_dollar.uint128_type + _t678 = _dollar_dollar.uint128_type else: - _t692 = None - return _t692 - _t693 = _t691(msg) - deconstruct_result111 = _t693 + _t678 = None + return _t678 + _t679 = _t677(msg) + deconstruct_result111 = _t679 if deconstruct_result111 is not None: - _t695 = self.pretty_uint128_type(deconstruct_result111) - _t694 = _t695 + _t681 = self.pretty_uint128_type(deconstruct_result111) + _t680 = _t681 else: - def _t696(_dollar_dollar): + def _t682(_dollar_dollar): if _dollar_dollar.HasField('int128_type'): - _t697 = _dollar_dollar.int128_type + _t683 = _dollar_dollar.int128_type else: - _t697 = None - return _t697 - _t698 = _t696(msg) - deconstruct_result110 = _t698 + _t683 = None + return _t683 + _t684 = _t682(msg) + deconstruct_result110 = _t684 if deconstruct_result110 is not None: - _t700 = self.pretty_int128_type(deconstruct_result110) - _t699 = _t700 + _t686 = self.pretty_int128_type(deconstruct_result110) + _t685 = _t686 else: - def _t701(_dollar_dollar): + def _t687(_dollar_dollar): if _dollar_dollar.HasField('date_type'): - _t702 = _dollar_dollar.date_type + _t688 = _dollar_dollar.date_type else: - _t702 = None - return _t702 - _t703 = _t701(msg) - deconstruct_result109 = _t703 + _t688 = None + return _t688 + _t689 = _t687(msg) + deconstruct_result109 = _t689 if deconstruct_result109 is not None: - _t705 = self.pretty_date_type(deconstruct_result109) - _t704 = _t705 + _t691 = self.pretty_date_type(deconstruct_result109) + _t690 = _t691 else: - def _t706(_dollar_dollar): + def _t692(_dollar_dollar): if _dollar_dollar.HasField('datetime_type'): - _t707 = _dollar_dollar.datetime_type + _t693 = _dollar_dollar.datetime_type else: - _t707 = None - return _t707 - _t708 = _t706(msg) - deconstruct_result108 = _t708 + _t693 = None + return _t693 + _t694 = _t692(msg) + deconstruct_result108 = _t694 if deconstruct_result108 is not None: - _t710 = self.pretty_datetime_type(deconstruct_result108) - _t709 = _t710 + _t696 = self.pretty_datetime_type(deconstruct_result108) + _t695 = _t696 else: - def _t711(_dollar_dollar): + def _t697(_dollar_dollar): if _dollar_dollar.HasField('missing_type'): - _t712 = _dollar_dollar.missing_type + _t698 = _dollar_dollar.missing_type else: - _t712 = None - return _t712 - _t713 = _t711(msg) - deconstruct_result107 = _t713 + _t698 = None + return _t698 + _t699 = _t697(msg) + deconstruct_result107 = _t699 if deconstruct_result107 is not None: - _t715 = self.pretty_missing_type(deconstruct_result107) - _t714 = _t715 + _t701 = self.pretty_missing_type(deconstruct_result107) + _t700 = _t701 else: - def _t716(_dollar_dollar): + def _t702(_dollar_dollar): if _dollar_dollar.HasField('decimal_type'): - _t717 = _dollar_dollar.decimal_type + _t703 = _dollar_dollar.decimal_type else: - _t717 = None - return _t717 - _t718 = _t716(msg) - deconstruct_result106 = _t718 + _t703 = None + return _t703 + _t704 = _t702(msg) + deconstruct_result106 = _t704 if deconstruct_result106 is not None: - _t720 = self.pretty_decimal_type(deconstruct_result106) - _t719 = _t720 + _t706 = self.pretty_decimal_type(deconstruct_result106) + _t705 = _t706 else: - def _t721(_dollar_dollar): + def _t707(_dollar_dollar): if _dollar_dollar.HasField('boolean_type'): - _t722 = _dollar_dollar.boolean_type + _t708 = _dollar_dollar.boolean_type else: - _t722 = None - return _t722 - _t723 = _t721(msg) - deconstruct_result105 = _t723 + _t708 = None + return _t708 + _t709 = _t707(msg) + deconstruct_result105 = _t709 if deconstruct_result105 is not None: - _t725 = self.pretty_boolean_type(deconstruct_result105) - _t724 = _t725 + _t711 = self.pretty_boolean_type(deconstruct_result105) + _t710 = _t711 else: raise ParseError('No matching rule for type') - _t719 = _t724 - _t714 = _t719 - _t709 = _t714 - _t704 = _t709 - _t699 = _t704 - _t694 = _t699 - _t689 = _t694 - _t684 = _t689 - _t679 = _t684 - _t674 = _t679 - return _t674 + _t705 = _t710 + _t700 = _t705 + _t695 = _t700 + _t690 = _t695 + _t685 = _t690 + _t680 = _t685 + _t675 = _t680 + _t670 = _t675 + _t665 = _t670 + _t660 = _t665 + return _t660 def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: - def _t726(_dollar_dollar): + def _t712(_dollar_dollar): return _dollar_dollar - _t727 = _t726(msg) - fields116 = _t727 + _t713 = _t712(msg) + fields116 = _t713 unwrapped_fields117 = fields116 self.write('UNKNOWN') return None def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: - def _t728(_dollar_dollar): + def _t714(_dollar_dollar): return _dollar_dollar - _t729 = _t728(msg) - fields118 = _t729 + _t715 = _t714(msg) + fields118 = _t715 unwrapped_fields119 = fields118 self.write('STRING') return None def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: - def _t730(_dollar_dollar): + def _t716(_dollar_dollar): return _dollar_dollar - _t731 = _t730(msg) - fields120 = _t731 + _t717 = _t716(msg) + fields120 = _t717 unwrapped_fields121 = fields120 self.write('INT') return None def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: - def _t732(_dollar_dollar): + def _t718(_dollar_dollar): return _dollar_dollar - _t733 = _t732(msg) - fields122 = _t733 + _t719 = _t718(msg) + fields122 = _t719 unwrapped_fields123 = fields122 self.write('FLOAT') return None def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: - def _t734(_dollar_dollar): + def _t720(_dollar_dollar): return _dollar_dollar - _t735 = _t734(msg) - fields124 = _t735 + _t721 = _t720(msg) + fields124 = _t721 unwrapped_fields125 = fields124 self.write('UINT128') return None def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: - def _t736(_dollar_dollar): + def _t722(_dollar_dollar): return _dollar_dollar - _t737 = _t736(msg) - fields126 = _t737 + _t723 = _t722(msg) + fields126 = _t723 unwrapped_fields127 = fields126 self.write('INT128') return None def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: - def _t738(_dollar_dollar): + def _t724(_dollar_dollar): return _dollar_dollar - _t739 = _t738(msg) - fields128 = _t739 + _t725 = _t724(msg) + fields128 = _t725 unwrapped_fields129 = fields128 self.write('DATE') return None def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: - def _t740(_dollar_dollar): + def _t726(_dollar_dollar): return _dollar_dollar - _t741 = _t740(msg) - fields130 = _t741 + _t727 = _t726(msg) + fields130 = _t727 unwrapped_fields131 = fields130 self.write('DATETIME') return None def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: - def _t742(_dollar_dollar): + def _t728(_dollar_dollar): return _dollar_dollar - _t743 = _t742(msg) - fields132 = _t743 + _t729 = _t728(msg) + fields132 = _t729 unwrapped_fields133 = fields132 self.write('MISSING') return None def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: - def _t744(_dollar_dollar): - _t745 = self.int32_to_int64(_dollar_dollar.precision) - _t746 = self.int32_to_int64(_dollar_dollar.scale) - return (_t745, _t746,) - _t747 = _t744(msg) - fields134 = _t747 + def _t730(_dollar_dollar): + return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) + _t731 = _t730(msg) + fields134 = _t731 unwrapped_fields135 = fields134 self.write('(') self.write('DECIMAL') @@ -1061,238 +1062,234 @@ def _t744(_dollar_dollar): return None def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: - def _t748(_dollar_dollar): + def _t732(_dollar_dollar): return _dollar_dollar - _t749 = _t748(msg) - fields138 = _t749 + _t733 = _t732(msg) + fields138 = _t733 unwrapped_fields139 = fields138 self.write('BOOLEAN') return None def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: - def _t750(_dollar_dollar): + def _t734(_dollar_dollar): return _dollar_dollar - _t751 = _t750(msg) - fields140 = _t751 + _t735 = _t734(msg) + fields140 = _t735 unwrapped_fields141 = fields140 self.write('|') for i143, elem142 in enumerate(unwrapped_fields141): if (i143 > 0): self.newline() - _t752 = None + _t736 = None else: - _t752 = None - _t753 = self.pretty_binding(elem142) + _t736 = None + _t737 = self.pretty_binding(elem142) return None def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: - def _t754(_dollar_dollar): - _t755 = self.is_empty(_dollar_dollar.conjunction.args) + def _t738(_dollar_dollar): - if (_dollar_dollar.HasField('conjunction') and _t755): - _t756 = _dollar_dollar.conjunction + if (_dollar_dollar.HasField('conjunction') and len(_dollar_dollar.conjunction.args) == 0): + _t739 = _dollar_dollar.conjunction else: - _t756 = None - return _t756 - _t757 = _t754(msg) - deconstruct_result156 = _t757 + _t739 = None + return _t739 + _t740 = _t738(msg) + deconstruct_result156 = _t740 if deconstruct_result156 is not None: - _t759 = self.pretty_true(deconstruct_result156) - _t758 = _t759 + _t742 = self.pretty_true(deconstruct_result156) + _t741 = _t742 else: - def _t760(_dollar_dollar): - _t761 = self.is_empty(_dollar_dollar.disjunction.args) + def _t743(_dollar_dollar): - if (_dollar_dollar.HasField('disjunction') and _t761): - _t762 = _dollar_dollar.disjunction + if (_dollar_dollar.HasField('disjunction') and len(_dollar_dollar.disjunction.args) == 0): + _t744 = _dollar_dollar.disjunction else: - _t762 = None - return _t762 - _t763 = _t760(msg) - deconstruct_result155 = _t763 + _t744 = None + return _t744 + _t745 = _t743(msg) + deconstruct_result155 = _t745 if deconstruct_result155 is not None: - _t765 = self.pretty_false(deconstruct_result155) - _t764 = _t765 + _t747 = self.pretty_false(deconstruct_result155) + _t746 = _t747 else: - def _t766(_dollar_dollar): + def _t748(_dollar_dollar): if _dollar_dollar.HasField('exists'): - _t767 = _dollar_dollar.exists + _t749 = _dollar_dollar.exists else: - _t767 = None - return _t767 - _t768 = _t766(msg) - deconstruct_result154 = _t768 + _t749 = None + return _t749 + _t750 = _t748(msg) + deconstruct_result154 = _t750 if deconstruct_result154 is not None: - _t770 = self.pretty_exists(deconstruct_result154) - _t769 = _t770 + _t752 = self.pretty_exists(deconstruct_result154) + _t751 = _t752 else: - def _t771(_dollar_dollar): + def _t753(_dollar_dollar): if _dollar_dollar.HasField('reduce'): - _t772 = _dollar_dollar.reduce + _t754 = _dollar_dollar.reduce else: - _t772 = None - return _t772 - _t773 = _t771(msg) - deconstruct_result153 = _t773 + _t754 = None + return _t754 + _t755 = _t753(msg) + deconstruct_result153 = _t755 if deconstruct_result153 is not None: - _t775 = self.pretty_reduce(deconstruct_result153) - _t774 = _t775 + _t757 = self.pretty_reduce(deconstruct_result153) + _t756 = _t757 else: - def _t776(_dollar_dollar): - _t777 = self.is_empty(_dollar_dollar.conjunction.args) + def _t758(_dollar_dollar): - if (_dollar_dollar.HasField('conjunction') and not _t777): - _t778 = _dollar_dollar.conjunction + if (_dollar_dollar.HasField('conjunction') and not len(_dollar_dollar.conjunction.args) == 0): + _t759 = _dollar_dollar.conjunction else: - _t778 = None - return _t778 - _t779 = _t776(msg) - deconstruct_result152 = _t779 + _t759 = None + return _t759 + _t760 = _t758(msg) + deconstruct_result152 = _t760 if deconstruct_result152 is not None: - _t781 = self.pretty_conjunction(deconstruct_result152) - _t780 = _t781 + _t762 = self.pretty_conjunction(deconstruct_result152) + _t761 = _t762 else: - def _t782(_dollar_dollar): - _t783 = self.is_empty(_dollar_dollar.disjunction.args) + def _t763(_dollar_dollar): - if (_dollar_dollar.HasField('disjunction') and not _t783): - _t784 = _dollar_dollar.disjunction + if (_dollar_dollar.HasField('disjunction') and not len(_dollar_dollar.disjunction.args) == 0): + _t764 = _dollar_dollar.disjunction else: - _t784 = None - return _t784 - _t785 = _t782(msg) - deconstruct_result151 = _t785 + _t764 = None + return _t764 + _t765 = _t763(msg) + deconstruct_result151 = _t765 if deconstruct_result151 is not None: - _t787 = self.pretty_disjunction(deconstruct_result151) - _t786 = _t787 + _t767 = self.pretty_disjunction(deconstruct_result151) + _t766 = _t767 else: - def _t788(_dollar_dollar): + def _t768(_dollar_dollar): if _dollar_dollar.HasField('not'): - _t789 = getattr(_dollar_dollar, 'not') + _t769 = getattr(_dollar_dollar, 'not') else: - _t789 = None - return _t789 - _t790 = _t788(msg) - deconstruct_result150 = _t790 + _t769 = None + return _t769 + _t770 = _t768(msg) + deconstruct_result150 = _t770 if deconstruct_result150 is not None: - _t792 = self.pretty_not(deconstruct_result150) - _t791 = _t792 + _t772 = self.pretty_not(deconstruct_result150) + _t771 = _t772 else: - def _t793(_dollar_dollar): + def _t773(_dollar_dollar): if _dollar_dollar.HasField('ffi'): - _t794 = _dollar_dollar.ffi + _t774 = _dollar_dollar.ffi else: - _t794 = None - return _t794 - _t795 = _t793(msg) - deconstruct_result149 = _t795 + _t774 = None + return _t774 + _t775 = _t773(msg) + deconstruct_result149 = _t775 if deconstruct_result149 is not None: - _t797 = self.pretty_ffi(deconstruct_result149) - _t796 = _t797 + _t777 = self.pretty_ffi(deconstruct_result149) + _t776 = _t777 else: - def _t798(_dollar_dollar): + def _t778(_dollar_dollar): if _dollar_dollar.HasField('atom'): - _t799 = _dollar_dollar.atom + _t779 = _dollar_dollar.atom else: - _t799 = None - return _t799 - _t800 = _t798(msg) - deconstruct_result148 = _t800 + _t779 = None + return _t779 + _t780 = _t778(msg) + deconstruct_result148 = _t780 if deconstruct_result148 is not None: - _t802 = self.pretty_atom(deconstruct_result148) - _t801 = _t802 + _t782 = self.pretty_atom(deconstruct_result148) + _t781 = _t782 else: - def _t803(_dollar_dollar): + def _t783(_dollar_dollar): if _dollar_dollar.HasField('pragma'): - _t804 = _dollar_dollar.pragma + _t784 = _dollar_dollar.pragma else: - _t804 = None - return _t804 - _t805 = _t803(msg) - deconstruct_result147 = _t805 + _t784 = None + return _t784 + _t785 = _t783(msg) + deconstruct_result147 = _t785 if deconstruct_result147 is not None: - _t807 = self.pretty_pragma(deconstruct_result147) - _t806 = _t807 + _t787 = self.pretty_pragma(deconstruct_result147) + _t786 = _t787 else: - def _t808(_dollar_dollar): + def _t788(_dollar_dollar): if _dollar_dollar.HasField('primitive'): - _t809 = _dollar_dollar.primitive + _t789 = _dollar_dollar.primitive else: - _t809 = None - return _t809 - _t810 = _t808(msg) - deconstruct_result146 = _t810 + _t789 = None + return _t789 + _t790 = _t788(msg) + deconstruct_result146 = _t790 if deconstruct_result146 is not None: - _t812 = self.pretty_primitive(deconstruct_result146) - _t811 = _t812 + _t792 = self.pretty_primitive(deconstruct_result146) + _t791 = _t792 else: - def _t813(_dollar_dollar): + def _t793(_dollar_dollar): if _dollar_dollar.HasField('rel_atom'): - _t814 = _dollar_dollar.rel_atom + _t794 = _dollar_dollar.rel_atom else: - _t814 = None - return _t814 - _t815 = _t813(msg) - deconstruct_result145 = _t815 + _t794 = None + return _t794 + _t795 = _t793(msg) + deconstruct_result145 = _t795 if deconstruct_result145 is not None: - _t817 = self.pretty_rel_atom(deconstruct_result145) - _t816 = _t817 + _t797 = self.pretty_rel_atom(deconstruct_result145) + _t796 = _t797 else: - def _t818(_dollar_dollar): + def _t798(_dollar_dollar): if _dollar_dollar.HasField('cast'): - _t819 = _dollar_dollar.cast + _t799 = _dollar_dollar.cast else: - _t819 = None - return _t819 - _t820 = _t818(msg) - deconstruct_result144 = _t820 + _t799 = None + return _t799 + _t800 = _t798(msg) + deconstruct_result144 = _t800 if deconstruct_result144 is not None: - _t822 = self.pretty_cast(deconstruct_result144) - _t821 = _t822 + _t802 = self.pretty_cast(deconstruct_result144) + _t801 = _t802 else: raise ParseError('No matching rule for formula') - _t816 = _t821 - _t811 = _t816 - _t806 = _t811 - _t801 = _t806 - _t796 = _t801 - _t791 = _t796 - _t786 = _t791 - _t780 = _t786 - _t774 = _t780 - _t769 = _t774 - _t764 = _t769 - _t758 = _t764 - return _t758 + _t796 = _t801 + _t791 = _t796 + _t786 = _t791 + _t781 = _t786 + _t776 = _t781 + _t771 = _t776 + _t766 = _t771 + _t761 = _t766 + _t756 = _t761 + _t751 = _t756 + _t746 = _t751 + _t741 = _t746 + return _t741 def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t823(_dollar_dollar): + def _t803(_dollar_dollar): return _dollar_dollar - _t824 = _t823(msg) - fields157 = _t824 + _t804 = _t803(msg) + fields157 = _t804 unwrapped_fields158 = fields157 self.write('(') self.write('true') @@ -1304,10 +1301,10 @@ def _t823(_dollar_dollar): return None def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t825(_dollar_dollar): + def _t805(_dollar_dollar): return _dollar_dollar - _t826 = _t825(msg) - fields159 = _t826 + _t806 = _t805(msg) + fields159 = _t806 unwrapped_fields160 = fields159 self.write('(') self.write('false') @@ -1319,54 +1316,54 @@ def _t825(_dollar_dollar): return None def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: - def _t827(_dollar_dollar): - _t828 = Parser.deconstruct_bindings(_dollar_dollar.body) - return (_t828, _dollar_dollar.body.value,) - _t829 = _t827(msg) - fields161 = _t829 + def _t807(_dollar_dollar): + _t808 = self.deconstruct_bindings(_dollar_dollar.body) + return (_t808, _dollar_dollar.body.value,) + _t809 = _t807(msg) + fields161 = _t809 unwrapped_fields162 = fields161 self.write('(') self.write('exists') self.newline() self.indent() field163 = unwrapped_fields162[0] - _t830 = self.pretty_bindings(field163) + _t810 = self.pretty_bindings(field163) self.newline() field164 = unwrapped_fields162[1] - _t831 = self.pretty_formula(field164) + _t811 = self.pretty_formula(field164) self.dedent() self.write(')') self.newline() return None def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: - def _t832(_dollar_dollar): + def _t812(_dollar_dollar): return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) - _t833 = _t832(msg) - fields165 = _t833 + _t813 = _t812(msg) + fields165 = _t813 unwrapped_fields166 = fields165 self.write('(') self.write('reduce') self.newline() self.indent() field167 = unwrapped_fields166[0] - _t834 = self.pretty_abstraction(field167) + _t814 = self.pretty_abstraction(field167) self.newline() field168 = unwrapped_fields166[1] - _t835 = self.pretty_abstraction(field168) + _t815 = self.pretty_abstraction(field168) self.newline() field169 = unwrapped_fields166[2] - _t836 = self.pretty_terms(field169) + _t816 = self.pretty_terms(field169) self.dedent() self.write(')') self.newline() return None def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: - def _t837(_dollar_dollar): + def _t817(_dollar_dollar): return _dollar_dollar - _t838 = _t837(msg) - fields170 = _t838 + _t818 = _t817(msg) + fields170 = _t818 unwrapped_fields171 = fields170 self.write('(') self.write('terms') @@ -1376,71 +1373,71 @@ def _t837(_dollar_dollar): if (i173 > 0): self.newline() - _t839 = None + _t819 = None else: - _t839 = None - _t840 = self.pretty_term(elem172) + _t819 = None + _t820 = self.pretty_term(elem172) self.dedent() self.write(')') self.newline() return None def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: - def _t841(_dollar_dollar): + def _t821(_dollar_dollar): if _dollar_dollar.HasField('var'): - _t842 = _dollar_dollar.var + _t822 = _dollar_dollar.var else: - _t842 = None - return _t842 - _t843 = _t841(msg) - deconstruct_result175 = _t843 + _t822 = None + return _t822 + _t823 = _t821(msg) + deconstruct_result175 = _t823 if deconstruct_result175 is not None: - _t845 = self.pretty_var(deconstruct_result175) - _t844 = _t845 + _t825 = self.pretty_var(deconstruct_result175) + _t824 = _t825 else: - def _t846(_dollar_dollar): + def _t826(_dollar_dollar): if _dollar_dollar.HasField('constant'): - _t847 = _dollar_dollar.constant + _t827 = _dollar_dollar.constant else: - _t847 = None - return _t847 - _t848 = _t846(msg) - deconstruct_result174 = _t848 + _t827 = None + return _t827 + _t828 = _t826(msg) + deconstruct_result174 = _t828 if deconstruct_result174 is not None: - _t850 = self.pretty_constant(deconstruct_result174) - _t849 = _t850 + _t830 = self.pretty_constant(deconstruct_result174) + _t829 = _t830 else: raise ParseError('No matching rule for term') - _t844 = _t849 - return _t844 + _t824 = _t829 + return _t824 def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: - def _t851(_dollar_dollar): + def _t831(_dollar_dollar): return _dollar_dollar.name - _t852 = _t851(msg) - fields176 = _t852 + _t832 = _t831(msg) + fields176 = _t832 unwrapped_fields177 = fields176 self.write(unwrapped_fields177) return None def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t853(_dollar_dollar): + def _t833(_dollar_dollar): return _dollar_dollar - _t854 = _t853(msg) - fields178 = _t854 + _t834 = _t833(msg) + fields178 = _t834 unwrapped_fields179 = fields178 - _t855 = self.pretty_value(unwrapped_fields179) - return _t855 + _t835 = self.pretty_value(unwrapped_fields179) + return _t835 def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t856(_dollar_dollar): + def _t836(_dollar_dollar): return _dollar_dollar.args - _t857 = _t856(msg) - fields180 = _t857 + _t837 = _t836(msg) + fields180 = _t837 unwrapped_fields181 = fields180 self.write('(') self.write('and') @@ -1450,20 +1447,20 @@ def _t856(_dollar_dollar): if (i183 > 0): self.newline() - _t858 = None + _t838 = None else: - _t858 = None - _t859 = self.pretty_formula(elem182) + _t838 = None + _t839 = self.pretty_formula(elem182) self.dedent() self.write(')') self.newline() return None def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t860(_dollar_dollar): + def _t840(_dollar_dollar): return _dollar_dollar.args - _t861 = _t860(msg) - fields184 = _t861 + _t841 = _t840(msg) + fields184 = _t841 unwrapped_fields185 = fields184 self.write('(') self.write('or') @@ -1473,69 +1470,69 @@ def _t860(_dollar_dollar): if (i187 > 0): self.newline() - _t862 = None + _t842 = None else: - _t862 = None - _t863 = self.pretty_formula(elem186) + _t842 = None + _t843 = self.pretty_formula(elem186) self.dedent() self.write(')') self.newline() return None def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: - def _t864(_dollar_dollar): + def _t844(_dollar_dollar): return _dollar_dollar.arg - _t865 = _t864(msg) - fields188 = _t865 + _t845 = _t844(msg) + fields188 = _t845 unwrapped_fields189 = fields188 self.write('(') self.write('not') self.newline() self.indent() - _t866 = self.pretty_formula(unwrapped_fields189) + _t846 = self.pretty_formula(unwrapped_fields189) self.dedent() self.write(')') self.newline() return None def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: - def _t867(_dollar_dollar): + def _t847(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) - _t868 = _t867(msg) - fields190 = _t868 + _t848 = _t847(msg) + fields190 = _t848 unwrapped_fields191 = fields190 self.write('(') self.write('ffi') self.newline() self.indent() field192 = unwrapped_fields191[0] - _t869 = self.pretty_name(field192) + _t849 = self.pretty_name(field192) self.newline() field193 = unwrapped_fields191[1] - _t870 = self.pretty_ffi_args(field193) + _t850 = self.pretty_ffi_args(field193) self.newline() field194 = unwrapped_fields191[2] - _t871 = self.pretty_terms(field194) + _t851 = self.pretty_terms(field194) self.dedent() self.write(')') self.newline() return None def pretty_name(self, msg: str) -> Optional[Never]: - def _t872(_dollar_dollar): + def _t852(_dollar_dollar): return _dollar_dollar - _t873 = _t872(msg) - fields195 = _t873 + _t853 = _t852(msg) + fields195 = _t853 unwrapped_fields196 = fields195 self.write(':') self.write(unwrapped_fields196) return None def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: - def _t874(_dollar_dollar): + def _t854(_dollar_dollar): return _dollar_dollar - _t875 = _t874(msg) - fields197 = _t875 + _t855 = _t854(msg) + fields197 = _t855 unwrapped_fields198 = fields197 self.write('(') self.write('args') @@ -1545,563 +1542,563 @@ def _t874(_dollar_dollar): if (i200 > 0): self.newline() - _t876 = None + _t856 = None else: - _t876 = None - _t877 = self.pretty_abstraction(elem199) + _t856 = None + _t857 = self.pretty_abstraction(elem199) self.dedent() self.write(')') self.newline() return None def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: - def _t878(_dollar_dollar): + def _t858(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t879 = _t878(msg) - fields201 = _t879 + _t859 = _t858(msg) + fields201 = _t859 unwrapped_fields202 = fields201 self.write('(') self.write('atom') self.newline() self.indent() field203 = unwrapped_fields202[0] - _t880 = self.pretty_relation_id(field203) + _t860 = self.pretty_relation_id(field203) self.newline() field204 = unwrapped_fields202[1] for i206, elem205 in enumerate(field204): if (i206 > 0): self.newline() - _t881 = None + _t861 = None else: - _t881 = None - _t882 = self.pretty_term(elem205) + _t861 = None + _t862 = self.pretty_term(elem205) self.dedent() self.write(')') self.newline() return None def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: - def _t883(_dollar_dollar): + def _t863(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t884 = _t883(msg) - fields207 = _t884 + _t864 = _t863(msg) + fields207 = _t864 unwrapped_fields208 = fields207 self.write('(') self.write('pragma') self.newline() self.indent() field209 = unwrapped_fields208[0] - _t885 = self.pretty_name(field209) + _t865 = self.pretty_name(field209) self.newline() field210 = unwrapped_fields208[1] for i212, elem211 in enumerate(field210): if (i212 > 0): self.newline() - _t886 = None + _t866 = None else: - _t886 = None - _t887 = self.pretty_term(elem211) + _t866 = None + _t867 = self.pretty_term(elem211) self.dedent() self.write(')') self.newline() return None def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t888(_dollar_dollar): + def _t868(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t889 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t869 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t889 = None - return _t889 - _t890 = _t888(msg) - guard_result227 = _t890 + _t869 = None + return _t869 + _t870 = _t868(msg) + guard_result227 = _t870 if guard_result227 is not None: - _t892 = self.pretty_eq(msg) - _t891 = _t892 + _t872 = self.pretty_eq(msg) + _t871 = _t872 else: - def _t893(_dollar_dollar): + def _t873(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t894 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t874 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t894 = None - return _t894 - _t895 = _t893(msg) - guard_result226 = _t895 + _t874 = None + return _t874 + _t875 = _t873(msg) + guard_result226 = _t875 if guard_result226 is not None: - _t897 = self.pretty_lt(msg) - _t896 = _t897 + _t877 = self.pretty_lt(msg) + _t876 = _t877 else: - def _t898(_dollar_dollar): + def _t878(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t899 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t879 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t899 = None - return _t899 - _t900 = _t898(msg) - guard_result225 = _t900 + _t879 = None + return _t879 + _t880 = _t878(msg) + guard_result225 = _t880 if guard_result225 is not None: - _t902 = self.pretty_lt_eq(msg) - _t901 = _t902 + _t882 = self.pretty_lt_eq(msg) + _t881 = _t882 else: - def _t903(_dollar_dollar): + def _t883(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t904 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t884 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t904 = None - return _t904 - _t905 = _t903(msg) - guard_result224 = _t905 + _t884 = None + return _t884 + _t885 = _t883(msg) + guard_result224 = _t885 if guard_result224 is not None: - _t907 = self.pretty_gt(msg) - _t906 = _t907 + _t887 = self.pretty_gt(msg) + _t886 = _t887 else: - def _t908(_dollar_dollar): + def _t888(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t909 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t889 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t909 = None - return _t909 - _t910 = _t908(msg) - guard_result223 = _t910 + _t889 = None + return _t889 + _t890 = _t888(msg) + guard_result223 = _t890 if guard_result223 is not None: - _t912 = self.pretty_gt_eq(msg) - _t911 = _t912 + _t892 = self.pretty_gt_eq(msg) + _t891 = _t892 else: - def _t913(_dollar_dollar): + def _t893(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t914 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t894 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t914 = None - return _t914 - _t915 = _t913(msg) - guard_result222 = _t915 + _t894 = None + return _t894 + _t895 = _t893(msg) + guard_result222 = _t895 if guard_result222 is not None: - _t917 = self.pretty_add(msg) - _t916 = _t917 + _t897 = self.pretty_add(msg) + _t896 = _t897 else: - def _t918(_dollar_dollar): + def _t898(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t919 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t899 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t919 = None - return _t919 - _t920 = _t918(msg) - guard_result221 = _t920 + _t899 = None + return _t899 + _t900 = _t898(msg) + guard_result221 = _t900 if guard_result221 is not None: - _t922 = self.pretty_minus(msg) - _t921 = _t922 + _t902 = self.pretty_minus(msg) + _t901 = _t902 else: - def _t923(_dollar_dollar): + def _t903(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t924 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t904 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t924 = None - return _t924 - _t925 = _t923(msg) - guard_result220 = _t925 + _t904 = None + return _t904 + _t905 = _t903(msg) + guard_result220 = _t905 if guard_result220 is not None: - _t927 = self.pretty_multiply(msg) - _t926 = _t927 + _t907 = self.pretty_multiply(msg) + _t906 = _t907 else: - def _t928(_dollar_dollar): + def _t908(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t929 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t909 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t929 = None - return _t929 - _t930 = _t928(msg) - guard_result219 = _t930 + _t909 = None + return _t909 + _t910 = _t908(msg) + guard_result219 = _t910 if guard_result219 is not None: - _t932 = self.pretty_divide(msg) - _t931 = _t932 + _t912 = self.pretty_divide(msg) + _t911 = _t912 else: - def _t933(_dollar_dollar): + def _t913(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t934 = _t933(msg) - fields213 = _t934 + _t914 = _t913(msg) + fields213 = _t914 unwrapped_fields214 = fields213 self.write('(') self.write('primitive') self.newline() self.indent() field215 = unwrapped_fields214[0] - _t935 = self.pretty_name(field215) + _t915 = self.pretty_name(field215) self.newline() field216 = unwrapped_fields214[1] for i218, elem217 in enumerate(field216): if (i218 > 0): self.newline() - _t936 = None + _t916 = None else: - _t936 = None - _t937 = self.pretty_rel_term(elem217) + _t916 = None + _t917 = self.pretty_rel_term(elem217) self.dedent() self.write(')') self.newline() - _t931 = None - _t926 = _t931 - _t921 = _t926 - _t916 = _t921 - _t911 = _t916 - _t906 = _t911 - _t901 = _t906 - _t896 = _t901 - _t891 = _t896 - return _t891 + _t911 = None + _t906 = _t911 + _t901 = _t906 + _t896 = _t901 + _t891 = _t896 + _t886 = _t891 + _t881 = _t886 + _t876 = _t881 + _t871 = _t876 + return _t871 def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t938(_dollar_dollar): + def _t918(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t939 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t919 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t939 = None - return _t939 - _t940 = _t938(msg) - fields228 = _t940 + _t919 = None + return _t919 + _t920 = _t918(msg) + fields228 = _t920 unwrapped_fields229 = fields228 self.write('(') self.write('=') self.newline() self.indent() field230 = unwrapped_fields229[0] - _t941 = self.pretty_term(field230) + _t921 = self.pretty_term(field230) self.newline() field231 = unwrapped_fields229[1] - _t942 = self.pretty_term(field231) + _t922 = self.pretty_term(field231) self.dedent() self.write(')') self.newline() return None def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t943(_dollar_dollar): + def _t923(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t944 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t924 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t944 = None - return _t944 - _t945 = _t943(msg) - fields232 = _t945 + _t924 = None + return _t924 + _t925 = _t923(msg) + fields232 = _t925 unwrapped_fields233 = fields232 self.write('(') self.write('<') self.newline() self.indent() field234 = unwrapped_fields233[0] - _t946 = self.pretty_term(field234) + _t926 = self.pretty_term(field234) self.newline() field235 = unwrapped_fields233[1] - _t947 = self.pretty_term(field235) + _t927 = self.pretty_term(field235) self.dedent() self.write(')') self.newline() return None def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t948(_dollar_dollar): + def _t928(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t949 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t929 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t949 = None - return _t949 - _t950 = _t948(msg) - fields236 = _t950 + _t929 = None + return _t929 + _t930 = _t928(msg) + fields236 = _t930 unwrapped_fields237 = fields236 self.write('(') self.write('<=') self.newline() self.indent() field238 = unwrapped_fields237[0] - _t951 = self.pretty_term(field238) + _t931 = self.pretty_term(field238) self.newline() field239 = unwrapped_fields237[1] - _t952 = self.pretty_term(field239) + _t932 = self.pretty_term(field239) self.dedent() self.write(')') self.newline() return None def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t953(_dollar_dollar): + def _t933(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t954 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t934 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t954 = None - return _t954 - _t955 = _t953(msg) - fields240 = _t955 + _t934 = None + return _t934 + _t935 = _t933(msg) + fields240 = _t935 unwrapped_fields241 = fields240 self.write('(') self.write('>') self.newline() self.indent() field242 = unwrapped_fields241[0] - _t956 = self.pretty_term(field242) + _t936 = self.pretty_term(field242) self.newline() field243 = unwrapped_fields241[1] - _t957 = self.pretty_term(field243) + _t937 = self.pretty_term(field243) self.dedent() self.write(')') self.newline() return None def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t958(_dollar_dollar): + def _t938(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t959 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t939 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t959 = None - return _t959 - _t960 = _t958(msg) - fields244 = _t960 + _t939 = None + return _t939 + _t940 = _t938(msg) + fields244 = _t940 unwrapped_fields245 = fields244 self.write('(') self.write('>=') self.newline() self.indent() field246 = unwrapped_fields245[0] - _t961 = self.pretty_term(field246) + _t941 = self.pretty_term(field246) self.newline() field247 = unwrapped_fields245[1] - _t962 = self.pretty_term(field247) + _t942 = self.pretty_term(field247) self.dedent() self.write(')') self.newline() return None def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t963(_dollar_dollar): + def _t943(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t964 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t944 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t964 = None - return _t964 - _t965 = _t963(msg) - fields248 = _t965 + _t944 = None + return _t944 + _t945 = _t943(msg) + fields248 = _t945 unwrapped_fields249 = fields248 self.write('(') self.write('+') self.newline() self.indent() field250 = unwrapped_fields249[0] - _t966 = self.pretty_term(field250) + _t946 = self.pretty_term(field250) self.newline() field251 = unwrapped_fields249[1] - _t967 = self.pretty_term(field251) + _t947 = self.pretty_term(field251) self.newline() field252 = unwrapped_fields249[2] - _t968 = self.pretty_term(field252) + _t948 = self.pretty_term(field252) self.dedent() self.write(')') self.newline() return None def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t969(_dollar_dollar): + def _t949(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t970 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t950 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t970 = None - return _t970 - _t971 = _t969(msg) - fields253 = _t971 + _t950 = None + return _t950 + _t951 = _t949(msg) + fields253 = _t951 unwrapped_fields254 = fields253 self.write('(') self.write('-') self.newline() self.indent() field255 = unwrapped_fields254[0] - _t972 = self.pretty_term(field255) + _t952 = self.pretty_term(field255) self.newline() field256 = unwrapped_fields254[1] - _t973 = self.pretty_term(field256) + _t953 = self.pretty_term(field256) self.newline() field257 = unwrapped_fields254[2] - _t974 = self.pretty_term(field257) + _t954 = self.pretty_term(field257) self.dedent() self.write(')') self.newline() return None def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t975(_dollar_dollar): + def _t955(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t976 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t956 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t976 = None - return _t976 - _t977 = _t975(msg) - fields258 = _t977 + _t956 = None + return _t956 + _t957 = _t955(msg) + fields258 = _t957 unwrapped_fields259 = fields258 self.write('(') self.write('*') self.newline() self.indent() field260 = unwrapped_fields259[0] - _t978 = self.pretty_term(field260) + _t958 = self.pretty_term(field260) self.newline() field261 = unwrapped_fields259[1] - _t979 = self.pretty_term(field261) + _t959 = self.pretty_term(field261) self.newline() field262 = unwrapped_fields259[2] - _t980 = self.pretty_term(field262) + _t960 = self.pretty_term(field262) self.dedent() self.write(')') self.newline() return None def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t981(_dollar_dollar): + def _t961(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t982 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t962 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t982 = None - return _t982 - _t983 = _t981(msg) - fields263 = _t983 + _t962 = None + return _t962 + _t963 = _t961(msg) + fields263 = _t963 unwrapped_fields264 = fields263 self.write('(') self.write('/') self.newline() self.indent() field265 = unwrapped_fields264[0] - _t984 = self.pretty_term(field265) + _t964 = self.pretty_term(field265) self.newline() field266 = unwrapped_fields264[1] - _t985 = self.pretty_term(field266) + _t965 = self.pretty_term(field266) self.newline() field267 = unwrapped_fields264[2] - _t986 = self.pretty_term(field267) + _t966 = self.pretty_term(field267) self.dedent() self.write(')') self.newline() return None def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: - def _t987(_dollar_dollar): + def _t967(_dollar_dollar): if _dollar_dollar.HasField('specialized_value'): - _t988 = _dollar_dollar.specialized_value + _t968 = _dollar_dollar.specialized_value else: - _t988 = None - return _t988 - _t989 = _t987(msg) - deconstruct_result269 = _t989 + _t968 = None + return _t968 + _t969 = _t967(msg) + deconstruct_result269 = _t969 if deconstruct_result269 is not None: - _t991 = self.pretty_specialized_value(deconstruct_result269) - _t990 = _t991 + _t971 = self.pretty_specialized_value(deconstruct_result269) + _t970 = _t971 else: - def _t992(_dollar_dollar): + def _t972(_dollar_dollar): if _dollar_dollar.HasField('var'): - _t993 = _dollar_dollar.var + _t973 = _dollar_dollar.var else: - _t993 = None - return _t993 - _t994 = _t992(msg) - guard_result268 = _t994 + _t973 = None + return _t973 + _t974 = _t972(msg) + guard_result268 = _t974 if guard_result268 is not None: - _t996 = self.pretty_term(msg) - _t995 = _t996 + _t976 = self.pretty_term(msg) + _t975 = _t976 else: raise ParseError('No matching rule for rel_term') - _t990 = _t995 - return _t990 + _t970 = _t975 + return _t970 def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t997(_dollar_dollar): + def _t977(_dollar_dollar): return _dollar_dollar - _t998 = _t997(msg) - fields270 = _t998 + _t978 = _t977(msg) + fields270 = _t978 unwrapped_fields271 = fields270 self.write('#') - _t999 = self.pretty_value(unwrapped_fields271) - return _t999 + _t979 = self.pretty_value(unwrapped_fields271) + return _t979 def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: - def _t1000(_dollar_dollar): + def _t980(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t1001 = _t1000(msg) - fields272 = _t1001 + _t981 = _t980(msg) + fields272 = _t981 unwrapped_fields273 = fields272 self.write('(') self.write('relatom') self.newline() self.indent() field274 = unwrapped_fields273[0] - _t1002 = self.pretty_name(field274) + _t982 = self.pretty_name(field274) self.newline() field275 = unwrapped_fields273[1] for i277, elem276 in enumerate(field275): if (i277 > 0): self.newline() - _t1003 = None + _t983 = None else: - _t1003 = None - _t1004 = self.pretty_rel_term(elem276) + _t983 = None + _t984 = self.pretty_rel_term(elem276) self.dedent() self.write(')') self.newline() return None def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: - def _t1005(_dollar_dollar): + def _t985(_dollar_dollar): return (_dollar_dollar.input, _dollar_dollar.result,) - _t1006 = _t1005(msg) - fields278 = _t1006 + _t986 = _t985(msg) + fields278 = _t986 unwrapped_fields279 = fields278 self.write('(') self.write('cast') self.newline() self.indent() field280 = unwrapped_fields279[0] - _t1007 = self.pretty_term(field280) + _t987 = self.pretty_term(field280) self.newline() field281 = unwrapped_fields279[1] - _t1008 = self.pretty_term(field281) + _t988 = self.pretty_term(field281) self.dedent() self.write(')') self.newline() return None def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: - def _t1009(_dollar_dollar): + def _t989(_dollar_dollar): return _dollar_dollar - _t1010 = _t1009(msg) - fields282 = _t1010 + _t990 = _t989(msg) + fields282 = _t990 unwrapped_fields283 = fields282 self.write('(') self.write('attrs') @@ -2111,47 +2108,47 @@ def _t1009(_dollar_dollar): if (i285 > 0): self.newline() - _t1011 = None + _t991 = None else: - _t1011 = None - _t1012 = self.pretty_attribute(elem284) + _t991 = None + _t992 = self.pretty_attribute(elem284) self.dedent() self.write(')') self.newline() return None def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: - def _t1013(_dollar_dollar): + def _t993(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args,) - _t1014 = _t1013(msg) - fields286 = _t1014 + _t994 = _t993(msg) + fields286 = _t994 unwrapped_fields287 = fields286 self.write('(') self.write('attribute') self.newline() self.indent() field288 = unwrapped_fields287[0] - _t1015 = self.pretty_name(field288) + _t995 = self.pretty_name(field288) self.newline() field289 = unwrapped_fields287[1] for i291, elem290 in enumerate(field289): if (i291 > 0): self.newline() - _t1016 = None + _t996 = None else: - _t1016 = None - _t1017 = self.pretty_value(elem290) + _t996 = None + _t997 = self.pretty_value(elem290) self.dedent() self.write(')') self.newline() return None def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: - def _t1018(_dollar_dollar): + def _t998(_dollar_dollar): return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) - _t1019 = _t1018(msg) - fields292 = _t1019 + _t999 = _t998(msg) + fields292 = _t999 unwrapped_fields293 = fields292 self.write('(') self.write('algorithm') @@ -2162,23 +2159,23 @@ def _t1018(_dollar_dollar): if (i296 > 0): self.newline() - _t1020 = None + _t1000 = None else: - _t1020 = None - _t1021 = self.pretty_relation_id(elem295) + _t1000 = None + _t1001 = self.pretty_relation_id(elem295) self.newline() field297 = unwrapped_fields293[1] - _t1022 = self.pretty_script(field297) + _t1002 = self.pretty_script(field297) self.dedent() self.write(')') self.newline() return None def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: - def _t1023(_dollar_dollar): + def _t1003(_dollar_dollar): return _dollar_dollar.constructs - _t1024 = _t1023(msg) - fields298 = _t1024 + _t1004 = _t1003(msg) + fields298 = _t1004 unwrapped_fields299 = fields298 self.write('(') self.write('script') @@ -2188,73 +2185,73 @@ def _t1023(_dollar_dollar): if (i301 > 0): self.newline() - _t1025 = None + _t1005 = None else: - _t1025 = None - _t1026 = self.pretty_construct(elem300) + _t1005 = None + _t1006 = self.pretty_construct(elem300) self.dedent() self.write(')') self.newline() return None def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: - def _t1027(_dollar_dollar): + def _t1007(_dollar_dollar): if _dollar_dollar.HasField('loop'): - _t1028 = _dollar_dollar.loop + _t1008 = _dollar_dollar.loop else: - _t1028 = None - return _t1028 - _t1029 = _t1027(msg) - deconstruct_result303 = _t1029 + _t1008 = None + return _t1008 + _t1009 = _t1007(msg) + deconstruct_result303 = _t1009 if deconstruct_result303 is not None: - _t1031 = self.pretty_loop(deconstruct_result303) - _t1030 = _t1031 + _t1011 = self.pretty_loop(deconstruct_result303) + _t1010 = _t1011 else: - def _t1032(_dollar_dollar): + def _t1012(_dollar_dollar): if _dollar_dollar.HasField('assign'): - _t1033 = _dollar_dollar.assign + _t1013 = _dollar_dollar.assign else: - _t1033 = None - return _t1033 - _t1034 = _t1032(msg) - guard_result302 = _t1034 + _t1013 = None + return _t1013 + _t1014 = _t1012(msg) + guard_result302 = _t1014 if guard_result302 is not None: - _t1036 = self.pretty_instruction(msg) - _t1035 = _t1036 + _t1016 = self.pretty_instruction(msg) + _t1015 = _t1016 else: raise ParseError('No matching rule for construct') - _t1030 = _t1035 - return _t1030 + _t1010 = _t1015 + return _t1010 def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: - def _t1037(_dollar_dollar): + def _t1017(_dollar_dollar): return (_dollar_dollar.init, _dollar_dollar.body,) - _t1038 = _t1037(msg) - fields304 = _t1038 + _t1018 = _t1017(msg) + fields304 = _t1018 unwrapped_fields305 = fields304 self.write('(') self.write('loop') self.newline() self.indent() field306 = unwrapped_fields305[0] - _t1039 = self.pretty_init(field306) + _t1019 = self.pretty_init(field306) self.newline() field307 = unwrapped_fields305[1] - _t1040 = self.pretty_script(field307) + _t1020 = self.pretty_script(field307) self.dedent() self.write(')') self.newline() return None def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: - def _t1041(_dollar_dollar): + def _t1021(_dollar_dollar): return _dollar_dollar - _t1042 = _t1041(msg) - fields308 = _t1042 + _t1022 = _t1021(msg) + fields308 = _t1022 unwrapped_fields309 = fields308 self.write('(') self.write('init') @@ -2264,326 +2261,317 @@ def _t1041(_dollar_dollar): if (i311 > 0): self.newline() - _t1043 = None + _t1023 = None else: - _t1043 = None - _t1044 = self.pretty_instruction(elem310) + _t1023 = None + _t1024 = self.pretty_instruction(elem310) self.dedent() self.write(')') self.newline() return None def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: - def _t1045(_dollar_dollar): - _t1046 = self.is_empty(_dollar_dollar.attrs) + def _t1025(_dollar_dollar): - if not _t1046: - _t1047 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if _dollar_dollar.HasField('assign'): + _t1026 = _dollar_dollar.assign else: - _t1047 = None - return _t1047 - _t1048 = _t1045(msg) - guard_result316 = _t1048 + _t1026 = None + return _t1026 + _t1027 = _t1025(msg) + deconstruct_result316 = _t1027 - if guard_result316 is not None: - _t1050 = self.pretty_assign(msg) - _t1049 = _t1050 + if deconstruct_result316 is not None: + _t1029 = self.pretty_assign(deconstruct_result316) + _t1028 = _t1029 else: - def _t1051(_dollar_dollar): - _t1052 = self.is_empty(_dollar_dollar.attrs) + def _t1030(_dollar_dollar): - if not _t1052: - _t1053 = (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if _dollar_dollar.HasField('upsert'): + _t1031 = _dollar_dollar.upsert else: - _t1053 = None - return _t1053 - _t1054 = _t1051(msg) - guard_result315 = _t1054 + _t1031 = None + return _t1031 + _t1032 = _t1030(msg) + deconstruct_result315 = _t1032 - if guard_result315 is not None: - _t1056 = self.pretty_upsert(msg) - _t1055 = _t1056 + if deconstruct_result315 is not None: + _t1034 = self.pretty_upsert(deconstruct_result315) + _t1033 = _t1034 else: - def _t1057(_dollar_dollar): - _t1058 = self.is_empty(_dollar_dollar.attrs) + def _t1035(_dollar_dollar): - if not _t1058: - _t1059 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if _dollar_dollar.HasField('break'): + _t1036 = getattr(_dollar_dollar, 'break') else: - _t1059 = None - return _t1059 - _t1060 = _t1057(msg) - guard_result314 = _t1060 + _t1036 = None + return _t1036 + _t1037 = _t1035(msg) + deconstruct_result314 = _t1037 - if guard_result314 is not None: - _t1062 = self.pretty_break(msg) - _t1061 = _t1062 + if deconstruct_result314 is not None: + _t1039 = self.pretty_break(deconstruct_result314) + _t1038 = _t1039 else: - def _t1063(_dollar_dollar): - _t1064 = self.is_empty(_dollar_dollar.attrs) + def _t1040(_dollar_dollar): - if not _t1064: - _t1065 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if _dollar_dollar.HasField('monoid_def'): + _t1041 = _dollar_dollar.monoid_def else: - _t1065 = None - return _t1065 - _t1066 = _t1063(msg) - guard_result313 = _t1066 + _t1041 = None + return _t1041 + _t1042 = _t1040(msg) + deconstruct_result313 = _t1042 - if guard_result313 is not None: - _t1068 = self.pretty_monoid_def(msg) - _t1067 = _t1068 + if deconstruct_result313 is not None: + _t1044 = self.pretty_monoid_def(deconstruct_result313) + _t1043 = _t1044 else: - def _t1069(_dollar_dollar): - _t1070 = self.is_empty(_dollar_dollar.attrs) + def _t1045(_dollar_dollar): - if not _t1070: - _t1071 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if _dollar_dollar.HasField('monus_def'): + _t1046 = _dollar_dollar.monus_def else: - _t1071 = None - return _t1071 - _t1072 = _t1069(msg) - guard_result312 = _t1072 + _t1046 = None + return _t1046 + _t1047 = _t1045(msg) + deconstruct_result312 = _t1047 - if guard_result312 is not None: - _t1074 = self.pretty_monus_def(msg) - _t1073 = _t1074 + if deconstruct_result312 is not None: + _t1049 = self.pretty_monus_def(deconstruct_result312) + _t1048 = _t1049 else: raise ParseError('No matching rule for instruction') - _t1067 = _t1073 - _t1061 = _t1067 - _t1055 = _t1061 - _t1049 = _t1055 - return _t1049 + _t1043 = _t1048 + _t1038 = _t1043 + _t1033 = _t1038 + _t1028 = _t1033 + return _t1028 def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: - def _t1075(_dollar_dollar): - _t1076 = self.is_empty(_dollar_dollar.attrs) + def _t1050(_dollar_dollar): - if not _t1076: - _t1077 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t1051 = _dollar_dollar.attrs else: - _t1077 = None - return _t1077 - _t1078 = _t1075(msg) - fields317 = _t1078 + _t1051 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1051,) + _t1052 = _t1050(msg) + fields317 = _t1052 unwrapped_fields318 = fields317 self.write('(') self.write('assign') self.newline() self.indent() field319 = unwrapped_fields318[0] - _t1079 = self.pretty_relation_id(field319) + _t1053 = self.pretty_relation_id(field319) self.newline() field320 = unwrapped_fields318[1] - _t1080 = self.pretty_abstraction(field320) + _t1054 = self.pretty_abstraction(field320) self.newline() field321 = unwrapped_fields318[2] if field321 is not None: opt_val322 = field321 - _t1082 = self.pretty_attrs(opt_val322) - _t1081 = _t1082 + _t1056 = self.pretty_attrs(opt_val322) + _t1055 = _t1056 else: - _t1081 = None + _t1055 = None self.dedent() self.write(')') self.newline() return None def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: - def _t1083(_dollar_dollar): - _t1084 = self.is_empty(_dollar_dollar.attrs) + def _t1057(_dollar_dollar): - if not _t1084: - _t1085 = (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t1058 = _dollar_dollar.attrs else: - _t1085 = None - return _t1085 - _t1086 = _t1083(msg) - fields323 = _t1086 + _t1058 = None + return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1058,) + _t1059 = _t1057(msg) + fields323 = _t1059 unwrapped_fields324 = fields323 self.write('(') self.write('upsert') self.newline() self.indent() field325 = unwrapped_fields324[0] - _t1087 = self.pretty_relation_id(field325) + _t1060 = self.pretty_relation_id(field325) self.newline() field326 = unwrapped_fields324[1] - _t1088 = self.pretty_abstraction_with_arity(field326) + _t1061 = self.pretty_abstraction_with_arity(field326) self.newline() field327 = unwrapped_fields324[2] if field327 is not None: opt_val328 = field327 - _t1090 = self.pretty_attrs(opt_val328) - _t1089 = _t1090 + _t1063 = self.pretty_attrs(opt_val328) + _t1062 = _t1063 else: - _t1089 = None + _t1062 = None self.dedent() self.write(')') self.newline() return None def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: - def _t1091(_dollar_dollar): - _t1092 = Parser.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) - return (_t1092, _dollar_dollar[0].value,) - _t1093 = _t1091(msg) - fields329 = _t1093 + def _t1064(_dollar_dollar): + _t1065 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) + return (_t1065, _dollar_dollar[0].value,) + _t1066 = _t1064(msg) + fields329 = _t1066 unwrapped_fields330 = fields329 self.write('(') field331 = unwrapped_fields330[0] - _t1094 = self.pretty_bindings(field331) + _t1067 = self.pretty_bindings(field331) field332 = unwrapped_fields330[1] - _t1095 = self.pretty_formula(field332) + _t1068 = self.pretty_formula(field332) self.dedent() self.write(')') self.newline() return None def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: - def _t1096(_dollar_dollar): - _t1097 = self.is_empty(_dollar_dollar.attrs) + def _t1069(_dollar_dollar): - if not _t1097: - _t1098 = (_dollar_dollar.name, _dollar_dollar.body, _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t1070 = _dollar_dollar.attrs else: - _t1098 = None - return _t1098 - _t1099 = _t1096(msg) - fields333 = _t1099 + _t1070 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1070,) + _t1071 = _t1069(msg) + fields333 = _t1071 unwrapped_fields334 = fields333 self.write('(') self.write('break') self.newline() self.indent() field335 = unwrapped_fields334[0] - _t1100 = self.pretty_relation_id(field335) + _t1072 = self.pretty_relation_id(field335) self.newline() field336 = unwrapped_fields334[1] - _t1101 = self.pretty_abstraction(field336) + _t1073 = self.pretty_abstraction(field336) self.newline() field337 = unwrapped_fields334[2] if field337 is not None: opt_val338 = field337 - _t1103 = self.pretty_attrs(opt_val338) - _t1102 = _t1103 + _t1075 = self.pretty_attrs(opt_val338) + _t1074 = _t1075 else: - _t1102 = None + _t1074 = None self.dedent() self.write(')') self.newline() return None def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: - def _t1104(_dollar_dollar): - _t1105 = self.is_empty(_dollar_dollar.attrs) + def _t1076(_dollar_dollar): - if not _t1105: - _t1106 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t1077 = _dollar_dollar.attrs else: - _t1106 = None - return _t1106 - _t1107 = _t1104(msg) - fields339 = _t1107 + _t1077 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1077,) + _t1078 = _t1076(msg) + fields339 = _t1078 unwrapped_fields340 = fields339 self.write('(') self.write('monoid') self.newline() self.indent() field341 = unwrapped_fields340[0] - _t1108 = self.pretty_monoid(field341) + _t1079 = self.pretty_monoid(field341) self.newline() field342 = unwrapped_fields340[1] - _t1109 = self.pretty_relation_id(field342) + _t1080 = self.pretty_relation_id(field342) self.newline() field343 = unwrapped_fields340[2] - _t1110 = self.pretty_abstraction_with_arity(field343) + _t1081 = self.pretty_abstraction_with_arity(field343) self.newline() field344 = unwrapped_fields340[3] if field344 is not None: opt_val345 = field344 - _t1112 = self.pretty_attrs(opt_val345) - _t1111 = _t1112 + _t1083 = self.pretty_attrs(opt_val345) + _t1082 = _t1083 else: - _t1111 = None + _t1082 = None self.dedent() self.write(')') self.newline() return None def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: - def _t1113(_dollar_dollar): + def _t1084(_dollar_dollar): if _dollar_dollar.HasField('or_monoid'): - _t1114 = _dollar_dollar.or_monoid + _t1085 = _dollar_dollar.or_monoid else: - _t1114 = None - return _t1114 - _t1115 = _t1113(msg) - deconstruct_result349 = _t1115 + _t1085 = None + return _t1085 + _t1086 = _t1084(msg) + deconstruct_result349 = _t1086 if deconstruct_result349 is not None: - _t1117 = self.pretty_or_monoid(deconstruct_result349) - _t1116 = _t1117 + _t1088 = self.pretty_or_monoid(deconstruct_result349) + _t1087 = _t1088 else: - def _t1118(_dollar_dollar): + def _t1089(_dollar_dollar): if _dollar_dollar.HasField('min_monoid'): - _t1119 = _dollar_dollar.min_monoid + _t1090 = _dollar_dollar.min_monoid else: - _t1119 = None - return _t1119 - _t1120 = _t1118(msg) - deconstruct_result348 = _t1120 + _t1090 = None + return _t1090 + _t1091 = _t1089(msg) + deconstruct_result348 = _t1091 if deconstruct_result348 is not None: - _t1122 = self.pretty_min_monoid(deconstruct_result348) - _t1121 = _t1122 + _t1093 = self.pretty_min_monoid(deconstruct_result348) + _t1092 = _t1093 else: - def _t1123(_dollar_dollar): + def _t1094(_dollar_dollar): if _dollar_dollar.HasField('max_monoid'): - _t1124 = _dollar_dollar.max_monoid + _t1095 = _dollar_dollar.max_monoid else: - _t1124 = None - return _t1124 - _t1125 = _t1123(msg) - deconstruct_result347 = _t1125 + _t1095 = None + return _t1095 + _t1096 = _t1094(msg) + deconstruct_result347 = _t1096 if deconstruct_result347 is not None: - _t1127 = self.pretty_max_monoid(deconstruct_result347) - _t1126 = _t1127 + _t1098 = self.pretty_max_monoid(deconstruct_result347) + _t1097 = _t1098 else: - def _t1128(_dollar_dollar): + def _t1099(_dollar_dollar): if _dollar_dollar.HasField('sum_monoid'): - _t1129 = _dollar_dollar.sum_monoid + _t1100 = _dollar_dollar.sum_monoid else: - _t1129 = None - return _t1129 - _t1130 = _t1128(msg) - deconstruct_result346 = _t1130 + _t1100 = None + return _t1100 + _t1101 = _t1099(msg) + deconstruct_result346 = _t1101 if deconstruct_result346 is not None: - _t1132 = self.pretty_sum_monoid(deconstruct_result346) - _t1131 = _t1132 + _t1103 = self.pretty_sum_monoid(deconstruct_result346) + _t1102 = _t1103 else: raise ParseError('No matching rule for monoid') - _t1126 = _t1131 - _t1121 = _t1126 - _t1116 = _t1121 - return _t1116 + _t1097 = _t1102 + _t1092 = _t1097 + _t1087 = _t1092 + return _t1087 def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: - def _t1133(_dollar_dollar): + def _t1104(_dollar_dollar): return _dollar_dollar - _t1134 = _t1133(msg) - fields350 = _t1134 + _t1105 = _t1104(msg) + fields350 = _t1105 unwrapped_fields351 = fields350 self.write('(') self.write('or') @@ -2595,122 +2583,121 @@ def _t1133(_dollar_dollar): return None def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: - def _t1135(_dollar_dollar): + def _t1106(_dollar_dollar): return _dollar_dollar.type - _t1136 = _t1135(msg) - fields352 = _t1136 + _t1107 = _t1106(msg) + fields352 = _t1107 unwrapped_fields353 = fields352 self.write('(') self.write('min') self.newline() self.indent() - _t1137 = self.pretty_type(unwrapped_fields353) + _t1108 = self.pretty_type(unwrapped_fields353) self.dedent() self.write(')') self.newline() return None def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: - def _t1138(_dollar_dollar): + def _t1109(_dollar_dollar): return _dollar_dollar.type - _t1139 = _t1138(msg) - fields354 = _t1139 + _t1110 = _t1109(msg) + fields354 = _t1110 unwrapped_fields355 = fields354 self.write('(') self.write('max') self.newline() self.indent() - _t1140 = self.pretty_type(unwrapped_fields355) + _t1111 = self.pretty_type(unwrapped_fields355) self.dedent() self.write(')') self.newline() return None def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: - def _t1141(_dollar_dollar): + def _t1112(_dollar_dollar): return _dollar_dollar.type - _t1142 = _t1141(msg) - fields356 = _t1142 + _t1113 = _t1112(msg) + fields356 = _t1113 unwrapped_fields357 = fields356 self.write('(') self.write('sum') self.newline() self.indent() - _t1143 = self.pretty_type(unwrapped_fields357) + _t1114 = self.pretty_type(unwrapped_fields357) self.dedent() self.write(')') self.newline() return None def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: - def _t1144(_dollar_dollar): - _t1145 = self.is_empty(_dollar_dollar.attrs) + def _t1115(_dollar_dollar): - if not _t1145: - _t1146 = (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _dollar_dollar.attrs,) + if not len(_dollar_dollar.attrs) == 0: + _t1116 = _dollar_dollar.attrs else: - _t1146 = None - return _t1146 - _t1147 = _t1144(msg) - fields358 = _t1147 + _t1116 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1116,) + _t1117 = _t1115(msg) + fields358 = _t1117 unwrapped_fields359 = fields358 self.write('(') self.write('monus') self.newline() self.indent() field360 = unwrapped_fields359[0] - _t1148 = self.pretty_monoid(field360) + _t1118 = self.pretty_monoid(field360) self.newline() field361 = unwrapped_fields359[1] - _t1149 = self.pretty_relation_id(field361) + _t1119 = self.pretty_relation_id(field361) self.newline() field362 = unwrapped_fields359[2] - _t1150 = self.pretty_abstraction_with_arity(field362) + _t1120 = self.pretty_abstraction_with_arity(field362) self.newline() field363 = unwrapped_fields359[3] if field363 is not None: opt_val364 = field363 - _t1152 = self.pretty_attrs(opt_val364) - _t1151 = _t1152 + _t1122 = self.pretty_attrs(opt_val364) + _t1121 = _t1122 else: - _t1151 = None + _t1121 = None self.dedent() self.write(')') self.newline() return None def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: - def _t1153(_dollar_dollar): + def _t1123(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) - _t1154 = _t1153(msg) - fields365 = _t1154 + _t1124 = _t1123(msg) + fields365 = _t1124 unwrapped_fields366 = fields365 self.write('(') self.write('functional_dependency') self.newline() self.indent() field367 = unwrapped_fields366[0] - _t1155 = self.pretty_relation_id(field367) + _t1125 = self.pretty_relation_id(field367) self.newline() field368 = unwrapped_fields366[1] - _t1156 = self.pretty_abstraction(field368) + _t1126 = self.pretty_abstraction(field368) self.newline() field369 = unwrapped_fields366[2] - _t1157 = self.pretty_functional_dependency_keys(field369) + _t1127 = self.pretty_functional_dependency_keys(field369) self.newline() field370 = unwrapped_fields366[3] - _t1158 = self.pretty_functional_dependency_values(field370) + _t1128 = self.pretty_functional_dependency_values(field370) self.dedent() self.write(')') self.newline() return None def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1159(_dollar_dollar): + def _t1129(_dollar_dollar): return _dollar_dollar - _t1160 = _t1159(msg) - fields371 = _t1160 + _t1130 = _t1129(msg) + fields371 = _t1130 unwrapped_fields372 = fields371 self.write('(') self.write('keys') @@ -2720,20 +2707,20 @@ def _t1159(_dollar_dollar): if (i374 > 0): self.newline() - _t1161 = None + _t1131 = None else: - _t1161 = None - _t1162 = self.pretty_var(elem373) + _t1131 = None + _t1132 = self.pretty_var(elem373) self.dedent() self.write(')') self.newline() return None def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1163(_dollar_dollar): + def _t1133(_dollar_dollar): return _dollar_dollar - _t1164 = _t1163(msg) - fields375 = _t1164 + _t1134 = _t1133(msg) + fields375 = _t1134 unwrapped_fields376 = fields375 self.write('(') self.write('values') @@ -2743,171 +2730,171 @@ def _t1163(_dollar_dollar): if (i378 > 0): self.newline() - _t1165 = None + _t1135 = None else: - _t1165 = None - _t1166 = self.pretty_var(elem377) + _t1135 = None + _t1136 = self.pretty_var(elem377) self.dedent() self.write(')') self.newline() return None def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: - def _t1167(_dollar_dollar): + def _t1137(_dollar_dollar): if _dollar_dollar.HasField('rel_edb'): - _t1168 = _dollar_dollar.rel_edb + _t1138 = _dollar_dollar.rel_edb else: - _t1168 = None - return _t1168 - _t1169 = _t1167(msg) - deconstruct_result381 = _t1169 + _t1138 = None + return _t1138 + _t1139 = _t1137(msg) + deconstruct_result381 = _t1139 if deconstruct_result381 is not None: - _t1171 = self.pretty_rel_edb(deconstruct_result381) - _t1170 = _t1171 + _t1141 = self.pretty_rel_edb(deconstruct_result381) + _t1140 = _t1141 else: - def _t1172(_dollar_dollar): + def _t1142(_dollar_dollar): if _dollar_dollar.HasField('betree_relation'): - _t1173 = _dollar_dollar.betree_relation + _t1143 = _dollar_dollar.betree_relation else: - _t1173 = None - return _t1173 - _t1174 = _t1172(msg) - deconstruct_result380 = _t1174 + _t1143 = None + return _t1143 + _t1144 = _t1142(msg) + deconstruct_result380 = _t1144 if deconstruct_result380 is not None: - _t1176 = self.pretty_betree_relation(deconstruct_result380) - _t1175 = _t1176 + _t1146 = self.pretty_betree_relation(deconstruct_result380) + _t1145 = _t1146 else: - def _t1177(_dollar_dollar): + def _t1147(_dollar_dollar): if _dollar_dollar.HasField('csv_data'): - _t1178 = _dollar_dollar.csv_data + _t1148 = _dollar_dollar.csv_data else: - _t1178 = None - return _t1178 - _t1179 = _t1177(msg) - deconstruct_result379 = _t1179 + _t1148 = None + return _t1148 + _t1149 = _t1147(msg) + deconstruct_result379 = _t1149 if deconstruct_result379 is not None: - _t1181 = self.pretty_csv_data(deconstruct_result379) - _t1180 = _t1181 + _t1151 = self.pretty_csv_data(deconstruct_result379) + _t1150 = _t1151 else: raise ParseError('No matching rule for data') - _t1175 = _t1180 - _t1170 = _t1175 - return _t1170 + _t1145 = _t1150 + _t1140 = _t1145 + return _t1140 def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: - def _t1182(_dollar_dollar): + def _t1152(_dollar_dollar): return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) - _t1183 = _t1182(msg) - fields382 = _t1183 + _t1153 = _t1152(msg) + fields382 = _t1153 unwrapped_fields383 = fields382 self.write('(') self.write('rel_edb') self.newline() self.indent() field384 = unwrapped_fields383[0] - _t1184 = self.pretty_relation_id(field384) + _t1154 = self.pretty_relation_id(field384) self.newline() field385 = unwrapped_fields383[1] - _t1185 = self.pretty_rel_edb_path(field385) + _t1155 = self.pretty_rel_edb_path(field385) self.newline() field386 = unwrapped_fields383[2] - _t1186 = self.pretty_rel_edb_types(field386) + _t1156 = self.pretty_rel_edb_types(field386) self.dedent() self.write(')') self.newline() return None def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: - def _t1187(_dollar_dollar): + def _t1157(_dollar_dollar): return _dollar_dollar - _t1188 = _t1187(msg) - fields387 = _t1188 + _t1158 = _t1157(msg) + fields387 = _t1158 unwrapped_fields388 = fields387 self.write('[') for i390, elem389 in enumerate(unwrapped_fields388): if (i390 > 0): self.newline() - _t1189 = None + _t1159 = None else: - _t1189 = None + _t1159 = None self.write(repr(elem389)) self.write(']') return None def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1190(_dollar_dollar): + def _t1160(_dollar_dollar): return _dollar_dollar - _t1191 = _t1190(msg) - fields391 = _t1191 + _t1161 = _t1160(msg) + fields391 = _t1161 unwrapped_fields392 = fields391 self.write('[') for i394, elem393 in enumerate(unwrapped_fields392): if (i394 > 0): self.newline() - _t1192 = None + _t1162 = None else: - _t1192 = None - _t1193 = self.pretty_type(elem393) + _t1162 = None + _t1163 = self.pretty_type(elem393) self.write(']') return None def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: - def _t1194(_dollar_dollar): + def _t1164(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_info,) - _t1195 = _t1194(msg) - fields395 = _t1195 + _t1165 = _t1164(msg) + fields395 = _t1165 unwrapped_fields396 = fields395 self.write('(') self.write('betree_relation') self.newline() self.indent() field397 = unwrapped_fields396[0] - _t1196 = self.pretty_relation_id(field397) + _t1166 = self.pretty_relation_id(field397) self.newline() field398 = unwrapped_fields396[1] - _t1197 = self.pretty_betree_info(field398) + _t1167 = self.pretty_betree_info(field398) self.dedent() self.write(')') self.newline() return None def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: - def _t1198(_dollar_dollar): - _t1199 = Parser.deconstruct_betree_info_config(_dollar_dollar) - return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1199,) - _t1200 = _t1198(msg) - fields399 = _t1200 + def _t1168(_dollar_dollar): + _t1169 = self.deconstruct_betree_info_config(_dollar_dollar) + return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1169,) + _t1170 = _t1168(msg) + fields399 = _t1170 unwrapped_fields400 = fields399 self.write('(') self.write('betree_info') self.newline() self.indent() field401 = unwrapped_fields400[0] - _t1201 = self.pretty_betree_info_key_types(field401) + _t1171 = self.pretty_betree_info_key_types(field401) self.newline() field402 = unwrapped_fields400[1] - _t1202 = self.pretty_betree_info_value_types(field402) + _t1172 = self.pretty_betree_info_value_types(field402) self.newline() field403 = unwrapped_fields400[2] - _t1203 = self.pretty_config_dict(field403) + _t1173 = self.pretty_config_dict(field403) self.dedent() self.write(')') self.newline() return None def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1204(_dollar_dollar): + def _t1174(_dollar_dollar): return _dollar_dollar - _t1205 = _t1204(msg) - fields404 = _t1205 + _t1175 = _t1174(msg) + fields404 = _t1175 unwrapped_fields405 = fields404 self.write('(') self.write('key_types') @@ -2917,20 +2904,20 @@ def _t1204(_dollar_dollar): if (i407 > 0): self.newline() - _t1206 = None + _t1176 = None else: - _t1206 = None - _t1207 = self.pretty_type(elem406) + _t1176 = None + _t1177 = self.pretty_type(elem406) self.dedent() self.write(')') self.newline() return None def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1208(_dollar_dollar): + def _t1178(_dollar_dollar): return _dollar_dollar - _t1209 = _t1208(msg) - fields408 = _t1209 + _t1179 = _t1178(msg) + fields408 = _t1179 unwrapped_fields409 = fields408 self.write('(') self.write('value_types') @@ -2940,54 +2927,56 @@ def _t1208(_dollar_dollar): if (i411 > 0): self.newline() - _t1210 = None + _t1180 = None else: - _t1210 = None - _t1211 = self.pretty_type(elem410) + _t1180 = None + _t1181 = self.pretty_type(elem410) self.dedent() self.write(')') self.newline() return None def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: - def _t1212(_dollar_dollar): + def _t1182(_dollar_dollar): return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) - _t1213 = _t1212(msg) - fields412 = _t1213 + _t1183 = _t1182(msg) + fields412 = _t1183 unwrapped_fields413 = fields412 self.write('(') self.write('csv_data') self.newline() self.indent() field414 = unwrapped_fields413[0] - _t1214 = self.pretty_csvlocator(field414) + _t1184 = self.pretty_csvlocator(field414) self.newline() field415 = unwrapped_fields413[1] - _t1215 = self.pretty_csv_config(field415) + _t1185 = self.pretty_csv_config(field415) self.newline() field416 = unwrapped_fields413[2] - _t1216 = self.pretty_csv_columns(field416) + _t1186 = self.pretty_csv_columns(field416) self.newline() field417 = unwrapped_fields413[3] - _t1217 = self.pretty_csv_asof(field417) + _t1187 = self.pretty_csv_asof(field417) self.dedent() self.write(')') self.newline() return None def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: - def _t1218(_dollar_dollar): - _t1219 = self.is_empty(_dollar_dollar.paths) - _t1220 = self.decode_string(_dollar_dollar.inline_data) + def _t1188(_dollar_dollar): - if (not _t1219 and _t1220 != ''): - _t1222 = self.decode_string(_dollar_dollar.inline_data) - _t1221 = (_dollar_dollar.paths, _t1222,) + if not len(_dollar_dollar.paths) == 0: + _t1189 = _dollar_dollar.paths else: - _t1221 = None - return _t1221 - _t1223 = _t1218(msg) - fields418 = _t1223 + _t1189 = None + + if _dollar_dollar.inline_data.decode('utf-8') != '': + _t1190 = _dollar_dollar.inline_data.decode('utf-8') + else: + _t1190 = None + return (_t1189, _t1190,) + _t1191 = _t1188(msg) + fields418 = _t1191 unwrapped_fields419 = fields418 self.write('(') self.write('csv_locator') @@ -2997,29 +2986,29 @@ def _t1218(_dollar_dollar): if field420 is not None: opt_val421 = field420 - _t1225 = self.pretty_csv_locator_paths(opt_val421) - _t1224 = _t1225 + _t1193 = self.pretty_csv_locator_paths(opt_val421) + _t1192 = _t1193 else: - _t1224 = None + _t1192 = None self.newline() field422 = unwrapped_fields419[1] if field422 is not None: opt_val423 = field422 - _t1227 = self.pretty_csv_locator_inline_data(opt_val423) - _t1226 = _t1227 + _t1195 = self.pretty_csv_locator_inline_data(opt_val423) + _t1194 = _t1195 else: - _t1226 = None + _t1194 = None self.dedent() self.write(')') self.newline() return None def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: - def _t1228(_dollar_dollar): + def _t1196(_dollar_dollar): return _dollar_dollar - _t1229 = _t1228(msg) - fields424 = _t1229 + _t1197 = _t1196(msg) + fields424 = _t1197 unwrapped_fields425 = fields424 self.write('(') self.write('paths') @@ -3029,9 +3018,9 @@ def _t1228(_dollar_dollar): if (i427 > 0): self.newline() - _t1230 = None + _t1198 = None else: - _t1230 = None + _t1198 = None self.write(repr(elem426)) self.dedent() self.write(')') @@ -3039,10 +3028,10 @@ def _t1228(_dollar_dollar): return None def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: - def _t1231(_dollar_dollar): + def _t1199(_dollar_dollar): return _dollar_dollar - _t1232 = _t1231(msg) - fields428 = _t1232 + _t1200 = _t1199(msg) + fields428 = _t1200 unwrapped_fields429 = fields428 self.write('(') self.write('inline_data') @@ -3055,27 +3044,27 @@ def _t1231(_dollar_dollar): return None def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: - def _t1233(_dollar_dollar): - _t1234 = Parser.deconstruct_csv_config(_dollar_dollar) - return _t1234 - _t1235 = _t1233(msg) - fields430 = _t1235 + def _t1201(_dollar_dollar): + _t1202 = self.deconstruct_csv_config(_dollar_dollar) + return _t1202 + _t1203 = _t1201(msg) + fields430 = _t1203 unwrapped_fields431 = fields430 self.write('(') self.write('csv_config') self.newline() self.indent() - _t1236 = self.pretty_config_dict(unwrapped_fields431) + _t1204 = self.pretty_config_dict(unwrapped_fields431) self.dedent() self.write(')') self.newline() return None def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: - def _t1237(_dollar_dollar): + def _t1205(_dollar_dollar): return _dollar_dollar - _t1238 = _t1237(msg) - fields432 = _t1238 + _t1206 = _t1205(msg) + fields432 = _t1206 unwrapped_fields433 = fields432 self.write('(') self.write('columns') @@ -3085,20 +3074,20 @@ def _t1237(_dollar_dollar): if (i435 > 0): self.newline() - _t1239 = None + _t1207 = None else: - _t1239 = None - _t1240 = self.pretty_csv_column(elem434) + _t1207 = None + _t1208 = self.pretty_csv_column(elem434) self.dedent() self.write(')') self.newline() return None def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: - def _t1241(_dollar_dollar): + def _t1209(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) - _t1242 = _t1241(msg) - fields436 = _t1242 + _t1210 = _t1209(msg) + fields436 = _t1210 unwrapped_fields437 = fields436 self.write('(') self.write('column') @@ -3108,7 +3097,7 @@ def _t1241(_dollar_dollar): self.write(repr(field438)) self.newline() field439 = unwrapped_fields437[1] - _t1243 = self.pretty_relation_id(field439) + _t1211 = self.pretty_relation_id(field439) self.write('[') self.newline() field440 = unwrapped_fields437[2] @@ -3116,10 +3105,10 @@ def _t1241(_dollar_dollar): if (i442 > 0): self.newline() - _t1244 = None + _t1212 = None else: - _t1244 = None - _t1245 = self.pretty_type(elem441) + _t1212 = None + _t1213 = self.pretty_type(elem441) self.write(']') self.dedent() self.write(')') @@ -3127,10 +3116,10 @@ def _t1241(_dollar_dollar): return None def pretty_csv_asof(self, msg: str) -> Optional[Never]: - def _t1246(_dollar_dollar): + def _t1214(_dollar_dollar): return _dollar_dollar - _t1247 = _t1246(msg) - fields443 = _t1247 + _t1215 = _t1214(msg) + fields443 = _t1215 unwrapped_fields444 = fields443 self.write('(') self.write('asof') @@ -3143,26 +3132,26 @@ def _t1246(_dollar_dollar): return None def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: - def _t1248(_dollar_dollar): + def _t1216(_dollar_dollar): return _dollar_dollar.fragment_id - _t1249 = _t1248(msg) - fields445 = _t1249 + _t1217 = _t1216(msg) + fields445 = _t1217 unwrapped_fields446 = fields445 self.write('(') self.write('undefine') self.newline() self.indent() - _t1250 = self.pretty_fragment_id(unwrapped_fields446) + _t1218 = self.pretty_fragment_id(unwrapped_fields446) self.dedent() self.write(')') self.newline() return None def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: - def _t1251(_dollar_dollar): + def _t1219(_dollar_dollar): return _dollar_dollar.relations - _t1252 = _t1251(msg) - fields447 = _t1252 + _t1220 = _t1219(msg) + fields447 = _t1220 unwrapped_fields448 = fields447 self.write('(') self.write('context') @@ -3172,20 +3161,20 @@ def _t1251(_dollar_dollar): if (i450 > 0): self.newline() - _t1253 = None + _t1221 = None else: - _t1253 = None - _t1254 = self.pretty_relation_id(elem449) + _t1221 = None + _t1222 = self.pretty_relation_id(elem449) self.dedent() self.write(')') self.newline() return None def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: - def _t1255(_dollar_dollar): + def _t1223(_dollar_dollar): return _dollar_dollar - _t1256 = _t1255(msg) - fields451 = _t1256 + _t1224 = _t1223(msg) + fields451 = _t1224 unwrapped_fields452 = fields451 self.write('(') self.write('reads') @@ -3195,119 +3184,119 @@ def _t1255(_dollar_dollar): if (i454 > 0): self.newline() - _t1257 = None + _t1225 = None else: - _t1257 = None - _t1258 = self.pretty_read(elem453) + _t1225 = None + _t1226 = self.pretty_read(elem453) self.dedent() self.write(')') self.newline() return None def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: - def _t1259(_dollar_dollar): + def _t1227(_dollar_dollar): if _dollar_dollar.HasField('demand'): - _t1260 = _dollar_dollar.demand + _t1228 = _dollar_dollar.demand else: - _t1260 = None - return _t1260 - _t1261 = _t1259(msg) - deconstruct_result459 = _t1261 + _t1228 = None + return _t1228 + _t1229 = _t1227(msg) + deconstruct_result459 = _t1229 if deconstruct_result459 is not None: - _t1263 = self.pretty_demand(deconstruct_result459) - _t1262 = _t1263 + _t1231 = self.pretty_demand(deconstruct_result459) + _t1230 = _t1231 else: - def _t1264(_dollar_dollar): + def _t1232(_dollar_dollar): - if _dollar_dollar.name != 'output': - _t1265 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + if _dollar_dollar.HasField('output'): + _t1233 = _dollar_dollar.output else: - _t1265 = None - return _t1265 - _t1266 = _t1264(msg) - guard_result458 = _t1266 + _t1233 = None + return _t1233 + _t1234 = _t1232(msg) + deconstruct_result458 = _t1234 - if guard_result458 is not None: - _t1268 = self.pretty_output(msg) - _t1267 = _t1268 + if deconstruct_result458 is not None: + _t1236 = self.pretty_output(deconstruct_result458) + _t1235 = _t1236 else: - def _t1269(_dollar_dollar): + def _t1237(_dollar_dollar): if _dollar_dollar.HasField('what_if'): - _t1270 = _dollar_dollar.what_if + _t1238 = _dollar_dollar.what_if else: - _t1270 = None - return _t1270 - _t1271 = _t1269(msg) - deconstruct_result457 = _t1271 + _t1238 = None + return _t1238 + _t1239 = _t1237(msg) + deconstruct_result457 = _t1239 if deconstruct_result457 is not None: - _t1273 = self.pretty_what_if(deconstruct_result457) - _t1272 = _t1273 + _t1241 = self.pretty_what_if(deconstruct_result457) + _t1240 = _t1241 else: - def _t1274(_dollar_dollar): + def _t1242(_dollar_dollar): - if _dollar_dollar.name != 'abort': - _t1275 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + if _dollar_dollar.HasField('abort'): + _t1243 = _dollar_dollar.abort else: - _t1275 = None - return _t1275 - _t1276 = _t1274(msg) - guard_result456 = _t1276 + _t1243 = None + return _t1243 + _t1244 = _t1242(msg) + deconstruct_result456 = _t1244 - if guard_result456 is not None: - _t1278 = self.pretty_abort(msg) - _t1277 = _t1278 + if deconstruct_result456 is not None: + _t1246 = self.pretty_abort(deconstruct_result456) + _t1245 = _t1246 else: - def _t1279(_dollar_dollar): + def _t1247(_dollar_dollar): if _dollar_dollar.HasField('export'): - _t1280 = _dollar_dollar.export + _t1248 = _dollar_dollar.export else: - _t1280 = None - return _t1280 - _t1281 = _t1279(msg) - deconstruct_result455 = _t1281 + _t1248 = None + return _t1248 + _t1249 = _t1247(msg) + deconstruct_result455 = _t1249 if deconstruct_result455 is not None: - _t1283 = self.pretty_export(deconstruct_result455) - _t1282 = _t1283 + _t1251 = self.pretty_export(deconstruct_result455) + _t1250 = _t1251 else: raise ParseError('No matching rule for read') - _t1277 = _t1282 - _t1272 = _t1277 - _t1267 = _t1272 - _t1262 = _t1267 - return _t1262 + _t1245 = _t1250 + _t1240 = _t1245 + _t1235 = _t1240 + _t1230 = _t1235 + return _t1230 def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: - def _t1284(_dollar_dollar): + def _t1252(_dollar_dollar): return _dollar_dollar.relation_id - _t1285 = _t1284(msg) - fields460 = _t1285 + _t1253 = _t1252(msg) + fields460 = _t1253 unwrapped_fields461 = fields460 self.write('(') self.write('demand') self.newline() self.indent() - _t1286 = self.pretty_relation_id(unwrapped_fields461) + _t1254 = self.pretty_relation_id(unwrapped_fields461) self.dedent() self.write(')') self.newline() return None def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: - def _t1287(_dollar_dollar): + def _t1255(_dollar_dollar): if _dollar_dollar.name != 'output': - _t1288 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + _t1256 = _dollar_dollar.name else: - _t1288 = None - return _t1288 - _t1289 = _t1287(msg) - fields462 = _t1289 + _t1256 = None + return (_t1256, _dollar_dollar.relation_id,) + _t1257 = _t1255(msg) + fields462 = _t1257 unwrapped_fields463 = fields462 self.write('(') self.write('output') @@ -3317,48 +3306,48 @@ def _t1287(_dollar_dollar): if field464 is not None: opt_val465 = field464 - _t1291 = self.pretty_name(opt_val465) - _t1290 = _t1291 + _t1259 = self.pretty_name(opt_val465) + _t1258 = _t1259 else: - _t1290 = None + _t1258 = None self.newline() field466 = unwrapped_fields463[1] - _t1292 = self.pretty_relation_id(field466) + _t1260 = self.pretty_relation_id(field466) self.dedent() self.write(')') self.newline() return None def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: - def _t1293(_dollar_dollar): + def _t1261(_dollar_dollar): return (_dollar_dollar.branch, _dollar_dollar.epoch,) - _t1294 = _t1293(msg) - fields467 = _t1294 + _t1262 = _t1261(msg) + fields467 = _t1262 unwrapped_fields468 = fields467 self.write('(') self.write('what_if') self.newline() self.indent() field469 = unwrapped_fields468[0] - _t1295 = self.pretty_name(field469) + _t1263 = self.pretty_name(field469) self.newline() field470 = unwrapped_fields468[1] - _t1296 = self.pretty_epoch(field470) + _t1264 = self.pretty_epoch(field470) self.dedent() self.write(')') self.newline() return None def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: - def _t1297(_dollar_dollar): + def _t1265(_dollar_dollar): if _dollar_dollar.name != 'abort': - _t1298 = (_dollar_dollar.name, _dollar_dollar.relation_id,) + _t1266 = _dollar_dollar.name else: - _t1298 = None - return _t1298 - _t1299 = _t1297(msg) - fields471 = _t1299 + _t1266 = None + return (_t1266, _dollar_dollar.relation_id,) + _t1267 = _t1265(msg) + fields471 = _t1267 unwrapped_fields472 = fields471 self.write('(') self.write('abort') @@ -3368,63 +3357,63 @@ def _t1297(_dollar_dollar): if field473 is not None: opt_val474 = field473 - _t1301 = self.pretty_name(opt_val474) - _t1300 = _t1301 + _t1269 = self.pretty_name(opt_val474) + _t1268 = _t1269 else: - _t1300 = None + _t1268 = None self.newline() field475 = unwrapped_fields472[1] - _t1302 = self.pretty_relation_id(field475) + _t1270 = self.pretty_relation_id(field475) self.dedent() self.write(')') self.newline() return None def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: - def _t1303(_dollar_dollar): + def _t1271(_dollar_dollar): return _dollar_dollar.csv_config - _t1304 = _t1303(msg) - fields476 = _t1304 + _t1272 = _t1271(msg) + fields476 = _t1272 unwrapped_fields477 = fields476 self.write('(') self.write('export') self.newline() self.indent() - _t1305 = self.pretty_export_csv_config(unwrapped_fields477) + _t1273 = self.pretty_export_csv_config(unwrapped_fields477) self.dedent() self.write(')') self.newline() return None def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: - def _t1306(_dollar_dollar): - _t1307 = Parser.deconstruct_export_csv_config(_dollar_dollar) - return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1307,) - _t1308 = _t1306(msg) - fields478 = _t1308 + def _t1274(_dollar_dollar): + _t1275 = self.deconstruct_export_csv_config(_dollar_dollar) + return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1275,) + _t1276 = _t1274(msg) + fields478 = _t1276 unwrapped_fields479 = fields478 self.write('(') self.write('export_csv_config') self.newline() self.indent() field480 = unwrapped_fields479[0] - _t1309 = self.pretty_export_csv_path(field480) + _t1277 = self.pretty_export_csv_path(field480) self.newline() field481 = unwrapped_fields479[1] - _t1310 = self.pretty_export_csv_columns(field481) + _t1278 = self.pretty_export_csv_columns(field481) self.newline() field482 = unwrapped_fields479[2] - _t1311 = self.pretty_config_dict(field482) + _t1279 = self.pretty_config_dict(field482) self.dedent() self.write(')') self.newline() return None def pretty_export_csv_path(self, msg: str) -> Optional[Never]: - def _t1312(_dollar_dollar): + def _t1280(_dollar_dollar): return _dollar_dollar - _t1313 = _t1312(msg) - fields483 = _t1313 + _t1281 = _t1280(msg) + fields483 = _t1281 unwrapped_fields484 = fields483 self.write('(') self.write('path') @@ -3437,10 +3426,10 @@ def _t1312(_dollar_dollar): return None def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: - def _t1314(_dollar_dollar): + def _t1282(_dollar_dollar): return _dollar_dollar - _t1315 = _t1314(msg) - fields485 = _t1315 + _t1283 = _t1282(msg) + fields485 = _t1283 unwrapped_fields486 = fields485 self.write('(') self.write('columns') @@ -3450,20 +3439,20 @@ def _t1314(_dollar_dollar): if (i488 > 0): self.newline() - _t1316 = None + _t1284 = None else: - _t1316 = None - _t1317 = self.pretty_export_csv_column(elem487) + _t1284 = None + _t1285 = self.pretty_export_csv_column(elem487) self.dedent() self.write(')') self.newline() return None def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: - def _t1318(_dollar_dollar): + def _t1286(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.column_data,) - _t1319 = _t1318(msg) - fields489 = _t1319 + _t1287 = _t1286(msg) + fields489 = _t1287 unwrapped_fields490 = fields489 self.write('(') self.write('column') @@ -3473,14 +3462,443 @@ def _t1318(_dollar_dollar): self.write(repr(field491)) self.newline() field492 = unwrapped_fields490[1] - _t1320 = self.pretty_relation_id(field492) + _t1288 = self.pretty_relation_id(field492) self.dedent() self.write(')') - self.newline() + self.newline() + return None + + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + if (value is not None and value.HasField('int_value')): + return value.int_value + return default + + def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: + if (value is not None and value.HasField('float_value')): + return value.float_value + return default + + def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + if (value is not None and value.HasField('string_value')): + return value.string_value + return default + + def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + if (value is not None and value.HasField('boolean_value')): + return value.boolean_value + return default + + def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: + if (value is not None and value.HasField('string_value')): + return value.string_value.encode() + return default + + def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + if (value is not None and value.HasField('uint128_value')): + return value.uint128_value + return default + + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + if (value is not None and value.HasField('string_value')): + return [value.string_value] + return default + + def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + if (value is not None and value.HasField('int_value')): + return value.int_value + return None + + def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + if (value is not None and value.HasField('float_value')): + return value.float_value + return None + + def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: + if (value is not None and value.HasField('string_value')): + return value.string_value + return None + + def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + if (value is not None and value.HasField('string_value')): + return value.string_value.encode() + return None + + def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + if (value is not None and value.HasField('uint128_value')): + return value.uint128_value + return None + + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + if (value is not None and value.HasField('string_value')): + return [value.string_value] + return None + + def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + config = dict(config_dict) + _t1289 = self._extract_value_int64(config.get('csv_header_row'), 1) + header_row = _t1289 + _t1290 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1290 + _t1291 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1291 + _t1292 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1292 + _t1293 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1293 + _t1294 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1294 + _t1295 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1295 + _t1296 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1296 + _t1297 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1297 + _t1298 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1298 + _t1299 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1299 + _t1300 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1300 + + def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + config = dict(config_dict) + _t1301 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1301 + _t1302 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1302 + _t1303 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1303 + _t1304 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1304 + _t1305 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1305 + _t1306 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1306 + _t1307 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1307 + _t1308 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1308 + _t1309 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1309 + _t1310 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1310 + _t1311 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1311 + + def default_configure(self) -> transactions_pb2.Configure: + _t1312 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1312 + _t1313 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1313 + + def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + config = dict(config_dict) + maintenance_level_val = config.get('ivm.maintenance_level') + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + if (maintenance_level_val is not None and maintenance_level_val.HasField('string_value')): + if maintenance_level_val.string_value == 'off': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + else: + if maintenance_level_val.string_value == 'auto': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO + else: + if maintenance_level_val.string_value == 'all': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL + else: + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + _t1314 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1314 + _t1315 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1315 + _t1316 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1316 + + def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + config = dict(config_dict) + _t1317 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1317 + _t1318 = self._extract_value_string(config.get('compression'), '') + compression = _t1318 + _t1319 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1319 + _t1320 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1320 + _t1321 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1321 + _t1322 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1322 + _t1323 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1323 + _t1324 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1324 + + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t1325 = logic_pb2.Value(int_value=v) + return _t1325 + + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t1326 = logic_pb2.Value(float_value=v) + return _t1326 + + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t1327 = logic_pb2.Value(string_value=v) + return _t1327 + + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t1328 = logic_pb2.Value(boolean_value=v) + return _t1328 + + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t1329 = logic_pb2.Value(uint128_value=v) + return _t1329 + + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: + if cfg.semantics_version != 0: + return False + if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + return False + return True + + def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.semantics_version != 0: + _t1331 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1331,)) + _t1330 = None + else: + _t1330 = None + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: + _t1333 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1333,)) + _t1332 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: + _t1335 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1335,)) + _t1334 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + _t1337 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1337,)) + _t1336 = None + else: + _t1336 = None + _t1334 = _t1336 + _t1332 = _t1334 + return result + + def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.header_row != 1: + _t1339 = self._make_value_int64(int(msg.header_row)) + result.append(('csv_header_row', _t1339,)) + _t1338 = None + else: + _t1338 = None + + if msg.skip != 0: + _t1341 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1341,)) + _t1340 = None + else: + _t1340 = None + + if msg.new_line != '': + _t1343 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1343,)) + _t1342 = None + else: + _t1342 = None + + if msg.delimiter != ',': + _t1345 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1345,)) + _t1344 = None + else: + _t1344 = None + + if msg.quotechar != '"': + _t1347 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1347,)) + _t1346 = None + else: + _t1346 = None + + if msg.escapechar != '"': + _t1349 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1349,)) + _t1348 = None + else: + _t1348 = None + + if msg.comment != '': + _t1351 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1351,)) + _t1350 = None + else: + _t1350 = None + + if not len(msg.missing_strings) == 0: + _t1353 = self._make_value_string(msg.missing_strings[0]) + result.append(('csv_missing_strings', _t1353,)) + _t1352 = None + else: + _t1352 = None + + if msg.decimal_separator != '.': + _t1355 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1355,)) + _t1354 = None + else: + _t1354 = None + + if msg.encoding != 'utf-8': + _t1357 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1357,)) + _t1356 = None + else: + _t1356 = None + + if msg.compression != 'auto': + _t1359 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1359,)) + _t1358 = None + else: + _t1358 = None + return result + + def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: + + if val is not None: + _t1361 = self._make_value_float64(val) + result.append((key, _t1361,)) + _t1360 = None + else: + _t1360 = None + return None + + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: + + if val is not None: + _t1363 = self._make_value_int64(val) + result.append((key, _t1363,)) + _t1362 = None + else: + _t1362 = None + return None + + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + + if val is not None: + _t1365 = self._make_value_uint128(val) + result.append((key, _t1365,)) + _t1364 = None + else: + _t1364 = None return None + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + _t1367 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1367,)) + _t1366 = None + else: + _t1366 = None + return None + + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: + result = [] + _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1372 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1373 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1374 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1375 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return result + + def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if (msg.partition_size is not None and msg.partition_size != 0): + _t1377 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1377,)) + _t1376 = None + else: + _t1376 = None + + if (msg.compression is not None and msg.compression != ''): + _t1379 = self._make_value_string(msg.compression) + result.append(('compression', _t1379,)) + _t1378 = None + else: + _t1378 = None + + if msg.syntax_header_row is not None: + _t1381 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1381,)) + _t1380 = None + else: + _t1380 = None + + if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + _t1383 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1383,)) + _t1382 = None + else: + _t1382 = None + + if (msg.syntax_delim is not None and msg.syntax_delim != ','): + _t1385 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1385,)) + _t1384 = None + else: + _t1384 = None + + if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + _t1387 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1387,)) + _t1386 = None + else: + _t1386 = None + + if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + _t1389 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1389,)) + _t1388 = None + else: + _t1388 = None + return result + + def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: + name = self.relation_id_to_string(msg) + if name != '': + return name + return None + + def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: + name = self.relation_id_to_string(msg) + if name == '': + return self.relation_id_to_uint128(msg) + return None + + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + return (abs.vars, [],) + + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + n = len(abs.vars) + key_end = (n - value_arity) + return (abs.vars[0:key_end], abs.vars[key_end:n],) + -def pretty(msg: Any, io: IO[str] = None) -> str: +def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io) printer.pretty_transaction(msg) diff --git a/python-tools/src/meta/__init__.py b/python-tools/src/meta/__init__.py index ae8dda4b..fa702970 100644 --- a/python-tools/src/meta/__init__.py +++ b/python-tools/src/meta/__init__.py @@ -27,8 +27,10 @@ TupleType, ListType, FunDef, - VisitNonterminalDef, - VisitNonterminal, + ParseNonterminalDef, + PrintNonterminalDef, + ParseNonterminal, + PrintNonterminal, ) # Grammar data structures @@ -97,8 +99,10 @@ 'TupleType', 'ListType', 'FunDef', - 'VisitNonterminalDef', - 'VisitNonterminal', + 'ParseNonterminalDef', + 'PrintNonterminalDef', + 'ParseNonterminal', + 'PrintNonterminal', # Grammar 'Grammar', 'Rule', diff --git a/python-tools/src/meta/codegen_base.py b/python-tools/src/meta/codegen_base.py index 6f74fc99..a3b6e8ce 100644 --- a/python-tools/src/meta/codegen_base.py +++ b/python-tools/src/meta/codegen_base.py @@ -14,8 +14,10 @@ from .target import ( TargetExpr, Var, Lit, Symbol, Builtin, NamedFun, NewMessage, EnumValue, OneOf, ListExpr, Call, Lambda, Let, - IfElse, Seq, While, Foreach, ForeachEnumerated, Assign, Return, FunDef, VisitNonterminalDef, - VisitNonterminal, TargetType, BaseType, TupleType, ListType, DictType, OptionType, + IfElse, Seq, While, Foreach, ForeachEnumerated, Assign, Return, FunDef, + ParseNonterminalDef, PrintNonterminalDef, + ParseNonterminal, PrintNonterminal, + TargetType, BaseType, TupleType, ListType, DictType, OptionType, MessageType, EnumType, FunctionType, VarType, GetField, GetElement ) from .target_builtins import get_builtin @@ -416,9 +418,10 @@ def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") - elif isinstance(expr, NamedFun): return self.gen_named_fun_ref(expr.name) - elif isinstance(expr, VisitNonterminal): - if expr.visitor_name == 'pretty': - return self.gen_pretty_nonterminal_ref(expr.nonterminal.name) + elif isinstance(expr, PrintNonterminal): + return self.gen_pretty_nonterminal_ref(expr.nonterminal.name) + + elif isinstance(expr, ParseNonterminal): return self.gen_parse_nonterminal_ref(expr.nonterminal.name) elif isinstance(expr, OneOf): @@ -429,6 +432,7 @@ def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") - elif isinstance(expr, GetField): obj_code = self.generate_lines(expr.object, lines, indent) + assert obj_code is not None, "GetField object should not contain a return" return self.gen_field_access(obj_code, expr.field_name) elif isinstance(expr, GetElement): @@ -792,13 +796,13 @@ def _generate_return(self, expr: Return, lines: List[str], indent: str) -> None: # --- Function definition generation --- - def generate_def(self, expr: Union[FunDef, VisitNonterminalDef], indent: str = "") -> str: + def generate_def(self, expr: Union[FunDef, ParseNonterminalDef, PrintNonterminalDef], indent: str = "") -> str: """Generate a function definition.""" if isinstance(expr, FunDef): return self._generate_fun_def(expr, indent) - elif isinstance(expr, VisitNonterminalDef): - if expr.visitor_name == 'pretty': - return self._generate_pretty_def(expr, indent) + elif isinstance(expr, PrintNonterminalDef): + return self._generate_pretty_def(expr, indent) + elif isinstance(expr, ParseNonterminalDef): return self._generate_parse_def(expr, indent) else: raise ValueError(f"Unknown definition type: {type(expr)}") @@ -832,12 +836,12 @@ def generate_method_def(self, expr: FunDef, indent: str) -> str: pass @abstractmethod - def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: """Generate a parse method definition. Language-specific due to method syntax.""" pass @abstractmethod - def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: """Generate a pretty-print method definition. Language-specific due to method syntax.""" pass diff --git a/python-tools/src/meta/codegen_julia.py b/python-tools/src/meta/codegen_julia.py index a797b309..240ab7ca 100644 --- a/python-tools/src/meta/codegen_julia.py +++ b/python-tools/src/meta/codegen_julia.py @@ -10,8 +10,9 @@ from .codegen_templates import JULIA_TEMPLATES from .target import ( TargetExpr, Var, Lit, Symbol, NamedFun, NewMessage, OneOf, ListExpr, Call, Lambda, Let, - FunDef, VisitNonterminalDef, VisitNonterminal, GetField, GetElement, BaseType, - MessageType, + FunDef, ParseNonterminalDef, PrintNonterminalDef, + ParseNonterminal, PrintNonterminal, + GetField, GetElement, BaseType, MessageType, ) from .gensym import gensym @@ -377,8 +378,8 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ lines.append(f"{indent}{self.gen_assignment(tmp, f'OneOf({field_symbol}, {field_value})', is_declaration=True)}") return tmp - # Check for VisitNonterminal or NamedFun calls - need to add parser as first argument - if isinstance(expr.func, (VisitNonterminal, NamedFun)): + # Check for parse/print nonterminal or NamedFun calls - need to add parser as first argument + if isinstance(expr.func, (ParseNonterminal, PrintNonterminal, NamedFun)): f = self.generate_lines(expr.func, lines, indent) args: List[str] = [] for arg in expr.args: @@ -406,7 +407,7 @@ def _generate_oneof(self, expr: OneOf, lines: List[str], indent: str) -> str: """ raise ValueError(f"OneOf should only appear in Call(OneOf(...), [value]) pattern: {expr}") - def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: """Generate a parse method definition.""" func_name = f"parse_{expr.nonterminal.name}" @@ -432,7 +433,7 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: return f"{indent}function {func_name}({params_str}){ret_hint}\n{body_code}\n{indent}end" - def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: """Generate a pretty-print function definition.""" func_name = f"pretty_{expr.nonterminal.name}" @@ -505,7 +506,7 @@ def generate_julia_lines(expr: TargetExpr, lines: List[str], indent: str = "") - return JuliaCodeGenerator().generate_lines(expr, lines, indent) -def generate_julia_def(expr: Union[FunDef, VisitNonterminalDef], indent: str = "") -> str: +def generate_julia_def(expr: Union[FunDef, ParseNonterminalDef, PrintNonterminalDef], indent: str = "") -> str: """Generate Julia function definition.""" return JuliaCodeGenerator().generate_def(expr, indent) diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index 5705f96d..396f8509 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -11,7 +11,7 @@ from .gensym import gensym from .target import ( TargetExpr, Var, Lit, Symbol, NewMessage, OneOf, ListExpr, Call, Lambda, Let, - FunDef, VisitNonterminalDef + FunDef, ParseNonterminalDef, PrintNonterminalDef ) @@ -30,6 +30,7 @@ class PythonCodeGenerator(CodeGenerator): keywords = PYTHON_KEYWORDS indent_str = " " + named_fun_class = "Parser" base_type_map = { 'Int32': 'int', @@ -103,7 +104,7 @@ def gen_builtin_ref(self, name: str) -> str: return f"self.{name}" def gen_named_fun_ref(self, name: str) -> str: - return f"Parser.{name}" + return f"{self.named_fun_class}.{name}" def gen_parse_nonterminal_ref(self, name: str) -> str: return f"self.parse_{name}" @@ -294,7 +295,7 @@ def _build_message_field_map(self) -> dict: self._message_field_map = field_map return field_map - def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: """Generate a parse method definition.""" func_name = f"parse_{expr.nonterminal.name}" @@ -319,7 +320,7 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" - def _generate_pretty_def(self, expr: VisitNonterminalDef, indent: str) -> str: + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: """Generate a pretty-print method definition.""" func_name = f"pretty_{expr.nonterminal.name}" @@ -356,9 +357,30 @@ def format_command_line_comment(self, command_line: str) -> str: return f"\nCommand: {command_line}\n" def generate_method_def(self, expr: FunDef, indent: str) -> str: - """Generate a function definition as a static method on Parser.""" - result = self._generate_fun_def(expr, indent) - return f"{indent}@staticmethod\n{result}" + """Generate a function definition as an instance method.""" + func_name = self.escape_identifier(expr.name) + params = [] + for p in expr.params: + escaped_name = self.escape_identifier(p.name) + type_hint = self.gen_type(p.type) + params.append(f"{escaped_name}: {type_hint}") + + params_str = ', '.join(params) if params else '' + if params_str: + params_str = ', ' + params_str + + ret_hint = f" -> {self.gen_type(expr.return_type)}" if expr.return_type else "" + + body_lines: List[str] = [] + if expr.body is None: + body_lines.append(f"{indent} pass") + else: + body_inner = self.generate_lines(expr.body, body_lines, indent + " ") + if body_inner is not None: + body_lines.append(f"{indent} return {body_inner}") + body_code = "\n".join(body_lines) + + return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" def escape_identifier(name: str) -> str: @@ -395,7 +417,7 @@ def generate_python_lines( def generate_python_def( - expr: Union[FunDef, VisitNonterminalDef], + expr: Union[FunDef, ParseNonterminalDef, PrintNonterminalDef], indent: str = "", generator: Optional[PythonCodeGenerator] = None, ) -> str: diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index 7a32052f..a0b3988b 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -67,6 +67,32 @@ class BuiltinTemplate: "error_with_token": BuiltinTemplate( None, ['raise ParseError(f"{{{0}}}: {{{1}.type}}=`{{{1}.value}}`")'] ), + # Pretty-printing builtins + "write_io": BuiltinTemplate("None", ["self.write({0})"]), + "newline_io": BuiltinTemplate("None", ["self.newline()"]), + "indent_io": BuiltinTemplate("None", ["self.indent()"]), + "dedent_io": BuiltinTemplate("None", ["self.dedent()"]), + "format_int64": BuiltinTemplate("str({0})"), + "format_int32": BuiltinTemplate("str({0})"), + "format_float64": BuiltinTemplate("str({0})"), + "format_string": BuiltinTemplate("repr({0})"), + "format_symbol": BuiltinTemplate("{0}"), + "format_bool": BuiltinTemplate("('true' if {0} else 'false')"), + "format_decimal": BuiltinTemplate("self.format_decimal({0})"), + "format_int128": BuiltinTemplate("self.format_int128({0})"), + "format_uint128": BuiltinTemplate("self.format_uint128({0})"), + "greater": BuiltinTemplate("({0} > {1})"), + "to_string": BuiltinTemplate("str({0})"), + # Type conversions used by pretty printer + "int32_to_int64": BuiltinTemplate("int({0})"), + "is_empty": BuiltinTemplate("len({0}) == 0"), + "decode_string": BuiltinTemplate("{0}.decode('utf-8')"), + "fragment_id_to_string": BuiltinTemplate("self.fragment_id_to_string({0})"), + "relation_id_to_string": BuiltinTemplate("self.relation_id_to_string({0})"), + "relation_id_to_int": BuiltinTemplate("self.relation_id_to_int({0})"), + "relation_id_to_uint128": BuiltinTemplate("self.relation_id_to_uint128({0})"), + "subtract": BuiltinTemplate("({0} - {1})"), + "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), } @@ -116,31 +142,7 @@ class BuiltinTemplate: "construct_fragment": BuiltinTemplate("construct_fragment(parser, {0}, {1})"), "error": BuiltinTemplate(None, ["throw(ParseError({0}))"]), "error_with_token": BuiltinTemplate(None, ['throw(ParseError({0} * ": " * string({1})))']), -} - - - -# Python pretty-printing builtin templates -PYTHON_PRETTY_TEMPLATES: Dict[str, BuiltinTemplate] = { - "write_io": BuiltinTemplate("None", ["self.write({0})"]), - "newline_io": BuiltinTemplate("None", ["self.newline()"]), - "indent_io": BuiltinTemplate("None", ["self.indent()"]), - "dedent_io": BuiltinTemplate("None", ["self.dedent()"]), - "format_int64": BuiltinTemplate("str({0})"), - "format_int32": BuiltinTemplate("str({0})"), - "format_float64": BuiltinTemplate("str({0})"), - "format_string": BuiltinTemplate("repr({0})"), - "format_symbol": BuiltinTemplate("{0}"), - "format_bool": BuiltinTemplate("('true' if {0} else 'false')"), - "format_decimal": BuiltinTemplate("self.format_decimal({0})"), - "format_int128": BuiltinTemplate("self.format_int128({0})"), - "format_uint128": BuiltinTemplate("self.format_uint128({0})"), - "greater": BuiltinTemplate("({0} > {1})"), - "to_string": BuiltinTemplate("str({0})"), -} - -# Julia pretty-printing builtin templates -JULIA_PRETTY_TEMPLATES: Dict[str, BuiltinTemplate] = { + # Pretty-printing builtins "write_io": BuiltinTemplate("nothing", ["write(pp, {0})"]), "newline_io": BuiltinTemplate("nothing", ["newline(pp)"]), "indent_io": BuiltinTemplate("nothing", ["indent!(pp)"]), @@ -156,6 +158,16 @@ class BuiltinTemplate: "format_uint128": BuiltinTemplate("format_uint128(pp, {0})"), "greater": BuiltinTemplate("({0} > {1})"), "to_string": BuiltinTemplate("string({0})"), + # Type conversions used by pretty printer + "int32_to_int64": BuiltinTemplate("Int64({0})"), + "is_empty": BuiltinTemplate("isempty({0})"), + "decode_string": BuiltinTemplate("String({0})"), + "fragment_id_to_string": BuiltinTemplate("fragment_id_to_string(pp, {0})"), + "relation_id_to_string": BuiltinTemplate("relation_id_to_string(pp, {0})"), + "relation_id_to_int": BuiltinTemplate("relation_id_to_int(pp, {0})"), + "relation_id_to_uint128": BuiltinTemplate("relation_id_to_uint128(pp, {0})"), + "subtract": BuiltinTemplate("({0} - {1})"), + "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), } @@ -163,6 +175,4 @@ class BuiltinTemplate: 'BuiltinTemplate', 'PYTHON_TEMPLATES', 'JULIA_TEMPLATES', - 'PYTHON_PRETTY_TEMPLATES', - 'JULIA_PRETTY_TEMPLATES', ] diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index a23fd0ae..24590186 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -21,9 +21,9 @@ # # Deconstruct actions use `$N = expr` assignments to extract RHS element # values from the LHS value ($$). If omitted, the default is the identity -# deconstruct. If any assignment uses a conditional guard of the form -# `$N = expr if COND else None`, the deconstructor returns None when the -# condition fails, signaling that this rule does not match. +# deconstruct. Use `assert COND` to guard the deconstructor: if any assert +# condition fails, the deconstructor returns None, signaling that this rule +# does not match the LHS value. # # The pretty printer uses the deconstruct actions. For nonterminals with # multiple alternatives, it tries the rules in declaration order, choosing @@ -183,7 +183,7 @@ transaction construct: $$ = transactions.Transaction(epochs=$5, configure=builtin.unwrap_option_or($3, default_configure()), sync=$4) deconstruct: $3 = $$.configure if not is_default_configure($$.configure) else None - $4 = $$.sync + $4 = $$.sync # TODO: if sync.fragments is not empty else None $5 = $$.epochs configure @@ -204,38 +204,59 @@ config_key_value value : date construct: $$ = logic.Value(date_value=$1) - deconstruct: $1 = $$.date_value if builtin.has_proto_field($$, 'date_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'date_value') + $1 = $$.date_value | datetime construct: $$ = logic.Value(datetime_value=$1) - deconstruct: $1 = $$.datetime_value if builtin.has_proto_field($$, 'datetime_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'datetime_value') + $1 = $$.datetime_value | STRING construct: $$ = logic.Value(string_value=$1) - deconstruct: $1 = $$.string_value if builtin.has_proto_field($$, 'string_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'string_value') + $1 = $$.string_value | INT construct: $$ = logic.Value(int_value=$1) - deconstruct: $1 = $$.int_value if builtin.has_proto_field($$, 'int_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'int_value') + $1 = $$.int_value | FLOAT construct: $$ = logic.Value(float_value=$1) - deconstruct: $1 = $$.float_value if builtin.has_proto_field($$, 'float_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'float_value') + $1 = $$.float_value | UINT128 construct: $$ = logic.Value(uint128_value=$1) - deconstruct: $1 = $$.uint128_value if builtin.has_proto_field($$, 'uint128_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'uint128_value') + $1 = $$.uint128_value | INT128 construct: $$ = logic.Value(int128_value=$1) - deconstruct: $1 = $$.int128_value if builtin.has_proto_field($$, 'int128_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'int128_value') + $1 = $$.int128_value | DECIMAL construct: $$ = logic.Value(decimal_value=$1) - deconstruct: $1 = $$.decimal_value if builtin.has_proto_field($$, 'decimal_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'decimal_value') + $1 = $$.decimal_value | "missing" construct: $$ = logic.Value(missing_value=logic.MissingValue()) | boolean_value construct: $$ = logic.Value(boolean_value=$1) - deconstruct: $1 = $$.boolean_value if builtin.has_proto_field($$, 'boolean_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'boolean_value') + $1 = $$.boolean_value date : "(" "date" INT INT INT ")" construct: $$ = logic.DateValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5)) - deconstruct: $3 = builtin.int32_to_int64($$.year); $4 = builtin.int32_to_int64($$.month); $5 = builtin.int32_to_int64($$.day) + deconstruct: + $3 = builtin.int32_to_int64($$.year) + $4 = builtin.int32_to_int64($$.month) + $5 = builtin.int32_to_int64($$.day) datetime : "(" "datetime" INT INT INT INT INT INT INT? ")" @@ -278,13 +299,19 @@ epoch_writes write : define construct: $$ = transactions.Write(define=$1) - deconstruct: $1 = $$.define if builtin.has_proto_field($$, 'define') else None + deconstruct: + assert builtin.has_proto_field($$, 'define') + $1 = $$.define | undefine construct: $$ = transactions.Write(undefine=$1) - deconstruct: $1 = $$.undefine if builtin.has_proto_field($$, 'undefine') else None + deconstruct: + assert builtin.has_proto_field($$, 'undefine') + $1 = $$.undefine | context construct: $$ = transactions.Write(context=$1) - deconstruct: $1 = $$.context if builtin.has_proto_field($$, 'context') else None + deconstruct: + assert builtin.has_proto_field($$, 'context') + $1 = $$.context define : "(" "define" fragment ")" @@ -294,7 +321,10 @@ define fragment : "(" "fragment" new_fragment_id declaration* ")" construct: $$ = builtin.construct_fragment($3, $4) - deconstruct: $3 = $$.id; $4 = $$.declarations + deconstruct: + builtin.start_pretty_fragment($$) + $3 = $$.id + $4 = $$.declarations new_fragment_id : fragment_id @@ -305,16 +335,24 @@ new_fragment_id declaration : def construct: $$ = logic.Declaration(def=$1) - deconstruct: $1 = $$.def if builtin.has_proto_field($$, 'def') else None + deconstruct: + assert builtin.has_proto_field($$, 'def') + $1 = $$.def | algorithm construct: $$ = logic.Declaration(algorithm=$1) - deconstruct: $1 = $$.algorithm if builtin.has_proto_field($$, 'algorithm') else None + deconstruct: + assert builtin.has_proto_field($$, 'algorithm') + $1 = $$.algorithm | constraint construct: $$ = logic.Declaration(constraint=$1) - deconstruct: $1 = $$.constraint if builtin.has_proto_field($$, 'constraint') else None + deconstruct: + assert builtin.has_proto_field($$, 'constraint') + $1 = $$.constraint | data construct: $$ = logic.Declaration(data=$1) - deconstruct: $1 = $$.data if builtin.has_proto_field($$, 'data') else None + deconstruct: + assert builtin.has_proto_field($$, 'data') + $1 = $$.data def : "(" "def" relation_id abstraction attrs? ")" @@ -335,52 +373,80 @@ relation_id abstraction : "(" bindings formula ")" construct: $$ = logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3) - deconstruct: $2 = deconstruct_bindings($$); $3 = $$.value + deconstruct: + $2 = deconstruct_bindings($$) + $3 = $$.value bindings : "[" binding* value_bindings? "]" construct: $$ = builtin.tuple($2, builtin.unwrap_option_or($3, list[logic.Binding]())) - deconstruct: $2 = $$[0]; $3 = $$[1] if not builtin.is_empty($$[1]) else None + deconstruct: + $2 = $$[0] + $3 = $$[1] if not builtin.is_empty($$[1]) else None binding : SYMBOL "::" type construct: $$ = logic.Binding(var=logic.Var(name=$1), type=$3) - deconstruct: $1 = $$.var.name; $3 = $$.type + deconstruct: + $1 = $$.var.name + $3 = $$.type type : unspecified_type construct: $$ = logic.Type(unspecified_type=$1) - deconstruct: $1 = $$.unspecified_type if builtin.has_proto_field($$, 'unspecified_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'unspecified_type') + $1 = $$.unspecified_type | string_type construct: $$ = logic.Type(string_type=$1) - deconstruct: $1 = $$.string_type if builtin.has_proto_field($$, 'string_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'string_type') + $1 = $$.string_type | int_type construct: $$ = logic.Type(int_type=$1) - deconstruct: $1 = $$.int_type if builtin.has_proto_field($$, 'int_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'int_type') + $1 = $$.int_type | float_type construct: $$ = logic.Type(float_type=$1) - deconstruct: $1 = $$.float_type if builtin.has_proto_field($$, 'float_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'float_type') + $1 = $$.float_type | uint128_type construct: $$ = logic.Type(uint128_type=$1) - deconstruct: $1 = $$.uint128_type if builtin.has_proto_field($$, 'uint128_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'uint128_type') + $1 = $$.uint128_type | int128_type construct: $$ = logic.Type(int128_type=$1) - deconstruct: $1 = $$.int128_type if builtin.has_proto_field($$, 'int128_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'int128_type') + $1 = $$.int128_type | date_type construct: $$ = logic.Type(date_type=$1) - deconstruct: $1 = $$.date_type if builtin.has_proto_field($$, 'date_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'date_type') + $1 = $$.date_type | datetime_type construct: $$ = logic.Type(datetime_type=$1) - deconstruct: $1 = $$.datetime_type if builtin.has_proto_field($$, 'datetime_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'datetime_type') + $1 = $$.datetime_type | missing_type construct: $$ = logic.Type(missing_type=$1) - deconstruct: $1 = $$.missing_type if builtin.has_proto_field($$, 'missing_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'missing_type') + $1 = $$.missing_type | decimal_type construct: $$ = logic.Type(decimal_type=$1) - deconstruct: $1 = $$.decimal_type if builtin.has_proto_field($$, 'decimal_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'decimal_type') + $1 = $$.decimal_type | boolean_type construct: $$ = logic.Type(boolean_type=$1) - deconstruct: $1 = $$.boolean_type if builtin.has_proto_field($$, 'boolean_type') else None + deconstruct: + assert builtin.has_proto_field($$, 'boolean_type') + $1 = $$.boolean_type unspecified_type : "UNKNOWN" @@ -421,7 +487,9 @@ missing_type decimal_type : "(" "DECIMAL" INT INT ")" construct: $$ = logic.DecimalType(precision=builtin.int64_to_int32($3), scale=builtin.int64_to_int32($4)) - deconstruct: $3 = builtin.int32_to_int64($$.precision); $4 = builtin.int32_to_int64($$.scale) + deconstruct: + $3 = builtin.int32_to_int64($$.precision) + $4 = builtin.int32_to_int64($$.scale) boolean_type : "BOOLEAN" @@ -433,43 +501,69 @@ value_bindings formula : true construct: $$ = logic.Formula(conjunction=$1) - deconstruct: $1 = $$.conjunction if builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args) else None + deconstruct: + assert builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args) + $1 = $$.conjunction | false construct: $$ = logic.Formula(disjunction=$1) - deconstruct: $1 = $$.disjunction if builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args) else None + deconstruct: + assert builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args) + $1 = $$.disjunction | exists construct: $$ = logic.Formula(exists=$1) - deconstruct: $1 = $$.exists if builtin.has_proto_field($$, 'exists') else None + deconstruct: + assert builtin.has_proto_field($$, 'exists') + $1 = $$.exists | reduce construct: $$ = logic.Formula(reduce=$1) - deconstruct: $1 = $$.reduce if builtin.has_proto_field($$, 'reduce') else None + deconstruct: + assert builtin.has_proto_field($$, 'reduce') + $1 = $$.reduce | conjunction construct: $$ = logic.Formula(conjunction=$1) - deconstruct: $1 = $$.conjunction if builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args) else None + deconstruct: + assert builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args) + $1 = $$.conjunction | disjunction construct: $$ = logic.Formula(disjunction=$1) - deconstruct: $1 = $$.disjunction if builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args) else None + deconstruct: + assert builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args) + $1 = $$.disjunction | not construct: $$ = logic.Formula(not=$1) - deconstruct: $1 = $$.not if builtin.has_proto_field($$, 'not') else None + deconstruct: + assert builtin.has_proto_field($$, 'not') + $1 = $$.not | ffi construct: $$ = logic.Formula(ffi=$1) - deconstruct: $1 = $$.ffi if builtin.has_proto_field($$, 'ffi') else None + deconstruct: + assert builtin.has_proto_field($$, 'ffi') + $1 = $$.ffi | atom construct: $$ = logic.Formula(atom=$1) - deconstruct: $1 = $$.atom if builtin.has_proto_field($$, 'atom') else None + deconstruct: + assert builtin.has_proto_field($$, 'atom') + $1 = $$.atom | pragma construct: $$ = logic.Formula(pragma=$1) - deconstruct: $1 = $$.pragma if builtin.has_proto_field($$, 'pragma') else None + deconstruct: + assert builtin.has_proto_field($$, 'pragma') + $1 = $$.pragma | primitive construct: $$ = logic.Formula(primitive=$1) - deconstruct: $1 = $$.primitive if builtin.has_proto_field($$, 'primitive') else None + deconstruct: + assert builtin.has_proto_field($$, 'primitive') + $1 = $$.primitive | rel_atom construct: $$ = logic.Formula(rel_atom=$1) - deconstruct: $1 = $$.rel_atom if builtin.has_proto_field($$, 'rel_atom') else None + deconstruct: + assert builtin.has_proto_field($$, 'rel_atom') + $1 = $$.rel_atom | cast construct: $$ = logic.Formula(cast=$1) - deconstruct: $1 = $$.cast if builtin.has_proto_field($$, 'cast') else None + deconstruct: + assert builtin.has_proto_field($$, 'cast') + $1 = $$.cast true : "(" "true" ")" @@ -482,20 +576,29 @@ false exists : "(" "exists" bindings formula ")" construct: $$ = logic.Exists(body=logic.Abstraction(vars=builtin.list_concat($3[0], $3[1]), value=$4)) - deconstruct: $3 = deconstruct_bindings($$.body); $4 = $$.body.value + deconstruct: + $3 = deconstruct_bindings($$.body) + $4 = $$.body.value reduce : "(" "reduce" abstraction abstraction terms ")" construct: $$ = logic.Reduce(op=$3, body=$4, terms=$5) - deconstruct: $3 = $$.op; $4 = $$.body; $5 = $$.terms + deconstruct: + $3 = $$.op + $4 = $$.body + $5 = $$.terms term : var construct: $$ = logic.Term(var=$1) - deconstruct: $1 = $$.var if builtin.has_proto_field($$, 'var') else None + deconstruct: + assert builtin.has_proto_field($$, 'var') + $1 = $$.var | constant construct: $$ = logic.Term(constant=$1) - deconstruct: $1 = $$.constant if builtin.has_proto_field($$, 'constant') else None + deconstruct: + assert builtin.has_proto_field($$, 'constant') + $1 = $$.constant var : SYMBOL @@ -523,7 +626,10 @@ not ffi : "(" "ffi" name ffi_args terms ")" construct: $$ = logic.FFI(name=$3, args=$4, terms=$5) - deconstruct: $3 = $$.name; $4 = $$.args; $5 = $$.terms + deconstruct: + $3 = $$.name + $4 = $$.args + $5 = $$.terms ffi_args : "(" "args" abstraction* ")" @@ -537,12 +643,16 @@ name atom : "(" "atom" relation_id term* ")" construct: $$ = logic.Atom(name=$3, terms=$4) - deconstruct: $3 = $$.name; $4 = $$.terms + deconstruct: + $3 = $$.name + $4 = $$.terms pragma : "(" "pragma" name term* ")" construct: $$ = logic.Pragma(name=$3, terms=$4) - deconstruct: $3 = $$.name; $4 = $$.terms + deconstruct: + $3 = $$.name + $4 = $$.terms primitive : eq @@ -556,48 +666,56 @@ primitive | divide | "(" "primitive" name rel_term* ")" construct: $$ = logic.Primitive(name=$3, terms=$4) - deconstruct: $3 = $$.name; $4 = $$.terms + deconstruct: + $3 = $$.name + $4 = $$.terms eq : "(" "=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_eq", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_eq" else None + assert $$.name == "rel_primitive_eq" + $3 = $$.terms[0].term $4 = $$.terms[1].term lt : "(" "<" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_lt_monotype" else None + assert $$.name == "rel_primitive_lt_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term lt_eq : "(" "<=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_lt_eq_monotype" else None + assert $$.name == "rel_primitive_lt_eq_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term gt : "(" ">" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_gt_monotype" else None + assert $$.name == "rel_primitive_gt_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term gt_eq : "(" ">=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_gt_eq_monotype" else None + assert $$.name == "rel_primitive_gt_eq_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term add : "(" "+" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_add_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_add_monotype" else None + assert $$.name == "rel_primitive_add_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term $5 = $$.terms[2].term @@ -605,7 +723,8 @@ minus : "(" "-" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_subtract_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_subtract_monotype" else None + assert $$.name == "rel_primitive_subtract_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term $5 = $$.terms[2].term @@ -613,7 +732,8 @@ multiply : "(" "*" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_multiply_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_multiply_monotype" else None + assert $$.name == "rel_primitive_multiply_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term $5 = $$.terms[2].term @@ -621,17 +741,22 @@ divide : "(" "/" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_divide_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: - $3 = $$.terms[0].term if $$.name == "rel_primitive_divide_monotype" else None + assert $$.name == "rel_primitive_divide_monotype" + $3 = $$.terms[0].term $4 = $$.terms[1].term $5 = $$.terms[2].term rel_term : specialized_value construct: $$ = logic.RelTerm(specialized_value=$1) - deconstruct: $1 = $$.specialized_value if builtin.has_proto_field($$, 'specialized_value') else None + deconstruct: + assert builtin.has_proto_field($$, 'specialized_value') + $1 = $$.specialized_value | term construct: $$ = logic.RelTerm(term=$1) - deconstruct: $1 = $$.term if builtin.has_proto_field($$, 'term') else None + deconstruct: + assert builtin.has_proto_field($$, 'term') + $1 = $$.term specialized_value : "#" value @@ -639,12 +764,16 @@ specialized_value rel_atom : "(" "relatom" name rel_term* ")" construct: $$ = logic.RelAtom(name=$3, terms=$4) - deconstruct: $3 = $$.name; $4 = $$.terms + deconstruct: + $3 = $$.name + $4 = $$.terms cast : "(" "cast" term term ")" construct: $$ = logic.Cast(input=$3, result=$4) - deconstruct: $3 = $$.input; $4 = $$.result + deconstruct: + $3 = $$.input + $4 = $$.result attrs : "(" "attrs" attribute* ")" @@ -652,12 +781,16 @@ attrs attribute : "(" "attribute" name value* ")" construct: $$ = logic.Attribute(name=$3, args=$4) - deconstruct: $3 = $$.name; $4 = $$.args + deconstruct: + $3 = $$.name + $4 = $$.args algorithm : "(" "algorithm" relation_id* script ")" construct: $$ = logic.Algorithm(global=$3, body=$4) - deconstruct: $3 = $$.global; $4 = $$.body + deconstruct: + $3 = $$.global + $4 = $$.body script : "(" "script" construct* ")" @@ -667,15 +800,21 @@ script construct : loop construct: $$ = logic.Construct(loop=$1) - deconstruct: $1 = $$.loop if builtin.has_proto_field($$, 'loop') else None + deconstruct: + assert builtin.has_proto_field($$, 'loop') + $1 = $$.loop | instruction construct: $$ = logic.Construct(instruction=$1) - deconstruct: $1 = $$.instruction if builtin.has_proto_field($$, 'instruction') else None + deconstruct: + assert builtin.has_proto_field($$, 'instruction') + $1 = $$.instruction loop : "(" "loop" init script ")" construct: $$ = logic.Loop(init=$3, body=$4) - deconstruct: $3 = $$.init; $4 = $$.body + deconstruct: + $3 = $$.init + $4 = $$.body init : "(" "init" instruction* ")" @@ -683,19 +822,29 @@ init instruction : assign construct: $$ = logic.Instruction(assign=$1) - deconstruct: $1 = $$.assign if builtin.has_proto_field($$, 'assign') else None + deconstruct: + assert builtin.has_proto_field($$, 'assign') + $1 = $$.assign | upsert construct: $$ = logic.Instruction(upsert=$1) - deconstruct: $1 = $$.upsert if builtin.has_proto_field($$, 'upsert') else None + deconstruct: + assert builtin.has_proto_field($$, 'upsert') + $1 = $$.upsert | break construct: $$ = logic.Instruction(break=$1) - deconstruct: $1 = $$.break if builtin.has_proto_field($$, 'break') else None + deconstruct: + assert builtin.has_proto_field($$, 'break') + $1 = $$.break | monoid_def construct: $$ = logic.Instruction(monoid_def=$1) - deconstruct: $1 = $$.monoid_def if builtin.has_proto_field($$, 'monoid_def') else None + deconstruct: + assert builtin.has_proto_field($$, 'monoid_def') + $1 = $$.monoid_def | monus_def construct: $$ = logic.Instruction(monus_def=$1) - deconstruct: $1 = $$.monus_def if builtin.has_proto_field($$, 'monus_def') else None + deconstruct: + assert builtin.has_proto_field($$, 'monus_def') + $1 = $$.monus_def assign : "(" "assign" relation_id abstraction attrs? ")" @@ -716,7 +865,9 @@ upsert abstraction_with_arity : "(" bindings formula ")" construct: $$ = builtin.tuple(logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3), builtin.length($2[1])) - deconstruct: $2 = deconstruct_bindings_with_arity($$[0], $$[1]); $3 = $$[0].value + deconstruct: + $2 = deconstruct_bindings_with_arity($$[0], $$[1]) + $3 = $$[0].value break : "(" "break" relation_id abstraction attrs? ")" @@ -738,16 +889,24 @@ monoid_def monoid : or_monoid construct: $$ = logic.Monoid(or_monoid=$1) - deconstruct: $1 = $$.or_monoid if builtin.has_proto_field($$, 'or_monoid') else None + deconstruct: + assert builtin.has_proto_field($$, 'or_monoid') + $1 = $$.or_monoid | min_monoid construct: $$ = logic.Monoid(min_monoid=$1) - deconstruct: $1 = $$.min_monoid if builtin.has_proto_field($$, 'min_monoid') else None + deconstruct: + assert builtin.has_proto_field($$, 'min_monoid') + $1 = $$.min_monoid | max_monoid construct: $$ = logic.Monoid(max_monoid=$1) - deconstruct: $1 = $$.max_monoid if builtin.has_proto_field($$, 'max_monoid') else None + deconstruct: + assert builtin.has_proto_field($$, 'max_monoid') + $1 = $$.max_monoid | sum_monoid construct: $$ = logic.Monoid(sum_monoid=$1) - deconstruct: $1 = $$.sum_monoid if builtin.has_proto_field($$, 'sum_monoid') else None + deconstruct: + assert builtin.has_proto_field($$, 'sum_monoid') + $1 = $$.sum_monoid or_monoid : "(" "or" ")" @@ -795,13 +954,19 @@ functional_dependency_values data : rel_edb construct: $$ = logic.Data(rel_edb=$1) - deconstruct: $1 = $$.rel_edb if builtin.has_proto_field($$, 'rel_edb') else None + deconstruct: + assert builtin.has_proto_field($$, 'rel_edb') + $1 = $$.rel_edb | betree_relation construct: $$ = logic.Data(betree_relation=$1) - deconstruct: $1 = $$.betree_relation if builtin.has_proto_field($$, 'betree_relation') else None + deconstruct: + assert builtin.has_proto_field($$, 'betree_relation') + $1 = $$.betree_relation | csv_data construct: $$ = logic.Data(csv_data=$1) - deconstruct: $1 = $$.csv_data if builtin.has_proto_field($$, 'csv_data') else None + deconstruct: + assert builtin.has_proto_field($$, 'csv_data') + $1 = $$.csv_data rel_edb_path : "[" STRING* "]" @@ -812,12 +977,17 @@ rel_edb_types rel_edb : "(" "rel_edb" relation_id rel_edb_path rel_edb_types ")" construct: $$ = logic.RelEDB(target_id=$3, path=$4, types=$5) - deconstruct: $3 = $$.target_id; $4 = $$.path; $5 = $$.types + deconstruct: + $3 = $$.target_id + $4 = $$.path + $5 = $$.types betree_relation : "(" "betree_relation" relation_id betree_info ")" construct: $$ = logic.BeTreeRelation(name=$3, relation_info=$4) - deconstruct: $3 = $$.name; $4 = $$.relation_info + deconstruct: + $3 = $$.name + $4 = $$.relation_info betree_info : "(" "betree_info" betree_info_key_types betree_info_value_types config_dict ")" @@ -842,7 +1012,11 @@ csv_asof csv_data : "(" "csv_data" csvlocator csv_config csv_columns csv_asof ")" construct: $$ = logic.CSVData(locator=$3, config=$4, columns=$5, asof=$6) - deconstruct: $3 = $$.locator; $4 = $$.config; $5 = $$.columns; $6 = $$.asof + deconstruct: + $3 = $$.locator + $4 = $$.config + $5 = $$.columns + $6 = $$.asof csv_locator_paths : "(" "paths" STRING* ")" @@ -865,7 +1039,10 @@ csv_config csv_column : "(" "column" STRING relation_id "[" type* "]" ")" construct: $$ = logic.CSVColumn(column_name=$3, target_id=$4, types=$6) - deconstruct: $3 = $$.column_name; $4 = $$.target_id; $6 = $$.types + deconstruct: + $3 = $$.column_name + $4 = $$.target_id + $6 = $$.types undefine : "(" "undefine" fragment_id ")" @@ -883,19 +1060,29 @@ epoch_reads read : demand construct: $$ = transactions.Read(demand=$1) - deconstruct: $1 = $$.demand if builtin.has_proto_field($$, 'demand') else None + deconstruct: + assert builtin.has_proto_field($$, 'demand') + $1 = $$.demand | output construct: $$ = transactions.Read(output=$1) - deconstruct: $1 = $$.output if builtin.has_proto_field($$, 'output') else None + deconstruct: + assert builtin.has_proto_field($$, 'output') + $1 = $$.output | what_if construct: $$ = transactions.Read(what_if=$1) - deconstruct: $1 = $$.what_if if builtin.has_proto_field($$, 'what_if') else None + deconstruct: + assert builtin.has_proto_field($$, 'what_if') + $1 = $$.what_if | abort construct: $$ = transactions.Read(abort=$1) - deconstruct: $1 = $$.abort if builtin.has_proto_field($$, 'abort') else None + deconstruct: + assert builtin.has_proto_field($$, 'abort') + $1 = $$.abort | export construct: $$ = transactions.Read(export=$1) - deconstruct: $1 = $$.export if builtin.has_proto_field($$, 'export') else None + deconstruct: + assert builtin.has_proto_field($$, 'export') + $1 = $$.export demand : "(" "demand" relation_id ")" @@ -905,17 +1092,23 @@ demand output : "(" "output" name? relation_id ")" construct: $$ = transactions.Output(name=builtin.unwrap_option_or($3, "output"), relation_id=$4) - deconstruct: $3 = $$.name if $$.name != "output" else None; $4 = $$.relation_id + deconstruct: + $3 = $$.name if $$.name != "output" else None + $4 = $$.relation_id what_if : "(" "what_if" name epoch ")" construct: $$ = transactions.WhatIf(branch=$3, epoch=$4) - deconstruct: $3 = $$.branch; $4 = $$.epoch + deconstruct: + $3 = $$.branch + $4 = $$.epoch abort : "(" "abort" name? relation_id ")" construct: $$ = transactions.Abort(name=builtin.unwrap_option_or($3, "abort"), relation_id=$4) - deconstruct: $3 = $$.name if $$.name != "abort" else None; $4 = $$.relation_id + deconstruct: + $3 = $$.name if $$.name != "abort" else None + $4 = $$.relation_id export : "(" "export" export_csv_config ")" @@ -939,7 +1132,9 @@ export_csv_columns export_csv_column : "(" "column" STRING relation_id ")" construct: $$ = transactions.ExportCSVColumn(column_name=$3, column_data=$4) - deconstruct: $3 = $$.column_name; $4 = $$.column_data + deconstruct: + $3 = $$.column_name + $4 = $$.column_data %% diff --git a/python-tools/src/meta/parser_gen.py b/python-tools/src/meta/parser_gen.py index 3da2b84f..e3c6cd83 100644 --- a/python-tools/src/meta/parser_gen.py +++ b/python-tools/src/meta/parser_gen.py @@ -6,7 +6,7 @@ Overview -------- -The parser generator takes a Grammar and produces a list of VisitNonterminalDef +The parser generator takes a Grammar and produces a list of ParseNonterminalDef objects, one for each reachable nonterminal. Each definition contains: - The nonterminal being parsed - Parameters (for parameterized nonterminals) @@ -79,7 +79,7 @@ from typing import Dict, List, Optional, Set, Tuple from .grammar import Grammar, Rule, Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Terminal, Sequence from .grammar_utils import is_epsilon, rhs_elements -from .target import Lambda, Call, VisitNonterminalDef, Var, Lit, Let, IfElse, BaseType, ListType, ListExpr, TargetExpr, Seq, While, Assign, VisitNonterminal +from .target import Lambda, Call, ParseNonterminalDef, Var, Lit, Let, IfElse, BaseType, ListType, ListExpr, TargetExpr, Seq, While, Assign, ParseNonterminal from .target_builtins import make_builtin, make_builtin_with_type from .target_utils import apply_lambda from .gensym import gensym @@ -103,7 +103,7 @@ class AmbiguousGrammarError(Exception): pass -def generate_parse_functions(grammar: Grammar, indent: str = "") -> List[VisitNonterminalDef]: +def generate_parse_functions(grammar: Grammar, indent: str = "") -> List[ParseNonterminalDef]: parser_methods = [] reachable, _ = grammar.analysis.partition_nonterminals_by_reachability() for nt in reachable: @@ -112,7 +112,7 @@ def generate_parse_functions(grammar: Grammar, indent: str = "") -> List[VisitNo parser_methods.append(method_code) return parser_methods -def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar, indent: str = "") -> VisitNonterminalDef: +def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar, indent: str = "") -> ParseNonterminalDef: """Generate parse method code as string (preserving existing logic).""" return_type = None rhs = None @@ -138,7 +138,7 @@ def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar tail = IfElse(Call(make_builtin('equal'), [Var(prediction, BaseType('Int64')), Lit(i)]), _generate_parse_rhs_ir(rule.rhs, grammar, follow_set, True, rule.constructor), tail) rhs = Let(Var(prediction, BaseType('Int64')), predictor, tail) assert return_type is not None - return VisitNonterminalDef('parse', lhs, [], return_type, rhs, indent) + return ParseNonterminalDef(lhs, [], return_type, rhs, indent) def _build_predictor(grammar: Grammar, rules: List[Rule]) -> TargetExpr: """Build a predictor expression that returns the index of the matching rule. @@ -330,7 +330,7 @@ def _generate_parse_rhs_ir(rhs: Rhs, grammar: Grammar, follow_set: TerminalSeque return Let(var, parse_expr, apply_lambda(action,[var])) return parse_expr elif isinstance(rhs, Nonterminal): - parse_expr = Call(VisitNonterminal('parse', rhs), []) + parse_expr = Call(ParseNonterminal(rhs), []) if apply_action and action: if len(action.params) == 0: return Seq([parse_expr, apply_lambda(action,[])]) diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index 137bc9fb..aa425d5e 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -12,8 +12,8 @@ from .grammar import Grammar, GrammarConfig, Rule, Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence from .grammar_utils import is_epsilon, rhs_elements from .target import ( - Lambda, Call, VisitNonterminalDef, Var, Lit, Builtin, Let, IfElse, - BaseType, ListType, TupleType, TargetExpr, Seq, VisitNonterminal, gensym, + Lambda, Call, PrintNonterminalDef, Var, Lit, Builtin, Let, IfElse, + BaseType, ListType, TupleType, TargetExpr, Seq, PrintNonterminal, gensym, OptionType, ForeachEnumerated, GetElement ) from .target_builtins import make_builtin @@ -28,7 +28,7 @@ def _get_rules_dict(grammar: GrammarLike) -> Dict[Nonterminal, List[Rule]]: def generate_pretty_functions(grammar: GrammarLike, - proto_messages: Optional[Dict] = None) -> List[VisitNonterminalDef]: + proto_messages: Optional[Dict] = None) -> List[PrintNonterminalDef]: """Generate pretty printer functions for all nonterminals.""" pretty_methods = [] @@ -49,7 +49,7 @@ def generate_pretty_functions(grammar: GrammarLike, def _generate_pretty_method(lhs: Nonterminal, rules: List[Rule], grammar: GrammarLike, - proto_messages: Optional[Dict]) -> VisitNonterminalDef: + proto_messages: Optional[Dict]) -> PrintNonterminalDef: """Generate a pretty-print visitor method for a nonterminal.""" nt = rules[0].lhs msg_param = Var("msg", nt.type) @@ -59,8 +59,7 @@ def _generate_pretty_method(lhs: Nonterminal, rules: List[Rule], else: body = _generate_pretty_alternatives(rules, msg_param, grammar, proto_messages) - return VisitNonterminalDef( - visitor_name='pretty', + return PrintNonterminalDef( nonterminal=nt, params=[msg_param], return_type=OptionType(BaseType("Never")), @@ -185,11 +184,11 @@ def _generate_nonterminal_ref_dispatch(rule: Rule, msg_param: Var, break if guard_deconstructor is None: - return Call(VisitNonterminal('pretty', nt_ref), [msg_param]) + return Call(PrintNonterminal(nt_ref), [msg_param]) deconstruct_result_var = Var(gensym('guard_result'), guard_deconstructor.return_type) deconstruct_call = Call(guard_deconstructor, [msg_param]) - pretty_call = Call(VisitNonterminal('pretty', nt_ref), [msg_param]) + pretty_call = Call(PrintNonterminal(nt_ref), [msg_param]) return Let( deconstruct_result_var, @@ -253,7 +252,7 @@ def _generate_pretty_from_fields(rhs: Rhs, fields_var: Var, formatted = _format_terminal(rhs, fields_var) return Call(make_builtin('write_io'), [formatted]) elif isinstance(rhs, Nonterminal): - return Call(VisitNonterminal('pretty', rhs), [fields_var]) + return Call(PrintNonterminal(rhs), [fields_var]) elif isinstance(rhs, Option): return _generate_pretty_option_from_field(rhs, fields_var, grammar, proto_messages) elif isinstance(rhs, Star): @@ -316,7 +315,7 @@ def _pretty_print_element(elem: Rhs, var: Var, grammar: GrammarLike, formatted = _format_terminal(elem, var) return Call(make_builtin('write_io'), [formatted]) elif isinstance(elem, Nonterminal): - return Call(VisitNonterminal('pretty', elem), [var]) + return Call(PrintNonterminal(elem), [var]) elif isinstance(elem, Option): return _generate_pretty_option_from_field(elem, var, grammar, proto_messages) elif isinstance(elem, Star): @@ -342,7 +341,7 @@ def _generate_pretty_option_from_field(rhs: Option, field_var: Var, formatted = _format_terminal(rhs.rhs, value_var) pretty_inner = Call(make_builtin('write_io'), [formatted]) elif isinstance(rhs.rhs, Nonterminal): - pretty_inner = Call(VisitNonterminal('pretty', rhs.rhs), [value_var]) + pretty_inner = Call(PrintNonterminal(rhs.rhs), [value_var]) elif isinstance(rhs.rhs, Sequence): pretty_inner = _generate_pretty_from_fields(rhs.rhs, value_var, grammar, proto_messages) else: @@ -372,7 +371,7 @@ def _generate_pretty_star_from_field(rhs: Star, field_var: Var, formatted = _format_terminal(rhs.rhs, elem_var) pretty_elem = Call(make_builtin('write_io'), [formatted]) elif isinstance(rhs.rhs, Nonterminal): - pretty_elem = Call(VisitNonterminal('pretty', rhs.rhs), [elem_var]) + pretty_elem = Call(PrintNonterminal(rhs.rhs), [elem_var]) elif isinstance(rhs.rhs, Sequence): pretty_elem = _generate_pretty_from_fields(rhs.rhs, elem_var, grammar, proto_messages) else: @@ -426,7 +425,7 @@ def _format_terminal(terminal: NamedTerminal, value_var: Var) -> TargetExpr: return Call(make_builtin('format_float64'), [value_var]) elif terminal.name == 'BOOL': return Call(make_builtin('format_bool'), [value_var]) - elif terminal.name == 'HEX_UINT128': + elif terminal.name == 'UINT128': return Call(make_builtin('format_uint128'), [value_var]) else: return Call(make_builtin('to_string'), [value_var]) diff --git a/python-tools/src/meta/pretty_gen_python.py b/python-tools/src/meta/pretty_gen_python.py index ba596e0d..100ce20e 100644 --- a/python-tools/src/meta/pretty_gen_python.py +++ b/python-tools/src/meta/pretty_gen_python.py @@ -5,11 +5,10 @@ print method generation, and epilogue. """ -from typing import Optional, Set +from typing import Optional from .grammar import Grammar, Nonterminal from .codegen_python import PythonCodeGenerator -from .codegen_templates import PYTHON_TEMPLATES, PYTHON_PRETTY_TEMPLATES from .pretty_gen import generate_pretty_functions @@ -24,18 +23,23 @@ {command_line_comment}""" from io import StringIO -from typing import Any, IO +from typing import Any, IO, Never, Optional from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 +class ParseError(Exception): + pass + + class PrettyPrinter: """Pretty printer for protobuf messages.""" - def __init__(self, io: IO[str] = None): + def __init__(self, io: Optional[IO[str]] = None): self.io = io if io is not None else StringIO() self.indent_level = 0 self.at_line_start = True + self._debug_info: dict[tuple[int, int], str] = {{}} def write(self, s: str) -> None: """Write a string to the output, with indentation at line start.""" @@ -84,22 +88,30 @@ def fragment_id_to_string(self, msg) -> str: """Convert FragmentId to string representation.""" return msg.id.decode('utf-8') if msg.id else "" - def relation_id_to_string(self, msg): - """Convert RelationId to string representation if it has symbol.""" - if msg.symbol: - return msg.symbol - return None + def start_pretty_fragment(self, msg) -> None: + """Extract debug info from Fragment for relation ID lookup.""" + debug_info = msg.debug_info + for rid, name in zip(debug_info.ids, debug_info.orig_names): + self._debug_info[(rid.id_low, rid.id_high)] = name + + def relation_id_to_string(self, msg) -> str: + """Convert RelationId to string representation using debug info.""" + return self._debug_info.get((msg.id_low, msg.id_high), "") def relation_id_to_int(self, msg): """Convert RelationId to int representation if it has id.""" if msg.id_low or msg.id_high: return (msg.id_high << 64) | msg.id_low return None + + def relation_id_to_uint128(self, msg): + """Convert RelationId to UInt128Value representation.""" + return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) ''' EPILOGUE_TEMPLATE = ''' -def pretty(msg: Any, io: IO[str] = None) -> str: +def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io) printer.pretty_{start_name}(msg) @@ -113,14 +125,17 @@ def generate_pretty_printer_python(grammar: Grammar, command_line: Optional[str] prologue = _generate_prologue(command_line) codegen = PythonCodeGenerator(proto_messages=proto_messages) - # Register pretty-printing templates (on top of the default parser templates) - codegen.register_builtins_from_templates(PYTHON_PRETTY_TEMPLATES) + codegen.named_fun_class = "self" defns = generate_pretty_functions(grammar, proto_messages) lines = [] for defn in defns: lines.append("") lines.append(codegen.generate_def(defn, " ")) + + for fundef in grammar.function_defs.values(): + lines.append("") + lines.append(codegen.generate_method_def(fundef, " ")) lines.append("") epilogue = _generate_epilogue(grammar.start) diff --git a/python-tools/src/meta/target.py b/python-tools/src/meta/target.py index b273d27f..5c50b4db 100644 --- a/python-tools/src/meta/target.py +++ b/python-tools/src/meta/target.py @@ -38,7 +38,7 @@ """ from dataclasses import dataclass, field -from typing import Any, Optional, Sequence, TYPE_CHECKING +from typing import Any, Optional, Sequence, Union, TYPE_CHECKING from .gensym import gensym if TYPE_CHECKING: @@ -278,23 +278,32 @@ def target_type(self) -> 'TargetType': @dataclass(frozen=True) -class VisitNonterminal(TargetExpr): - """Visitor method call for a nonterminal. +class ParseNonterminal(TargetExpr): + """Parse method call for a nonterminal.""" + nonterminal: 'Nonterminal' - Like Call but specifically for calling visitor methods, with a Nonterminal - instead of an expression for the function. - """ - visitor_name: str # e.g., 'parse', 'pretty' + def __str__(self) -> str: + return f"parse_{self.nonterminal.name}" + + def target_type(self) -> 'TargetType': + return self.nonterminal.target_type() + + +@dataclass(frozen=True) +class PrintNonterminal(TargetExpr): + """Pretty-print method call for a nonterminal.""" nonterminal: 'Nonterminal' def __str__(self) -> str: - return f"{self.visitor_name}_{self.nonterminal.name}" + return f"pretty_{self.nonterminal.name}" def target_type(self) -> 'TargetType': - """Return the type of the nonterminal.""" return self.nonterminal.target_type() +VisitNonterminal = Union[ParseNonterminal, PrintNonterminal] + + @dataclass(frozen=True) class Call(TargetExpr): """Function call expression. @@ -313,8 +322,7 @@ def __post_init__(self): _freeze_sequence(self, 'args') def target_type(self) -> 'TargetType': - # For VisitNonterminal, the type is the nonterminal's target type directly - if isinstance(self.func, VisitNonterminal): + if isinstance(self.func, (ParseNonterminal, PrintNonterminal)): return self.func.target_type() func_type = self.func.target_type() if isinstance(func_type, FunctionType): @@ -770,31 +778,48 @@ def __post_init__(self): @dataclass(frozen=True) -class VisitNonterminalDef(TargetNode): - """Visitor method definition for a nonterminal. +class ParseNonterminalDef(TargetNode): + """Parse method definition for a nonterminal.""" + nonterminal: 'Nonterminal' + params: Sequence['Var'] + return_type: TargetType + body: 'TargetExpr' + indent: str = "" - Like FunDef but specifically for visitor methods, with a Nonterminal - instead of a string name. - """ - visitor_name: str # e.g., 'parse', 'pretty' + def __str__(self) -> str: + params_str = ', '.join(f"{p.name}: {p.type}" for p in self.params) + return f"parse_{self.nonterminal.name}({params_str}) -> {self.return_type}: {self.body}" + + def __post_init__(self): + _freeze_sequence(self, 'params') + + def function_type(self) -> 'FunctionType': + return FunctionType([p.type for p in self.params], self.return_type) + + +@dataclass(frozen=True) +class PrintNonterminalDef(TargetNode): + """Pretty-print method definition for a nonterminal.""" nonterminal: 'Nonterminal' params: Sequence['Var'] return_type: TargetType body: 'TargetExpr' - indent: str = "" # base indentation for code generation + indent: str = "" def __str__(self) -> str: params_str = ', '.join(f"{p.name}: {p.type}" for p in self.params) - return f"{self.visitor_name}_{self.nonterminal.name}({params_str}) -> {self.return_type}: {self.body}" + return f"pretty_{self.nonterminal.name}({params_str}) -> {self.return_type}: {self.body}" def __post_init__(self): _freeze_sequence(self, 'params') def function_type(self) -> 'FunctionType': - """Return the function type of this visitor method.""" return FunctionType([p.type for p in self.params], self.return_type) +VisitNonterminalDef = Union[ParseNonterminalDef, PrintNonterminalDef] + + __all__ = [ 'TargetNode', 'TargetExpr', @@ -830,7 +855,11 @@ def function_type(self) -> 'FunctionType': 'OptionType', 'FunctionType', 'FunDef', + 'ParseNonterminalDef', + 'PrintNonterminalDef', 'VisitNonterminalDef', + 'ParseNonterminal', + 'PrintNonterminal', 'VisitNonterminal', 'gensym', ] diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index 5bc602ec..c19b8d20 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -159,6 +159,7 @@ def is_builtin(name: str) -> bool: ListType(MessageType("logic", "Declaration"))], MessageType("fragments", "Fragment")) register_builtin("start_fragment", [MessageType("fragments", "FragmentId")], BaseType("None")) +register_builtin("start_pretty_fragment", [MessageType("fragments", "Fragment")], BaseType("None")) # === Dict operations === register_builtin("dict_from_list", [ListType(TupleType([K, V]))], DictType(K, V)) diff --git a/python-tools/src/meta/target_print.py b/python-tools/src/meta/target_print.py index 2c2de5a5..99212d88 100644 --- a/python-tools/src/meta/target_print.py +++ b/python-tools/src/meta/target_print.py @@ -10,7 +10,7 @@ TargetExpr, Var, Lit, Symbol, Builtin, NamedFun, NewMessage, OneOf, ListExpr, Call, Lambda, Let, IfElse, Seq, While, Assign, Return, GetField, GetElement, - VisitNonterminal, FunDef + ParseNonterminal, PrintNonterminal, FunDef ) @@ -128,8 +128,11 @@ def expr_to_str(expr: TargetExpr) -> str: elif isinstance(expr, GetElement): return f"{expr_to_str(expr.tuple_expr)}[{expr.index}]" - elif isinstance(expr, VisitNonterminal): - return f"visit_{expr.nonterminal.name}()" + elif isinstance(expr, ParseNonterminal): + return f"parse_{expr.nonterminal.name}()" + + elif isinstance(expr, PrintNonterminal): + return f"pretty_{expr.nonterminal.name}()" else: return str(expr) diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 7e588fb6..29488d91 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -610,12 +610,20 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', except SyntaxError as e: raise YaccGrammarError(f"Syntax error in deconstruct action: {e}", line) - # Extract $N assignments from the AST + # Extract assert conditions, side-effects, and $N assignments from the AST # assignments maps 1-indexed $N to the expression AST node assignments: Dict[int, ast.expr] = {} + assert_conditions: List[ast.expr] = [] + side_effects: List[ast.expr] = [] extra_vars: Dict[str, TargetType] = {"_dollar_dollar": lhs_type} for stmt in tree.body: + if isinstance(stmt, ast.Assert): + assert_conditions.append(stmt.test) + continue + if isinstance(stmt, ast.Expr): + side_effects.append(stmt.value) + continue if isinstance(stmt, ast.Assign) and len(stmt.targets) == 1: target = stmt.targets[0] if isinstance(target, ast.Name) and target.id.startswith('_dollar_') and target.id[8:].isdigit(): @@ -623,7 +631,8 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', assignments[dollar_idx] = stmt.value continue raise YaccGrammarError( - f"Deconstruct actions must be $N = expr assignments. Got: {ast.dump(stmt)}", + f"Deconstruct actions must be assert, side-effect expressions, " + f"or $N = expr assignments. Got: {ast.dump(stmt)}", line) # Validate all non-literal RHS elements are assigned @@ -649,27 +658,28 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', expr = _convert_node_with_vars(assignments[idx], param_info, empty_params, ctx, line, extra_vars) converted.append(expr) - # Detect conditional assignments: IfElse(cond, then_val, None) - # These are guards — if any condition fails, the deconstruct should return None. - conditions: List[TargetExpr] = [] - unconditional: List[TargetExpr] = [] - for expr in converted: - if (isinstance(expr, IfElse) and isinstance(expr.else_branch, Lit) - and expr.else_branch.value is None): - conditions.append(expr.condition) - unconditional.append(expr.then_branch) - else: - unconditional.append(expr) - - if conditions: - # Build guarded body: if all conditions met, return Some(tuple); else None - if len(unconditional) == 1: - success_body: TargetExpr = Call(_make_builtin('some'), [unconditional[0]]) - inner_type = _infer_type(unconditional[0], line, ctx) + # Convert side-effect expressions to target IR + side_effect_exprs: List[TargetExpr] = [] + for se_node in side_effects: + se_expr = _convert_node_with_vars(se_node, param_info, empty_params, ctx, line, extra_vars) + side_effect_exprs.append(se_expr) + + # Build body from assert conditions and assignments + if assert_conditions: + # Convert assert conditions to target IR + conditions: List[TargetExpr] = [] + for cond_node in assert_conditions: + cond_expr = _convert_node_with_vars(cond_node, param_info, empty_params, ctx, line, extra_vars) + conditions.append(cond_expr) + + # Build guarded body: if all conditions met, return Some(vals); else None + if len(converted) == 1: + success_body: TargetExpr = Call(_make_builtin('some'), [converted[0]]) + inner_type = _infer_type(converted[0], line, ctx) else: - tuple_expr = Call(_make_builtin('tuple'), unconditional) + tuple_expr = Call(_make_builtin('tuple'), converted) success_body = Call(_make_builtin('some'), [tuple_expr]) - element_types = [_infer_type(c, line, ctx) for c in unconditional] + element_types = [_infer_type(c, line, ctx) for c in converted] inner_type = TupleType(tuple(element_types)) # Combine conditions with 'and' @@ -687,6 +697,10 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', element_types = [_infer_type(c, line, ctx) for c in converted] return_type = TupleType(tuple(element_types)) + # Wrap with side-effects if any + if side_effect_exprs: + body = Seq(tuple(side_effect_exprs) + (body,)) + return Lambda([msg_param], return_type, body) diff --git a/python-tools/tests/meta/test_codegen_julia.py b/python-tools/tests/meta/test_codegen_julia.py index 3b1e81e5..1b4c75e8 100644 --- a/python-tools/tests/meta/test_codegen_julia.py +++ b/python-tools/tests/meta/test_codegen_julia.py @@ -3,7 +3,7 @@ from meta.target import ( Var, Lit, Symbol, NamedFun, NewMessage, ListExpr, Call, Lambda, Let, - IfElse, Seq, While, Assign, Return, FunDef, VisitNonterminalDef, + IfElse, Seq, While, Assign, Return, FunDef, ParseNonterminalDef, BaseType, MessageType, ListType, OptionType, GetElement, FunctionType, ) from meta.target_builtins import make_builtin @@ -312,7 +312,7 @@ def test_julia_fun_def_generation(): def test_julia_visit_nonterminal_def_generation(): - """Test Julia VisitNonterminalDef code generation.""" + """Test Julia ParseNonterminalDef code generation.""" gen = JuliaCodeGenerator() # Create a nonterminal @@ -320,8 +320,7 @@ def test_julia_visit_nonterminal_def_generation(): # Simple parse method reset_gensym() - parse_def = VisitNonterminalDef( - visitor_name="parse", + parse_def = ParseNonterminalDef( nonterminal=nt, params=[], return_type=MessageType("logic", "Expr"), @@ -334,8 +333,7 @@ def test_julia_visit_nonterminal_def_generation(): # Parse method with parameters reset_gensym() - parse_def = VisitNonterminalDef( - visitor_name="parse", + parse_def = ParseNonterminalDef( nonterminal=nt, params=[Var("context", _str_type)], return_type=MessageType("logic", "Expr"), diff --git a/python-tools/tests/meta/test_codegen_python.py b/python-tools/tests/meta/test_codegen_python.py index 2ae0c37c..faa5aded 100644 --- a/python-tools/tests/meta/test_codegen_python.py +++ b/python-tools/tests/meta/test_codegen_python.py @@ -3,7 +3,7 @@ from meta.target import ( Var, Lit, Symbol, NamedFun, NewMessage, ListExpr, Call, Lambda, Let, - IfElse, Seq, While, Assign, Return, FunDef, VisitNonterminalDef, + IfElse, Seq, While, Assign, Return, FunDef, ParseNonterminalDef, BaseType, MessageType, ListType, OptionType, GetElement, FunctionType, ) from meta.target_builtins import make_builtin @@ -363,7 +363,7 @@ def test_python_fun_def_generation(): def test_python_visit_nonterminal_def_generation(): - """Test Python VisitNonterminalDef code generation.""" + """Test Python ParseNonterminalDef code generation.""" gen = PythonCodeGenerator() # Create a nonterminal @@ -371,8 +371,7 @@ def test_python_visit_nonterminal_def_generation(): # Simple parse method reset_gensym() - parse_def = VisitNonterminalDef( - visitor_name="parse", + parse_def = ParseNonterminalDef( nonterminal=nt, params=[], return_type=MessageType("logic", "Expr"), @@ -384,8 +383,7 @@ def test_python_visit_nonterminal_def_generation(): # Parse method with parameters reset_gensym() - parse_def = VisitNonterminalDef( - visitor_name="parse", + parse_def = ParseNonterminalDef( nonterminal=nt, params=[Var("context", _str_type)], return_type=MessageType("logic", "Expr"), diff --git a/python-tools/tests/meta/test_parser_gen.py b/python-tools/tests/meta/test_parser_gen.py index 315d0b08..af72bc6f 100644 --- a/python-tools/tests/meta/test_parser_gen.py +++ b/python-tools/tests/meta/test_parser_gen.py @@ -9,12 +9,12 @@ sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src")) from meta.grammar import make_rule, Grammar, Rule, Nonterminal, LitTerminal, NamedTerminal, Option, Star, Sequence -from meta.target import Lambda, Var, MessageType, VisitNonterminalDef, BaseType, ListType +from meta.target import Lambda, Var, MessageType, ParseNonterminalDef, BaseType, ListType from meta.parser_gen import generate_parse_functions, GrammarConflictError, AmbiguousGrammarError def test_generate_parse_functions_simple(): - """Test that generate_parse_functions produces VisitNonterminalDef for each nonterminal.""" + """Test that generate_parse_functions produces ParseNonterminalDef for each nonterminal.""" # Create a simple grammar: S -> "a" s_type = MessageType("test", "S") s = Nonterminal("S", s_type) @@ -29,7 +29,7 @@ def test_generate_parse_functions_simple(): # Should have one definition for S assert len(defs) == 1 - assert isinstance(defs[0], VisitNonterminalDef) + assert isinstance(defs[0], ParseNonterminalDef) assert defs[0].nonterminal == s diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py new file mode 100644 index 00000000..0cd3041e --- /dev/null +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -0,0 +1,132 @@ +"""Tests for the generated pretty printer. + +Three test suites: +1. Roundtrip (idempotency): parse → print → parse → print → compare the two prints. +2. Comparison: generated pretty printer output vs old IR-based pretty printer output. +3. Bin roundtrip: parse .bin → print → re-parse → compare protobuf with original. +""" + +import pytest +from pathlib import Path + +from lqp.parser import parse_lqp +from lqp.emit import ir_to_proto +from lqp.generated_pretty_printer import pretty +from lqp.generated_parser import parse as generated_parse +from lqp.cli import read_bin_to_proto +import lqp.print as lqp_print + +from .utils import get_lqp_input_files, get_all_files, PARENT_DIR + + +# Files where the generated pretty printer crashes (proto field issues). +PRETTY_PRINT_CRASHES = { + "arithmetic", + "csv", + "edb", + "loops", + "monoid_monus", + "multiple_export", + "outer", + "piece_of_q1", + "primitives", + "quantifier", + "simple_cast", + "simple_relatom", + "unicode", + "upsert", + "value_types", +} + +BIN_DIR = PARENT_DIR / "test_files" / "bin" + + +def get_bin_input_files(): + """Find all .bin files in the test inputs directory.""" + return get_all_files(BIN_DIR, ".bin") + + +def _stem(path: str) -> str: + return Path(path).stem + + +def _parse_and_pretty(input_file: str) -> str: + """Parse an .lqp file through IR → protobuf → generated pretty printer.""" + with open(input_file, "r") as f: + content = f.read() + ir_node = parse_lqp(input_file, content) + proto = ir_to_proto(ir_node) + return pretty(proto) + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_roundtrip_idempotent(input_file): + """Parse → print → parse → print, then compare the two printed outputs.""" + stem = _stem(input_file) + if stem in PRETTY_PRINT_CRASHES: + pytest.xfail(f"{stem}: generated pretty printer crashes") + + # First pass: .lqp → IR → proto → pretty-print + text1 = _parse_and_pretty(input_file) + + # Second pass: parse printed output → proto → pretty-print again + proto2 = generated_parse(text1) + text2 = pretty(proto2) + + assert text1 == text2, ( + f"Pretty printer is not idempotent for {stem}.\n" + f"=== First print ===\n{text1}\n" + f"=== Second print ===\n{text2}" + ) + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_matches_old_pretty_printer(input_file): + """Compare generated pretty printer output to old IR-based pretty printer.""" + stem = _stem(input_file) + if stem in PRETTY_PRINT_CRASHES: + pytest.xfail(f"{stem}: generated pretty printer crashes") + + with open(input_file, "r") as f: + content = f.read() + + # Generated pretty printer: IR → proto → pretty + ir_node = parse_lqp(input_file, content) + proto = ir_to_proto(ir_node) + generated_output = pretty(proto) + + # Old pretty printer: IR → string (with names, no debug info) + options = lqp_print.ugly_config.copy() + options[str(lqp_print.PrettyOptions.PRINT_NAMES)] = True + options[str(lqp_print.PrettyOptions.PRINT_DEBUG)] = False + old_output = lqp_print.to_string(ir_node, options) + + assert generated_output == old_output, ( + f"Outputs differ for {stem}.\n" + f"=== Generated ===\n{generated_output}\n" + f"=== Old (PRINT_NAMES) ===\n{old_output}" + ) + + +@pytest.mark.parametrize("input_file", get_bin_input_files()) +def test_bin_roundtrip(input_file): + """Parse .bin → print → re-parse → compare protobuf with original.""" + stem = _stem(input_file) + if stem in PRETTY_PRINT_CRASHES: + pytest.xfail(f"{stem}: generated pretty printer crashes") + + # Parse binary protobuf + proto1 = read_bin_to_proto(input_file) + + # Pretty-print → re-parse + text = pretty(proto1) + proto2 = generated_parse(text) + + # Compare serialized protobufs + binary1 = proto1.SerializeToString() + binary2 = proto2.SerializeToString() + + assert binary1 == binary2, ( + f"Bin roundtrip failed for {stem}.\n" + f"=== Pretty-printed ===\n{text}" + ) From 3f9f682d7d074f2363bdd0b3ba486e8da387bd56 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Tue, 10 Feb 2026 19:09:08 +0100 Subject: [PATCH 03/25] WIP checkpoint --- .../src/lqp/generated_pretty_printer.py | 115 +++-- python-tools/src/meta/codegen_templates.py | 4 +- python-tools/src/meta/grammar.y | 418 +++++++++--------- python-tools/src/meta/pretty_gen.py | 14 +- python-tools/src/meta/pretty_gen_python.py | 141 +----- python-tools/src/meta/target_builtins.py | 2 + .../meta/templates/pretty_printer.py.template | 126 ++++++ python-tools/src/meta/yacc_action_parser.py | 101 ++++- .../tests/test_generated_pretty_printer.py | 46 +- 9 files changed, 559 insertions(+), 408 deletions(-) create mode 100644 python-tools/src/meta/templates/pretty_printer.py.template diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py index c322bfb0..fdff3383 100644 --- a/python-tools/src/lqp/generated_pretty_printer.py +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -55,16 +55,30 @@ def get_output(self) -> str: return "" def format_decimal(self, msg) -> str: - """Format a DecimalValue protobuf message as a string.""" - # DecimalValue has 'value' field as string - return str(msg.value) if msg.value else "0" + """Format a DecimalValue as '.d'.""" + int_val = (msg.value.high << 64) | msg.value.low + if msg.value.high & (1 << 63): + int_val -= (1 << 128) + sign = "" + if int_val < 0: + sign = "-" + int_val = -int_val + digits = str(int_val) + scale = msg.scale + if scale <= 0: + decimal_str = digits + "." + "0" * (-scale) + elif scale >= len(digits): + decimal_str = "0." + "0" * (scale - len(digits)) + digits + else: + decimal_str = digits[:-scale] + "." + digits[-scale:] + return sign + decimal_str + "d" + str(msg.precision) def format_int128(self, msg) -> str: - """Format an Int128Value protobuf message as a string.""" + """Format an Int128Value protobuf message as a string with i128 suffix.""" value = (msg.high << 64) | msg.low if msg.high & (1 << 63): value -= (1 << 128) - return str(value) + return str(value) + "i128" def format_uint128(self, msg) -> str: """Format a UInt128Value protobuf message as a hex string.""" @@ -81,20 +95,26 @@ def start_pretty_fragment(self, msg) -> None: for rid, name in zip(debug_info.ids, debug_info.orig_names): self._debug_info[(rid.id_low, rid.id_high)] = name - def relation_id_to_string(self, msg) -> str: + def relation_id_to_string(self, msg): """Convert RelationId to string representation using debug info.""" - return self._debug_info.get((msg.id_low, msg.id_high), "") + return self._debug_info.get((msg.id_low, msg.id_high)) def relation_id_to_int(self, msg): - """Convert RelationId to int representation if it has id.""" - if msg.id_low or msg.id_high: - return (msg.id_high << 64) | msg.id_low + """Convert RelationId to int if it fits in signed 64-bit range.""" + value = (msg.id_high << 64) | msg.id_low + if value <= 0x7FFFFFFFFFFFFFFF: + return value return None def relation_id_to_uint128(self, msg): """Convert RelationId to UInt128Value representation.""" return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) + def format_string_value(self, s: str) -> str: + """Format a string value with double quotes for LQP output.""" + escaped = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t') + return '"' + escaped + '"' + def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: def _t493(_dollar_dollar): _t494 = self.is_default_configure(_dollar_dollar.configure) @@ -167,6 +187,7 @@ def _t507(_dollar_dollar): fields11 = _t508 unwrapped_fields12 = fields11 self.write('{') + self.write(' ') for i14, elem13 in enumerate(unwrapped_fields12): if (i14 > 0): @@ -175,6 +196,7 @@ def _t507(_dollar_dollar): else: _t509 = None _t510 = self.pretty_config_key_value(elem13) + self.write(' ') self.write('}') return None @@ -185,8 +207,10 @@ def _t511(_dollar_dollar): fields15 = _t512 unwrapped_fields16 = fields15 self.write(':') + self.write(' ') field17 = unwrapped_fields16[0] self.write(field17) + self.write(' ') field18 = unwrapped_fields16[1] _t513 = self.pretty_value(field18) return _t513 @@ -231,7 +255,7 @@ def _t524(_dollar_dollar): deconstruct_result27 = _t526 if deconstruct_result27 is not None: - self.write(repr(deconstruct_result27)) + self.write(self.format_string_value(deconstruct_result27)) _t527 = None else: def _t528(_dollar_dollar): @@ -287,7 +311,7 @@ def _t540(_dollar_dollar): deconstruct_result23 = _t542 if deconstruct_result23 is not None: - self.write(str(deconstruct_result23)) + self.write(self.format_int128(deconstruct_result23)) _t543 = None else: def _t544(_dollar_dollar): @@ -301,7 +325,7 @@ def _t544(_dollar_dollar): deconstruct_result22 = _t546 if deconstruct_result22 is not None: - self.write(str(deconstruct_result22)) + self.write(self.format_decimal(deconstruct_result22)) _t547 = None else: def _t548(_dollar_dollar): @@ -438,6 +462,7 @@ def _t566(_dollar_dollar): fields53 = _t567 unwrapped_fields54 = fields53 self.write(':') + self.write(' ') self.write(unwrapped_fields54) return None @@ -652,16 +677,16 @@ def _t617(_dollar_dollar): else: def _t622(_dollar_dollar): - if _dollar_dollar.HasField('rel_edb'): - _t623 = _dollar_dollar.rel_edb + if _dollar_dollar.HasField('data'): + _t623 = _dollar_dollar.data else: _t623 = None return _t623 _t624 = _t622(msg) - guard_result78 = _t624 + deconstruct_result78 = _t624 - if guard_result78 is not None: - _t626 = self.pretty_data(msg) + if deconstruct_result78 is not None: + _t626 = self.pretty_data(deconstruct_result78) _t625 = _t626 else: raise ParseError('No matching rule for declaration') @@ -713,6 +738,7 @@ def _t634(_dollar_dollar): if deconstruct_result89 is not None: self.write(':') + self.write(' ') self.write(deconstruct_result89) _t637 = None else: @@ -738,10 +764,13 @@ def _t642(_dollar_dollar): fields90 = _t644 unwrapped_fields91 = fields90 self.write('(') + self.write(' ') field92 = unwrapped_fields91[0] _t645 = self.pretty_bindings(field92) + self.write(' ') field93 = unwrapped_fields91[1] _t646 = self.pretty_formula(field93) + self.write(' ') self.dedent() self.write(')') self.newline() @@ -759,6 +788,7 @@ def _t647(_dollar_dollar): fields94 = _t649 unwrapped_fields95 = fields94 self.write('[') + self.write(' ') field96 = unwrapped_fields95[0] for i98, elem97 in enumerate(field96): @@ -768,6 +798,7 @@ def _t647(_dollar_dollar): else: _t650 = None _t651 = self.pretty_binding(elem97) + self.write(' ') field99 = unwrapped_fields95[1] if field99 is not None: @@ -776,6 +807,7 @@ def _t647(_dollar_dollar): _t652 = _t653 else: _t652 = None + self.write(' ') self.write(']') return None @@ -787,7 +819,9 @@ def _t654(_dollar_dollar): unwrapped_fields102 = fields101 field103 = unwrapped_fields102[0] self.write(field103) + self.write(' ') self.write('::') + self.write(' ') field104 = unwrapped_fields102[1] _t656 = self.pretty_type(field104) return _t656 @@ -1077,6 +1111,7 @@ def _t734(_dollar_dollar): fields140 = _t735 unwrapped_fields141 = fields140 self.write('|') + self.write(' ') for i143, elem142 in enumerate(unwrapped_fields141): if (i143 > 0): @@ -1525,6 +1560,7 @@ def _t852(_dollar_dollar): fields195 = _t853 unwrapped_fields196 = fields195 self.write(':') + self.write(' ') self.write(unwrapped_fields196) return None @@ -2021,16 +2057,16 @@ def _t967(_dollar_dollar): else: def _t972(_dollar_dollar): - if _dollar_dollar.HasField('var'): - _t973 = _dollar_dollar.var + if _dollar_dollar.HasField('term'): + _t973 = _dollar_dollar.term else: _t973 = None return _t973 _t974 = _t972(msg) - guard_result268 = _t974 + deconstruct_result268 = _t974 - if guard_result268 is not None: - _t976 = self.pretty_term(msg) + if deconstruct_result268 is not None: + _t976 = self.pretty_term(deconstruct_result268) _t975 = _t976 else: raise ParseError('No matching rule for rel_term') @@ -2044,6 +2080,7 @@ def _t977(_dollar_dollar): fields270 = _t978 unwrapped_fields271 = fields270 self.write('#') + self.write(' ') _t979 = self.pretty_value(unwrapped_fields271) return _t979 @@ -2211,16 +2248,16 @@ def _t1007(_dollar_dollar): else: def _t1012(_dollar_dollar): - if _dollar_dollar.HasField('assign'): - _t1013 = _dollar_dollar.assign + if _dollar_dollar.HasField('instruction'): + _t1013 = _dollar_dollar.instruction else: _t1013 = None return _t1013 _t1014 = _t1012(msg) - guard_result302 = _t1014 + deconstruct_result302 = _t1014 - if guard_result302 is not None: - _t1016 = self.pretty_instruction(msg) + if deconstruct_result302 is not None: + _t1016 = self.pretty_instruction(deconstruct_result302) _t1015 = _t1016 else: raise ParseError('No matching rule for construct') @@ -2424,10 +2461,13 @@ def _t1064(_dollar_dollar): fields329 = _t1066 unwrapped_fields330 = fields329 self.write('(') + self.write(' ') field331 = unwrapped_fields330[0] _t1067 = self.pretty_bindings(field331) + self.write(' ') field332 = unwrapped_fields330[1] _t1068 = self.pretty_formula(field332) + self.write(' ') self.dedent() self.write(')') self.newline() @@ -2817,6 +2857,7 @@ def _t1157(_dollar_dollar): fields387 = _t1158 unwrapped_fields388 = fields387 self.write('[') + self.write(' ') for i390, elem389 in enumerate(unwrapped_fields388): if (i390 > 0): @@ -2824,7 +2865,8 @@ def _t1157(_dollar_dollar): _t1159 = None else: _t1159 = None - self.write(repr(elem389)) + self.write(self.format_string_value(elem389)) + self.write(' ') self.write(']') return None @@ -2835,6 +2877,7 @@ def _t1160(_dollar_dollar): fields391 = _t1161 unwrapped_fields392 = fields391 self.write('[') + self.write(' ') for i394, elem393 in enumerate(unwrapped_fields392): if (i394 > 0): @@ -2843,6 +2886,7 @@ def _t1160(_dollar_dollar): else: _t1162 = None _t1163 = self.pretty_type(elem393) + self.write(' ') self.write(']') return None @@ -3021,7 +3065,7 @@ def _t1196(_dollar_dollar): _t1198 = None else: _t1198 = None - self.write(repr(elem426)) + self.write(self.format_string_value(elem426)) self.dedent() self.write(')') self.newline() @@ -3037,7 +3081,7 @@ def _t1199(_dollar_dollar): self.write('inline_data') self.newline() self.indent() - self.write(repr(unwrapped_fields429)) + self.write(self.format_string_value(unwrapped_fields429)) self.dedent() self.write(')') self.newline() @@ -3094,7 +3138,7 @@ def _t1209(_dollar_dollar): self.newline() self.indent() field438 = unwrapped_fields437[0] - self.write(repr(field438)) + self.write(self.format_string_value(field438)) self.newline() field439 = unwrapped_fields437[1] _t1211 = self.pretty_relation_id(field439) @@ -3125,7 +3169,7 @@ def _t1214(_dollar_dollar): self.write('asof') self.newline() self.indent() - self.write(repr(unwrapped_fields444)) + self.write(self.format_string_value(unwrapped_fields444)) self.dedent() self.write(')') self.newline() @@ -3419,7 +3463,7 @@ def _t1280(_dollar_dollar): self.write('path') self.newline() self.indent() - self.write(repr(unwrapped_fields484)) + self.write(self.format_string_value(unwrapped_fields484)) self.dedent() self.write(')') self.newline() @@ -3459,7 +3503,7 @@ def _t1286(_dollar_dollar): self.newline() self.indent() field491 = unwrapped_fields490[0] - self.write(repr(field491)) + self.write(self.format_string_value(field491)) self.newline() field492 = unwrapped_fields490[1] _t1288 = self.pretty_relation_id(field492) @@ -3903,3 +3947,4 @@ def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: printer = PrettyPrinter(io) printer.pretty_transaction(msg) return printer.get_output() + diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index a0b3988b..6eacf6d1 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -75,7 +75,7 @@ class BuiltinTemplate: "format_int64": BuiltinTemplate("str({0})"), "format_int32": BuiltinTemplate("str({0})"), "format_float64": BuiltinTemplate("str({0})"), - "format_string": BuiltinTemplate("repr({0})"), + "format_string": BuiltinTemplate("self.format_string_value({0})"), "format_symbol": BuiltinTemplate("{0}"), "format_bool": BuiltinTemplate("('true' if {0} else 'false')"), "format_decimal": BuiltinTemplate("self.format_decimal({0})"), @@ -150,7 +150,7 @@ class BuiltinTemplate: "format_int64": BuiltinTemplate("string({0})"), "format_int32": BuiltinTemplate("string({0})"), "format_float64": BuiltinTemplate("string({0})"), - "format_string": BuiltinTemplate("repr({0})"), + "format_string": BuiltinTemplate("format_string_value({0})"), "format_symbol": BuiltinTemplate("{0}"), "format_bool": BuiltinTemplate("({0} ? \"true\" : \"false\")"), "format_decimal": BuiltinTemplate("format_decimal(pp, {0})"), diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 24590186..302aa36c 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -182,14 +182,14 @@ transaction : "(" "transaction" configure? sync? epoch* ")" construct: $$ = transactions.Transaction(epochs=$5, configure=builtin.unwrap_option_or($3, default_configure()), sync=$4) deconstruct: - $3 = $$.configure if not is_default_configure($$.configure) else None - $4 = $$.sync # TODO: if sync.fragments is not empty else None - $5 = $$.epochs + $3: Optional[transactions.Configure] = $$.configure if not is_default_configure($$.configure) else None + $4: Optional[transactions.Sync] = $$.sync # TODO: if sync.fragments is not empty else None + $5: List[transactions.Epoch] = $$.epochs configure : "(" "configure" config_dict ")" construct: $$ = construct_configure($3) - deconstruct: $3 = deconstruct_configure($$) + deconstruct: $3: List[Tuple[String, logic.Value]] = deconstruct_configure($$) config_dict : "{" config_key_value* "}" @@ -198,77 +198,77 @@ config_key_value : ":" SYMBOL value construct: $$ = builtin.tuple($2, $3) deconstruct: - $2 = $$[0] - $3 = $$[1] + $2: String = $$[0] + $3: logic.Value = $$[1] value : date construct: $$ = logic.Value(date_value=$1) deconstruct: assert builtin.has_proto_field($$, 'date_value') - $1 = $$.date_value + $1: logic.DateValue = $$.date_value | datetime construct: $$ = logic.Value(datetime_value=$1) deconstruct: assert builtin.has_proto_field($$, 'datetime_value') - $1 = $$.datetime_value + $1: logic.DateTimeValue = $$.datetime_value | STRING construct: $$ = logic.Value(string_value=$1) deconstruct: assert builtin.has_proto_field($$, 'string_value') - $1 = $$.string_value + $1: String = $$.string_value | INT construct: $$ = logic.Value(int_value=$1) deconstruct: assert builtin.has_proto_field($$, 'int_value') - $1 = $$.int_value + $1: Int64 = $$.int_value | FLOAT construct: $$ = logic.Value(float_value=$1) deconstruct: assert builtin.has_proto_field($$, 'float_value') - $1 = $$.float_value + $1: Float64 = $$.float_value | UINT128 construct: $$ = logic.Value(uint128_value=$1) deconstruct: assert builtin.has_proto_field($$, 'uint128_value') - $1 = $$.uint128_value + $1: logic.UInt128Value = $$.uint128_value | INT128 construct: $$ = logic.Value(int128_value=$1) deconstruct: assert builtin.has_proto_field($$, 'int128_value') - $1 = $$.int128_value + $1: logic.Int128Value = $$.int128_value | DECIMAL construct: $$ = logic.Value(decimal_value=$1) deconstruct: assert builtin.has_proto_field($$, 'decimal_value') - $1 = $$.decimal_value + $1: logic.DecimalValue = $$.decimal_value | "missing" construct: $$ = logic.Value(missing_value=logic.MissingValue()) | boolean_value construct: $$ = logic.Value(boolean_value=$1) deconstruct: assert builtin.has_proto_field($$, 'boolean_value') - $1 = $$.boolean_value + $1: Boolean = $$.boolean_value date : "(" "date" INT INT INT ")" construct: $$ = logic.DateValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5)) deconstruct: - $3 = builtin.int32_to_int64($$.year) - $4 = builtin.int32_to_int64($$.month) - $5 = builtin.int32_to_int64($$.day) + $3: Int64 = builtin.int32_to_int64($$.year) + $4: Int64 = builtin.int32_to_int64($$.month) + $5: Int64 = builtin.int32_to_int64($$.day) datetime : "(" "datetime" INT INT INT INT INT INT INT? ")" construct: $$ = logic.DateTimeValue(year=builtin.int64_to_int32($3), month=builtin.int64_to_int32($4), day=builtin.int64_to_int32($5), hour=builtin.int64_to_int32($6), minute=builtin.int64_to_int32($7), second=builtin.int64_to_int32($8), microsecond=builtin.int64_to_int32(builtin.unwrap_option_or($9, 0))) deconstruct: - $3 = builtin.int32_to_int64($$.year) - $4 = builtin.int32_to_int64($$.month) - $5 = builtin.int32_to_int64($$.day) - $6 = builtin.int32_to_int64($$.hour) - $7 = builtin.int32_to_int64($$.minute) - $8 = builtin.int32_to_int64($$.second) - $9 = builtin.int32_to_int64($$.microsecond) + $3: Int64 = builtin.int32_to_int64($$.year) + $4: Int64 = builtin.int32_to_int64($$.month) + $5: Int64 = builtin.int32_to_int64($$.day) + $6: Int64 = builtin.int32_to_int64($$.hour) + $7: Int64 = builtin.int32_to_int64($$.minute) + $8: Int64 = builtin.int32_to_int64($$.second) + $9: Optional[Int64] = builtin.int32_to_int64($$.microsecond) boolean_value : "true" @@ -279,19 +279,19 @@ boolean_value sync : "(" "sync" fragment_id* ")" construct: $$ = transactions.Sync(fragments=$3) - deconstruct: $3 = $$.fragments + deconstruct: $3: List[fragments.FragmentId] = $$.fragments fragment_id : ":" SYMBOL construct: $$ = builtin.fragment_id_from_string($2) - deconstruct: $2 = builtin.fragment_id_to_string($$) + deconstruct: $2: String = builtin.fragment_id_to_string($$) epoch : "(" "epoch" epoch_writes? epoch_reads? ")" construct: $$ = transactions.Epoch(writes=builtin.unwrap_option_or($3, list[transactions.Write]()), reads=builtin.unwrap_option_or($4, list[transactions.Read]())) deconstruct: - $3 = $$.writes if not builtin.is_empty($$.writes) else None - $4 = $$.reads if not builtin.is_empty($$.reads) else None + $3: Optional[List[transactions.Write]] = $$.writes if not builtin.is_empty($$.writes) else None + $4: Optional[List[transactions.Read]] = $$.reads if not builtin.is_empty($$.reads) else None epoch_writes : "(" "writes" write* ")" @@ -301,30 +301,30 @@ write construct: $$ = transactions.Write(define=$1) deconstruct: assert builtin.has_proto_field($$, 'define') - $1 = $$.define + $1: transactions.Define = $$.define | undefine construct: $$ = transactions.Write(undefine=$1) deconstruct: assert builtin.has_proto_field($$, 'undefine') - $1 = $$.undefine + $1: transactions.Undefine = $$.undefine | context construct: $$ = transactions.Write(context=$1) deconstruct: assert builtin.has_proto_field($$, 'context') - $1 = $$.context + $1: transactions.Context = $$.context define : "(" "define" fragment ")" construct: $$ = transactions.Define(fragment=$3) - deconstruct: $3 = $$.fragment + deconstruct: $3: fragments.Fragment = $$.fragment fragment : "(" "fragment" new_fragment_id declaration* ")" construct: $$ = builtin.construct_fragment($3, $4) deconstruct: builtin.start_pretty_fragment($$) - $3 = $$.id - $4 = $$.declarations + $3: fragments.FragmentId = $$.id + $4: List[logic.Declaration] = $$.declarations new_fragment_id : fragment_id @@ -337,116 +337,116 @@ declaration construct: $$ = logic.Declaration(def=$1) deconstruct: assert builtin.has_proto_field($$, 'def') - $1 = $$.def + $1: logic.Def = $$.def | algorithm construct: $$ = logic.Declaration(algorithm=$1) deconstruct: assert builtin.has_proto_field($$, 'algorithm') - $1 = $$.algorithm + $1: logic.Algorithm = $$.algorithm | constraint construct: $$ = logic.Declaration(constraint=$1) deconstruct: assert builtin.has_proto_field($$, 'constraint') - $1 = $$.constraint + $1: logic.Constraint = $$.constraint | data construct: $$ = logic.Declaration(data=$1) deconstruct: assert builtin.has_proto_field($$, 'data') - $1 = $$.data + $1: logic.Data = $$.data def : "(" "def" relation_id abstraction attrs? ")" construct: $$ = logic.Def(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) deconstruct: - $3 = $$.name - $4 = $$.body - $5 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.RelationId = $$.name + $4: logic.Abstraction = $$.body + $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None relation_id : ":" SYMBOL construct: $$ = builtin.relation_id_from_string($2) - deconstruct: $2 = deconstruct_relation_id_string($$) + deconstruct: $2: String = deconstruct_relation_id_string($$) | UINT128 construct: $$ = builtin.relation_id_from_uint128($1) - deconstruct: $1 = deconstruct_relation_id_uint128($$) + deconstruct: $1: logic.UInt128Value = deconstruct_relation_id_uint128($$) abstraction : "(" bindings formula ")" construct: $$ = logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3) deconstruct: - $2 = deconstruct_bindings($$) - $3 = $$.value + $2: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings($$) + $3: logic.Formula = $$.value bindings : "[" binding* value_bindings? "]" construct: $$ = builtin.tuple($2, builtin.unwrap_option_or($3, list[logic.Binding]())) deconstruct: - $2 = $$[0] - $3 = $$[1] if not builtin.is_empty($$[1]) else None + $2: List[logic.Binding] = $$[0] + $3: Optional[List[logic.Binding]] = $$[1] if not builtin.is_empty($$[1]) else None binding : SYMBOL "::" type construct: $$ = logic.Binding(var=logic.Var(name=$1), type=$3) deconstruct: - $1 = $$.var.name - $3 = $$.type + $1: String = $$.var.name + $3: logic.Type = $$.type type : unspecified_type construct: $$ = logic.Type(unspecified_type=$1) deconstruct: assert builtin.has_proto_field($$, 'unspecified_type') - $1 = $$.unspecified_type + $1: logic.UnspecifiedType = $$.unspecified_type | string_type construct: $$ = logic.Type(string_type=$1) deconstruct: assert builtin.has_proto_field($$, 'string_type') - $1 = $$.string_type + $1: logic.StringType = $$.string_type | int_type construct: $$ = logic.Type(int_type=$1) deconstruct: assert builtin.has_proto_field($$, 'int_type') - $1 = $$.int_type + $1: logic.IntType = $$.int_type | float_type construct: $$ = logic.Type(float_type=$1) deconstruct: assert builtin.has_proto_field($$, 'float_type') - $1 = $$.float_type + $1: logic.FloatType = $$.float_type | uint128_type construct: $$ = logic.Type(uint128_type=$1) deconstruct: assert builtin.has_proto_field($$, 'uint128_type') - $1 = $$.uint128_type + $1: logic.UInt128Type = $$.uint128_type | int128_type construct: $$ = logic.Type(int128_type=$1) deconstruct: assert builtin.has_proto_field($$, 'int128_type') - $1 = $$.int128_type + $1: logic.Int128Type = $$.int128_type | date_type construct: $$ = logic.Type(date_type=$1) deconstruct: assert builtin.has_proto_field($$, 'date_type') - $1 = $$.date_type + $1: logic.DateType = $$.date_type | datetime_type construct: $$ = logic.Type(datetime_type=$1) deconstruct: assert builtin.has_proto_field($$, 'datetime_type') - $1 = $$.datetime_type + $1: logic.DateTimeType = $$.datetime_type | missing_type construct: $$ = logic.Type(missing_type=$1) deconstruct: assert builtin.has_proto_field($$, 'missing_type') - $1 = $$.missing_type + $1: logic.MissingType = $$.missing_type | decimal_type construct: $$ = logic.Type(decimal_type=$1) deconstruct: assert builtin.has_proto_field($$, 'decimal_type') - $1 = $$.decimal_type + $1: logic.DecimalType = $$.decimal_type | boolean_type construct: $$ = logic.Type(boolean_type=$1) deconstruct: assert builtin.has_proto_field($$, 'boolean_type') - $1 = $$.boolean_type + $1: logic.BooleanType = $$.boolean_type unspecified_type : "UNKNOWN" @@ -488,8 +488,8 @@ decimal_type : "(" "DECIMAL" INT INT ")" construct: $$ = logic.DecimalType(precision=builtin.int64_to_int32($3), scale=builtin.int64_to_int32($4)) deconstruct: - $3 = builtin.int32_to_int64($$.precision) - $4 = builtin.int32_to_int64($$.scale) + $3: Int64 = builtin.int32_to_int64($$.precision) + $4: Int64 = builtin.int32_to_int64($$.scale) boolean_type : "BOOLEAN" @@ -503,67 +503,67 @@ formula construct: $$ = logic.Formula(conjunction=$1) deconstruct: assert builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args) - $1 = $$.conjunction + $1: logic.Conjunction = $$.conjunction | false construct: $$ = logic.Formula(disjunction=$1) deconstruct: assert builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args) - $1 = $$.disjunction + $1: logic.Disjunction = $$.disjunction | exists construct: $$ = logic.Formula(exists=$1) deconstruct: assert builtin.has_proto_field($$, 'exists') - $1 = $$.exists + $1: logic.Exists = $$.exists | reduce construct: $$ = logic.Formula(reduce=$1) deconstruct: assert builtin.has_proto_field($$, 'reduce') - $1 = $$.reduce + $1: logic.Reduce = $$.reduce | conjunction construct: $$ = logic.Formula(conjunction=$1) deconstruct: assert builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args) - $1 = $$.conjunction + $1: logic.Conjunction = $$.conjunction | disjunction construct: $$ = logic.Formula(disjunction=$1) deconstruct: assert builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args) - $1 = $$.disjunction + $1: logic.Disjunction = $$.disjunction | not construct: $$ = logic.Formula(not=$1) deconstruct: assert builtin.has_proto_field($$, 'not') - $1 = $$.not + $1: logic.Not = $$.not | ffi construct: $$ = logic.Formula(ffi=$1) deconstruct: assert builtin.has_proto_field($$, 'ffi') - $1 = $$.ffi + $1: logic.FFI = $$.ffi | atom construct: $$ = logic.Formula(atom=$1) deconstruct: assert builtin.has_proto_field($$, 'atom') - $1 = $$.atom + $1: logic.Atom = $$.atom | pragma construct: $$ = logic.Formula(pragma=$1) deconstruct: assert builtin.has_proto_field($$, 'pragma') - $1 = $$.pragma + $1: logic.Pragma = $$.pragma | primitive construct: $$ = logic.Formula(primitive=$1) deconstruct: assert builtin.has_proto_field($$, 'primitive') - $1 = $$.primitive + $1: logic.Primitive = $$.primitive | rel_atom construct: $$ = logic.Formula(rel_atom=$1) deconstruct: assert builtin.has_proto_field($$, 'rel_atom') - $1 = $$.rel_atom + $1: logic.RelAtom = $$.rel_atom | cast construct: $$ = logic.Formula(cast=$1) deconstruct: assert builtin.has_proto_field($$, 'cast') - $1 = $$.cast + $1: logic.Cast = $$.cast true : "(" "true" ")" @@ -577,33 +577,33 @@ exists : "(" "exists" bindings formula ")" construct: $$ = logic.Exists(body=logic.Abstraction(vars=builtin.list_concat($3[0], $3[1]), value=$4)) deconstruct: - $3 = deconstruct_bindings($$.body) - $4 = $$.body.value + $3: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings($$.body) + $4: logic.Formula = $$.body.value reduce : "(" "reduce" abstraction abstraction terms ")" construct: $$ = logic.Reduce(op=$3, body=$4, terms=$5) deconstruct: - $3 = $$.op - $4 = $$.body - $5 = $$.terms + $3: logic.Abstraction = $$.op + $4: logic.Abstraction = $$.body + $5: List[logic.Term] = $$.terms term : var construct: $$ = logic.Term(var=$1) deconstruct: assert builtin.has_proto_field($$, 'var') - $1 = $$.var + $1: logic.Var = $$.var | constant construct: $$ = logic.Term(constant=$1) deconstruct: assert builtin.has_proto_field($$, 'constant') - $1 = $$.constant + $1: logic.Value = $$.constant var : SYMBOL construct: $$ = logic.Var(name=$1) - deconstruct: $1 = $$.name + deconstruct: $1: String = $$.name constant : value @@ -611,25 +611,25 @@ constant conjunction : "(" "and" formula* ")" construct: $$ = logic.Conjunction(args=$3) - deconstruct: $3 = $$.args + deconstruct: $3: List[logic.Formula] = $$.args disjunction : "(" "or" formula* ")" construct: $$ = logic.Disjunction(args=$3) - deconstruct: $3 = $$.args + deconstruct: $3: List[logic.Formula] = $$.args not : "(" "not" formula ")" construct: $$ = logic.Not(arg=$3) - deconstruct: $3 = $$.arg + deconstruct: $3: logic.Formula = $$.arg ffi : "(" "ffi" name ffi_args terms ")" construct: $$ = logic.FFI(name=$3, args=$4, terms=$5) deconstruct: - $3 = $$.name - $4 = $$.args - $5 = $$.terms + $3: String = $$.name + $4: List[logic.Abstraction] = $$.args + $5: List[logic.Term] = $$.terms ffi_args : "(" "args" abstraction* ")" @@ -644,15 +644,15 @@ atom : "(" "atom" relation_id term* ")" construct: $$ = logic.Atom(name=$3, terms=$4) deconstruct: - $3 = $$.name - $4 = $$.terms + $3: logic.RelationId = $$.name + $4: List[logic.Term] = $$.terms pragma : "(" "pragma" name term* ")" construct: $$ = logic.Pragma(name=$3, terms=$4) deconstruct: - $3 = $$.name - $4 = $$.terms + $3: String = $$.name + $4: List[logic.Term] = $$.terms primitive : eq @@ -667,96 +667,96 @@ primitive | "(" "primitive" name rel_term* ")" construct: $$ = logic.Primitive(name=$3, terms=$4) deconstruct: - $3 = $$.name - $4 = $$.terms + $3: String = $$.name + $4: List[logic.RelTerm] = $$.terms eq : "(" "=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_eq", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: assert $$.name == "rel_primitive_eq" - $3 = $$.terms[0].term - $4 = $$.terms[1].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term lt : "(" "<" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: assert $$.name == "rel_primitive_lt_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term lt_eq : "(" "<=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: assert $$.name == "rel_primitive_lt_eq_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term gt : "(" ">" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: assert $$.name == "rel_primitive_gt_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term gt_eq : "(" ">=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) deconstruct: assert $$.name == "rel_primitive_gt_eq_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term add : "(" "+" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_add_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: assert $$.name == "rel_primitive_add_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term - $5 = $$.terms[2].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term + $5: logic.Term = $$.terms[2].term minus : "(" "-" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_subtract_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: assert $$.name == "rel_primitive_subtract_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term - $5 = $$.terms[2].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term + $5: logic.Term = $$.terms[2].term multiply : "(" "*" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_multiply_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: assert $$.name == "rel_primitive_multiply_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term - $5 = $$.terms[2].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term + $5: logic.Term = $$.terms[2].term divide : "(" "/" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_divide_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) deconstruct: assert $$.name == "rel_primitive_divide_monotype" - $3 = $$.terms[0].term - $4 = $$.terms[1].term - $5 = $$.terms[2].term + $3: logic.Term = $$.terms[0].term + $4: logic.Term = $$.terms[1].term + $5: logic.Term = $$.terms[2].term rel_term : specialized_value construct: $$ = logic.RelTerm(specialized_value=$1) deconstruct: assert builtin.has_proto_field($$, 'specialized_value') - $1 = $$.specialized_value + $1: logic.Value = $$.specialized_value | term construct: $$ = logic.RelTerm(term=$1) deconstruct: assert builtin.has_proto_field($$, 'term') - $1 = $$.term + $1: logic.Term = $$.term specialized_value : "#" value @@ -765,15 +765,15 @@ rel_atom : "(" "relatom" name rel_term* ")" construct: $$ = logic.RelAtom(name=$3, terms=$4) deconstruct: - $3 = $$.name - $4 = $$.terms + $3: String = $$.name + $4: List[logic.RelTerm] = $$.terms cast : "(" "cast" term term ")" construct: $$ = logic.Cast(input=$3, result=$4) deconstruct: - $3 = $$.input - $4 = $$.result + $3: logic.Term = $$.input + $4: logic.Term = $$.result attrs : "(" "attrs" attribute* ")" @@ -782,39 +782,39 @@ attribute : "(" "attribute" name value* ")" construct: $$ = logic.Attribute(name=$3, args=$4) deconstruct: - $3 = $$.name - $4 = $$.args + $3: String = $$.name + $4: List[logic.Value] = $$.args algorithm : "(" "algorithm" relation_id* script ")" construct: $$ = logic.Algorithm(global=$3, body=$4) deconstruct: - $3 = $$.global - $4 = $$.body + $3: List[logic.RelationId] = $$.global + $4: logic.Script = $$.body script : "(" "script" construct* ")" construct: $$ = logic.Script(constructs=$3) - deconstruct: $3 = $$.constructs + deconstruct: $3: List[logic.Construct] = $$.constructs construct : loop construct: $$ = logic.Construct(loop=$1) deconstruct: assert builtin.has_proto_field($$, 'loop') - $1 = $$.loop + $1: logic.Loop = $$.loop | instruction construct: $$ = logic.Construct(instruction=$1) deconstruct: assert builtin.has_proto_field($$, 'instruction') - $1 = $$.instruction + $1: logic.Instruction = $$.instruction loop : "(" "loop" init script ")" construct: $$ = logic.Loop(init=$3, body=$4) deconstruct: - $3 = $$.init - $4 = $$.body + $3: List[logic.Instruction] = $$.init + $4: logic.Script = $$.body init : "(" "init" instruction* ")" @@ -824,89 +824,89 @@ instruction construct: $$ = logic.Instruction(assign=$1) deconstruct: assert builtin.has_proto_field($$, 'assign') - $1 = $$.assign + $1: logic.Assign = $$.assign | upsert construct: $$ = logic.Instruction(upsert=$1) deconstruct: assert builtin.has_proto_field($$, 'upsert') - $1 = $$.upsert + $1: logic.Upsert = $$.upsert | break construct: $$ = logic.Instruction(break=$1) deconstruct: assert builtin.has_proto_field($$, 'break') - $1 = $$.break + $1: logic.Break = $$.break | monoid_def construct: $$ = logic.Instruction(monoid_def=$1) deconstruct: assert builtin.has_proto_field($$, 'monoid_def') - $1 = $$.monoid_def + $1: logic.MonoidDef = $$.monoid_def | monus_def construct: $$ = logic.Instruction(monus_def=$1) deconstruct: assert builtin.has_proto_field($$, 'monus_def') - $1 = $$.monus_def + $1: logic.MonusDef = $$.monus_def assign : "(" "assign" relation_id abstraction attrs? ")" construct: $$ = logic.Assign(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) deconstruct: - $3 = $$.name - $4 = $$.body - $5 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.RelationId = $$.name + $4: logic.Abstraction = $$.body + $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None upsert : "(" "upsert" relation_id abstraction_with_arity attrs? ")" construct: $$ = logic.Upsert(name=$3, body=$4[0], attrs=builtin.unwrap_option_or($5, list[logic.Attribute]()), value_arity=$4[1]) deconstruct: - $3 = $$.name - $4 = builtin.tuple($$.body, $$.value_arity) - $5 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.RelationId = $$.name + $4: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) + $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None abstraction_with_arity : "(" bindings formula ")" construct: $$ = builtin.tuple(logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3), builtin.length($2[1])) deconstruct: - $2 = deconstruct_bindings_with_arity($$[0], $$[1]) - $3 = $$[0].value + $2: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings_with_arity($$[0], $$[1]) + $3: logic.Formula = $$[0].value break : "(" "break" relation_id abstraction attrs? ")" construct: $$ = logic.Break(name=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]())) deconstruct: - $3 = $$.name - $4 = $$.body - $5 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.RelationId = $$.name + $4: logic.Abstraction = $$.body + $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None monoid_def : "(" "monoid" monoid relation_id abstraction_with_arity attrs? ")" construct: $$ = logic.MonoidDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) deconstruct: - $3 = $$.monoid - $4 = $$.name - $5 = builtin.tuple($$.body, $$.value_arity) - $6 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.Monoid = $$.monoid + $4: logic.RelationId = $$.name + $5: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) + $6: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None monoid : or_monoid construct: $$ = logic.Monoid(or_monoid=$1) deconstruct: assert builtin.has_proto_field($$, 'or_monoid') - $1 = $$.or_monoid + $1: logic.OrMonoid = $$.or_monoid | min_monoid construct: $$ = logic.Monoid(min_monoid=$1) deconstruct: assert builtin.has_proto_field($$, 'min_monoid') - $1 = $$.min_monoid + $1: logic.MinMonoid = $$.min_monoid | max_monoid construct: $$ = logic.Monoid(max_monoid=$1) deconstruct: assert builtin.has_proto_field($$, 'max_monoid') - $1 = $$.max_monoid + $1: logic.MaxMonoid = $$.max_monoid | sum_monoid construct: $$ = logic.Monoid(sum_monoid=$1) deconstruct: assert builtin.has_proto_field($$, 'sum_monoid') - $1 = $$.sum_monoid + $1: logic.SumMonoid = $$.sum_monoid or_monoid : "(" "or" ")" @@ -915,35 +915,35 @@ or_monoid min_monoid : "(" "min" type ")" construct: $$ = logic.MinMonoid(type=$3) - deconstruct: $3 = $$.type + deconstruct: $3: logic.Type = $$.type max_monoid : "(" "max" type ")" construct: $$ = logic.MaxMonoid(type=$3) - deconstruct: $3 = $$.type + deconstruct: $3: logic.Type = $$.type sum_monoid : "(" "sum" type ")" construct: $$ = logic.SumMonoid(type=$3) - deconstruct: $3 = $$.type + deconstruct: $3: logic.Type = $$.type monus_def : "(" "monus" monoid relation_id abstraction_with_arity attrs? ")" construct: $$ = logic.MonusDef(monoid=$3, name=$4, body=$5[0], attrs=builtin.unwrap_option_or($6, list[logic.Attribute]()), value_arity=$5[1]) deconstruct: - $3 = $$.monoid - $4 = $$.name - $5 = builtin.tuple($$.body, $$.value_arity) - $6 = $$.attrs if not builtin.is_empty($$.attrs) else None + $3: logic.Monoid = $$.monoid + $4: logic.RelationId = $$.name + $5: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) + $6: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None constraint : "(" "functional_dependency" relation_id abstraction functional_dependency_keys functional_dependency_values ")" construct: $$ = logic.Constraint(name=$3, functional_dependency=logic.FunctionalDependency(guard=$4, keys=$5, values=$6)) deconstruct: - $3 = $$.name - $4 = $$.functional_dependency.guard - $5 = $$.functional_dependency.keys - $6 = $$.functional_dependency.values + $3: logic.RelationId = $$.name + $4: logic.Abstraction = $$.functional_dependency.guard + $5: List[logic.Var] = $$.functional_dependency.keys + $6: List[logic.Var] = $$.functional_dependency.values functional_dependency_keys : "(" "keys" var* ")" @@ -956,17 +956,17 @@ data construct: $$ = logic.Data(rel_edb=$1) deconstruct: assert builtin.has_proto_field($$, 'rel_edb') - $1 = $$.rel_edb + $1: logic.RelEDB = $$.rel_edb | betree_relation construct: $$ = logic.Data(betree_relation=$1) deconstruct: assert builtin.has_proto_field($$, 'betree_relation') - $1 = $$.betree_relation + $1: logic.BeTreeRelation = $$.betree_relation | csv_data construct: $$ = logic.Data(csv_data=$1) deconstruct: assert builtin.has_proto_field($$, 'csv_data') - $1 = $$.csv_data + $1: logic.CSVData = $$.csv_data rel_edb_path : "[" STRING* "]" @@ -978,24 +978,24 @@ rel_edb : "(" "rel_edb" relation_id rel_edb_path rel_edb_types ")" construct: $$ = logic.RelEDB(target_id=$3, path=$4, types=$5) deconstruct: - $3 = $$.target_id - $4 = $$.path - $5 = $$.types + $3: logic.RelationId = $$.target_id + $4: List[String] = $$.path + $5: List[logic.Type] = $$.types betree_relation : "(" "betree_relation" relation_id betree_info ")" construct: $$ = logic.BeTreeRelation(name=$3, relation_info=$4) deconstruct: - $3 = $$.name - $4 = $$.relation_info + $3: logic.RelationId = $$.name + $4: logic.BeTreeInfo = $$.relation_info betree_info : "(" "betree_info" betree_info_key_types betree_info_value_types config_dict ")" construct: $$ = construct_betree_info($3, $4, $5) deconstruct: - $3 = $$.key_types - $4 = $$.value_types - $5 = deconstruct_betree_info_config($$) + $3: List[logic.Type] = $$.key_types + $4: List[logic.Type] = $$.value_types + $5: List[Tuple[String, logic.Value]] = deconstruct_betree_info_config($$) betree_info_key_types : "(" "key_types" type* ")" @@ -1013,10 +1013,10 @@ csv_data : "(" "csv_data" csvlocator csv_config csv_columns csv_asof ")" construct: $$ = logic.CSVData(locator=$3, config=$4, columns=$5, asof=$6) deconstruct: - $3 = $$.locator - $4 = $$.config - $5 = $$.columns - $6 = $$.asof + $3: logic.CSVLocator = $$.locator + $4: logic.CSVConfig = $$.config + $5: List[logic.CSVColumn] = $$.columns + $6: String = $$.asof csv_locator_paths : "(" "paths" STRING* ")" @@ -1028,31 +1028,31 @@ csvlocator : "(" "csv_locator" csv_locator_paths? csv_locator_inline_data? ")" construct: $$ = logic.CSVLocator(paths=builtin.unwrap_option_or($3, list[str]()), inline_data=builtin.encode_string(builtin.unwrap_option_or($4, ""))) deconstruct: - $3 = $$.paths if not builtin.is_empty($$.paths) else None - $4 = builtin.decode_string($$.inline_data) if builtin.decode_string($$.inline_data) != "" else None + $3: Optional[List[String]] = $$.paths if not builtin.is_empty($$.paths) else None + $4: Optional[String] = builtin.decode_string($$.inline_data) if builtin.decode_string($$.inline_data) != "" else None csv_config : "(" "csv_config" config_dict ")" construct: $$ = construct_csv_config($3) - deconstruct: $3 = deconstruct_csv_config($$) + deconstruct: $3: List[Tuple[String, logic.Value]] = deconstruct_csv_config($$) csv_column : "(" "column" STRING relation_id "[" type* "]" ")" construct: $$ = logic.CSVColumn(column_name=$3, target_id=$4, types=$6) deconstruct: - $3 = $$.column_name - $4 = $$.target_id - $6 = $$.types + $3: String = $$.column_name + $4: logic.RelationId = $$.target_id + $6: List[logic.Type] = $$.types undefine : "(" "undefine" fragment_id ")" construct: $$ = transactions.Undefine(fragment_id=$3) - deconstruct: $3 = $$.fragment_id + deconstruct: $3: fragments.FragmentId = $$.fragment_id context : "(" "context" relation_id* ")" construct: $$ = transactions.Context(relations=$3) - deconstruct: $3 = $$.relations + deconstruct: $3: List[logic.RelationId] = $$.relations epoch_reads : "(" "reads" read* ")" @@ -1062,66 +1062,66 @@ read construct: $$ = transactions.Read(demand=$1) deconstruct: assert builtin.has_proto_field($$, 'demand') - $1 = $$.demand + $1: transactions.Demand = $$.demand | output construct: $$ = transactions.Read(output=$1) deconstruct: assert builtin.has_proto_field($$, 'output') - $1 = $$.output + $1: transactions.Output = $$.output | what_if construct: $$ = transactions.Read(what_if=$1) deconstruct: assert builtin.has_proto_field($$, 'what_if') - $1 = $$.what_if + $1: transactions.WhatIf = $$.what_if | abort construct: $$ = transactions.Read(abort=$1) deconstruct: assert builtin.has_proto_field($$, 'abort') - $1 = $$.abort + $1: transactions.Abort = $$.abort | export construct: $$ = transactions.Read(export=$1) deconstruct: assert builtin.has_proto_field($$, 'export') - $1 = $$.export + $1: transactions.Export = $$.export demand : "(" "demand" relation_id ")" construct: $$ = transactions.Demand(relation_id=$3) - deconstruct: $3 = $$.relation_id + deconstruct: $3: logic.RelationId = $$.relation_id output : "(" "output" name? relation_id ")" construct: $$ = transactions.Output(name=builtin.unwrap_option_or($3, "output"), relation_id=$4) deconstruct: - $3 = $$.name if $$.name != "output" else None - $4 = $$.relation_id + $3: Optional[String] = $$.name if $$.name != "output" else None + $4: logic.RelationId = $$.relation_id what_if : "(" "what_if" name epoch ")" construct: $$ = transactions.WhatIf(branch=$3, epoch=$4) deconstruct: - $3 = $$.branch - $4 = $$.epoch + $3: String = $$.branch + $4: transactions.Epoch = $$.epoch abort : "(" "abort" name? relation_id ")" construct: $$ = transactions.Abort(name=builtin.unwrap_option_or($3, "abort"), relation_id=$4) deconstruct: - $3 = $$.name if $$.name != "abort" else None - $4 = $$.relation_id + $3: Optional[String] = $$.name if $$.name != "abort" else None + $4: logic.RelationId = $$.relation_id export : "(" "export" export_csv_config ")" construct: $$ = transactions.Export(csv_config=$3) - deconstruct: $3 = $$.csv_config + deconstruct: $3: transactions.ExportCSVConfig = $$.csv_config export_csv_config : "(" "export_csv_config" export_csv_path export_csv_columns config_dict ")" construct: $$ = export_csv_config($3, $4, $5) deconstruct: - $3 = $$.path - $4 = $$.data_columns - $5 = deconstruct_export_csv_config($$) + $3: String = $$.path + $4: List[transactions.ExportCSVColumn] = $$.data_columns + $5: List[Tuple[String, logic.Value]] = deconstruct_export_csv_config($$) export_csv_path : "(" "path" STRING ")" @@ -1133,8 +1133,8 @@ export_csv_column : "(" "column" STRING relation_id ")" construct: $$ = transactions.ExportCSVColumn(column_name=$3, column_data=$4) deconstruct: - $3 = $$.column_name - $4 = $$.column_data + $3: String = $$.column_name + $4: logic.RelationId = $$.column_data %% diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index aa425d5e..b664a180 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -102,9 +102,7 @@ def _generate_pretty_alternatives(rules: List[Rule], msg_param: Var, guarded_indices = [i for i in range(len(rules)) if i != fallback_idx] for i in reversed(guarded_indices): rule = rules[i] - if _is_nonterminal_ref(rule) and _has_guarded_deconstruct(rule.rhs, grammar): - result = _generate_nonterminal_ref_dispatch(rule, msg_param, grammar, proto_messages, result) - elif rule.deconstructor is not None and isinstance(rule.deconstructor.return_type, OptionType): + if rule.deconstructor is not None and isinstance(rule.deconstructor.return_type, OptionType): deconstruct_result_var = Var(gensym('deconstruct_result'), rule.deconstructor.return_type) deconstruct_call = Call(rule.deconstructor, [msg_param]) pretty_body = _generate_pretty_from_fields( @@ -118,6 +116,8 @@ def _generate_pretty_alternatives(rules: List[Rule], msg_param: Var, result ) ) + elif _is_nonterminal_ref(rule) and _has_guarded_deconstruct(rule.rhs, grammar): + result = _generate_nonterminal_ref_dispatch(rule, msg_param, grammar, proto_messages, result) else: # Unguarded non-fallback rule — treat as always matching at this position result = _generate_pretty_with_deconstruct(rule, msg_param, grammar, proto_messages) @@ -281,6 +281,10 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, non_lit_count = sum(1 for e in elems if not isinstance(e, LitTerminal)) for i, elem in enumerate(elems): + # In non-S-expression mode, add space between elements + if not is_sexp and stmts: + stmts.append(Call(make_builtin('write_io'), [Lit(' ')])) + if isinstance(elem, LitTerminal): is_keyword = is_sexp and i == 1 stmts.append(_format_literal(elem, is_sexp_keyword=is_keyword)) @@ -421,8 +425,12 @@ def _format_terminal(terminal: NamedTerminal, value_var: Var) -> TargetExpr: return Call(make_builtin('format_string'), [value_var]) elif terminal.name in ['INT', 'NUMBER']: return Call(make_builtin('format_int64'), [value_var]) + elif terminal.name == 'INT128': + return Call(make_builtin('format_int128'), [value_var]) elif terminal.name == 'FLOAT': return Call(make_builtin('format_float64'), [value_var]) + elif terminal.name == 'DECIMAL': + return Call(make_builtin('format_decimal'), [value_var]) elif terminal.name == 'BOOL': return Call(make_builtin('format_bool'), [value_var]) elif terminal.name == 'UINT128': diff --git a/python-tools/src/meta/pretty_gen_python.py b/python-tools/src/meta/pretty_gen_python.py index 100ce20e..ffa79a2a 100644 --- a/python-tools/src/meta/pretty_gen_python.py +++ b/python-tools/src/meta/pretty_gen_python.py @@ -5,150 +5,45 @@ print method generation, and epilogue. """ +from pathlib import Path from typing import Optional -from .grammar import Grammar, Nonterminal +from .grammar import Grammar from .codegen_python import PythonCodeGenerator from .pretty_gen import generate_pretty_functions -PROLOGUE_TEMPLATE = '''\ -""" -Auto-generated pretty printer. - -Generated from protobuf specifications. -Do not modify this file! If you need to modify the pretty printer, edit the generator code -in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. - -{command_line_comment}""" - -from io import StringIO -from typing import Any, IO, Never, Optional - -from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 - - -class ParseError(Exception): - pass - - -class PrettyPrinter: - """Pretty printer for protobuf messages.""" - - def __init__(self, io: Optional[IO[str]] = None): - self.io = io if io is not None else StringIO() - self.indent_level = 0 - self.at_line_start = True - self._debug_info: dict[tuple[int, int], str] = {{}} - - def write(self, s: str) -> None: - """Write a string to the output, with indentation at line start.""" - if self.at_line_start and s.strip(): - self.io.write(' ' * self.indent_level) - self.at_line_start = False - self.io.write(s) - - def newline(self) -> None: - """Write a newline to the output.""" - self.io.write('\\n') - self.at_line_start = True - - def indent(self, delta: int = 1) -> None: - """Increase indentation level.""" - self.indent_level += delta - - def dedent(self, delta: int = 1) -> None: - """Decrease indentation level.""" - self.indent_level = max(0, self.indent_level - delta) - - def get_output(self) -> str: - """Get the accumulated output as a string.""" - if isinstance(self.io, StringIO): - return self.io.getvalue() - return "" - - def format_decimal(self, msg) -> str: - """Format a DecimalValue protobuf message as a string.""" - # DecimalValue has 'value' field as string - return str(msg.value) if msg.value else "0" - - def format_int128(self, msg) -> str: - """Format an Int128Value protobuf message as a string.""" - value = (msg.high << 64) | msg.low - if msg.high & (1 << 63): - value -= (1 << 128) - return str(value) - - def format_uint128(self, msg) -> str: - """Format a UInt128Value protobuf message as a hex string.""" - value = (msg.high << 64) | msg.low - return f"0x{{value:032x}}" - - def fragment_id_to_string(self, msg) -> str: - """Convert FragmentId to string representation.""" - return msg.id.decode('utf-8') if msg.id else "" - - def start_pretty_fragment(self, msg) -> None: - """Extract debug info from Fragment for relation ID lookup.""" - debug_info = msg.debug_info - for rid, name in zip(debug_info.ids, debug_info.orig_names): - self._debug_info[(rid.id_low, rid.id_high)] = name - - def relation_id_to_string(self, msg) -> str: - """Convert RelationId to string representation using debug info.""" - return self._debug_info.get((msg.id_low, msg.id_high), "") - - def relation_id_to_int(self, msg): - """Convert RelationId to int representation if it has id.""" - if msg.id_low or msg.id_high: - return (msg.id_high << 64) | msg.id_low - return None - - def relation_id_to_uint128(self, msg): - """Convert RelationId to UInt128Value representation.""" - return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) -''' - -EPILOGUE_TEMPLATE = ''' - -def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: - """Pretty print a protobuf message and return the string representation.""" - printer = PrettyPrinter(io) - printer.pretty_{start_name}(msg) - return printer.get_output() -''' +_TEMPLATE_PATH = Path(__file__).parent / "templates" / "pretty_printer.py.template" def generate_pretty_printer_python(grammar: Grammar, command_line: Optional[str] = None, proto_messages=None) -> str: """Generate pretty printer in Python.""" - prologue = _generate_prologue(command_line) + template = _TEMPLATE_PATH.read_text() codegen = PythonCodeGenerator(proto_messages=proto_messages) codegen.named_fun_class = "self" + indent = " " defns = generate_pretty_functions(grammar, proto_messages) lines = [] for defn in defns: lines.append("") - lines.append(codegen.generate_def(defn, " ")) - - for fundef in grammar.function_defs.values(): - lines.append("") - lines.append(codegen.generate_method_def(fundef, " ")) + lines.append(codegen.generate_def(defn, indent)) lines.append("") + pretty_nonterminal_defns = "\n".join(lines) - epilogue = _generate_epilogue(grammar.start) - - return prologue + "\n".join(lines) + epilogue - + function_lines = [] + for fundef in grammar.function_defs.values(): + function_lines.append("") + function_lines.append(codegen.generate_method_def(fundef, indent)) + named_function_defns = "\n".join(function_lines) if function_lines else "" -def _generate_prologue(command_line: Optional[str] = None) -> str: - """Generate pretty printer prologue with imports and class start.""" command_line_comment = f"\nCommand: {command_line}\n" if command_line else "" - return PROLOGUE_TEMPLATE.format(command_line_comment=command_line_comment) - -def _generate_epilogue(start: Nonterminal) -> str: - """Generate pretty function.""" - return EPILOGUE_TEMPLATE.format(start_name=start.name.lower()) + return template.format( + command_line_comment=command_line_comment, + start_name=grammar.start.name.lower(), + pretty_nonterminal_defns=pretty_nonterminal_defns, + named_function_defns=named_function_defns, + ) diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index c19b8d20..80ac0031 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -152,7 +152,9 @@ def is_builtin(name: str) -> bool: register_builtin("fragment_id_to_string", [MessageType("fragments", "FragmentId")], STRING) register_builtin("relation_id_from_string", [STRING], MessageType("logic", "RelationId")) register_builtin("relation_id_from_uint128", [MessageType("logic", "UInt128Value")], MessageType("logic", "RelationId")) +register_builtin("relation_id_from_int", [INT64], MessageType("logic", "RelationId")) register_builtin("relation_id_to_string", [MessageType("logic", "RelationId")], STRING) +register_builtin("relation_id_to_int", [MessageType("logic", "RelationId")], OptionType(INT64)) register_builtin("relation_id_to_uint128", [MessageType("logic", "RelationId")], MessageType("logic", "UInt128Value")) register_builtin("construct_fragment", [MessageType("fragments", "FragmentId"), diff --git a/python-tools/src/meta/templates/pretty_printer.py.template b/python-tools/src/meta/templates/pretty_printer.py.template new file mode 100644 index 00000000..a4ec6dd2 --- /dev/null +++ b/python-tools/src/meta/templates/pretty_printer.py.template @@ -0,0 +1,126 @@ +""" +Auto-generated pretty printer. + +Generated from protobuf specifications. +Do not modify this file! If you need to modify the pretty printer, edit the generator code +in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. + +{command_line_comment}""" + +from io import StringIO +from typing import Any, IO, Never, Optional + +from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 + + +class ParseError(Exception): + pass + + +class PrettyPrinter: + """Pretty printer for protobuf messages.""" + + def __init__(self, io: Optional[IO[str]] = None): + self.io = io if io is not None else StringIO() + self.indent_level = 0 + self.at_line_start = True + self._debug_info: dict[tuple[int, int], str] = {{}} + + def write(self, s: str) -> None: + """Write a string to the output, with indentation at line start.""" + if self.at_line_start and s.strip(): + self.io.write(' ' * self.indent_level) + self.at_line_start = False + self.io.write(s) + + def newline(self) -> None: + """Write a newline to the output.""" + self.io.write('\n') + self.at_line_start = True + + def indent(self, delta: int = 1) -> None: + """Increase indentation level.""" + self.indent_level += delta + + def dedent(self, delta: int = 1) -> None: + """Decrease indentation level.""" + self.indent_level = max(0, self.indent_level - delta) + + def get_output(self) -> str: + """Get the accumulated output as a string.""" + if isinstance(self.io, StringIO): + return self.io.getvalue() + return "" + + def format_decimal(self, msg) -> str: + """Format a DecimalValue as '.d'.""" + int_val = (msg.value.high << 64) | msg.value.low + if msg.value.high & (1 << 63): + int_val -= (1 << 128) + sign = "" + if int_val < 0: + sign = "-" + int_val = -int_val + digits = str(int_val) + scale = msg.scale + if scale <= 0: + decimal_str = digits + "." + "0" * (-scale) + elif scale >= len(digits): + decimal_str = "0." + "0" * (scale - len(digits)) + digits + else: + decimal_str = digits[:-scale] + "." + digits[-scale:] + return sign + decimal_str + "d" + str(msg.precision) + + def format_int128(self, msg) -> str: + """Format an Int128Value protobuf message as a string with i128 suffix.""" + value = (msg.high << 64) | msg.low + if msg.high & (1 << 63): + value -= (1 << 128) + return str(value) + "i128" + + def format_uint128(self, msg) -> str: + """Format a UInt128Value protobuf message as a hex string.""" + value = (msg.high << 64) | msg.low + return f"0x{{value:032x}}" + + def fragment_id_to_string(self, msg) -> str: + """Convert FragmentId to string representation.""" + return msg.id.decode('utf-8') if msg.id else "" + + def start_pretty_fragment(self, msg) -> None: + """Extract debug info from Fragment for relation ID lookup.""" + debug_info = msg.debug_info + for rid, name in zip(debug_info.ids, debug_info.orig_names): + self._debug_info[(rid.id_low, rid.id_high)] = name + + def relation_id_to_string(self, msg): + """Convert RelationId to string representation using debug info.""" + return self._debug_info.get((msg.id_low, msg.id_high)) + + def relation_id_to_int(self, msg): + """Convert RelationId to int if it fits in signed 64-bit range.""" + value = (msg.id_high << 64) | msg.id_low + if value <= 0x7FFFFFFFFFFFFFFF: + return value + return None + + def relation_id_to_uint128(self, msg): + """Convert RelationId to UInt128Value representation.""" + return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) + + def format_string_value(self, s: str) -> str: + """Format a string value with double quotes for LQP output.""" + escaped = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t') + return '"' + escaped + '"' + + # --- Helper functions --- +{named_function_defns} + + # --- Pretty-print methods --- +{pretty_nonterminal_defns} + +def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: + """Pretty print a protobuf message and return the string representation.""" + printer = PrettyPrinter(io) + printer.pretty_{start_name}(msg) + return printer.get_output() diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 29488d91..15f23d93 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -12,6 +12,10 @@ - List literals: [a, b, c] - Conditional expressions: x if cond else y - Tuple indexing: x[0] +- Arithmetic operators: +, -, *, /, //, % +- Comparison operators: ==, !=, <, >, <=, >=, is, is not, in, not in +- Boolean operators: and, or, not +- Unary minus: -x """ import ast @@ -20,12 +24,12 @@ from .grammar import Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence from .target import ( - TargetType, BaseType, MessageType, EnumType, ListType, OptionType, TupleType, DictType, FunctionType, + TargetType, BaseType, MessageType, EnumType, ListType, OptionType, TupleType, DictType, FunctionType, VarType, TargetExpr, Var, Lit, NamedFun, NewMessage, EnumValue, Call, Lambda, Let, IfElse, Seq, ListExpr, GetElement, GetField, FunDef, OneOf, Assign, Return ) from .target_builtins import make_builtin -from .target_utils import type_join +from .target_utils import type_join, is_subtype class YaccGrammarError(Exception): @@ -206,14 +210,9 @@ def _unsupported_node_error(node: ast.AST, line: Optional[int], reason: str = "" # Map AST node types to user-friendly descriptions and suggestions node_explanations = { - 'UnaryOp': "Unary operators (like -x, +x, ~x, not x) are not supported. " - "Use builtin functions instead (e.g., 'subtract(0, x)' for negation).", - 'BinOp': "Binary operators (+, -, *, /, etc.) are not supported. " - "Use builtin functions instead (e.g., 'add(x, y)', 'multiply(x, y)').", - 'BoolOp': "Boolean operators (and, or) are not supported directly. " - "Use builtin functions instead (e.g., 'and(x, y)', 'or(x, y)').", - 'Compare': "Comparison operators (==, !=, <, >, etc.) are not supported. " - "Use builtin functions instead (e.g., 'equal(x, y)', 'less_than(x, y)').", + 'UnaryOp': "Unsupported unary operator. " + "Supported: not, unary minus (-x). " + "Bitwise operators (~x, +x) are not supported.", 'Lambda': "Python lambda expressions are not supported in actions. " "Define named functions in the %functions section instead.", 'Dict': "Dictionary literals are not supported. " @@ -436,6 +435,14 @@ def convert(n: ast.AST) -> TargetExpr: return Call(make_builtin("equal"), [left, right]) elif isinstance(op, ast.NotEq): return Call(make_builtin("not_equal"), [left, right]) + elif isinstance(op, ast.Lt): + return Call(make_builtin("less_than"), [left, right]) + elif isinstance(op, ast.LtE): + return Call(make_builtin("less_equal"), [left, right]) + elif isinstance(op, ast.Gt): + return Call(make_builtin("greater_than"), [left, right]) + elif isinstance(op, ast.GtE): + return Call(make_builtin("greater_equal"), [left, right]) elif isinstance(op, ast.In): return Call(make_builtin("string_in_list"), [left, right]) elif isinstance(op, ast.NotIn): @@ -457,9 +464,26 @@ def convert(n: ast.AST) -> TargetExpr: return result raise YaccGrammarError(f"Unsupported boolean operation", line) + elif isinstance(node, ast.BinOp): + left = convert(node.left) + right = convert(node.right) + if isinstance(node.op, ast.Add): + return Call(make_builtin("add"), [left, right]) + elif isinstance(node.op, ast.Sub): + return Call(make_builtin("subtract"), [left, right]) + elif isinstance(node.op, ast.Mult): + return Call(make_builtin("multiply"), [left, right]) + elif isinstance(node.op, ast.Div) or isinstance(node.op, ast.FloorDiv): + return Call(make_builtin("divide"), [left, right]) + elif isinstance(node.op, ast.Mod): + return Call(make_builtin("modulo"), [left, right]) + raise YaccGrammarError(f"Unsupported binary operator: {type(node.op).__name__}", line) + elif isinstance(node, ast.UnaryOp): if isinstance(node.op, ast.Not): return Call(make_builtin("not"), [convert(node.operand)]) + elif isinstance(node.op, ast.USub): + return Call(make_builtin("subtract"), [Lit(0), convert(node.operand)]) raise _unsupported_node_error(node, line) else: @@ -613,6 +637,8 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', # Extract assert conditions, side-effects, and $N assignments from the AST # assignments maps 1-indexed $N to the expression AST node assignments: Dict[int, ast.expr] = {} + # type_annotations maps 1-indexed $N to the declared TargetType (if any) + type_annotations: Dict[int, TargetType] = {} assert_conditions: List[ast.expr] = [] side_effects: List[ast.expr] = [] extra_vars: Dict[str, TargetType] = {"_dollar_dollar": lhs_type} @@ -630,6 +656,13 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', dollar_idx = int(target.id[8:]) # 1-indexed assignments[dollar_idx] = stmt.value continue + if isinstance(stmt, ast.AnnAssign) and isinstance(stmt.target, ast.Name): + target = stmt.target + if target.id.startswith('_dollar_') and target.id[8:].isdigit() and stmt.value is not None: + dollar_idx = int(target.id[8:]) # 1-indexed + assignments[dollar_idx] = stmt.value + type_annotations[dollar_idx] = _annotation_to_type(stmt.annotation, line or 0) + continue raise YaccGrammarError( f"Deconstruct actions must be assert, side-effect expressions, " f"or $N = expr assignments. Got: {ast.dump(stmt)}", @@ -650,6 +683,18 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', f"{', '.join(f'${i}' for i in sorted(extra))}", line) + # Type-check annotations against the expected RHS element types + for idx, declared_type in type_annotations.items(): + # idx is 1-indexed; rhs_param_info is 0-indexed + rhs_idx = idx - 1 + if rhs_idx < len(rhs_param_info): + _, expected_type = rhs_param_info[rhs_idx] + if expected_type is not None and not is_subtype(declared_type, expected_type): + raise YaccGrammarError( + f"Type annotation on ${idx} is {declared_type}, " + f"but RHS element type is {expected_type}", + line) + # Convert each assignment's value expression to target IR param_info: List[Tuple[Optional[str], Optional[TargetType]]] = [] empty_params: List[Var] = [] @@ -658,6 +703,28 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', expr = _convert_node_with_vars(assignments[idx], param_info, empty_params, ctx, line, extra_vars) converted.append(expr) + # Type-check: inferred expression types must be compatible with declared types + unknown_type = BaseType("Unknown") + for i, idx in enumerate(sorted(assignments.keys())): + if idx in type_annotations: + declared_type = type_annotations[idx] + inferred_type = _infer_type(converted[i], line, ctx) + # Skip check when inferred type is Unknown or a type variable + if inferred_type == unknown_type or isinstance(inferred_type, VarType): + continue + # T <: Optional[T]: non-None means "present" for optional RHS elements + # Optional[T] <: T: None encodes match failure, handled by framework + compatible = (is_subtype(inferred_type, declared_type) + or (isinstance(declared_type, OptionType) + and is_subtype(inferred_type, declared_type.element_type)) + or (isinstance(inferred_type, OptionType) + and is_subtype(inferred_type.element_type, declared_type))) + if not compatible: + raise YaccGrammarError( + f"Type mismatch in deconstruct ${idx}: " + f"declared {declared_type}, but expression has type {inferred_type}", + line) + # Convert side-effect expressions to target IR side_effect_exprs: List[TargetExpr] = [] for se_node in side_effects: @@ -1130,6 +1197,14 @@ def _convert_func_expr(node: ast.expr, ctx: 'TypeContext', line: int, return Call(make_builtin("equal"), [left, right]) elif isinstance(op, ast.NotEq): return Call(make_builtin("not_equal"), [left, right]) + elif isinstance(op, ast.Lt): + return Call(make_builtin("less_than"), [left, right]) + elif isinstance(op, ast.LtE): + return Call(make_builtin("less_equal"), [left, right]) + elif isinstance(op, ast.Gt): + return Call(make_builtin("greater_than"), [left, right]) + elif isinstance(op, ast.GtE): + return Call(make_builtin("greater_equal"), [left, right]) elif isinstance(op, ast.In): return Call(make_builtin("string_in_list"), [left, right]) elif isinstance(op, ast.NotIn): @@ -1159,6 +1234,10 @@ def _convert_func_expr(node: ast.expr, ctx: 'TypeContext', line: int, return Call(make_builtin("subtract"), [left, right]) elif isinstance(node.op, ast.Mult): return Call(make_builtin("multiply"), [left, right]) + elif isinstance(node.op, ast.Div) or isinstance(node.op, ast.FloorDiv): + return Call(make_builtin("divide"), [left, right]) + elif isinstance(node.op, ast.Mod): + return Call(make_builtin("modulo"), [left, right]) raise YaccGrammarError(f"Unsupported binary operation: {type(node.op).__name__}", line) elif isinstance(node, ast.Tuple): @@ -1168,6 +1247,8 @@ def _convert_func_expr(node: ast.expr, ctx: 'TypeContext', line: int, elif isinstance(node, ast.UnaryOp): if isinstance(node.op, ast.Not): return Call(make_builtin("not"), [_convert_func_expr(node.operand, ctx, line, local_vars)]) + elif isinstance(node.op, ast.USub): + return Call(make_builtin("subtract"), [Lit(0), _convert_func_expr(node.operand, ctx, line, local_vars)]) raise YaccGrammarError(f"Unsupported unary operation: {type(node.op).__name__}", line) elif isinstance(node, ast.Subscript): diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index 0cd3041e..78d03002 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -6,6 +6,7 @@ 3. Bin roundtrip: parse .bin → print → re-parse → compare protobuf with original. """ +import re import pytest from pathlib import Path @@ -19,25 +20,6 @@ from .utils import get_lqp_input_files, get_all_files, PARENT_DIR -# Files where the generated pretty printer crashes (proto field issues). -PRETTY_PRINT_CRASHES = { - "arithmetic", - "csv", - "edb", - "loops", - "monoid_monus", - "multiple_export", - "outer", - "piece_of_q1", - "primitives", - "quantifier", - "simple_cast", - "simple_relatom", - "unicode", - "upsert", - "value_types", -} - BIN_DIR = PARENT_DIR / "test_files" / "bin" @@ -59,12 +41,23 @@ def _parse_and_pretty(input_file: str) -> str: return pretty(proto) +def _normalize_ws(s: str) -> str: + """Collapse all whitespace sequences to a single space.""" + return re.sub(r'\s+', ' ', s).strip() + + +def _clear_debug_info(proto): + """Clear debug_info from all fragments in a Transaction.""" + for epoch in proto.epochs: + for write in epoch.writes: + if write.HasField('define'): + write.define.fragment.ClearField('debug_info') + + @pytest.mark.parametrize("input_file", get_lqp_input_files()) def test_roundtrip_idempotent(input_file): """Parse → print → parse → print, then compare the two printed outputs.""" stem = _stem(input_file) - if stem in PRETTY_PRINT_CRASHES: - pytest.xfail(f"{stem}: generated pretty printer crashes") # First pass: .lqp → IR → proto → pretty-print text1 = _parse_and_pretty(input_file) @@ -84,8 +77,6 @@ def test_roundtrip_idempotent(input_file): def test_matches_old_pretty_printer(input_file): """Compare generated pretty printer output to old IR-based pretty printer.""" stem = _stem(input_file) - if stem in PRETTY_PRINT_CRASHES: - pytest.xfail(f"{stem}: generated pretty printer crashes") with open(input_file, "r") as f: content = f.read() @@ -101,7 +92,7 @@ def test_matches_old_pretty_printer(input_file): options[str(lqp_print.PrettyOptions.PRINT_DEBUG)] = False old_output = lqp_print.to_string(ir_node, options) - assert generated_output == old_output, ( + assert _normalize_ws(generated_output) == _normalize_ws(old_output), ( f"Outputs differ for {stem}.\n" f"=== Generated ===\n{generated_output}\n" f"=== Old (PRINT_NAMES) ===\n{old_output}" @@ -112,8 +103,6 @@ def test_matches_old_pretty_printer(input_file): def test_bin_roundtrip(input_file): """Parse .bin → print → re-parse → compare protobuf with original.""" stem = _stem(input_file) - if stem in PRETTY_PRINT_CRASHES: - pytest.xfail(f"{stem}: generated pretty printer crashes") # Parse binary protobuf proto1 = read_bin_to_proto(input_file) @@ -122,6 +111,11 @@ def test_bin_roundtrip(input_file): text = pretty(proto1) proto2 = generated_parse(text) + # Clear debug info before comparison since pretty printer + # consumes but does not output debug info + _clear_debug_info(proto1) + _clear_debug_info(proto2) + # Compare serialized protobufs binary1 = proto1.SerializeToString() binary2 = proto2.SerializeToString() From 9b1ad21ba90030f9c822eee6e9c7532384850be9 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 12:53:34 +0100 Subject: [PATCH 04/25] Working --- .../src/lqp/generated_pretty_printer.py | 5023 ++++++++--------- python-tools/src/meta/grammar.y | 238 +- python-tools/src/meta/pretty_gen.py | 112 +- .../meta/templates/pretty_printer.py.template | 5 +- python-tools/src/meta/yacc_action_parser.py | 78 +- python-tools/src/meta/yacc_parser.py | 42 +- 6 files changed, 2715 insertions(+), 2783 deletions(-) diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py index fdff3383..d2f3e30b 100644 --- a/python-tools/src/lqp/generated_pretty_printer.py +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -6,7 +6,7 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. -Command: python -m meta.cli proto/relationalai/lqp/v1/fragments.proto proto/relationalai/lqp/v1/logic.proto proto/relationalai/lqp/v1/transactions.proto --grammar python-tools/src/meta/grammar.y --printer python +Command: python -m meta.cli /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto --grammar src/meta/grammar.y --printer python """ from io import StringIO @@ -83,7 +83,7 @@ def format_int128(self, msg) -> str: def format_uint128(self, msg) -> str: """Format a UInt128Value protobuf message as a hex string.""" value = (msg.high << 64) | msg.low - return f"0x{value:032x}" + return f"0x{value:x}" def fragment_id_to_string(self, msg) -> str: """Convert FragmentId to string representation.""" @@ -97,7 +97,7 @@ def start_pretty_fragment(self, msg) -> None: def relation_id_to_string(self, msg): """Convert RelationId to string representation using debug info.""" - return self._debug_info.get((msg.id_low, msg.id_high)) + return self._debug_info.get((msg.id_low, msg.id_high), "") def relation_id_to_int(self, msg): """Convert RelationId to int if it fits in signed 64-bit range.""" @@ -115,260 +115,700 @@ def format_string_value(self, s: str) -> str: escaped = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t') return '"' + escaped + '"' + # --- Helper functions --- + + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + if (value is not None and value.HasField('int_value')): + return value.int_value + return default + + def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: + if (value is not None and value.HasField('float_value')): + return value.float_value + return default + + def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + if (value is not None and value.HasField('string_value')): + return value.string_value + return default + + def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + if (value is not None and value.HasField('boolean_value')): + return value.boolean_value + return default + + def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: + if (value is not None and value.HasField('string_value')): + return value.string_value.encode() + return default + + def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + if (value is not None and value.HasField('uint128_value')): + return value.uint128_value + return default + + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + if (value is not None and value.HasField('string_value')): + return [value.string_value] + return default + + def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + if (value is not None and value.HasField('int_value')): + return value.int_value + return None + + def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + if (value is not None and value.HasField('float_value')): + return value.float_value + return None + + def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: + if (value is not None and value.HasField('string_value')): + return value.string_value + return None + + def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + if (value is not None and value.HasField('string_value')): + return value.string_value.encode() + return None + + def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + if (value is not None and value.HasField('uint128_value')): + return value.uint128_value + return None + + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + if (value is not None and value.HasField('string_value')): + return [value.string_value] + return None + + def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + config = dict(config_dict) + _t1289 = self._extract_value_int64(config.get('csv_header_row'), 1) + header_row = _t1289 + _t1290 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1290 + _t1291 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1291 + _t1292 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1292 + _t1293 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1293 + _t1294 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1294 + _t1295 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1295 + _t1296 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1296 + _t1297 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1297 + _t1298 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1298 + _t1299 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1299 + _t1300 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1300 + + def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + config = dict(config_dict) + _t1301 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1301 + _t1302 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1302 + _t1303 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1303 + _t1304 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1304 + _t1305 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1305 + _t1306 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1306 + _t1307 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1307 + _t1308 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1308 + _t1309 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1309 + _t1310 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1310 + _t1311 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1311 + + def default_configure(self) -> transactions_pb2.Configure: + _t1312 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1312 + _t1313 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1313 + + def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + config = dict(config_dict) + maintenance_level_val = config.get('ivm.maintenance_level') + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + if (maintenance_level_val is not None and maintenance_level_val.HasField('string_value')): + if maintenance_level_val.string_value == 'off': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + else: + if maintenance_level_val.string_value == 'auto': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO + else: + if maintenance_level_val.string_value == 'all': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL + else: + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + _t1314 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1314 + _t1315 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1315 + _t1316 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1316 + + def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + config = dict(config_dict) + _t1317 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1317 + _t1318 = self._extract_value_string(config.get('compression'), '') + compression = _t1318 + _t1319 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1319 + _t1320 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1320 + _t1321 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1321 + _t1322 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1322 + _t1323 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1323 + _t1324 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1324 + + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t1325 = logic_pb2.Value(int_value=v) + return _t1325 + + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t1326 = logic_pb2.Value(float_value=v) + return _t1326 + + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t1327 = logic_pb2.Value(string_value=v) + return _t1327 + + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t1328 = logic_pb2.Value(boolean_value=v) + return _t1328 + + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t1329 = logic_pb2.Value(uint128_value=v) + return _t1329 + + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: + if cfg.semantics_version != 0: + return False + if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + return False + return True + + def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: + _t1331 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1331,)) + _t1330 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: + _t1333 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1333,)) + _t1332 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + _t1335 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1335,)) + _t1334 = None + else: + _t1334 = None + _t1332 = _t1334 + _t1330 = _t1332 + _t1336 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1336,)) + return result + + def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.header_row != 1: + _t1338 = self._make_value_int64(int(msg.header_row)) + result.append(('csv_header_row', _t1338,)) + _t1337 = None + else: + _t1337 = None + + if msg.skip != 0: + _t1340 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1340,)) + _t1339 = None + else: + _t1339 = None + + if msg.new_line != '': + _t1342 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1342,)) + _t1341 = None + else: + _t1341 = None + + if msg.delimiter != ',': + _t1344 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1344,)) + _t1343 = None + else: + _t1343 = None + + if msg.quotechar != '"': + _t1346 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1346,)) + _t1345 = None + else: + _t1345 = None + + if msg.escapechar != '"': + _t1348 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1348,)) + _t1347 = None + else: + _t1347 = None + + if msg.comment != '': + _t1350 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1350,)) + _t1349 = None + else: + _t1349 = None + + if not len(msg.missing_strings) == 0: + _t1352 = self._make_value_string(msg.missing_strings[0]) + result.append(('csv_missing_strings', _t1352,)) + _t1351 = None + else: + _t1351 = None + + if msg.decimal_separator != '.': + _t1354 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1354,)) + _t1353 = None + else: + _t1353 = None + + if msg.encoding != 'utf-8': + _t1356 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1356,)) + _t1355 = None + else: + _t1355 = None + + if msg.compression != 'auto': + _t1358 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1358,)) + _t1357 = None + else: + _t1357 = None + return result + + def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: + + if val is not None: + _t1360 = self._make_value_float64(val) + result.append((key, _t1360,)) + _t1359 = None + else: + _t1359 = None + return None + + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: + + if val is not None: + _t1362 = self._make_value_int64(val) + result.append((key, _t1362,)) + _t1361 = None + else: + _t1361 = None + return None + + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + + if val is not None: + _t1364 = self._make_value_uint128(val) + result.append((key, _t1364,)) + _t1363 = None + else: + _t1363 = None + return None + + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + _t1366 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1366,)) + _t1365 = None + else: + _t1365 = None + return None + + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: + result = [] + _t1367 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1368 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1369 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1370 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + + if msg.relation_locator.HasField('root_pageid'): + _t1372 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1371 = _t1372 + else: + _t1371 = None + + if msg.relation_locator.HasField('inline_data'): + _t1374 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1373 = _t1374 + else: + _t1373 = None + _t1375 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1376 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return result + + def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if (msg.partition_size is not None and msg.partition_size != 0): + _t1378 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1378,)) + _t1377 = None + else: + _t1377 = None + + if (msg.compression is not None and msg.compression != ''): + _t1380 = self._make_value_string(msg.compression) + result.append(('compression', _t1380,)) + _t1379 = None + else: + _t1379 = None + + if msg.syntax_header_row is not None: + _t1382 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1382,)) + _t1381 = None + else: + _t1381 = None + + if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + _t1384 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1384,)) + _t1383 = None + else: + _t1383 = None + + if (msg.syntax_delim is not None and msg.syntax_delim != ','): + _t1386 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1386,)) + _t1385 = None + else: + _t1385 = None + + if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + _t1388 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1388,)) + _t1387 = None + else: + _t1387 = None + + if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + _t1390 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1390,)) + _t1389 = None + else: + _t1389 = None + return result + + def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: + name = self.relation_id_to_string(msg) + if name != '': + return name + return None + + def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: + name = self.relation_id_to_string(msg) + if name == '': + return self.relation_id_to_uint128(msg) + return None + + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + return (abs.vars, [],) + + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + n = len(abs.vars) + key_end = (n - value_arity) + return (abs.vars[0:key_end], abs.vars[key_end:n],) + + # --- Pretty-print methods --- + def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: - def _t493(_dollar_dollar): - _t494 = self.is_default_configure(_dollar_dollar.configure) + def _t491(_dollar_dollar): - if not _t494: - _t495 = _dollar_dollar.configure + if _dollar_dollar.HasField('configure'): + _t492 = _dollar_dollar.configure else: - _t495 = None - return (_t495, _dollar_dollar.sync, _dollar_dollar.epochs,) - _t496 = _t493(msg) - fields0 = _t496 + _t492 = None + + if _dollar_dollar.HasField('sync'): + _t493 = _dollar_dollar.sync + else: + _t493 = None + return (_t492, _t493, _dollar_dollar.epochs,) + _t494 = _t491(msg) + fields0 = _t494 unwrapped_fields1 = fields0 self.write('(') self.write('transaction') - self.newline() self.indent() field2 = unwrapped_fields1[0] if field2 is not None: + self.newline() opt_val3 = field2 - _t498 = self.pretty_configure(opt_val3) - _t497 = _t498 + _t496 = self.pretty_configure(opt_val3) + _t495 = _t496 else: - _t497 = None - self.newline() + _t495 = None field4 = unwrapped_fields1[1] if field4 is not None: + self.newline() opt_val5 = field4 - _t500 = self.pretty_sync(opt_val5) - _t499 = _t500 + _t498 = self.pretty_sync(opt_val5) + _t497 = _t498 else: - _t499 = None - self.newline() + _t497 = None field6 = unwrapped_fields1[2] - for i8, elem7 in enumerate(field6): - - if (i8 > 0): - self.newline() - _t501 = None - else: - _t501 = None - _t502 = self.pretty_epoch(elem7) + if not len(field6) == 0: + self.newline() + for i8, elem7 in enumerate(field6): + + if (i8 > 0): + self.newline() + _t499 = None + else: + _t499 = None + _t500 = self.pretty_epoch(elem7) self.dedent() self.write(')') - self.newline() return None def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: - def _t503(_dollar_dollar): - _t504 = self.deconstruct_configure(_dollar_dollar) - return _t504 - _t505 = _t503(msg) - fields9 = _t505 + def _t501(_dollar_dollar): + _t502 = self.deconstruct_configure(_dollar_dollar) + return _t502 + _t503 = _t501(msg) + fields9 = _t503 unwrapped_fields10 = fields9 self.write('(') self.write('configure') - self.newline() self.indent() - _t506 = self.pretty_config_dict(unwrapped_fields10) + self.newline() + _t504 = self.pretty_config_dict(unwrapped_fields10) self.dedent() self.write(')') - self.newline() return None def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: - def _t507(_dollar_dollar): + def _t505(_dollar_dollar): return _dollar_dollar - _t508 = _t507(msg) - fields11 = _t508 + _t506 = _t505(msg) + fields11 = _t506 unwrapped_fields12 = fields11 self.write('{') - self.write(' ') - for i14, elem13 in enumerate(unwrapped_fields12): - - if (i14 > 0): - self.newline() - _t509 = None - else: - _t509 = None - _t510 = self.pretty_config_key_value(elem13) - self.write(' ') + if not len(unwrapped_fields12) == 0: + self.write(' ') + for i14, elem13 in enumerate(unwrapped_fields12): + + if (i14 > 0): + self.newline() + _t507 = None + else: + _t507 = None + _t508 = self.pretty_config_key_value(elem13) self.write('}') return None def pretty_config_key_value(self, msg: tuple[str, logic_pb2.Value]) -> Optional[Never]: - def _t511(_dollar_dollar): + def _t509(_dollar_dollar): return (_dollar_dollar[0], _dollar_dollar[1],) - _t512 = _t511(msg) - fields15 = _t512 + _t510 = _t509(msg) + fields15 = _t510 unwrapped_fields16 = fields15 self.write(':') - self.write(' ') field17 = unwrapped_fields16[0] self.write(field17) self.write(' ') field18 = unwrapped_fields16[1] - _t513 = self.pretty_value(field18) - return _t513 + _t511 = self.pretty_value(field18) + return _t511 def pretty_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t514(_dollar_dollar): + def _t512(_dollar_dollar): if _dollar_dollar.HasField('date_value'): - _t515 = _dollar_dollar.date_value + _t513 = _dollar_dollar.date_value else: - _t515 = None - return _t515 - _t516 = _t514(msg) - deconstruct_result29 = _t516 + _t513 = None + return _t513 + _t514 = _t512(msg) + deconstruct_result29 = _t514 if deconstruct_result29 is not None: - _t518 = self.pretty_date(deconstruct_result29) - _t517 = _t518 + _t516 = self.pretty_date(deconstruct_result29) + _t515 = _t516 else: - def _t519(_dollar_dollar): + def _t517(_dollar_dollar): if _dollar_dollar.HasField('datetime_value'): - _t520 = _dollar_dollar.datetime_value + _t518 = _dollar_dollar.datetime_value else: - _t520 = None - return _t520 - _t521 = _t519(msg) - deconstruct_result28 = _t521 + _t518 = None + return _t518 + _t519 = _t517(msg) + deconstruct_result28 = _t519 if deconstruct_result28 is not None: - _t523 = self.pretty_datetime(deconstruct_result28) - _t522 = _t523 + _t521 = self.pretty_datetime(deconstruct_result28) + _t520 = _t521 else: - def _t524(_dollar_dollar): + def _t522(_dollar_dollar): if _dollar_dollar.HasField('string_value'): - _t525 = _dollar_dollar.string_value + _t523 = _dollar_dollar.string_value else: - _t525 = None - return _t525 - _t526 = _t524(msg) - deconstruct_result27 = _t526 + _t523 = None + return _t523 + _t524 = _t522(msg) + deconstruct_result27 = _t524 if deconstruct_result27 is not None: self.write(self.format_string_value(deconstruct_result27)) - _t527 = None + _t525 = None else: - def _t528(_dollar_dollar): + def _t526(_dollar_dollar): if _dollar_dollar.HasField('int_value'): - _t529 = _dollar_dollar.int_value + _t527 = _dollar_dollar.int_value else: - _t529 = None - return _t529 - _t530 = _t528(msg) - deconstruct_result26 = _t530 + _t527 = None + return _t527 + _t528 = _t526(msg) + deconstruct_result26 = _t528 if deconstruct_result26 is not None: self.write(str(deconstruct_result26)) - _t531 = None + _t529 = None else: - def _t532(_dollar_dollar): + def _t530(_dollar_dollar): if _dollar_dollar.HasField('float_value'): - _t533 = _dollar_dollar.float_value + _t531 = _dollar_dollar.float_value else: - _t533 = None - return _t533 - _t534 = _t532(msg) - deconstruct_result25 = _t534 + _t531 = None + return _t531 + _t532 = _t530(msg) + deconstruct_result25 = _t532 if deconstruct_result25 is not None: self.write(str(deconstruct_result25)) - _t535 = None + _t533 = None else: - def _t536(_dollar_dollar): + def _t534(_dollar_dollar): if _dollar_dollar.HasField('uint128_value'): - _t537 = _dollar_dollar.uint128_value + _t535 = _dollar_dollar.uint128_value else: - _t537 = None - return _t537 - _t538 = _t536(msg) - deconstruct_result24 = _t538 + _t535 = None + return _t535 + _t536 = _t534(msg) + deconstruct_result24 = _t536 if deconstruct_result24 is not None: self.write(self.format_uint128(deconstruct_result24)) - _t539 = None + _t537 = None else: - def _t540(_dollar_dollar): + def _t538(_dollar_dollar): if _dollar_dollar.HasField('int128_value'): - _t541 = _dollar_dollar.int128_value + _t539 = _dollar_dollar.int128_value else: - _t541 = None - return _t541 - _t542 = _t540(msg) - deconstruct_result23 = _t542 + _t539 = None + return _t539 + _t540 = _t538(msg) + deconstruct_result23 = _t540 if deconstruct_result23 is not None: self.write(self.format_int128(deconstruct_result23)) - _t543 = None + _t541 = None else: - def _t544(_dollar_dollar): + def _t542(_dollar_dollar): if _dollar_dollar.HasField('decimal_value'): - _t545 = _dollar_dollar.decimal_value + _t543 = _dollar_dollar.decimal_value else: - _t545 = None - return _t545 - _t546 = _t544(msg) - deconstruct_result22 = _t546 + _t543 = None + return _t543 + _t544 = _t542(msg) + deconstruct_result22 = _t544 if deconstruct_result22 is not None: self.write(self.format_decimal(deconstruct_result22)) - _t547 = None + _t545 = None else: - def _t548(_dollar_dollar): + def _t546(_dollar_dollar): if _dollar_dollar.HasField('boolean_value'): - _t549 = _dollar_dollar.boolean_value + _t547 = _dollar_dollar.boolean_value else: - _t549 = None - return _t549 - _t550 = _t548(msg) - deconstruct_result21 = _t550 + _t547 = None + return _t547 + _t548 = _t546(msg) + deconstruct_result21 = _t548 if deconstruct_result21 is not None: - _t552 = self.pretty_boolean_value(deconstruct_result21) - _t551 = _t552 + _t550 = self.pretty_boolean_value(deconstruct_result21) + _t549 = _t550 else: - def _t553(_dollar_dollar): + def _t551(_dollar_dollar): return _dollar_dollar - _t554 = _t553(msg) - fields19 = _t554 + _t552 = _t551(msg) + fields19 = _t552 unwrapped_fields20 = fields19 self.write('missing') - _t551 = None - _t547 = _t551 - _t543 = _t547 - _t539 = _t543 - _t535 = _t539 - _t531 = _t535 - _t527 = _t531 - _t522 = _t527 - _t517 = _t522 - return _t517 + _t549 = None + _t545 = _t549 + _t541 = _t545 + _t537 = _t541 + _t533 = _t537 + _t529 = _t533 + _t525 = _t529 + _t520 = _t525 + _t515 = _t520 + return _t515 def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: - def _t555(_dollar_dollar): + def _t553(_dollar_dollar): return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) - _t556 = _t555(msg) - fields30 = _t556 + _t554 = _t553(msg) + fields30 = _t554 unwrapped_fields31 = fields30 self.write('(') self.write('date') - self.newline() self.indent() + self.newline() field32 = unwrapped_fields31[0] self.write(str(field32)) self.newline() @@ -379,19 +819,18 @@ def _t555(_dollar_dollar): self.write(str(field34)) self.dedent() self.write(')') - self.newline() return None def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: - def _t557(_dollar_dollar): + def _t555(_dollar_dollar): return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), int(_dollar_dollar.microsecond),) - _t558 = _t557(msg) - fields35 = _t558 + _t556 = _t555(msg) + fields35 = _t556 unwrapped_fields36 = fields35 self.write('(') self.write('datetime') - self.newline() self.indent() + self.newline() field37 = unwrapped_fields36[0] self.write(str(field37)) self.newline() @@ -409,3542 +848,3040 @@ def _t557(_dollar_dollar): self.newline() field42 = unwrapped_fields36[5] self.write(str(field42)) - self.newline() field43 = unwrapped_fields36[6] if field43 is not None: + self.newline() opt_val44 = field43 self.write(str(opt_val44)) - _t559 = None + _t557 = None else: - _t559 = None + _t557 = None self.dedent() self.write(')') - self.newline() return None def pretty_boolean_value(self, msg: bool) -> Optional[Never]: - def _t560(_dollar_dollar): - return _dollar_dollar - _t561 = _t560(msg) - fields47 = _t561 - unwrapped_fields48 = fields47 - self.write('true') - return None + def _t558(_dollar_dollar): + + if _dollar_dollar: + _t559 = () + else: + _t559 = None + return _t559 + _t560 = _t558(msg) + deconstruct_result47 = _t560 + + if deconstruct_result47 is not None: + self.write('true') + _t561 = None + else: + def _t562(_dollar_dollar): + return _dollar_dollar + _t563 = _t562(msg) + fields45 = _t563 + unwrapped_fields46 = fields45 + self.write('false') + _t561 = None + return _t561 def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: - def _t562(_dollar_dollar): + def _t564(_dollar_dollar): return _dollar_dollar.fragments - _t563 = _t562(msg) - fields49 = _t563 - unwrapped_fields50 = fields49 + _t565 = _t564(msg) + fields48 = _t565 + unwrapped_fields49 = fields48 self.write('(') self.write('sync') - self.newline() self.indent() - for i52, elem51 in enumerate(unwrapped_fields50): - - if (i52 > 0): - self.newline() - _t564 = None - else: - _t564 = None - _t565 = self.pretty_fragment_id(elem51) + if not len(unwrapped_fields49) == 0: + self.newline() + for i51, elem50 in enumerate(unwrapped_fields49): + + if (i51 > 0): + self.newline() + _t566 = None + else: + _t566 = None + _t567 = self.pretty_fragment_id(elem50) self.dedent() self.write(')') - self.newline() return None def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t566(_dollar_dollar): + def _t568(_dollar_dollar): return self.fragment_id_to_string(_dollar_dollar) - _t567 = _t566(msg) - fields53 = _t567 - unwrapped_fields54 = fields53 + _t569 = _t568(msg) + fields52 = _t569 + unwrapped_fields53 = fields52 self.write(':') - self.write(' ') - self.write(unwrapped_fields54) + self.write(unwrapped_fields53) return None def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: - def _t568(_dollar_dollar): + def _t570(_dollar_dollar): if not len(_dollar_dollar.writes) == 0: - _t569 = _dollar_dollar.writes + _t571 = _dollar_dollar.writes else: - _t569 = None + _t571 = None if not len(_dollar_dollar.reads) == 0: - _t570 = _dollar_dollar.reads + _t572 = _dollar_dollar.reads else: - _t570 = None - return (_t569, _t570,) - _t571 = _t568(msg) - fields55 = _t571 - unwrapped_fields56 = fields55 + _t572 = None + return (_t571, _t572,) + _t573 = _t570(msg) + fields54 = _t573 + unwrapped_fields55 = fields54 self.write('(') self.write('epoch') - self.newline() self.indent() - field57 = unwrapped_fields56[0] - - if field57 is not None: - opt_val58 = field57 - _t573 = self.pretty_epoch_writes(opt_val58) - _t572 = _t573 - else: - _t572 = None - self.newline() - field59 = unwrapped_fields56[1] + field56 = unwrapped_fields55[0] - if field59 is not None: - opt_val60 = field59 - _t575 = self.pretty_epoch_reads(opt_val60) + if field56 is not None: + self.newline() + opt_val57 = field56 + _t575 = self.pretty_epoch_writes(opt_val57) _t574 = _t575 else: _t574 = None + field58 = unwrapped_fields55[1] + + if field58 is not None: + self.newline() + opt_val59 = field58 + _t577 = self.pretty_epoch_reads(opt_val59) + _t576 = _t577 + else: + _t576 = None self.dedent() self.write(')') - self.newline() return None def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: - def _t576(_dollar_dollar): + def _t578(_dollar_dollar): return _dollar_dollar - _t577 = _t576(msg) - fields61 = _t577 - unwrapped_fields62 = fields61 + _t579 = _t578(msg) + fields60 = _t579 + unwrapped_fields61 = fields60 self.write('(') self.write('writes') - self.newline() self.indent() - for i64, elem63 in enumerate(unwrapped_fields62): - - if (i64 > 0): - self.newline() - _t578 = None - else: - _t578 = None - _t579 = self.pretty_write(elem63) + if not len(unwrapped_fields61) == 0: + self.newline() + for i63, elem62 in enumerate(unwrapped_fields61): + + if (i63 > 0): + self.newline() + _t580 = None + else: + _t580 = None + _t581 = self.pretty_write(elem62) self.dedent() self.write(')') - self.newline() return None def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: - def _t580(_dollar_dollar): + def _t582(_dollar_dollar): if _dollar_dollar.HasField('define'): - _t581 = _dollar_dollar.define + _t583 = _dollar_dollar.define else: - _t581 = None - return _t581 - _t582 = _t580(msg) - deconstruct_result67 = _t582 + _t583 = None + return _t583 + _t584 = _t582(msg) + deconstruct_result66 = _t584 - if deconstruct_result67 is not None: - _t584 = self.pretty_define(deconstruct_result67) - _t583 = _t584 + if deconstruct_result66 is not None: + _t586 = self.pretty_define(deconstruct_result66) + _t585 = _t586 else: - def _t585(_dollar_dollar): + def _t587(_dollar_dollar): if _dollar_dollar.HasField('undefine'): - _t586 = _dollar_dollar.undefine + _t588 = _dollar_dollar.undefine else: - _t586 = None - return _t586 - _t587 = _t585(msg) - deconstruct_result66 = _t587 + _t588 = None + return _t588 + _t589 = _t587(msg) + deconstruct_result65 = _t589 - if deconstruct_result66 is not None: - _t589 = self.pretty_undefine(deconstruct_result66) - _t588 = _t589 + if deconstruct_result65 is not None: + _t591 = self.pretty_undefine(deconstruct_result65) + _t590 = _t591 else: - def _t590(_dollar_dollar): + def _t592(_dollar_dollar): if _dollar_dollar.HasField('context'): - _t591 = _dollar_dollar.context + _t593 = _dollar_dollar.context else: - _t591 = None - return _t591 - _t592 = _t590(msg) - deconstruct_result65 = _t592 + _t593 = None + return _t593 + _t594 = _t592(msg) + deconstruct_result64 = _t594 - if deconstruct_result65 is not None: - _t594 = self.pretty_context(deconstruct_result65) - _t593 = _t594 + if deconstruct_result64 is not None: + _t596 = self.pretty_context(deconstruct_result64) + _t595 = _t596 else: raise ParseError('No matching rule for write') - _t588 = _t593 - _t583 = _t588 - return _t583 + _t590 = _t595 + _t585 = _t590 + return _t585 def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: - def _t595(_dollar_dollar): + def _t597(_dollar_dollar): return _dollar_dollar.fragment - _t596 = _t595(msg) - fields68 = _t596 - unwrapped_fields69 = fields68 + _t598 = _t597(msg) + fields67 = _t598 + unwrapped_fields68 = fields67 self.write('(') self.write('define') - self.newline() self.indent() - _t597 = self.pretty_fragment(unwrapped_fields69) + self.newline() + _t599 = self.pretty_fragment(unwrapped_fields68) self.dedent() self.write(')') - self.newline() return None def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: - def _t598(_dollar_dollar): - _t599 = self.start_pretty_fragment(_dollar_dollar) + def _t600(_dollar_dollar): + _t601 = self.start_pretty_fragment(_dollar_dollar) return (_dollar_dollar.id, _dollar_dollar.declarations,) - _t600 = _t598(msg) - fields70 = _t600 - unwrapped_fields71 = fields70 + _t602 = _t600(msg) + fields69 = _t602 + unwrapped_fields70 = fields69 self.write('(') self.write('fragment') - self.newline() self.indent() - field72 = unwrapped_fields71[0] - _t601 = self.pretty_new_fragment_id(field72) self.newline() - field73 = unwrapped_fields71[1] - for i75, elem74 in enumerate(field73): - - if (i75 > 0): - self.newline() - _t602 = None - else: - _t602 = None - _t603 = self.pretty_declaration(elem74) + field71 = unwrapped_fields70[0] + _t603 = self.pretty_new_fragment_id(field71) + field72 = unwrapped_fields70[1] + if not len(field72) == 0: + self.newline() + for i74, elem73 in enumerate(field72): + + if (i74 > 0): + self.newline() + _t604 = None + else: + _t604 = None + _t605 = self.pretty_declaration(elem73) self.dedent() self.write(')') - self.newline() return None def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t604(_dollar_dollar): + def _t606(_dollar_dollar): return _dollar_dollar - _t605 = _t604(msg) - fields76 = _t605 - unwrapped_fields77 = fields76 - _t606 = self.pretty_fragment_id(unwrapped_fields77) - return _t606 + _t607 = _t606(msg) + fields75 = _t607 + unwrapped_fields76 = fields75 + _t608 = self.pretty_fragment_id(unwrapped_fields76) + return _t608 def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: - def _t607(_dollar_dollar): + def _t609(_dollar_dollar): if _dollar_dollar.HasField('def'): - _t608 = getattr(_dollar_dollar, 'def') + _t610 = getattr(_dollar_dollar, 'def') else: - _t608 = None - return _t608 - _t609 = _t607(msg) - deconstruct_result81 = _t609 + _t610 = None + return _t610 + _t611 = _t609(msg) + deconstruct_result80 = _t611 - if deconstruct_result81 is not None: - _t611 = self.pretty_def(deconstruct_result81) - _t610 = _t611 + if deconstruct_result80 is not None: + _t613 = self.pretty_def(deconstruct_result80) + _t612 = _t613 else: - def _t612(_dollar_dollar): + def _t614(_dollar_dollar): if _dollar_dollar.HasField('algorithm'): - _t613 = _dollar_dollar.algorithm + _t615 = _dollar_dollar.algorithm else: - _t613 = None - return _t613 - _t614 = _t612(msg) - deconstruct_result80 = _t614 + _t615 = None + return _t615 + _t616 = _t614(msg) + deconstruct_result79 = _t616 - if deconstruct_result80 is not None: - _t616 = self.pretty_algorithm(deconstruct_result80) - _t615 = _t616 + if deconstruct_result79 is not None: + _t618 = self.pretty_algorithm(deconstruct_result79) + _t617 = _t618 else: - def _t617(_dollar_dollar): + def _t619(_dollar_dollar): if _dollar_dollar.HasField('constraint'): - _t618 = _dollar_dollar.constraint + _t620 = _dollar_dollar.constraint else: - _t618 = None - return _t618 - _t619 = _t617(msg) - deconstruct_result79 = _t619 + _t620 = None + return _t620 + _t621 = _t619(msg) + deconstruct_result78 = _t621 - if deconstruct_result79 is not None: - _t621 = self.pretty_constraint(deconstruct_result79) - _t620 = _t621 + if deconstruct_result78 is not None: + _t623 = self.pretty_constraint(deconstruct_result78) + _t622 = _t623 else: - def _t622(_dollar_dollar): + def _t624(_dollar_dollar): if _dollar_dollar.HasField('data'): - _t623 = _dollar_dollar.data + _t625 = _dollar_dollar.data else: - _t623 = None - return _t623 - _t624 = _t622(msg) - deconstruct_result78 = _t624 + _t625 = None + return _t625 + _t626 = _t624(msg) + deconstruct_result77 = _t626 - if deconstruct_result78 is not None: - _t626 = self.pretty_data(deconstruct_result78) - _t625 = _t626 + if deconstruct_result77 is not None: + _t628 = self.pretty_data(deconstruct_result77) + _t627 = _t628 else: raise ParseError('No matching rule for declaration') - _t620 = _t625 - _t615 = _t620 - _t610 = _t615 - return _t610 + _t622 = _t627 + _t617 = _t622 + _t612 = _t617 + return _t612 def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: - def _t627(_dollar_dollar): + def _t629(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t628 = _dollar_dollar.attrs + _t630 = _dollar_dollar.attrs else: - _t628 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t628,) - _t629 = _t627(msg) - fields82 = _t629 - unwrapped_fields83 = fields82 + _t630 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t630,) + _t631 = _t629(msg) + fields81 = _t631 + unwrapped_fields82 = fields81 self.write('(') self.write('def') - self.newline() self.indent() - field84 = unwrapped_fields83[0] - _t630 = self.pretty_relation_id(field84) self.newline() - field85 = unwrapped_fields83[1] - _t631 = self.pretty_abstraction(field85) + field83 = unwrapped_fields82[0] + _t632 = self.pretty_relation_id(field83) self.newline() - field86 = unwrapped_fields83[2] + field84 = unwrapped_fields82[1] + _t633 = self.pretty_abstraction(field84) + field85 = unwrapped_fields82[2] - if field86 is not None: - opt_val87 = field86 - _t633 = self.pretty_attrs(opt_val87) - _t632 = _t633 + if field85 is not None: + self.newline() + opt_val86 = field85 + _t635 = self.pretty_attrs(opt_val86) + _t634 = _t635 else: - _t632 = None + _t634 = None self.dedent() self.write(')') - self.newline() return None def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: - def _t634(_dollar_dollar): - _t635 = self.deconstruct_relation_id_string(_dollar_dollar) - return _t635 - _t636 = _t634(msg) - deconstruct_result89 = _t636 + def _t636(_dollar_dollar): + _t637 = self.deconstruct_relation_id_string(_dollar_dollar) + return _t637 + _t638 = _t636(msg) + deconstruct_result88 = _t638 - if deconstruct_result89 is not None: + if deconstruct_result88 is not None: self.write(':') - self.write(' ') - self.write(deconstruct_result89) - _t637 = None + self.write(deconstruct_result88) + _t639 = None else: - def _t638(_dollar_dollar): - _t639 = self.deconstruct_relation_id_uint128(_dollar_dollar) - return _t639 - _t640 = _t638(msg) - deconstruct_result88 = _t640 + def _t640(_dollar_dollar): + _t641 = self.deconstruct_relation_id_uint128(_dollar_dollar) + return _t641 + _t642 = _t640(msg) + deconstruct_result87 = _t642 - if deconstruct_result88 is not None: - self.write(self.format_uint128(deconstruct_result88)) - _t641 = None + if deconstruct_result87 is not None: + self.write(self.format_uint128(deconstruct_result87)) + _t643 = None else: raise ParseError('No matching rule for relation_id') - _t637 = _t641 - return _t637 + _t639 = _t643 + return _t639 def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: - def _t642(_dollar_dollar): - _t643 = self.deconstruct_bindings(_dollar_dollar) - return (_t643, _dollar_dollar.value,) - _t644 = _t642(msg) - fields90 = _t644 - unwrapped_fields91 = fields90 - self.write('(') - self.write(' ') - field92 = unwrapped_fields91[0] - _t645 = self.pretty_bindings(field92) + def _t644(_dollar_dollar): + _t645 = self.deconstruct_bindings(_dollar_dollar) + return (_t645, _dollar_dollar.value,) + _t646 = _t644(msg) + fields89 = _t646 + unwrapped_fields90 = fields89 + self.write('(') + field91 = unwrapped_fields90[0] + _t647 = self.pretty_bindings(field91) self.write(' ') - field93 = unwrapped_fields91[1] - _t646 = self.pretty_formula(field93) - self.write(' ') - self.dedent() + field92 = unwrapped_fields90[1] + _t648 = self.pretty_formula(field92) self.write(')') - self.newline() return None def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: - def _t647(_dollar_dollar): + def _t649(_dollar_dollar): if not len(_dollar_dollar[1]) == 0: - _t648 = _dollar_dollar[1] + _t650 = _dollar_dollar[1] else: - _t648 = None - return (_dollar_dollar[0], _t648,) - _t649 = _t647(msg) - fields94 = _t649 - unwrapped_fields95 = fields94 + _t650 = None + return (_dollar_dollar[0], _t650,) + _t651 = _t649(msg) + fields93 = _t651 + unwrapped_fields94 = fields93 self.write('[') - self.write(' ') - field96 = unwrapped_fields95[0] - for i98, elem97 in enumerate(field96): + field95 = unwrapped_fields94[0] + for i97, elem96 in enumerate(field95): - if (i98 > 0): + if (i97 > 0): self.newline() - _t650 = None + _t652 = None else: - _t650 = None - _t651 = self.pretty_binding(elem97) - self.write(' ') - field99 = unwrapped_fields95[1] + _t652 = None + _t653 = self.pretty_binding(elem96) + field98 = unwrapped_fields94[1] - if field99 is not None: - opt_val100 = field99 - _t653 = self.pretty_value_bindings(opt_val100) - _t652 = _t653 + if field98 is not None: + self.write(' ') + opt_val99 = field98 + _t655 = self.pretty_value_bindings(opt_val99) + _t654 = _t655 else: - _t652 = None - self.write(' ') + _t654 = None self.write(']') return None def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: - def _t654(_dollar_dollar): + def _t656(_dollar_dollar): return (_dollar_dollar.var.name, _dollar_dollar.type,) - _t655 = _t654(msg) - fields101 = _t655 - unwrapped_fields102 = fields101 - field103 = unwrapped_fields102[0] - self.write(field103) - self.write(' ') + _t657 = _t656(msg) + fields100 = _t657 + unwrapped_fields101 = fields100 + field102 = unwrapped_fields101[0] + self.write(field102) self.write('::') - self.write(' ') - field104 = unwrapped_fields102[1] - _t656 = self.pretty_type(field104) - return _t656 + field103 = unwrapped_fields101[1] + _t658 = self.pretty_type(field103) + return _t658 def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: - def _t657(_dollar_dollar): + def _t659(_dollar_dollar): if _dollar_dollar.HasField('unspecified_type'): - _t658 = _dollar_dollar.unspecified_type + _t660 = _dollar_dollar.unspecified_type else: - _t658 = None - return _t658 - _t659 = _t657(msg) - deconstruct_result115 = _t659 + _t660 = None + return _t660 + _t661 = _t659(msg) + deconstruct_result114 = _t661 - if deconstruct_result115 is not None: - _t661 = self.pretty_unspecified_type(deconstruct_result115) - _t660 = _t661 + if deconstruct_result114 is not None: + _t663 = self.pretty_unspecified_type(deconstruct_result114) + _t662 = _t663 else: - def _t662(_dollar_dollar): + def _t664(_dollar_dollar): if _dollar_dollar.HasField('string_type'): - _t663 = _dollar_dollar.string_type + _t665 = _dollar_dollar.string_type else: - _t663 = None - return _t663 - _t664 = _t662(msg) - deconstruct_result114 = _t664 + _t665 = None + return _t665 + _t666 = _t664(msg) + deconstruct_result113 = _t666 - if deconstruct_result114 is not None: - _t666 = self.pretty_string_type(deconstruct_result114) - _t665 = _t666 + if deconstruct_result113 is not None: + _t668 = self.pretty_string_type(deconstruct_result113) + _t667 = _t668 else: - def _t667(_dollar_dollar): + def _t669(_dollar_dollar): if _dollar_dollar.HasField('int_type'): - _t668 = _dollar_dollar.int_type + _t670 = _dollar_dollar.int_type else: - _t668 = None - return _t668 - _t669 = _t667(msg) - deconstruct_result113 = _t669 + _t670 = None + return _t670 + _t671 = _t669(msg) + deconstruct_result112 = _t671 - if deconstruct_result113 is not None: - _t671 = self.pretty_int_type(deconstruct_result113) - _t670 = _t671 + if deconstruct_result112 is not None: + _t673 = self.pretty_int_type(deconstruct_result112) + _t672 = _t673 else: - def _t672(_dollar_dollar): + def _t674(_dollar_dollar): if _dollar_dollar.HasField('float_type'): - _t673 = _dollar_dollar.float_type + _t675 = _dollar_dollar.float_type else: - _t673 = None - return _t673 - _t674 = _t672(msg) - deconstruct_result112 = _t674 + _t675 = None + return _t675 + _t676 = _t674(msg) + deconstruct_result111 = _t676 - if deconstruct_result112 is not None: - _t676 = self.pretty_float_type(deconstruct_result112) - _t675 = _t676 + if deconstruct_result111 is not None: + _t678 = self.pretty_float_type(deconstruct_result111) + _t677 = _t678 else: - def _t677(_dollar_dollar): + def _t679(_dollar_dollar): if _dollar_dollar.HasField('uint128_type'): - _t678 = _dollar_dollar.uint128_type + _t680 = _dollar_dollar.uint128_type else: - _t678 = None - return _t678 - _t679 = _t677(msg) - deconstruct_result111 = _t679 + _t680 = None + return _t680 + _t681 = _t679(msg) + deconstruct_result110 = _t681 - if deconstruct_result111 is not None: - _t681 = self.pretty_uint128_type(deconstruct_result111) - _t680 = _t681 + if deconstruct_result110 is not None: + _t683 = self.pretty_uint128_type(deconstruct_result110) + _t682 = _t683 else: - def _t682(_dollar_dollar): + def _t684(_dollar_dollar): if _dollar_dollar.HasField('int128_type'): - _t683 = _dollar_dollar.int128_type + _t685 = _dollar_dollar.int128_type else: - _t683 = None - return _t683 - _t684 = _t682(msg) - deconstruct_result110 = _t684 + _t685 = None + return _t685 + _t686 = _t684(msg) + deconstruct_result109 = _t686 - if deconstruct_result110 is not None: - _t686 = self.pretty_int128_type(deconstruct_result110) - _t685 = _t686 + if deconstruct_result109 is not None: + _t688 = self.pretty_int128_type(deconstruct_result109) + _t687 = _t688 else: - def _t687(_dollar_dollar): + def _t689(_dollar_dollar): if _dollar_dollar.HasField('date_type'): - _t688 = _dollar_dollar.date_type + _t690 = _dollar_dollar.date_type else: - _t688 = None - return _t688 - _t689 = _t687(msg) - deconstruct_result109 = _t689 + _t690 = None + return _t690 + _t691 = _t689(msg) + deconstruct_result108 = _t691 - if deconstruct_result109 is not None: - _t691 = self.pretty_date_type(deconstruct_result109) - _t690 = _t691 + if deconstruct_result108 is not None: + _t693 = self.pretty_date_type(deconstruct_result108) + _t692 = _t693 else: - def _t692(_dollar_dollar): + def _t694(_dollar_dollar): if _dollar_dollar.HasField('datetime_type'): - _t693 = _dollar_dollar.datetime_type + _t695 = _dollar_dollar.datetime_type else: - _t693 = None - return _t693 - _t694 = _t692(msg) - deconstruct_result108 = _t694 + _t695 = None + return _t695 + _t696 = _t694(msg) + deconstruct_result107 = _t696 - if deconstruct_result108 is not None: - _t696 = self.pretty_datetime_type(deconstruct_result108) - _t695 = _t696 + if deconstruct_result107 is not None: + _t698 = self.pretty_datetime_type(deconstruct_result107) + _t697 = _t698 else: - def _t697(_dollar_dollar): + def _t699(_dollar_dollar): if _dollar_dollar.HasField('missing_type'): - _t698 = _dollar_dollar.missing_type + _t700 = _dollar_dollar.missing_type else: - _t698 = None - return _t698 - _t699 = _t697(msg) - deconstruct_result107 = _t699 + _t700 = None + return _t700 + _t701 = _t699(msg) + deconstruct_result106 = _t701 - if deconstruct_result107 is not None: - _t701 = self.pretty_missing_type(deconstruct_result107) - _t700 = _t701 + if deconstruct_result106 is not None: + _t703 = self.pretty_missing_type(deconstruct_result106) + _t702 = _t703 else: - def _t702(_dollar_dollar): + def _t704(_dollar_dollar): if _dollar_dollar.HasField('decimal_type'): - _t703 = _dollar_dollar.decimal_type + _t705 = _dollar_dollar.decimal_type else: - _t703 = None - return _t703 - _t704 = _t702(msg) - deconstruct_result106 = _t704 + _t705 = None + return _t705 + _t706 = _t704(msg) + deconstruct_result105 = _t706 - if deconstruct_result106 is not None: - _t706 = self.pretty_decimal_type(deconstruct_result106) - _t705 = _t706 + if deconstruct_result105 is not None: + _t708 = self.pretty_decimal_type(deconstruct_result105) + _t707 = _t708 else: - def _t707(_dollar_dollar): + def _t709(_dollar_dollar): if _dollar_dollar.HasField('boolean_type'): - _t708 = _dollar_dollar.boolean_type + _t710 = _dollar_dollar.boolean_type else: - _t708 = None - return _t708 - _t709 = _t707(msg) - deconstruct_result105 = _t709 + _t710 = None + return _t710 + _t711 = _t709(msg) + deconstruct_result104 = _t711 - if deconstruct_result105 is not None: - _t711 = self.pretty_boolean_type(deconstruct_result105) - _t710 = _t711 + if deconstruct_result104 is not None: + _t713 = self.pretty_boolean_type(deconstruct_result104) + _t712 = _t713 else: raise ParseError('No matching rule for type') - _t705 = _t710 - _t700 = _t705 - _t695 = _t700 - _t690 = _t695 - _t685 = _t690 - _t680 = _t685 - _t675 = _t680 - _t670 = _t675 - _t665 = _t670 - _t660 = _t665 - return _t660 + _t707 = _t712 + _t702 = _t707 + _t697 = _t702 + _t692 = _t697 + _t687 = _t692 + _t682 = _t687 + _t677 = _t682 + _t672 = _t677 + _t667 = _t672 + _t662 = _t667 + return _t662 def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: - def _t712(_dollar_dollar): + def _t714(_dollar_dollar): return _dollar_dollar - _t713 = _t712(msg) - fields116 = _t713 - unwrapped_fields117 = fields116 + _t715 = _t714(msg) + fields115 = _t715 + unwrapped_fields116 = fields115 self.write('UNKNOWN') return None def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: - def _t714(_dollar_dollar): + def _t716(_dollar_dollar): return _dollar_dollar - _t715 = _t714(msg) - fields118 = _t715 - unwrapped_fields119 = fields118 + _t717 = _t716(msg) + fields117 = _t717 + unwrapped_fields118 = fields117 self.write('STRING') return None def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: - def _t716(_dollar_dollar): + def _t718(_dollar_dollar): return _dollar_dollar - _t717 = _t716(msg) - fields120 = _t717 - unwrapped_fields121 = fields120 + _t719 = _t718(msg) + fields119 = _t719 + unwrapped_fields120 = fields119 self.write('INT') return None def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: - def _t718(_dollar_dollar): + def _t720(_dollar_dollar): return _dollar_dollar - _t719 = _t718(msg) - fields122 = _t719 - unwrapped_fields123 = fields122 + _t721 = _t720(msg) + fields121 = _t721 + unwrapped_fields122 = fields121 self.write('FLOAT') return None def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: - def _t720(_dollar_dollar): + def _t722(_dollar_dollar): return _dollar_dollar - _t721 = _t720(msg) - fields124 = _t721 - unwrapped_fields125 = fields124 + _t723 = _t722(msg) + fields123 = _t723 + unwrapped_fields124 = fields123 self.write('UINT128') return None def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: - def _t722(_dollar_dollar): + def _t724(_dollar_dollar): return _dollar_dollar - _t723 = _t722(msg) - fields126 = _t723 - unwrapped_fields127 = fields126 + _t725 = _t724(msg) + fields125 = _t725 + unwrapped_fields126 = fields125 self.write('INT128') return None def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: - def _t724(_dollar_dollar): + def _t726(_dollar_dollar): return _dollar_dollar - _t725 = _t724(msg) - fields128 = _t725 - unwrapped_fields129 = fields128 + _t727 = _t726(msg) + fields127 = _t727 + unwrapped_fields128 = fields127 self.write('DATE') return None def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: - def _t726(_dollar_dollar): + def _t728(_dollar_dollar): return _dollar_dollar - _t727 = _t726(msg) - fields130 = _t727 - unwrapped_fields131 = fields130 + _t729 = _t728(msg) + fields129 = _t729 + unwrapped_fields130 = fields129 self.write('DATETIME') return None def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: - def _t728(_dollar_dollar): + def _t730(_dollar_dollar): return _dollar_dollar - _t729 = _t728(msg) - fields132 = _t729 - unwrapped_fields133 = fields132 + _t731 = _t730(msg) + fields131 = _t731 + unwrapped_fields132 = fields131 self.write('MISSING') return None def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: - def _t730(_dollar_dollar): + def _t732(_dollar_dollar): return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) - _t731 = _t730(msg) - fields134 = _t731 - unwrapped_fields135 = fields134 + _t733 = _t732(msg) + fields133 = _t733 + unwrapped_fields134 = fields133 self.write('(') self.write('DECIMAL') - self.newline() self.indent() - field136 = unwrapped_fields135[0] - self.write(str(field136)) self.newline() - field137 = unwrapped_fields135[1] - self.write(str(field137)) + field135 = unwrapped_fields134[0] + self.write(str(field135)) + self.newline() + field136 = unwrapped_fields134[1] + self.write(str(field136)) self.dedent() self.write(')') - self.newline() return None def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: - def _t732(_dollar_dollar): + def _t734(_dollar_dollar): return _dollar_dollar - _t733 = _t732(msg) - fields138 = _t733 - unwrapped_fields139 = fields138 + _t735 = _t734(msg) + fields137 = _t735 + unwrapped_fields138 = fields137 self.write('BOOLEAN') return None def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: - def _t734(_dollar_dollar): + def _t736(_dollar_dollar): return _dollar_dollar - _t735 = _t734(msg) - fields140 = _t735 - unwrapped_fields141 = fields140 + _t737 = _t736(msg) + fields139 = _t737 + unwrapped_fields140 = fields139 self.write('|') - self.write(' ') - for i143, elem142 in enumerate(unwrapped_fields141): - - if (i143 > 0): - self.newline() - _t736 = None - else: - _t736 = None - _t737 = self.pretty_binding(elem142) + if not len(unwrapped_fields140) == 0: + self.write(' ') + for i142, elem141 in enumerate(unwrapped_fields140): + + if (i142 > 0): + self.newline() + _t738 = None + else: + _t738 = None + _t739 = self.pretty_binding(elem141) return None def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: - def _t738(_dollar_dollar): + def _t740(_dollar_dollar): if (_dollar_dollar.HasField('conjunction') and len(_dollar_dollar.conjunction.args) == 0): - _t739 = _dollar_dollar.conjunction + _t741 = _dollar_dollar.conjunction else: - _t739 = None - return _t739 - _t740 = _t738(msg) - deconstruct_result156 = _t740 + _t741 = None + return _t741 + _t742 = _t740(msg) + deconstruct_result155 = _t742 - if deconstruct_result156 is not None: - _t742 = self.pretty_true(deconstruct_result156) - _t741 = _t742 + if deconstruct_result155 is not None: + _t744 = self.pretty_true(deconstruct_result155) + _t743 = _t744 else: - def _t743(_dollar_dollar): + def _t745(_dollar_dollar): if (_dollar_dollar.HasField('disjunction') and len(_dollar_dollar.disjunction.args) == 0): - _t744 = _dollar_dollar.disjunction + _t746 = _dollar_dollar.disjunction else: - _t744 = None - return _t744 - _t745 = _t743(msg) - deconstruct_result155 = _t745 + _t746 = None + return _t746 + _t747 = _t745(msg) + deconstruct_result154 = _t747 - if deconstruct_result155 is not None: - _t747 = self.pretty_false(deconstruct_result155) - _t746 = _t747 + if deconstruct_result154 is not None: + _t749 = self.pretty_false(deconstruct_result154) + _t748 = _t749 else: - def _t748(_dollar_dollar): + def _t750(_dollar_dollar): if _dollar_dollar.HasField('exists'): - _t749 = _dollar_dollar.exists + _t751 = _dollar_dollar.exists else: - _t749 = None - return _t749 - _t750 = _t748(msg) - deconstruct_result154 = _t750 + _t751 = None + return _t751 + _t752 = _t750(msg) + deconstruct_result153 = _t752 - if deconstruct_result154 is not None: - _t752 = self.pretty_exists(deconstruct_result154) - _t751 = _t752 + if deconstruct_result153 is not None: + _t754 = self.pretty_exists(deconstruct_result153) + _t753 = _t754 else: - def _t753(_dollar_dollar): + def _t755(_dollar_dollar): if _dollar_dollar.HasField('reduce'): - _t754 = _dollar_dollar.reduce + _t756 = _dollar_dollar.reduce else: - _t754 = None - return _t754 - _t755 = _t753(msg) - deconstruct_result153 = _t755 + _t756 = None + return _t756 + _t757 = _t755(msg) + deconstruct_result152 = _t757 - if deconstruct_result153 is not None: - _t757 = self.pretty_reduce(deconstruct_result153) - _t756 = _t757 + if deconstruct_result152 is not None: + _t759 = self.pretty_reduce(deconstruct_result152) + _t758 = _t759 else: - def _t758(_dollar_dollar): + def _t760(_dollar_dollar): if (_dollar_dollar.HasField('conjunction') and not len(_dollar_dollar.conjunction.args) == 0): - _t759 = _dollar_dollar.conjunction + _t761 = _dollar_dollar.conjunction else: - _t759 = None - return _t759 - _t760 = _t758(msg) - deconstruct_result152 = _t760 + _t761 = None + return _t761 + _t762 = _t760(msg) + deconstruct_result151 = _t762 - if deconstruct_result152 is not None: - _t762 = self.pretty_conjunction(deconstruct_result152) - _t761 = _t762 + if deconstruct_result151 is not None: + _t764 = self.pretty_conjunction(deconstruct_result151) + _t763 = _t764 else: - def _t763(_dollar_dollar): + def _t765(_dollar_dollar): if (_dollar_dollar.HasField('disjunction') and not len(_dollar_dollar.disjunction.args) == 0): - _t764 = _dollar_dollar.disjunction + _t766 = _dollar_dollar.disjunction else: - _t764 = None - return _t764 - _t765 = _t763(msg) - deconstruct_result151 = _t765 + _t766 = None + return _t766 + _t767 = _t765(msg) + deconstruct_result150 = _t767 - if deconstruct_result151 is not None: - _t767 = self.pretty_disjunction(deconstruct_result151) - _t766 = _t767 + if deconstruct_result150 is not None: + _t769 = self.pretty_disjunction(deconstruct_result150) + _t768 = _t769 else: - def _t768(_dollar_dollar): + def _t770(_dollar_dollar): if _dollar_dollar.HasField('not'): - _t769 = getattr(_dollar_dollar, 'not') + _t771 = getattr(_dollar_dollar, 'not') else: - _t769 = None - return _t769 - _t770 = _t768(msg) - deconstruct_result150 = _t770 + _t771 = None + return _t771 + _t772 = _t770(msg) + deconstruct_result149 = _t772 - if deconstruct_result150 is not None: - _t772 = self.pretty_not(deconstruct_result150) - _t771 = _t772 + if deconstruct_result149 is not None: + _t774 = self.pretty_not(deconstruct_result149) + _t773 = _t774 else: - def _t773(_dollar_dollar): + def _t775(_dollar_dollar): if _dollar_dollar.HasField('ffi'): - _t774 = _dollar_dollar.ffi + _t776 = _dollar_dollar.ffi else: - _t774 = None - return _t774 - _t775 = _t773(msg) - deconstruct_result149 = _t775 + _t776 = None + return _t776 + _t777 = _t775(msg) + deconstruct_result148 = _t777 - if deconstruct_result149 is not None: - _t777 = self.pretty_ffi(deconstruct_result149) - _t776 = _t777 + if deconstruct_result148 is not None: + _t779 = self.pretty_ffi(deconstruct_result148) + _t778 = _t779 else: - def _t778(_dollar_dollar): + def _t780(_dollar_dollar): if _dollar_dollar.HasField('atom'): - _t779 = _dollar_dollar.atom + _t781 = _dollar_dollar.atom else: - _t779 = None - return _t779 - _t780 = _t778(msg) - deconstruct_result148 = _t780 + _t781 = None + return _t781 + _t782 = _t780(msg) + deconstruct_result147 = _t782 - if deconstruct_result148 is not None: - _t782 = self.pretty_atom(deconstruct_result148) - _t781 = _t782 + if deconstruct_result147 is not None: + _t784 = self.pretty_atom(deconstruct_result147) + _t783 = _t784 else: - def _t783(_dollar_dollar): + def _t785(_dollar_dollar): if _dollar_dollar.HasField('pragma'): - _t784 = _dollar_dollar.pragma + _t786 = _dollar_dollar.pragma else: - _t784 = None - return _t784 - _t785 = _t783(msg) - deconstruct_result147 = _t785 + _t786 = None + return _t786 + _t787 = _t785(msg) + deconstruct_result146 = _t787 - if deconstruct_result147 is not None: - _t787 = self.pretty_pragma(deconstruct_result147) - _t786 = _t787 + if deconstruct_result146 is not None: + _t789 = self.pretty_pragma(deconstruct_result146) + _t788 = _t789 else: - def _t788(_dollar_dollar): + def _t790(_dollar_dollar): if _dollar_dollar.HasField('primitive'): - _t789 = _dollar_dollar.primitive + _t791 = _dollar_dollar.primitive else: - _t789 = None - return _t789 - _t790 = _t788(msg) - deconstruct_result146 = _t790 + _t791 = None + return _t791 + _t792 = _t790(msg) + deconstruct_result145 = _t792 - if deconstruct_result146 is not None: - _t792 = self.pretty_primitive(deconstruct_result146) - _t791 = _t792 + if deconstruct_result145 is not None: + _t794 = self.pretty_primitive(deconstruct_result145) + _t793 = _t794 else: - def _t793(_dollar_dollar): + def _t795(_dollar_dollar): if _dollar_dollar.HasField('rel_atom'): - _t794 = _dollar_dollar.rel_atom + _t796 = _dollar_dollar.rel_atom else: - _t794 = None - return _t794 - _t795 = _t793(msg) - deconstruct_result145 = _t795 + _t796 = None + return _t796 + _t797 = _t795(msg) + deconstruct_result144 = _t797 - if deconstruct_result145 is not None: - _t797 = self.pretty_rel_atom(deconstruct_result145) - _t796 = _t797 + if deconstruct_result144 is not None: + _t799 = self.pretty_rel_atom(deconstruct_result144) + _t798 = _t799 else: - def _t798(_dollar_dollar): + def _t800(_dollar_dollar): if _dollar_dollar.HasField('cast'): - _t799 = _dollar_dollar.cast + _t801 = _dollar_dollar.cast else: - _t799 = None - return _t799 - _t800 = _t798(msg) - deconstruct_result144 = _t800 + _t801 = None + return _t801 + _t802 = _t800(msg) + deconstruct_result143 = _t802 - if deconstruct_result144 is not None: - _t802 = self.pretty_cast(deconstruct_result144) - _t801 = _t802 + if deconstruct_result143 is not None: + _t804 = self.pretty_cast(deconstruct_result143) + _t803 = _t804 else: raise ParseError('No matching rule for formula') - _t796 = _t801 - _t791 = _t796 - _t786 = _t791 - _t781 = _t786 - _t776 = _t781 - _t771 = _t776 - _t766 = _t771 - _t761 = _t766 - _t756 = _t761 - _t751 = _t756 - _t746 = _t751 - _t741 = _t746 - return _t741 + _t798 = _t803 + _t793 = _t798 + _t788 = _t793 + _t783 = _t788 + _t778 = _t783 + _t773 = _t778 + _t768 = _t773 + _t763 = _t768 + _t758 = _t763 + _t753 = _t758 + _t748 = _t753 + _t743 = _t748 + return _t743 def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t803(_dollar_dollar): + def _t805(_dollar_dollar): return _dollar_dollar - _t804 = _t803(msg) - fields157 = _t804 - unwrapped_fields158 = fields157 + _t806 = _t805(msg) + fields156 = _t806 + unwrapped_fields157 = fields156 self.write('(') self.write('true') - self.newline() - self.indent() - self.dedent() self.write(')') - self.newline() return None def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t805(_dollar_dollar): + def _t807(_dollar_dollar): return _dollar_dollar - _t806 = _t805(msg) - fields159 = _t806 - unwrapped_fields160 = fields159 + _t808 = _t807(msg) + fields158 = _t808 + unwrapped_fields159 = fields158 self.write('(') self.write('false') - self.newline() - self.indent() - self.dedent() self.write(')') - self.newline() return None def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: - def _t807(_dollar_dollar): - _t808 = self.deconstruct_bindings(_dollar_dollar.body) - return (_t808, _dollar_dollar.body.value,) - _t809 = _t807(msg) - fields161 = _t809 - unwrapped_fields162 = fields161 + def _t809(_dollar_dollar): + _t810 = self.deconstruct_bindings(_dollar_dollar.body) + return (_t810, _dollar_dollar.body.value,) + _t811 = _t809(msg) + fields160 = _t811 + unwrapped_fields161 = fields160 self.write('(') self.write('exists') - self.newline() self.indent() - field163 = unwrapped_fields162[0] - _t810 = self.pretty_bindings(field163) self.newline() - field164 = unwrapped_fields162[1] - _t811 = self.pretty_formula(field164) + field162 = unwrapped_fields161[0] + _t812 = self.pretty_bindings(field162) + self.newline() + field163 = unwrapped_fields161[1] + _t813 = self.pretty_formula(field163) self.dedent() self.write(')') - self.newline() return None def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: - def _t812(_dollar_dollar): + def _t814(_dollar_dollar): return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) - _t813 = _t812(msg) - fields165 = _t813 - unwrapped_fields166 = fields165 + _t815 = _t814(msg) + fields164 = _t815 + unwrapped_fields165 = fields164 self.write('(') self.write('reduce') - self.newline() self.indent() - field167 = unwrapped_fields166[0] - _t814 = self.pretty_abstraction(field167) self.newline() - field168 = unwrapped_fields166[1] - _t815 = self.pretty_abstraction(field168) + field166 = unwrapped_fields165[0] + _t816 = self.pretty_abstraction(field166) + self.newline() + field167 = unwrapped_fields165[1] + _t817 = self.pretty_abstraction(field167) self.newline() - field169 = unwrapped_fields166[2] - _t816 = self.pretty_terms(field169) + field168 = unwrapped_fields165[2] + _t818 = self.pretty_terms(field168) self.dedent() self.write(')') - self.newline() return None def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: - def _t817(_dollar_dollar): + def _t819(_dollar_dollar): return _dollar_dollar - _t818 = _t817(msg) - fields170 = _t818 - unwrapped_fields171 = fields170 + _t820 = _t819(msg) + fields169 = _t820 + unwrapped_fields170 = fields169 self.write('(') self.write('terms') - self.newline() self.indent() - for i173, elem172 in enumerate(unwrapped_fields171): - - if (i173 > 0): - self.newline() - _t819 = None - else: - _t819 = None - _t820 = self.pretty_term(elem172) + if not len(unwrapped_fields170) == 0: + self.newline() + for i172, elem171 in enumerate(unwrapped_fields170): + + if (i172 > 0): + self.newline() + _t821 = None + else: + _t821 = None + _t822 = self.pretty_term(elem171) self.dedent() self.write(')') - self.newline() return None def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: - def _t821(_dollar_dollar): + def _t823(_dollar_dollar): if _dollar_dollar.HasField('var'): - _t822 = _dollar_dollar.var + _t824 = _dollar_dollar.var else: - _t822 = None - return _t822 - _t823 = _t821(msg) - deconstruct_result175 = _t823 + _t824 = None + return _t824 + _t825 = _t823(msg) + deconstruct_result174 = _t825 - if deconstruct_result175 is not None: - _t825 = self.pretty_var(deconstruct_result175) - _t824 = _t825 + if deconstruct_result174 is not None: + _t827 = self.pretty_var(deconstruct_result174) + _t826 = _t827 else: - def _t826(_dollar_dollar): + def _t828(_dollar_dollar): if _dollar_dollar.HasField('constant'): - _t827 = _dollar_dollar.constant + _t829 = _dollar_dollar.constant else: - _t827 = None - return _t827 - _t828 = _t826(msg) - deconstruct_result174 = _t828 + _t829 = None + return _t829 + _t830 = _t828(msg) + deconstruct_result173 = _t830 - if deconstruct_result174 is not None: - _t830 = self.pretty_constant(deconstruct_result174) - _t829 = _t830 + if deconstruct_result173 is not None: + _t832 = self.pretty_constant(deconstruct_result173) + _t831 = _t832 else: raise ParseError('No matching rule for term') - _t824 = _t829 - return _t824 + _t826 = _t831 + return _t826 def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: - def _t831(_dollar_dollar): + def _t833(_dollar_dollar): return _dollar_dollar.name - _t832 = _t831(msg) - fields176 = _t832 - unwrapped_fields177 = fields176 - self.write(unwrapped_fields177) + _t834 = _t833(msg) + fields175 = _t834 + unwrapped_fields176 = fields175 + self.write(unwrapped_fields176) return None def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t833(_dollar_dollar): + def _t835(_dollar_dollar): return _dollar_dollar - _t834 = _t833(msg) - fields178 = _t834 - unwrapped_fields179 = fields178 - _t835 = self.pretty_value(unwrapped_fields179) - return _t835 + _t836 = _t835(msg) + fields177 = _t836 + unwrapped_fields178 = fields177 + _t837 = self.pretty_value(unwrapped_fields178) + return _t837 def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t836(_dollar_dollar): + def _t838(_dollar_dollar): return _dollar_dollar.args - _t837 = _t836(msg) - fields180 = _t837 - unwrapped_fields181 = fields180 + _t839 = _t838(msg) + fields179 = _t839 + unwrapped_fields180 = fields179 self.write('(') self.write('and') - self.newline() self.indent() - for i183, elem182 in enumerate(unwrapped_fields181): - - if (i183 > 0): - self.newline() - _t838 = None - else: - _t838 = None - _t839 = self.pretty_formula(elem182) + if not len(unwrapped_fields180) == 0: + self.newline() + for i182, elem181 in enumerate(unwrapped_fields180): + + if (i182 > 0): + self.newline() + _t840 = None + else: + _t840 = None + _t841 = self.pretty_formula(elem181) self.dedent() self.write(')') - self.newline() return None def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t840(_dollar_dollar): + def _t842(_dollar_dollar): return _dollar_dollar.args - _t841 = _t840(msg) - fields184 = _t841 - unwrapped_fields185 = fields184 + _t843 = _t842(msg) + fields183 = _t843 + unwrapped_fields184 = fields183 self.write('(') self.write('or') - self.newline() self.indent() - for i187, elem186 in enumerate(unwrapped_fields185): - - if (i187 > 0): - self.newline() - _t842 = None - else: - _t842 = None - _t843 = self.pretty_formula(elem186) + if not len(unwrapped_fields184) == 0: + self.newline() + for i186, elem185 in enumerate(unwrapped_fields184): + + if (i186 > 0): + self.newline() + _t844 = None + else: + _t844 = None + _t845 = self.pretty_formula(elem185) self.dedent() self.write(')') - self.newline() return None def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: - def _t844(_dollar_dollar): + def _t846(_dollar_dollar): return _dollar_dollar.arg - _t845 = _t844(msg) - fields188 = _t845 - unwrapped_fields189 = fields188 + _t847 = _t846(msg) + fields187 = _t847 + unwrapped_fields188 = fields187 self.write('(') self.write('not') - self.newline() self.indent() - _t846 = self.pretty_formula(unwrapped_fields189) + self.newline() + _t848 = self.pretty_formula(unwrapped_fields188) self.dedent() self.write(')') - self.newline() return None def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: - def _t847(_dollar_dollar): + def _t849(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) - _t848 = _t847(msg) - fields190 = _t848 - unwrapped_fields191 = fields190 + _t850 = _t849(msg) + fields189 = _t850 + unwrapped_fields190 = fields189 self.write('(') self.write('ffi') - self.newline() self.indent() - field192 = unwrapped_fields191[0] - _t849 = self.pretty_name(field192) self.newline() - field193 = unwrapped_fields191[1] - _t850 = self.pretty_ffi_args(field193) + field191 = unwrapped_fields190[0] + _t851 = self.pretty_name(field191) self.newline() - field194 = unwrapped_fields191[2] - _t851 = self.pretty_terms(field194) + field192 = unwrapped_fields190[1] + _t852 = self.pretty_ffi_args(field192) + self.newline() + field193 = unwrapped_fields190[2] + _t853 = self.pretty_terms(field193) self.dedent() self.write(')') - self.newline() return None def pretty_name(self, msg: str) -> Optional[Never]: - def _t852(_dollar_dollar): + def _t854(_dollar_dollar): return _dollar_dollar - _t853 = _t852(msg) - fields195 = _t853 - unwrapped_fields196 = fields195 + _t855 = _t854(msg) + fields194 = _t855 + unwrapped_fields195 = fields194 self.write(':') - self.write(' ') - self.write(unwrapped_fields196) + self.write(unwrapped_fields195) return None def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: - def _t854(_dollar_dollar): + def _t856(_dollar_dollar): return _dollar_dollar - _t855 = _t854(msg) - fields197 = _t855 - unwrapped_fields198 = fields197 + _t857 = _t856(msg) + fields196 = _t857 + unwrapped_fields197 = fields196 self.write('(') self.write('args') - self.newline() self.indent() - for i200, elem199 in enumerate(unwrapped_fields198): - - if (i200 > 0): - self.newline() - _t856 = None - else: - _t856 = None - _t857 = self.pretty_abstraction(elem199) + if not len(unwrapped_fields197) == 0: + self.newline() + for i199, elem198 in enumerate(unwrapped_fields197): + + if (i199 > 0): + self.newline() + _t858 = None + else: + _t858 = None + _t859 = self.pretty_abstraction(elem198) self.dedent() self.write(')') - self.newline() return None def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: - def _t858(_dollar_dollar): + def _t860(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t859 = _t858(msg) - fields201 = _t859 - unwrapped_fields202 = fields201 + _t861 = _t860(msg) + fields200 = _t861 + unwrapped_fields201 = fields200 self.write('(') self.write('atom') - self.newline() self.indent() - field203 = unwrapped_fields202[0] - _t860 = self.pretty_relation_id(field203) self.newline() - field204 = unwrapped_fields202[1] - for i206, elem205 in enumerate(field204): - - if (i206 > 0): - self.newline() - _t861 = None - else: - _t861 = None - _t862 = self.pretty_term(elem205) + field202 = unwrapped_fields201[0] + _t862 = self.pretty_relation_id(field202) + field203 = unwrapped_fields201[1] + if not len(field203) == 0: + self.newline() + for i205, elem204 in enumerate(field203): + + if (i205 > 0): + self.newline() + _t863 = None + else: + _t863 = None + _t864 = self.pretty_term(elem204) self.dedent() self.write(')') - self.newline() return None def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: - def _t863(_dollar_dollar): + def _t865(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t864 = _t863(msg) - fields207 = _t864 - unwrapped_fields208 = fields207 + _t866 = _t865(msg) + fields206 = _t866 + unwrapped_fields207 = fields206 self.write('(') self.write('pragma') - self.newline() self.indent() - field209 = unwrapped_fields208[0] - _t865 = self.pretty_name(field209) self.newline() - field210 = unwrapped_fields208[1] - for i212, elem211 in enumerate(field210): - - if (i212 > 0): - self.newline() - _t866 = None - else: - _t866 = None - _t867 = self.pretty_term(elem211) + field208 = unwrapped_fields207[0] + _t867 = self.pretty_name(field208) + field209 = unwrapped_fields207[1] + if not len(field209) == 0: + self.newline() + for i211, elem210 in enumerate(field209): + + if (i211 > 0): + self.newline() + _t868 = None + else: + _t868 = None + _t869 = self.pretty_term(elem210) self.dedent() self.write(')') - self.newline() return None def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t868(_dollar_dollar): + def _t870(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t869 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t871 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t869 = None - return _t869 - _t870 = _t868(msg) - guard_result227 = _t870 + _t871 = None + return _t871 + _t872 = _t870(msg) + guard_result226 = _t872 - if guard_result227 is not None: - _t872 = self.pretty_eq(msg) - _t871 = _t872 + if guard_result226 is not None: + _t874 = self.pretty_eq(msg) + _t873 = _t874 else: - def _t873(_dollar_dollar): + def _t875(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t874 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t876 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t874 = None - return _t874 - _t875 = _t873(msg) - guard_result226 = _t875 + _t876 = None + return _t876 + _t877 = _t875(msg) + guard_result225 = _t877 - if guard_result226 is not None: - _t877 = self.pretty_lt(msg) - _t876 = _t877 + if guard_result225 is not None: + _t879 = self.pretty_lt(msg) + _t878 = _t879 else: - def _t878(_dollar_dollar): + def _t880(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t879 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t881 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t879 = None - return _t879 - _t880 = _t878(msg) - guard_result225 = _t880 + _t881 = None + return _t881 + _t882 = _t880(msg) + guard_result224 = _t882 - if guard_result225 is not None: - _t882 = self.pretty_lt_eq(msg) - _t881 = _t882 + if guard_result224 is not None: + _t884 = self.pretty_lt_eq(msg) + _t883 = _t884 else: - def _t883(_dollar_dollar): + def _t885(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t884 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t886 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t884 = None - return _t884 - _t885 = _t883(msg) - guard_result224 = _t885 + _t886 = None + return _t886 + _t887 = _t885(msg) + guard_result223 = _t887 - if guard_result224 is not None: - _t887 = self.pretty_gt(msg) - _t886 = _t887 + if guard_result223 is not None: + _t889 = self.pretty_gt(msg) + _t888 = _t889 else: - def _t888(_dollar_dollar): + def _t890(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t889 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t891 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t889 = None - return _t889 - _t890 = _t888(msg) - guard_result223 = _t890 + _t891 = None + return _t891 + _t892 = _t890(msg) + guard_result222 = _t892 - if guard_result223 is not None: - _t892 = self.pretty_gt_eq(msg) - _t891 = _t892 + if guard_result222 is not None: + _t894 = self.pretty_gt_eq(msg) + _t893 = _t894 else: - def _t893(_dollar_dollar): + def _t895(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t894 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t896 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t894 = None - return _t894 - _t895 = _t893(msg) - guard_result222 = _t895 + _t896 = None + return _t896 + _t897 = _t895(msg) + guard_result221 = _t897 - if guard_result222 is not None: - _t897 = self.pretty_add(msg) - _t896 = _t897 + if guard_result221 is not None: + _t899 = self.pretty_add(msg) + _t898 = _t899 else: - def _t898(_dollar_dollar): + def _t900(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t899 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t901 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t899 = None - return _t899 - _t900 = _t898(msg) - guard_result221 = _t900 + _t901 = None + return _t901 + _t902 = _t900(msg) + guard_result220 = _t902 - if guard_result221 is not None: - _t902 = self.pretty_minus(msg) - _t901 = _t902 + if guard_result220 is not None: + _t904 = self.pretty_minus(msg) + _t903 = _t904 else: - def _t903(_dollar_dollar): + def _t905(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t904 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t906 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t904 = None - return _t904 - _t905 = _t903(msg) - guard_result220 = _t905 + _t906 = None + return _t906 + _t907 = _t905(msg) + guard_result219 = _t907 - if guard_result220 is not None: - _t907 = self.pretty_multiply(msg) - _t906 = _t907 + if guard_result219 is not None: + _t909 = self.pretty_multiply(msg) + _t908 = _t909 else: - def _t908(_dollar_dollar): + def _t910(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t909 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t911 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t909 = None - return _t909 - _t910 = _t908(msg) - guard_result219 = _t910 + _t911 = None + return _t911 + _t912 = _t910(msg) + guard_result218 = _t912 - if guard_result219 is not None: - _t912 = self.pretty_divide(msg) - _t911 = _t912 + if guard_result218 is not None: + _t914 = self.pretty_divide(msg) + _t913 = _t914 else: - def _t913(_dollar_dollar): + def _t915(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t914 = _t913(msg) - fields213 = _t914 - unwrapped_fields214 = fields213 + _t916 = _t915(msg) + fields212 = _t916 + unwrapped_fields213 = fields212 self.write('(') self.write('primitive') - self.newline() self.indent() - field215 = unwrapped_fields214[0] - _t915 = self.pretty_name(field215) self.newline() - field216 = unwrapped_fields214[1] - for i218, elem217 in enumerate(field216): - - if (i218 > 0): - self.newline() - _t916 = None - else: - _t916 = None - _t917 = self.pretty_rel_term(elem217) + field214 = unwrapped_fields213[0] + _t917 = self.pretty_name(field214) + field215 = unwrapped_fields213[1] + if not len(field215) == 0: + self.newline() + for i217, elem216 in enumerate(field215): + + if (i217 > 0): + self.newline() + _t918 = None + else: + _t918 = None + _t919 = self.pretty_rel_term(elem216) self.dedent() self.write(')') - self.newline() - _t911 = None - _t906 = _t911 - _t901 = _t906 - _t896 = _t901 - _t891 = _t896 - _t886 = _t891 - _t881 = _t886 - _t876 = _t881 - _t871 = _t876 - return _t871 + _t913 = None + _t908 = _t913 + _t903 = _t908 + _t898 = _t903 + _t893 = _t898 + _t888 = _t893 + _t883 = _t888 + _t878 = _t883 + _t873 = _t878 + return _t873 def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t918(_dollar_dollar): + def _t920(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t919 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t921 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t919 = None - return _t919 - _t920 = _t918(msg) - fields228 = _t920 - unwrapped_fields229 = fields228 + _t921 = None + return _t921 + _t922 = _t920(msg) + fields227 = _t922 + unwrapped_fields228 = fields227 self.write('(') self.write('=') - self.newline() self.indent() - field230 = unwrapped_fields229[0] - _t921 = self.pretty_term(field230) self.newline() - field231 = unwrapped_fields229[1] - _t922 = self.pretty_term(field231) + field229 = unwrapped_fields228[0] + _t923 = self.pretty_term(field229) + self.newline() + field230 = unwrapped_fields228[1] + _t924 = self.pretty_term(field230) self.dedent() self.write(')') - self.newline() return None def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t923(_dollar_dollar): + def _t925(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t924 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t926 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t924 = None - return _t924 - _t925 = _t923(msg) - fields232 = _t925 - unwrapped_fields233 = fields232 + _t926 = None + return _t926 + _t927 = _t925(msg) + fields231 = _t927 + unwrapped_fields232 = fields231 self.write('(') self.write('<') - self.newline() self.indent() - field234 = unwrapped_fields233[0] - _t926 = self.pretty_term(field234) self.newline() - field235 = unwrapped_fields233[1] - _t927 = self.pretty_term(field235) + field233 = unwrapped_fields232[0] + _t928 = self.pretty_term(field233) + self.newline() + field234 = unwrapped_fields232[1] + _t929 = self.pretty_term(field234) self.dedent() self.write(')') - self.newline() return None def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t928(_dollar_dollar): + def _t930(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t929 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t931 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t929 = None - return _t929 - _t930 = _t928(msg) - fields236 = _t930 - unwrapped_fields237 = fields236 + _t931 = None + return _t931 + _t932 = _t930(msg) + fields235 = _t932 + unwrapped_fields236 = fields235 self.write('(') self.write('<=') - self.newline() self.indent() - field238 = unwrapped_fields237[0] - _t931 = self.pretty_term(field238) self.newline() - field239 = unwrapped_fields237[1] - _t932 = self.pretty_term(field239) + field237 = unwrapped_fields236[0] + _t933 = self.pretty_term(field237) + self.newline() + field238 = unwrapped_fields236[1] + _t934 = self.pretty_term(field238) self.dedent() self.write(')') - self.newline() return None def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t933(_dollar_dollar): + def _t935(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t934 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t936 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t934 = None - return _t934 - _t935 = _t933(msg) - fields240 = _t935 - unwrapped_fields241 = fields240 + _t936 = None + return _t936 + _t937 = _t935(msg) + fields239 = _t937 + unwrapped_fields240 = fields239 self.write('(') self.write('>') - self.newline() self.indent() - field242 = unwrapped_fields241[0] - _t936 = self.pretty_term(field242) self.newline() - field243 = unwrapped_fields241[1] - _t937 = self.pretty_term(field243) + field241 = unwrapped_fields240[0] + _t938 = self.pretty_term(field241) + self.newline() + field242 = unwrapped_fields240[1] + _t939 = self.pretty_term(field242) self.dedent() self.write(')') - self.newline() return None def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t938(_dollar_dollar): + def _t940(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t939 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t941 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t939 = None - return _t939 - _t940 = _t938(msg) - fields244 = _t940 - unwrapped_fields245 = fields244 + _t941 = None + return _t941 + _t942 = _t940(msg) + fields243 = _t942 + unwrapped_fields244 = fields243 self.write('(') self.write('>=') - self.newline() self.indent() - field246 = unwrapped_fields245[0] - _t941 = self.pretty_term(field246) self.newline() - field247 = unwrapped_fields245[1] - _t942 = self.pretty_term(field247) + field245 = unwrapped_fields244[0] + _t943 = self.pretty_term(field245) + self.newline() + field246 = unwrapped_fields244[1] + _t944 = self.pretty_term(field246) self.dedent() self.write(')') - self.newline() return None def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t943(_dollar_dollar): + def _t945(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t944 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t946 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t944 = None - return _t944 - _t945 = _t943(msg) - fields248 = _t945 - unwrapped_fields249 = fields248 + _t946 = None + return _t946 + _t947 = _t945(msg) + fields247 = _t947 + unwrapped_fields248 = fields247 self.write('(') self.write('+') - self.newline() self.indent() - field250 = unwrapped_fields249[0] - _t946 = self.pretty_term(field250) self.newline() - field251 = unwrapped_fields249[1] - _t947 = self.pretty_term(field251) + field249 = unwrapped_fields248[0] + _t948 = self.pretty_term(field249) self.newline() - field252 = unwrapped_fields249[2] - _t948 = self.pretty_term(field252) + field250 = unwrapped_fields248[1] + _t949 = self.pretty_term(field250) + self.newline() + field251 = unwrapped_fields248[2] + _t950 = self.pretty_term(field251) self.dedent() self.write(')') - self.newline() return None def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t949(_dollar_dollar): + def _t951(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t950 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t952 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t950 = None - return _t950 - _t951 = _t949(msg) - fields253 = _t951 - unwrapped_fields254 = fields253 + _t952 = None + return _t952 + _t953 = _t951(msg) + fields252 = _t953 + unwrapped_fields253 = fields252 self.write('(') self.write('-') - self.newline() self.indent() - field255 = unwrapped_fields254[0] - _t952 = self.pretty_term(field255) self.newline() - field256 = unwrapped_fields254[1] - _t953 = self.pretty_term(field256) + field254 = unwrapped_fields253[0] + _t954 = self.pretty_term(field254) + self.newline() + field255 = unwrapped_fields253[1] + _t955 = self.pretty_term(field255) self.newline() - field257 = unwrapped_fields254[2] - _t954 = self.pretty_term(field257) + field256 = unwrapped_fields253[2] + _t956 = self.pretty_term(field256) self.dedent() self.write(')') - self.newline() return None def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t955(_dollar_dollar): + def _t957(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t956 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t958 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t956 = None - return _t956 - _t957 = _t955(msg) - fields258 = _t957 - unwrapped_fields259 = fields258 + _t958 = None + return _t958 + _t959 = _t957(msg) + fields257 = _t959 + unwrapped_fields258 = fields257 self.write('(') self.write('*') - self.newline() self.indent() - field260 = unwrapped_fields259[0] - _t958 = self.pretty_term(field260) self.newline() - field261 = unwrapped_fields259[1] - _t959 = self.pretty_term(field261) + field259 = unwrapped_fields258[0] + _t960 = self.pretty_term(field259) self.newline() - field262 = unwrapped_fields259[2] - _t960 = self.pretty_term(field262) + field260 = unwrapped_fields258[1] + _t961 = self.pretty_term(field260) + self.newline() + field261 = unwrapped_fields258[2] + _t962 = self.pretty_term(field261) self.dedent() self.write(')') - self.newline() return None def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t961(_dollar_dollar): + def _t963(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t962 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t964 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t962 = None - return _t962 - _t963 = _t961(msg) - fields263 = _t963 - unwrapped_fields264 = fields263 + _t964 = None + return _t964 + _t965 = _t963(msg) + fields262 = _t965 + unwrapped_fields263 = fields262 self.write('(') self.write('/') - self.newline() self.indent() - field265 = unwrapped_fields264[0] - _t964 = self.pretty_term(field265) self.newline() - field266 = unwrapped_fields264[1] - _t965 = self.pretty_term(field266) + field264 = unwrapped_fields263[0] + _t966 = self.pretty_term(field264) + self.newline() + field265 = unwrapped_fields263[1] + _t967 = self.pretty_term(field265) self.newline() - field267 = unwrapped_fields264[2] - _t966 = self.pretty_term(field267) + field266 = unwrapped_fields263[2] + _t968 = self.pretty_term(field266) self.dedent() self.write(')') - self.newline() return None def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: - def _t967(_dollar_dollar): + def _t969(_dollar_dollar): if _dollar_dollar.HasField('specialized_value'): - _t968 = _dollar_dollar.specialized_value + _t970 = _dollar_dollar.specialized_value else: - _t968 = None - return _t968 - _t969 = _t967(msg) - deconstruct_result269 = _t969 + _t970 = None + return _t970 + _t971 = _t969(msg) + deconstruct_result268 = _t971 - if deconstruct_result269 is not None: - _t971 = self.pretty_specialized_value(deconstruct_result269) - _t970 = _t971 + if deconstruct_result268 is not None: + _t973 = self.pretty_specialized_value(deconstruct_result268) + _t972 = _t973 else: - def _t972(_dollar_dollar): + def _t974(_dollar_dollar): if _dollar_dollar.HasField('term'): - _t973 = _dollar_dollar.term + _t975 = _dollar_dollar.term else: - _t973 = None - return _t973 - _t974 = _t972(msg) - deconstruct_result268 = _t974 + _t975 = None + return _t975 + _t976 = _t974(msg) + deconstruct_result267 = _t976 - if deconstruct_result268 is not None: - _t976 = self.pretty_term(deconstruct_result268) - _t975 = _t976 + if deconstruct_result267 is not None: + _t978 = self.pretty_term(deconstruct_result267) + _t977 = _t978 else: raise ParseError('No matching rule for rel_term') - _t970 = _t975 - return _t970 + _t972 = _t977 + return _t972 def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t977(_dollar_dollar): + def _t979(_dollar_dollar): return _dollar_dollar - _t978 = _t977(msg) - fields270 = _t978 - unwrapped_fields271 = fields270 + _t980 = _t979(msg) + fields269 = _t980 + unwrapped_fields270 = fields269 self.write('#') - self.write(' ') - _t979 = self.pretty_value(unwrapped_fields271) - return _t979 + _t981 = self.pretty_value(unwrapped_fields270) + return _t981 def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: - def _t980(_dollar_dollar): + def _t982(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t981 = _t980(msg) - fields272 = _t981 - unwrapped_fields273 = fields272 + _t983 = _t982(msg) + fields271 = _t983 + unwrapped_fields272 = fields271 self.write('(') self.write('relatom') - self.newline() self.indent() - field274 = unwrapped_fields273[0] - _t982 = self.pretty_name(field274) self.newline() - field275 = unwrapped_fields273[1] - for i277, elem276 in enumerate(field275): - - if (i277 > 0): - self.newline() - _t983 = None - else: - _t983 = None - _t984 = self.pretty_rel_term(elem276) + field273 = unwrapped_fields272[0] + _t984 = self.pretty_name(field273) + field274 = unwrapped_fields272[1] + if not len(field274) == 0: + self.newline() + for i276, elem275 in enumerate(field274): + + if (i276 > 0): + self.newline() + _t985 = None + else: + _t985 = None + _t986 = self.pretty_rel_term(elem275) self.dedent() self.write(')') - self.newline() return None def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: - def _t985(_dollar_dollar): + def _t987(_dollar_dollar): return (_dollar_dollar.input, _dollar_dollar.result,) - _t986 = _t985(msg) - fields278 = _t986 - unwrapped_fields279 = fields278 + _t988 = _t987(msg) + fields277 = _t988 + unwrapped_fields278 = fields277 self.write('(') self.write('cast') - self.newline() self.indent() - field280 = unwrapped_fields279[0] - _t987 = self.pretty_term(field280) self.newline() - field281 = unwrapped_fields279[1] - _t988 = self.pretty_term(field281) + field279 = unwrapped_fields278[0] + _t989 = self.pretty_term(field279) + self.newline() + field280 = unwrapped_fields278[1] + _t990 = self.pretty_term(field280) self.dedent() self.write(')') - self.newline() return None def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: - def _t989(_dollar_dollar): + def _t991(_dollar_dollar): return _dollar_dollar - _t990 = _t989(msg) - fields282 = _t990 - unwrapped_fields283 = fields282 + _t992 = _t991(msg) + fields281 = _t992 + unwrapped_fields282 = fields281 self.write('(') self.write('attrs') - self.newline() self.indent() - for i285, elem284 in enumerate(unwrapped_fields283): - - if (i285 > 0): - self.newline() - _t991 = None - else: - _t991 = None - _t992 = self.pretty_attribute(elem284) + if not len(unwrapped_fields282) == 0: + self.newline() + for i284, elem283 in enumerate(unwrapped_fields282): + + if (i284 > 0): + self.newline() + _t993 = None + else: + _t993 = None + _t994 = self.pretty_attribute(elem283) self.dedent() self.write(')') - self.newline() return None def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: - def _t993(_dollar_dollar): + def _t995(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args,) - _t994 = _t993(msg) - fields286 = _t994 - unwrapped_fields287 = fields286 + _t996 = _t995(msg) + fields285 = _t996 + unwrapped_fields286 = fields285 self.write('(') self.write('attribute') - self.newline() self.indent() - field288 = unwrapped_fields287[0] - _t995 = self.pretty_name(field288) self.newline() - field289 = unwrapped_fields287[1] - for i291, elem290 in enumerate(field289): - - if (i291 > 0): - self.newline() - _t996 = None - else: - _t996 = None - _t997 = self.pretty_value(elem290) + field287 = unwrapped_fields286[0] + _t997 = self.pretty_name(field287) + field288 = unwrapped_fields286[1] + if not len(field288) == 0: + self.newline() + for i290, elem289 in enumerate(field288): + + if (i290 > 0): + self.newline() + _t998 = None + else: + _t998 = None + _t999 = self.pretty_value(elem289) self.dedent() self.write(')') - self.newline() return None def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: - def _t998(_dollar_dollar): + def _t1000(_dollar_dollar): return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) - _t999 = _t998(msg) - fields292 = _t999 - unwrapped_fields293 = fields292 + _t1001 = _t1000(msg) + fields291 = _t1001 + unwrapped_fields292 = fields291 self.write('(') self.write('algorithm') - self.newline() self.indent() - field294 = unwrapped_fields293[0] - for i296, elem295 in enumerate(field294): - - if (i296 > 0): - self.newline() - _t1000 = None - else: - _t1000 = None - _t1001 = self.pretty_relation_id(elem295) + field293 = unwrapped_fields292[0] + if not len(field293) == 0: + self.newline() + for i295, elem294 in enumerate(field293): + + if (i295 > 0): + self.newline() + _t1002 = None + else: + _t1002 = None + _t1003 = self.pretty_relation_id(elem294) self.newline() - field297 = unwrapped_fields293[1] - _t1002 = self.pretty_script(field297) + field296 = unwrapped_fields292[1] + _t1004 = self.pretty_script(field296) self.dedent() self.write(')') - self.newline() return None def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: - def _t1003(_dollar_dollar): + def _t1005(_dollar_dollar): return _dollar_dollar.constructs - _t1004 = _t1003(msg) - fields298 = _t1004 - unwrapped_fields299 = fields298 + _t1006 = _t1005(msg) + fields297 = _t1006 + unwrapped_fields298 = fields297 self.write('(') self.write('script') - self.newline() self.indent() - for i301, elem300 in enumerate(unwrapped_fields299): - - if (i301 > 0): - self.newline() - _t1005 = None - else: - _t1005 = None - _t1006 = self.pretty_construct(elem300) + if not len(unwrapped_fields298) == 0: + self.newline() + for i300, elem299 in enumerate(unwrapped_fields298): + + if (i300 > 0): + self.newline() + _t1007 = None + else: + _t1007 = None + _t1008 = self.pretty_construct(elem299) self.dedent() self.write(')') - self.newline() return None def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: - def _t1007(_dollar_dollar): + def _t1009(_dollar_dollar): if _dollar_dollar.HasField('loop'): - _t1008 = _dollar_dollar.loop + _t1010 = _dollar_dollar.loop else: - _t1008 = None - return _t1008 - _t1009 = _t1007(msg) - deconstruct_result303 = _t1009 + _t1010 = None + return _t1010 + _t1011 = _t1009(msg) + deconstruct_result302 = _t1011 - if deconstruct_result303 is not None: - _t1011 = self.pretty_loop(deconstruct_result303) - _t1010 = _t1011 + if deconstruct_result302 is not None: + _t1013 = self.pretty_loop(deconstruct_result302) + _t1012 = _t1013 else: - def _t1012(_dollar_dollar): + def _t1014(_dollar_dollar): if _dollar_dollar.HasField('instruction'): - _t1013 = _dollar_dollar.instruction + _t1015 = _dollar_dollar.instruction else: - _t1013 = None - return _t1013 - _t1014 = _t1012(msg) - deconstruct_result302 = _t1014 + _t1015 = None + return _t1015 + _t1016 = _t1014(msg) + deconstruct_result301 = _t1016 - if deconstruct_result302 is not None: - _t1016 = self.pretty_instruction(deconstruct_result302) - _t1015 = _t1016 + if deconstruct_result301 is not None: + _t1018 = self.pretty_instruction(deconstruct_result301) + _t1017 = _t1018 else: raise ParseError('No matching rule for construct') - _t1010 = _t1015 - return _t1010 + _t1012 = _t1017 + return _t1012 def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: - def _t1017(_dollar_dollar): + def _t1019(_dollar_dollar): return (_dollar_dollar.init, _dollar_dollar.body,) - _t1018 = _t1017(msg) - fields304 = _t1018 - unwrapped_fields305 = fields304 + _t1020 = _t1019(msg) + fields303 = _t1020 + unwrapped_fields304 = fields303 self.write('(') self.write('loop') - self.newline() self.indent() - field306 = unwrapped_fields305[0] - _t1019 = self.pretty_init(field306) self.newline() - field307 = unwrapped_fields305[1] - _t1020 = self.pretty_script(field307) + field305 = unwrapped_fields304[0] + _t1021 = self.pretty_init(field305) + self.newline() + field306 = unwrapped_fields304[1] + _t1022 = self.pretty_script(field306) self.dedent() self.write(')') - self.newline() return None def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: - def _t1021(_dollar_dollar): + def _t1023(_dollar_dollar): return _dollar_dollar - _t1022 = _t1021(msg) - fields308 = _t1022 - unwrapped_fields309 = fields308 + _t1024 = _t1023(msg) + fields307 = _t1024 + unwrapped_fields308 = fields307 self.write('(') self.write('init') - self.newline() self.indent() - for i311, elem310 in enumerate(unwrapped_fields309): - - if (i311 > 0): - self.newline() - _t1023 = None - else: - _t1023 = None - _t1024 = self.pretty_instruction(elem310) + if not len(unwrapped_fields308) == 0: + self.newline() + for i310, elem309 in enumerate(unwrapped_fields308): + + if (i310 > 0): + self.newline() + _t1025 = None + else: + _t1025 = None + _t1026 = self.pretty_instruction(elem309) self.dedent() self.write(')') - self.newline() return None def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: - def _t1025(_dollar_dollar): + def _t1027(_dollar_dollar): if _dollar_dollar.HasField('assign'): - _t1026 = _dollar_dollar.assign + _t1028 = _dollar_dollar.assign else: - _t1026 = None - return _t1026 - _t1027 = _t1025(msg) - deconstruct_result316 = _t1027 + _t1028 = None + return _t1028 + _t1029 = _t1027(msg) + deconstruct_result315 = _t1029 - if deconstruct_result316 is not None: - _t1029 = self.pretty_assign(deconstruct_result316) - _t1028 = _t1029 + if deconstruct_result315 is not None: + _t1031 = self.pretty_assign(deconstruct_result315) + _t1030 = _t1031 else: - def _t1030(_dollar_dollar): + def _t1032(_dollar_dollar): if _dollar_dollar.HasField('upsert'): - _t1031 = _dollar_dollar.upsert + _t1033 = _dollar_dollar.upsert else: - _t1031 = None - return _t1031 - _t1032 = _t1030(msg) - deconstruct_result315 = _t1032 + _t1033 = None + return _t1033 + _t1034 = _t1032(msg) + deconstruct_result314 = _t1034 - if deconstruct_result315 is not None: - _t1034 = self.pretty_upsert(deconstruct_result315) - _t1033 = _t1034 + if deconstruct_result314 is not None: + _t1036 = self.pretty_upsert(deconstruct_result314) + _t1035 = _t1036 else: - def _t1035(_dollar_dollar): + def _t1037(_dollar_dollar): if _dollar_dollar.HasField('break'): - _t1036 = getattr(_dollar_dollar, 'break') + _t1038 = getattr(_dollar_dollar, 'break') else: - _t1036 = None - return _t1036 - _t1037 = _t1035(msg) - deconstruct_result314 = _t1037 + _t1038 = None + return _t1038 + _t1039 = _t1037(msg) + deconstruct_result313 = _t1039 - if deconstruct_result314 is not None: - _t1039 = self.pretty_break(deconstruct_result314) - _t1038 = _t1039 + if deconstruct_result313 is not None: + _t1041 = self.pretty_break(deconstruct_result313) + _t1040 = _t1041 else: - def _t1040(_dollar_dollar): + def _t1042(_dollar_dollar): if _dollar_dollar.HasField('monoid_def'): - _t1041 = _dollar_dollar.monoid_def + _t1043 = _dollar_dollar.monoid_def else: - _t1041 = None - return _t1041 - _t1042 = _t1040(msg) - deconstruct_result313 = _t1042 + _t1043 = None + return _t1043 + _t1044 = _t1042(msg) + deconstruct_result312 = _t1044 - if deconstruct_result313 is not None: - _t1044 = self.pretty_monoid_def(deconstruct_result313) - _t1043 = _t1044 + if deconstruct_result312 is not None: + _t1046 = self.pretty_monoid_def(deconstruct_result312) + _t1045 = _t1046 else: - def _t1045(_dollar_dollar): + def _t1047(_dollar_dollar): if _dollar_dollar.HasField('monus_def'): - _t1046 = _dollar_dollar.monus_def + _t1048 = _dollar_dollar.monus_def else: - _t1046 = None - return _t1046 - _t1047 = _t1045(msg) - deconstruct_result312 = _t1047 + _t1048 = None + return _t1048 + _t1049 = _t1047(msg) + deconstruct_result311 = _t1049 - if deconstruct_result312 is not None: - _t1049 = self.pretty_monus_def(deconstruct_result312) - _t1048 = _t1049 + if deconstruct_result311 is not None: + _t1051 = self.pretty_monus_def(deconstruct_result311) + _t1050 = _t1051 else: raise ParseError('No matching rule for instruction') - _t1043 = _t1048 - _t1038 = _t1043 - _t1033 = _t1038 - _t1028 = _t1033 - return _t1028 + _t1045 = _t1050 + _t1040 = _t1045 + _t1035 = _t1040 + _t1030 = _t1035 + return _t1030 def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: - def _t1050(_dollar_dollar): + def _t1052(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1051 = _dollar_dollar.attrs + _t1053 = _dollar_dollar.attrs else: - _t1051 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1051,) - _t1052 = _t1050(msg) - fields317 = _t1052 - unwrapped_fields318 = fields317 + _t1053 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1053,) + _t1054 = _t1052(msg) + fields316 = _t1054 + unwrapped_fields317 = fields316 self.write('(') self.write('assign') - self.newline() self.indent() - field319 = unwrapped_fields318[0] - _t1053 = self.pretty_relation_id(field319) self.newline() - field320 = unwrapped_fields318[1] - _t1054 = self.pretty_abstraction(field320) + field318 = unwrapped_fields317[0] + _t1055 = self.pretty_relation_id(field318) self.newline() - field321 = unwrapped_fields318[2] + field319 = unwrapped_fields317[1] + _t1056 = self.pretty_abstraction(field319) + field320 = unwrapped_fields317[2] - if field321 is not None: - opt_val322 = field321 - _t1056 = self.pretty_attrs(opt_val322) - _t1055 = _t1056 + if field320 is not None: + self.newline() + opt_val321 = field320 + _t1058 = self.pretty_attrs(opt_val321) + _t1057 = _t1058 else: - _t1055 = None + _t1057 = None self.dedent() self.write(')') - self.newline() return None def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: - def _t1057(_dollar_dollar): + def _t1059(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1058 = _dollar_dollar.attrs + _t1060 = _dollar_dollar.attrs else: - _t1058 = None - return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1058,) - _t1059 = _t1057(msg) - fields323 = _t1059 - unwrapped_fields324 = fields323 + _t1060 = None + return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1060,) + _t1061 = _t1059(msg) + fields322 = _t1061 + unwrapped_fields323 = fields322 self.write('(') self.write('upsert') - self.newline() self.indent() - field325 = unwrapped_fields324[0] - _t1060 = self.pretty_relation_id(field325) self.newline() - field326 = unwrapped_fields324[1] - _t1061 = self.pretty_abstraction_with_arity(field326) + field324 = unwrapped_fields323[0] + _t1062 = self.pretty_relation_id(field324) self.newline() - field327 = unwrapped_fields324[2] + field325 = unwrapped_fields323[1] + _t1063 = self.pretty_abstraction_with_arity(field325) + field326 = unwrapped_fields323[2] - if field327 is not None: - opt_val328 = field327 - _t1063 = self.pretty_attrs(opt_val328) - _t1062 = _t1063 + if field326 is not None: + self.newline() + opt_val327 = field326 + _t1065 = self.pretty_attrs(opt_val327) + _t1064 = _t1065 else: - _t1062 = None + _t1064 = None self.dedent() self.write(')') - self.newline() return None def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: - def _t1064(_dollar_dollar): - _t1065 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) - return (_t1065, _dollar_dollar[0].value,) - _t1066 = _t1064(msg) - fields329 = _t1066 - unwrapped_fields330 = fields329 - self.write('(') - self.write(' ') - field331 = unwrapped_fields330[0] - _t1067 = self.pretty_bindings(field331) + def _t1066(_dollar_dollar): + _t1067 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) + return (_t1067, _dollar_dollar[0].value,) + _t1068 = _t1066(msg) + fields328 = _t1068 + unwrapped_fields329 = fields328 + self.write('(') + field330 = unwrapped_fields329[0] + _t1069 = self.pretty_bindings(field330) self.write(' ') - field332 = unwrapped_fields330[1] - _t1068 = self.pretty_formula(field332) - self.write(' ') - self.dedent() + field331 = unwrapped_fields329[1] + _t1070 = self.pretty_formula(field331) self.write(')') - self.newline() return None def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: - def _t1069(_dollar_dollar): + def _t1071(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1070 = _dollar_dollar.attrs + _t1072 = _dollar_dollar.attrs else: - _t1070 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1070,) - _t1071 = _t1069(msg) - fields333 = _t1071 - unwrapped_fields334 = fields333 + _t1072 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1072,) + _t1073 = _t1071(msg) + fields332 = _t1073 + unwrapped_fields333 = fields332 self.write('(') self.write('break') - self.newline() self.indent() - field335 = unwrapped_fields334[0] - _t1072 = self.pretty_relation_id(field335) self.newline() - field336 = unwrapped_fields334[1] - _t1073 = self.pretty_abstraction(field336) + field334 = unwrapped_fields333[0] + _t1074 = self.pretty_relation_id(field334) self.newline() - field337 = unwrapped_fields334[2] + field335 = unwrapped_fields333[1] + _t1075 = self.pretty_abstraction(field335) + field336 = unwrapped_fields333[2] - if field337 is not None: - opt_val338 = field337 - _t1075 = self.pretty_attrs(opt_val338) - _t1074 = _t1075 + if field336 is not None: + self.newline() + opt_val337 = field336 + _t1077 = self.pretty_attrs(opt_val337) + _t1076 = _t1077 else: - _t1074 = None + _t1076 = None self.dedent() self.write(')') - self.newline() return None def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: - def _t1076(_dollar_dollar): + def _t1078(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1077 = _dollar_dollar.attrs + _t1079 = _dollar_dollar.attrs else: - _t1077 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1077,) - _t1078 = _t1076(msg) - fields339 = _t1078 - unwrapped_fields340 = fields339 + _t1079 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1079,) + _t1080 = _t1078(msg) + fields338 = _t1080 + unwrapped_fields339 = fields338 self.write('(') self.write('monoid') - self.newline() self.indent() - field341 = unwrapped_fields340[0] - _t1079 = self.pretty_monoid(field341) self.newline() - field342 = unwrapped_fields340[1] - _t1080 = self.pretty_relation_id(field342) + field340 = unwrapped_fields339[0] + _t1081 = self.pretty_monoid(field340) self.newline() - field343 = unwrapped_fields340[2] - _t1081 = self.pretty_abstraction_with_arity(field343) + field341 = unwrapped_fields339[1] + _t1082 = self.pretty_relation_id(field341) self.newline() - field344 = unwrapped_fields340[3] + field342 = unwrapped_fields339[2] + _t1083 = self.pretty_abstraction_with_arity(field342) + field343 = unwrapped_fields339[3] - if field344 is not None: - opt_val345 = field344 - _t1083 = self.pretty_attrs(opt_val345) - _t1082 = _t1083 + if field343 is not None: + self.newline() + opt_val344 = field343 + _t1085 = self.pretty_attrs(opt_val344) + _t1084 = _t1085 else: - _t1082 = None + _t1084 = None self.dedent() self.write(')') - self.newline() return None def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: - def _t1084(_dollar_dollar): + def _t1086(_dollar_dollar): if _dollar_dollar.HasField('or_monoid'): - _t1085 = _dollar_dollar.or_monoid + _t1087 = _dollar_dollar.or_monoid else: - _t1085 = None - return _t1085 - _t1086 = _t1084(msg) - deconstruct_result349 = _t1086 + _t1087 = None + return _t1087 + _t1088 = _t1086(msg) + deconstruct_result348 = _t1088 - if deconstruct_result349 is not None: - _t1088 = self.pretty_or_monoid(deconstruct_result349) - _t1087 = _t1088 + if deconstruct_result348 is not None: + _t1090 = self.pretty_or_monoid(deconstruct_result348) + _t1089 = _t1090 else: - def _t1089(_dollar_dollar): + def _t1091(_dollar_dollar): if _dollar_dollar.HasField('min_monoid'): - _t1090 = _dollar_dollar.min_monoid + _t1092 = _dollar_dollar.min_monoid else: - _t1090 = None - return _t1090 - _t1091 = _t1089(msg) - deconstruct_result348 = _t1091 + _t1092 = None + return _t1092 + _t1093 = _t1091(msg) + deconstruct_result347 = _t1093 - if deconstruct_result348 is not None: - _t1093 = self.pretty_min_monoid(deconstruct_result348) - _t1092 = _t1093 + if deconstruct_result347 is not None: + _t1095 = self.pretty_min_monoid(deconstruct_result347) + _t1094 = _t1095 else: - def _t1094(_dollar_dollar): + def _t1096(_dollar_dollar): if _dollar_dollar.HasField('max_monoid'): - _t1095 = _dollar_dollar.max_monoid + _t1097 = _dollar_dollar.max_monoid else: - _t1095 = None - return _t1095 - _t1096 = _t1094(msg) - deconstruct_result347 = _t1096 + _t1097 = None + return _t1097 + _t1098 = _t1096(msg) + deconstruct_result346 = _t1098 - if deconstruct_result347 is not None: - _t1098 = self.pretty_max_monoid(deconstruct_result347) - _t1097 = _t1098 + if deconstruct_result346 is not None: + _t1100 = self.pretty_max_monoid(deconstruct_result346) + _t1099 = _t1100 else: - def _t1099(_dollar_dollar): + def _t1101(_dollar_dollar): if _dollar_dollar.HasField('sum_monoid'): - _t1100 = _dollar_dollar.sum_monoid + _t1102 = _dollar_dollar.sum_monoid else: - _t1100 = None - return _t1100 - _t1101 = _t1099(msg) - deconstruct_result346 = _t1101 + _t1102 = None + return _t1102 + _t1103 = _t1101(msg) + deconstruct_result345 = _t1103 - if deconstruct_result346 is not None: - _t1103 = self.pretty_sum_monoid(deconstruct_result346) - _t1102 = _t1103 + if deconstruct_result345 is not None: + _t1105 = self.pretty_sum_monoid(deconstruct_result345) + _t1104 = _t1105 else: raise ParseError('No matching rule for monoid') - _t1097 = _t1102 - _t1092 = _t1097 - _t1087 = _t1092 - return _t1087 + _t1099 = _t1104 + _t1094 = _t1099 + _t1089 = _t1094 + return _t1089 def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: - def _t1104(_dollar_dollar): + def _t1106(_dollar_dollar): return _dollar_dollar - _t1105 = _t1104(msg) - fields350 = _t1105 - unwrapped_fields351 = fields350 + _t1107 = _t1106(msg) + fields349 = _t1107 + unwrapped_fields350 = fields349 self.write('(') self.write('or') - self.newline() - self.indent() - self.dedent() self.write(')') - self.newline() return None def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: - def _t1106(_dollar_dollar): + def _t1108(_dollar_dollar): return _dollar_dollar.type - _t1107 = _t1106(msg) - fields352 = _t1107 - unwrapped_fields353 = fields352 + _t1109 = _t1108(msg) + fields351 = _t1109 + unwrapped_fields352 = fields351 self.write('(') self.write('min') - self.newline() self.indent() - _t1108 = self.pretty_type(unwrapped_fields353) + self.newline() + _t1110 = self.pretty_type(unwrapped_fields352) self.dedent() self.write(')') - self.newline() return None def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: - def _t1109(_dollar_dollar): + def _t1111(_dollar_dollar): return _dollar_dollar.type - _t1110 = _t1109(msg) - fields354 = _t1110 - unwrapped_fields355 = fields354 + _t1112 = _t1111(msg) + fields353 = _t1112 + unwrapped_fields354 = fields353 self.write('(') self.write('max') - self.newline() self.indent() - _t1111 = self.pretty_type(unwrapped_fields355) + self.newline() + _t1113 = self.pretty_type(unwrapped_fields354) self.dedent() self.write(')') - self.newline() return None def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: - def _t1112(_dollar_dollar): + def _t1114(_dollar_dollar): return _dollar_dollar.type - _t1113 = _t1112(msg) - fields356 = _t1113 - unwrapped_fields357 = fields356 + _t1115 = _t1114(msg) + fields355 = _t1115 + unwrapped_fields356 = fields355 self.write('(') self.write('sum') - self.newline() self.indent() - _t1114 = self.pretty_type(unwrapped_fields357) + self.newline() + _t1116 = self.pretty_type(unwrapped_fields356) self.dedent() self.write(')') - self.newline() return None def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: - def _t1115(_dollar_dollar): + def _t1117(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1116 = _dollar_dollar.attrs + _t1118 = _dollar_dollar.attrs else: - _t1116 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1116,) - _t1117 = _t1115(msg) - fields358 = _t1117 - unwrapped_fields359 = fields358 + _t1118 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1118,) + _t1119 = _t1117(msg) + fields357 = _t1119 + unwrapped_fields358 = fields357 self.write('(') self.write('monus') - self.newline() self.indent() - field360 = unwrapped_fields359[0] - _t1118 = self.pretty_monoid(field360) self.newline() - field361 = unwrapped_fields359[1] - _t1119 = self.pretty_relation_id(field361) + field359 = unwrapped_fields358[0] + _t1120 = self.pretty_monoid(field359) self.newline() - field362 = unwrapped_fields359[2] - _t1120 = self.pretty_abstraction_with_arity(field362) + field360 = unwrapped_fields358[1] + _t1121 = self.pretty_relation_id(field360) self.newline() - field363 = unwrapped_fields359[3] + field361 = unwrapped_fields358[2] + _t1122 = self.pretty_abstraction_with_arity(field361) + field362 = unwrapped_fields358[3] - if field363 is not None: - opt_val364 = field363 - _t1122 = self.pretty_attrs(opt_val364) - _t1121 = _t1122 + if field362 is not None: + self.newline() + opt_val363 = field362 + _t1124 = self.pretty_attrs(opt_val363) + _t1123 = _t1124 else: - _t1121 = None + _t1123 = None self.dedent() self.write(')') - self.newline() return None def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: - def _t1123(_dollar_dollar): + def _t1125(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) - _t1124 = _t1123(msg) - fields365 = _t1124 - unwrapped_fields366 = fields365 + _t1126 = _t1125(msg) + fields364 = _t1126 + unwrapped_fields365 = fields364 self.write('(') self.write('functional_dependency') - self.newline() self.indent() - field367 = unwrapped_fields366[0] - _t1125 = self.pretty_relation_id(field367) self.newline() - field368 = unwrapped_fields366[1] - _t1126 = self.pretty_abstraction(field368) + field366 = unwrapped_fields365[0] + _t1127 = self.pretty_relation_id(field366) + self.newline() + field367 = unwrapped_fields365[1] + _t1128 = self.pretty_abstraction(field367) self.newline() - field369 = unwrapped_fields366[2] - _t1127 = self.pretty_functional_dependency_keys(field369) + field368 = unwrapped_fields365[2] + _t1129 = self.pretty_functional_dependency_keys(field368) self.newline() - field370 = unwrapped_fields366[3] - _t1128 = self.pretty_functional_dependency_values(field370) + field369 = unwrapped_fields365[3] + _t1130 = self.pretty_functional_dependency_values(field369) self.dedent() self.write(')') - self.newline() return None def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1129(_dollar_dollar): + def _t1131(_dollar_dollar): return _dollar_dollar - _t1130 = _t1129(msg) - fields371 = _t1130 - unwrapped_fields372 = fields371 + _t1132 = _t1131(msg) + fields370 = _t1132 + unwrapped_fields371 = fields370 self.write('(') self.write('keys') - self.newline() self.indent() - for i374, elem373 in enumerate(unwrapped_fields372): - - if (i374 > 0): - self.newline() - _t1131 = None - else: - _t1131 = None - _t1132 = self.pretty_var(elem373) + if not len(unwrapped_fields371) == 0: + self.newline() + for i373, elem372 in enumerate(unwrapped_fields371): + + if (i373 > 0): + self.newline() + _t1133 = None + else: + _t1133 = None + _t1134 = self.pretty_var(elem372) self.dedent() self.write(')') - self.newline() return None def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1133(_dollar_dollar): + def _t1135(_dollar_dollar): return _dollar_dollar - _t1134 = _t1133(msg) - fields375 = _t1134 - unwrapped_fields376 = fields375 + _t1136 = _t1135(msg) + fields374 = _t1136 + unwrapped_fields375 = fields374 self.write('(') - self.write('values') - self.newline() - self.indent() - for i378, elem377 in enumerate(unwrapped_fields376): - - if (i378 > 0): - self.newline() - _t1135 = None - else: - _t1135 = None - _t1136 = self.pretty_var(elem377) + self.write('values') + self.indent() + if not len(unwrapped_fields375) == 0: + self.newline() + for i377, elem376 in enumerate(unwrapped_fields375): + + if (i377 > 0): + self.newline() + _t1137 = None + else: + _t1137 = None + _t1138 = self.pretty_var(elem376) self.dedent() self.write(')') - self.newline() return None def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: - def _t1137(_dollar_dollar): + def _t1139(_dollar_dollar): if _dollar_dollar.HasField('rel_edb'): - _t1138 = _dollar_dollar.rel_edb + _t1140 = _dollar_dollar.rel_edb else: - _t1138 = None - return _t1138 - _t1139 = _t1137(msg) - deconstruct_result381 = _t1139 + _t1140 = None + return _t1140 + _t1141 = _t1139(msg) + deconstruct_result380 = _t1141 - if deconstruct_result381 is not None: - _t1141 = self.pretty_rel_edb(deconstruct_result381) - _t1140 = _t1141 + if deconstruct_result380 is not None: + _t1143 = self.pretty_rel_edb(deconstruct_result380) + _t1142 = _t1143 else: - def _t1142(_dollar_dollar): + def _t1144(_dollar_dollar): if _dollar_dollar.HasField('betree_relation'): - _t1143 = _dollar_dollar.betree_relation + _t1145 = _dollar_dollar.betree_relation else: - _t1143 = None - return _t1143 - _t1144 = _t1142(msg) - deconstruct_result380 = _t1144 + _t1145 = None + return _t1145 + _t1146 = _t1144(msg) + deconstruct_result379 = _t1146 - if deconstruct_result380 is not None: - _t1146 = self.pretty_betree_relation(deconstruct_result380) - _t1145 = _t1146 + if deconstruct_result379 is not None: + _t1148 = self.pretty_betree_relation(deconstruct_result379) + _t1147 = _t1148 else: - def _t1147(_dollar_dollar): + def _t1149(_dollar_dollar): if _dollar_dollar.HasField('csv_data'): - _t1148 = _dollar_dollar.csv_data + _t1150 = _dollar_dollar.csv_data else: - _t1148 = None - return _t1148 - _t1149 = _t1147(msg) - deconstruct_result379 = _t1149 + _t1150 = None + return _t1150 + _t1151 = _t1149(msg) + deconstruct_result378 = _t1151 - if deconstruct_result379 is not None: - _t1151 = self.pretty_csv_data(deconstruct_result379) - _t1150 = _t1151 + if deconstruct_result378 is not None: + _t1153 = self.pretty_csv_data(deconstruct_result378) + _t1152 = _t1153 else: raise ParseError('No matching rule for data') - _t1145 = _t1150 - _t1140 = _t1145 - return _t1140 + _t1147 = _t1152 + _t1142 = _t1147 + return _t1142 def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: - def _t1152(_dollar_dollar): + def _t1154(_dollar_dollar): return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) - _t1153 = _t1152(msg) - fields382 = _t1153 - unwrapped_fields383 = fields382 + _t1155 = _t1154(msg) + fields381 = _t1155 + unwrapped_fields382 = fields381 self.write('(') self.write('rel_edb') - self.newline() self.indent() - field384 = unwrapped_fields383[0] - _t1154 = self.pretty_relation_id(field384) self.newline() - field385 = unwrapped_fields383[1] - _t1155 = self.pretty_rel_edb_path(field385) + field383 = unwrapped_fields382[0] + _t1156 = self.pretty_relation_id(field383) self.newline() - field386 = unwrapped_fields383[2] - _t1156 = self.pretty_rel_edb_types(field386) + field384 = unwrapped_fields382[1] + _t1157 = self.pretty_rel_edb_path(field384) + self.newline() + field385 = unwrapped_fields382[2] + _t1158 = self.pretty_rel_edb_types(field385) self.dedent() self.write(')') - self.newline() return None def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: - def _t1157(_dollar_dollar): + def _t1159(_dollar_dollar): return _dollar_dollar - _t1158 = _t1157(msg) - fields387 = _t1158 - unwrapped_fields388 = fields387 + _t1160 = _t1159(msg) + fields386 = _t1160 + unwrapped_fields387 = fields386 self.write('[') - self.write(' ') - for i390, elem389 in enumerate(unwrapped_fields388): + for i389, elem388 in enumerate(unwrapped_fields387): - if (i390 > 0): + if (i389 > 0): self.newline() - _t1159 = None + _t1161 = None else: - _t1159 = None - self.write(self.format_string_value(elem389)) - self.write(' ') + _t1161 = None + self.write(self.format_string_value(elem388)) self.write(']') return None def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1160(_dollar_dollar): + def _t1162(_dollar_dollar): return _dollar_dollar - _t1161 = _t1160(msg) - fields391 = _t1161 - unwrapped_fields392 = fields391 + _t1163 = _t1162(msg) + fields390 = _t1163 + unwrapped_fields391 = fields390 self.write('[') - self.write(' ') - for i394, elem393 in enumerate(unwrapped_fields392): + for i393, elem392 in enumerate(unwrapped_fields391): - if (i394 > 0): + if (i393 > 0): self.newline() - _t1162 = None + _t1164 = None else: - _t1162 = None - _t1163 = self.pretty_type(elem393) - self.write(' ') + _t1164 = None + _t1165 = self.pretty_type(elem392) self.write(']') return None def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: - def _t1164(_dollar_dollar): + def _t1166(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_info,) - _t1165 = _t1164(msg) - fields395 = _t1165 - unwrapped_fields396 = fields395 + _t1167 = _t1166(msg) + fields394 = _t1167 + unwrapped_fields395 = fields394 self.write('(') self.write('betree_relation') - self.newline() self.indent() - field397 = unwrapped_fields396[0] - _t1166 = self.pretty_relation_id(field397) self.newline() - field398 = unwrapped_fields396[1] - _t1167 = self.pretty_betree_info(field398) + field396 = unwrapped_fields395[0] + _t1168 = self.pretty_relation_id(field396) + self.newline() + field397 = unwrapped_fields395[1] + _t1169 = self.pretty_betree_info(field397) self.dedent() self.write(')') - self.newline() return None def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: - def _t1168(_dollar_dollar): - _t1169 = self.deconstruct_betree_info_config(_dollar_dollar) - return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1169,) - _t1170 = _t1168(msg) - fields399 = _t1170 - unwrapped_fields400 = fields399 + def _t1170(_dollar_dollar): + _t1171 = self.deconstruct_betree_info_config(_dollar_dollar) + return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1171,) + _t1172 = _t1170(msg) + fields398 = _t1172 + unwrapped_fields399 = fields398 self.write('(') self.write('betree_info') - self.newline() self.indent() - field401 = unwrapped_fields400[0] - _t1171 = self.pretty_betree_info_key_types(field401) self.newline() - field402 = unwrapped_fields400[1] - _t1172 = self.pretty_betree_info_value_types(field402) + field400 = unwrapped_fields399[0] + _t1173 = self.pretty_betree_info_key_types(field400) self.newline() - field403 = unwrapped_fields400[2] - _t1173 = self.pretty_config_dict(field403) + field401 = unwrapped_fields399[1] + _t1174 = self.pretty_betree_info_value_types(field401) + self.newline() + field402 = unwrapped_fields399[2] + _t1175 = self.pretty_config_dict(field402) self.dedent() self.write(')') - self.newline() return None def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1174(_dollar_dollar): + def _t1176(_dollar_dollar): return _dollar_dollar - _t1175 = _t1174(msg) - fields404 = _t1175 - unwrapped_fields405 = fields404 + _t1177 = _t1176(msg) + fields403 = _t1177 + unwrapped_fields404 = fields403 self.write('(') self.write('key_types') - self.newline() self.indent() - for i407, elem406 in enumerate(unwrapped_fields405): - - if (i407 > 0): - self.newline() - _t1176 = None - else: - _t1176 = None - _t1177 = self.pretty_type(elem406) + if not len(unwrapped_fields404) == 0: + self.newline() + for i406, elem405 in enumerate(unwrapped_fields404): + + if (i406 > 0): + self.newline() + _t1178 = None + else: + _t1178 = None + _t1179 = self.pretty_type(elem405) self.dedent() self.write(')') - self.newline() return None def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1178(_dollar_dollar): + def _t1180(_dollar_dollar): return _dollar_dollar - _t1179 = _t1178(msg) - fields408 = _t1179 - unwrapped_fields409 = fields408 + _t1181 = _t1180(msg) + fields407 = _t1181 + unwrapped_fields408 = fields407 self.write('(') self.write('value_types') - self.newline() self.indent() - for i411, elem410 in enumerate(unwrapped_fields409): - - if (i411 > 0): - self.newline() - _t1180 = None - else: - _t1180 = None - _t1181 = self.pretty_type(elem410) + if not len(unwrapped_fields408) == 0: + self.newline() + for i410, elem409 in enumerate(unwrapped_fields408): + + if (i410 > 0): + self.newline() + _t1182 = None + else: + _t1182 = None + _t1183 = self.pretty_type(elem409) self.dedent() self.write(')') - self.newline() return None def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: - def _t1182(_dollar_dollar): + def _t1184(_dollar_dollar): return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) - _t1183 = _t1182(msg) - fields412 = _t1183 - unwrapped_fields413 = fields412 + _t1185 = _t1184(msg) + fields411 = _t1185 + unwrapped_fields412 = fields411 self.write('(') self.write('csv_data') - self.newline() self.indent() - field414 = unwrapped_fields413[0] - _t1184 = self.pretty_csvlocator(field414) self.newline() - field415 = unwrapped_fields413[1] - _t1185 = self.pretty_csv_config(field415) + field413 = unwrapped_fields412[0] + _t1186 = self.pretty_csvlocator(field413) + self.newline() + field414 = unwrapped_fields412[1] + _t1187 = self.pretty_csv_config(field414) self.newline() - field416 = unwrapped_fields413[2] - _t1186 = self.pretty_csv_columns(field416) + field415 = unwrapped_fields412[2] + _t1188 = self.pretty_csv_columns(field415) self.newline() - field417 = unwrapped_fields413[3] - _t1187 = self.pretty_csv_asof(field417) + field416 = unwrapped_fields412[3] + _t1189 = self.pretty_csv_asof(field416) self.dedent() self.write(')') - self.newline() return None def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: - def _t1188(_dollar_dollar): + def _t1190(_dollar_dollar): if not len(_dollar_dollar.paths) == 0: - _t1189 = _dollar_dollar.paths + _t1191 = _dollar_dollar.paths else: - _t1189 = None + _t1191 = None if _dollar_dollar.inline_data.decode('utf-8') != '': - _t1190 = _dollar_dollar.inline_data.decode('utf-8') + _t1192 = _dollar_dollar.inline_data.decode('utf-8') else: - _t1190 = None - return (_t1189, _t1190,) - _t1191 = _t1188(msg) - fields418 = _t1191 - unwrapped_fields419 = fields418 + _t1192 = None + return (_t1191, _t1192,) + _t1193 = _t1190(msg) + fields417 = _t1193 + unwrapped_fields418 = fields417 self.write('(') self.write('csv_locator') - self.newline() self.indent() - field420 = unwrapped_fields419[0] + field419 = unwrapped_fields418[0] - if field420 is not None: - opt_val421 = field420 - _t1193 = self.pretty_csv_locator_paths(opt_val421) - _t1192 = _t1193 - else: - _t1192 = None - self.newline() - field422 = unwrapped_fields419[1] - - if field422 is not None: - opt_val423 = field422 - _t1195 = self.pretty_csv_locator_inline_data(opt_val423) + if field419 is not None: + self.newline() + opt_val420 = field419 + _t1195 = self.pretty_csv_locator_paths(opt_val420) _t1194 = _t1195 else: _t1194 = None - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: - def _t1196(_dollar_dollar): - return _dollar_dollar - _t1197 = _t1196(msg) - fields424 = _t1197 - unwrapped_fields425 = fields424 - self.write('(') - self.write('paths') - self.newline() - self.indent() - for i427, elem426 in enumerate(unwrapped_fields425): - - if (i427 > 0): - self.newline() - _t1198 = None - else: - _t1198 = None - self.write(self.format_string_value(elem426)) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: - def _t1199(_dollar_dollar): - return _dollar_dollar - _t1200 = _t1199(msg) - fields428 = _t1200 - unwrapped_fields429 = fields428 - self.write('(') - self.write('inline_data') - self.newline() - self.indent() - self.write(self.format_string_value(unwrapped_fields429)) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: - def _t1201(_dollar_dollar): - _t1202 = self.deconstruct_csv_config(_dollar_dollar) - return _t1202 - _t1203 = _t1201(msg) - fields430 = _t1203 - unwrapped_fields431 = fields430 - self.write('(') - self.write('csv_config') - self.newline() - self.indent() - _t1204 = self.pretty_config_dict(unwrapped_fields431) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: - def _t1205(_dollar_dollar): - return _dollar_dollar - _t1206 = _t1205(msg) - fields432 = _t1206 - unwrapped_fields433 = fields432 - self.write('(') - self.write('columns') - self.newline() - self.indent() - for i435, elem434 in enumerate(unwrapped_fields433): - - if (i435 > 0): - self.newline() - _t1207 = None - else: - _t1207 = None - _t1208 = self.pretty_csv_column(elem434) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: - def _t1209(_dollar_dollar): - return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) - _t1210 = _t1209(msg) - fields436 = _t1210 - unwrapped_fields437 = fields436 - self.write('(') - self.write('column') - self.newline() - self.indent() - field438 = unwrapped_fields437[0] - self.write(self.format_string_value(field438)) - self.newline() - field439 = unwrapped_fields437[1] - _t1211 = self.pretty_relation_id(field439) - self.write('[') - self.newline() - field440 = unwrapped_fields437[2] - for i442, elem441 in enumerate(field440): - - if (i442 > 0): - self.newline() - _t1212 = None - else: - _t1212 = None - _t1213 = self.pretty_type(elem441) - self.write(']') - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_csv_asof(self, msg: str) -> Optional[Never]: - def _t1214(_dollar_dollar): - return _dollar_dollar - _t1215 = _t1214(msg) - fields443 = _t1215 - unwrapped_fields444 = fields443 - self.write('(') - self.write('asof') - self.newline() - self.indent() - self.write(self.format_string_value(unwrapped_fields444)) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: - def _t1216(_dollar_dollar): - return _dollar_dollar.fragment_id - _t1217 = _t1216(msg) - fields445 = _t1217 - unwrapped_fields446 = fields445 - self.write('(') - self.write('undefine') - self.newline() - self.indent() - _t1218 = self.pretty_fragment_id(unwrapped_fields446) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: - def _t1219(_dollar_dollar): - return _dollar_dollar.relations - _t1220 = _t1219(msg) - fields447 = _t1220 - unwrapped_fields448 = fields447 - self.write('(') - self.write('context') - self.newline() - self.indent() - for i450, elem449 in enumerate(unwrapped_fields448): - - if (i450 > 0): - self.newline() - _t1221 = None - else: - _t1221 = None - _t1222 = self.pretty_relation_id(elem449) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: - def _t1223(_dollar_dollar): - return _dollar_dollar - _t1224 = _t1223(msg) - fields451 = _t1224 - unwrapped_fields452 = fields451 - self.write('(') - self.write('reads') - self.newline() - self.indent() - for i454, elem453 in enumerate(unwrapped_fields452): - - if (i454 > 0): - self.newline() - _t1225 = None - else: - _t1225 = None - _t1226 = self.pretty_read(elem453) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: - def _t1227(_dollar_dollar): - - if _dollar_dollar.HasField('demand'): - _t1228 = _dollar_dollar.demand - else: - _t1228 = None - return _t1228 - _t1229 = _t1227(msg) - deconstruct_result459 = _t1229 - - if deconstruct_result459 is not None: - _t1231 = self.pretty_demand(deconstruct_result459) - _t1230 = _t1231 - else: - def _t1232(_dollar_dollar): - - if _dollar_dollar.HasField('output'): - _t1233 = _dollar_dollar.output - else: - _t1233 = None - return _t1233 - _t1234 = _t1232(msg) - deconstruct_result458 = _t1234 - - if deconstruct_result458 is not None: - _t1236 = self.pretty_output(deconstruct_result458) - _t1235 = _t1236 - else: - def _t1237(_dollar_dollar): - - if _dollar_dollar.HasField('what_if'): - _t1238 = _dollar_dollar.what_if - else: - _t1238 = None - return _t1238 - _t1239 = _t1237(msg) - deconstruct_result457 = _t1239 - - if deconstruct_result457 is not None: - _t1241 = self.pretty_what_if(deconstruct_result457) - _t1240 = _t1241 - else: - def _t1242(_dollar_dollar): - - if _dollar_dollar.HasField('abort'): - _t1243 = _dollar_dollar.abort - else: - _t1243 = None - return _t1243 - _t1244 = _t1242(msg) - deconstruct_result456 = _t1244 - - if deconstruct_result456 is not None: - _t1246 = self.pretty_abort(deconstruct_result456) - _t1245 = _t1246 - else: - def _t1247(_dollar_dollar): - - if _dollar_dollar.HasField('export'): - _t1248 = _dollar_dollar.export - else: - _t1248 = None - return _t1248 - _t1249 = _t1247(msg) - deconstruct_result455 = _t1249 - - if deconstruct_result455 is not None: - _t1251 = self.pretty_export(deconstruct_result455) - _t1250 = _t1251 - else: - raise ParseError('No matching rule for read') - _t1245 = _t1250 - _t1240 = _t1245 - _t1235 = _t1240 - _t1230 = _t1235 - return _t1230 - - def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: - def _t1252(_dollar_dollar): - return _dollar_dollar.relation_id - _t1253 = _t1252(msg) - fields460 = _t1253 - unwrapped_fields461 = fields460 - self.write('(') - self.write('demand') - self.newline() - self.indent() - _t1254 = self.pretty_relation_id(unwrapped_fields461) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: - def _t1255(_dollar_dollar): - - if _dollar_dollar.name != 'output': - _t1256 = _dollar_dollar.name - else: - _t1256 = None - return (_t1256, _dollar_dollar.relation_id,) - _t1257 = _t1255(msg) - fields462 = _t1257 - unwrapped_fields463 = fields462 - self.write('(') - self.write('output') - self.newline() - self.indent() - field464 = unwrapped_fields463[0] - - if field464 is not None: - opt_val465 = field464 - _t1259 = self.pretty_name(opt_val465) - _t1258 = _t1259 - else: - _t1258 = None - self.newline() - field466 = unwrapped_fields463[1] - _t1260 = self.pretty_relation_id(field466) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: - def _t1261(_dollar_dollar): - return (_dollar_dollar.branch, _dollar_dollar.epoch,) - _t1262 = _t1261(msg) - fields467 = _t1262 - unwrapped_fields468 = fields467 - self.write('(') - self.write('what_if') - self.newline() - self.indent() - field469 = unwrapped_fields468[0] - _t1263 = self.pretty_name(field469) - self.newline() - field470 = unwrapped_fields468[1] - _t1264 = self.pretty_epoch(field470) - self.dedent() - self.write(')') - self.newline() - return None - - def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: - def _t1265(_dollar_dollar): - - if _dollar_dollar.name != 'abort': - _t1266 = _dollar_dollar.name - else: - _t1266 = None - return (_t1266, _dollar_dollar.relation_id,) - _t1267 = _t1265(msg) - fields471 = _t1267 - unwrapped_fields472 = fields471 - self.write('(') - self.write('abort') - self.newline() - self.indent() - field473 = unwrapped_fields472[0] + field421 = unwrapped_fields418[1] - if field473 is not None: - opt_val474 = field473 - _t1269 = self.pretty_name(opt_val474) - _t1268 = _t1269 + if field421 is not None: + self.newline() + opt_val422 = field421 + _t1197 = self.pretty_csv_locator_inline_data(opt_val422) + _t1196 = _t1197 else: - _t1268 = None - self.newline() - field475 = unwrapped_fields472[1] - _t1270 = self.pretty_relation_id(field475) + _t1196 = None self.dedent() self.write(')') - self.newline() - return None - - def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: - def _t1271(_dollar_dollar): - return _dollar_dollar.csv_config - _t1272 = _t1271(msg) - fields476 = _t1272 - unwrapped_fields477 = fields476 + return None + + def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: + def _t1198(_dollar_dollar): + return _dollar_dollar + _t1199 = _t1198(msg) + fields423 = _t1199 + unwrapped_fields424 = fields423 self.write('(') - self.write('export') - self.newline() + self.write('paths') self.indent() - _t1273 = self.pretty_export_csv_config(unwrapped_fields477) + if not len(unwrapped_fields424) == 0: + self.newline() + for i426, elem425 in enumerate(unwrapped_fields424): + + if (i426 > 0): + self.newline() + _t1200 = None + else: + _t1200 = None + self.write(self.format_string_value(elem425)) self.dedent() self.write(')') - self.newline() return None - def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: - def _t1274(_dollar_dollar): - _t1275 = self.deconstruct_export_csv_config(_dollar_dollar) - return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1275,) - _t1276 = _t1274(msg) - fields478 = _t1276 - unwrapped_fields479 = fields478 + def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: + def _t1201(_dollar_dollar): + return _dollar_dollar + _t1202 = _t1201(msg) + fields427 = _t1202 + unwrapped_fields428 = fields427 self.write('(') - self.write('export_csv_config') - self.newline() + self.write('inline_data') self.indent() - field480 = unwrapped_fields479[0] - _t1277 = self.pretty_export_csv_path(field480) - self.newline() - field481 = unwrapped_fields479[1] - _t1278 = self.pretty_export_csv_columns(field481) self.newline() - field482 = unwrapped_fields479[2] - _t1279 = self.pretty_config_dict(field482) + self.write(self.format_string_value(unwrapped_fields428)) self.dedent() self.write(')') - self.newline() return None - def pretty_export_csv_path(self, msg: str) -> Optional[Never]: - def _t1280(_dollar_dollar): - return _dollar_dollar - _t1281 = _t1280(msg) - fields483 = _t1281 - unwrapped_fields484 = fields483 + def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: + def _t1203(_dollar_dollar): + _t1204 = self.deconstruct_csv_config(_dollar_dollar) + return _t1204 + _t1205 = _t1203(msg) + fields429 = _t1205 + unwrapped_fields430 = fields429 self.write('(') - self.write('path') - self.newline() + self.write('csv_config') self.indent() - self.write(self.format_string_value(unwrapped_fields484)) + self.newline() + _t1206 = self.pretty_config_dict(unwrapped_fields430) self.dedent() self.write(')') - self.newline() return None - def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: - def _t1282(_dollar_dollar): + def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: + def _t1207(_dollar_dollar): return _dollar_dollar - _t1283 = _t1282(msg) - fields485 = _t1283 - unwrapped_fields486 = fields485 + _t1208 = _t1207(msg) + fields431 = _t1208 + unwrapped_fields432 = fields431 self.write('(') self.write('columns') - self.newline() self.indent() - for i488, elem487 in enumerate(unwrapped_fields486): - - if (i488 > 0): - self.newline() - _t1284 = None - else: - _t1284 = None - _t1285 = self.pretty_export_csv_column(elem487) + if not len(unwrapped_fields432) == 0: + self.newline() + for i434, elem433 in enumerate(unwrapped_fields432): + + if (i434 > 0): + self.newline() + _t1209 = None + else: + _t1209 = None + _t1210 = self.pretty_csv_column(elem433) self.dedent() self.write(')') - self.newline() return None - def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: - def _t1286(_dollar_dollar): - return (_dollar_dollar.column_name, _dollar_dollar.column_data,) - _t1287 = _t1286(msg) - fields489 = _t1287 - unwrapped_fields490 = fields489 + def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: + def _t1211(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) + _t1212 = _t1211(msg) + fields435 = _t1212 + unwrapped_fields436 = fields435 self.write('(') self.write('column') - self.newline() self.indent() - field491 = unwrapped_fields490[0] - self.write(self.format_string_value(field491)) self.newline() - field492 = unwrapped_fields490[1] - _t1288 = self.pretty_relation_id(field492) + field437 = unwrapped_fields436[0] + self.write(self.format_string_value(field437)) + self.newline() + field438 = unwrapped_fields436[1] + _t1213 = self.pretty_relation_id(field438) + self.write('[') + field439 = unwrapped_fields436[2] + if not len(field439) == 0: + self.newline() + for i441, elem440 in enumerate(field439): + + if (i441 > 0): + self.newline() + _t1214 = None + else: + _t1214 = None + _t1215 = self.pretty_type(elem440) + self.write(']') self.dedent() self.write(')') - self.newline() - return None - - def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: - if (value is not None and value.HasField('int_value')): - return value.int_value - return default - - def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: - if (value is not None and value.HasField('float_value')): - return value.float_value - return default - - def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: - if (value is not None and value.HasField('string_value')): - return value.string_value - return default - - def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: - if (value is not None and value.HasField('boolean_value')): - return value.boolean_value - return default - - def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: - if (value is not None and value.HasField('string_value')): - return value.string_value.encode() - return default - - def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: - if (value is not None and value.HasField('uint128_value')): - return value.uint128_value - return default - - def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: - if (value is not None and value.HasField('string_value')): - return [value.string_value] - return default - - def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: - if (value is not None and value.HasField('int_value')): - return value.int_value - return None - - def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: - if (value is not None and value.HasField('float_value')): - return value.float_value - return None - - def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: - if (value is not None and value.HasField('string_value')): - return value.string_value - return None - - def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: - if (value is not None and value.HasField('string_value')): - return value.string_value.encode() return None - def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: - if (value is not None and value.HasField('uint128_value')): - return value.uint128_value + def pretty_csv_asof(self, msg: str) -> Optional[Never]: + def _t1216(_dollar_dollar): + return _dollar_dollar + _t1217 = _t1216(msg) + fields442 = _t1217 + unwrapped_fields443 = fields442 + self.write('(') + self.write('asof') + self.indent() + self.newline() + self.write(self.format_string_value(unwrapped_fields443)) + self.dedent() + self.write(')') return None - def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: - if (value is not None and value.HasField('string_value')): - return [value.string_value] + def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: + def _t1218(_dollar_dollar): + return _dollar_dollar.fragment_id + _t1219 = _t1218(msg) + fields444 = _t1219 + unwrapped_fields445 = fields444 + self.write('(') + self.write('undefine') + self.indent() + self.newline() + _t1220 = self.pretty_fragment_id(unwrapped_fields445) + self.dedent() + self.write(')') return None - def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: - config = dict(config_dict) - _t1289 = self._extract_value_int64(config.get('csv_header_row'), 1) - header_row = _t1289 - _t1290 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t1290 - _t1291 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t1291 - _t1292 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t1292 - _t1293 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t1293 - _t1294 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t1294 - _t1295 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t1295 - _t1296 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t1296 - _t1297 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t1297 - _t1298 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t1298 - _t1299 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t1299 - _t1300 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1300 - - def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: - config = dict(config_dict) - _t1301 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t1301 - _t1302 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t1302 - _t1303 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t1303 - _t1304 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t1304 - _t1305 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1305 - _t1306 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t1306 - _t1307 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t1307 - _t1308 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t1308 - _t1309 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t1309 - _t1310 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1310 - _t1311 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1311 - - def default_configure(self) -> transactions_pb2.Configure: - _t1312 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1312 - _t1313 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1313 - - def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: - config = dict(config_dict) - maintenance_level_val = config.get('ivm.maintenance_level') - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - if (maintenance_level_val is not None and maintenance_level_val.HasField('string_value')): - if maintenance_level_val.string_value == 'off': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - else: - if maintenance_level_val.string_value == 'auto': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO - else: - if maintenance_level_val.string_value == 'all': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL - else: - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1314 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1314 - _t1315 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t1315 - _t1316 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1316 - - def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: - config = dict(config_dict) - _t1317 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t1317 - _t1318 = self._extract_value_string(config.get('compression'), '') - compression = _t1318 - _t1319 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t1319 - _t1320 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t1320 - _t1321 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t1321 - _t1322 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t1322 - _t1323 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t1323 - _t1324 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1324 - - def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t1325 = logic_pb2.Value(int_value=v) - return _t1325 - - def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t1326 = logic_pb2.Value(float_value=v) - return _t1326 - - def _make_value_string(self, v: str) -> logic_pb2.Value: - _t1327 = logic_pb2.Value(string_value=v) - return _t1327 - - def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t1328 = logic_pb2.Value(boolean_value=v) - return _t1328 - - def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1329 = logic_pb2.Value(uint128_value=v) - return _t1329 - - def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: - if cfg.semantics_version != 0: - return False - if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - return False - return True + def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: + def _t1221(_dollar_dollar): + return _dollar_dollar.relations + _t1222 = _t1221(msg) + fields446 = _t1222 + unwrapped_fields447 = fields446 + self.write('(') + self.write('context') + self.indent() + if not len(unwrapped_fields447) == 0: + self.newline() + for i449, elem448 in enumerate(unwrapped_fields447): + + if (i449 > 0): + self.newline() + _t1223 = None + else: + _t1223 = None + _t1224 = self.pretty_relation_id(elem448) + self.dedent() + self.write(')') + return None - def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: - result = [] - - if msg.semantics_version != 0: - _t1331 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1331,)) - _t1330 = None - else: - _t1330 = None + def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: + def _t1225(_dollar_dollar): + return _dollar_dollar + _t1226 = _t1225(msg) + fields450 = _t1226 + unwrapped_fields451 = fields450 + self.write('(') + self.write('reads') + self.indent() + if not len(unwrapped_fields451) == 0: + self.newline() + for i453, elem452 in enumerate(unwrapped_fields451): + + if (i453 > 0): + self.newline() + _t1227 = None + else: + _t1227 = None + _t1228 = self.pretty_read(elem452) + self.dedent() + self.write(')') + return None + + def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: + def _t1229(_dollar_dollar): + + if _dollar_dollar.HasField('demand'): + _t1230 = _dollar_dollar.demand + else: + _t1230 = None + return _t1230 + _t1231 = _t1229(msg) + deconstruct_result458 = _t1231 - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1333 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1333,)) - _t1332 = None + if deconstruct_result458 is not None: + _t1233 = self.pretty_demand(deconstruct_result458) + _t1232 = _t1233 else: + def _t1234(_dollar_dollar): + + if _dollar_dollar.HasField('output'): + _t1235 = _dollar_dollar.output + else: + _t1235 = None + return _t1235 + _t1236 = _t1234(msg) + deconstruct_result457 = _t1236 - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1335 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1335,)) - _t1334 = None + if deconstruct_result457 is not None: + _t1238 = self.pretty_output(deconstruct_result457) + _t1237 = _t1238 else: + def _t1239(_dollar_dollar): + + if _dollar_dollar.HasField('what_if'): + _t1240 = _dollar_dollar.what_if + else: + _t1240 = None + return _t1240 + _t1241 = _t1239(msg) + deconstruct_result456 = _t1241 - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1337 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1337,)) - _t1336 = None + if deconstruct_result456 is not None: + _t1243 = self.pretty_what_if(deconstruct_result456) + _t1242 = _t1243 else: - _t1336 = None - _t1334 = _t1336 - _t1332 = _t1334 - return result - - def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: - result = [] - - if msg.header_row != 1: - _t1339 = self._make_value_int64(int(msg.header_row)) - result.append(('csv_header_row', _t1339,)) - _t1338 = None - else: - _t1338 = None - - if msg.skip != 0: - _t1341 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1341,)) - _t1340 = None - else: - _t1340 = None - - if msg.new_line != '': - _t1343 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1343,)) - _t1342 = None - else: - _t1342 = None - - if msg.delimiter != ',': - _t1345 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1345,)) - _t1344 = None - else: - _t1344 = None - - if msg.quotechar != '"': - _t1347 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1347,)) - _t1346 = None - else: - _t1346 = None - - if msg.escapechar != '"': - _t1349 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1349,)) - _t1348 = None - else: - _t1348 = None - - if msg.comment != '': - _t1351 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1351,)) - _t1350 = None - else: - _t1350 = None - - if not len(msg.missing_strings) == 0: - _t1353 = self._make_value_string(msg.missing_strings[0]) - result.append(('csv_missing_strings', _t1353,)) - _t1352 = None - else: - _t1352 = None - - if msg.decimal_separator != '.': - _t1355 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1355,)) - _t1354 = None - else: - _t1354 = None - - if msg.encoding != 'utf-8': - _t1357 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1357,)) - _t1356 = None - else: - _t1356 = None - - if msg.compression != 'auto': - _t1359 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1359,)) - _t1358 = None - else: - _t1358 = None - return result + def _t1244(_dollar_dollar): + + if _dollar_dollar.HasField('abort'): + _t1245 = _dollar_dollar.abort + else: + _t1245 = None + return _t1245 + _t1246 = _t1244(msg) + deconstruct_result455 = _t1246 + + if deconstruct_result455 is not None: + _t1248 = self.pretty_abort(deconstruct_result455) + _t1247 = _t1248 + else: + def _t1249(_dollar_dollar): + + if _dollar_dollar.HasField('export'): + _t1250 = _dollar_dollar.export + else: + _t1250 = None + return _t1250 + _t1251 = _t1249(msg) + deconstruct_result454 = _t1251 + + if deconstruct_result454 is not None: + _t1253 = self.pretty_export(deconstruct_result454) + _t1252 = _t1253 + else: + raise ParseError('No matching rule for read') + _t1247 = _t1252 + _t1242 = _t1247 + _t1237 = _t1242 + _t1232 = _t1237 + return _t1232 - def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: - - if val is not None: - _t1361 = self._make_value_float64(val) - result.append((key, _t1361,)) - _t1360 = None - else: - _t1360 = None + def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: + def _t1254(_dollar_dollar): + return _dollar_dollar.relation_id + _t1255 = _t1254(msg) + fields459 = _t1255 + unwrapped_fields460 = fields459 + self.write('(') + self.write('demand') + self.indent() + self.newline() + _t1256 = self.pretty_relation_id(unwrapped_fields460) + self.dedent() + self.write(')') return None - def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: - - if val is not None: - _t1363 = self._make_value_int64(val) - result.append((key, _t1363,)) - _t1362 = None - else: - _t1362 = None + def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: + def _t1257(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.relation_id,) + _t1258 = _t1257(msg) + fields461 = _t1258 + unwrapped_fields462 = fields461 + self.write('(') + self.write('output') + self.indent() + self.newline() + field463 = unwrapped_fields462[0] + _t1259 = self.pretty_name(field463) + self.newline() + field464 = unwrapped_fields462[1] + _t1260 = self.pretty_relation_id(field464) + self.dedent() + self.write(')') return None - def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: - - if val is not None: - _t1365 = self._make_value_uint128(val) - result.append((key, _t1365,)) - _t1364 = None - else: - _t1364 = None + def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: + def _t1261(_dollar_dollar): + return (_dollar_dollar.branch, _dollar_dollar.epoch,) + _t1262 = _t1261(msg) + fields465 = _t1262 + unwrapped_fields466 = fields465 + self.write('(') + self.write('what_if') + self.indent() + self.newline() + field467 = unwrapped_fields466[0] + _t1263 = self.pretty_name(field467) + self.newline() + field468 = unwrapped_fields466[1] + _t1264 = self.pretty_epoch(field468) + self.dedent() + self.write(')') return None - def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: + def _t1265(_dollar_dollar): + + if _dollar_dollar.name != 'abort': + _t1266 = _dollar_dollar.name + else: + _t1266 = None + return (_t1266, _dollar_dollar.relation_id,) + _t1267 = _t1265(msg) + fields469 = _t1267 + unwrapped_fields470 = fields469 + self.write('(') + self.write('abort') + self.indent() + field471 = unwrapped_fields470[0] - if val is not None: - _t1367 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1367,)) - _t1366 = None + if field471 is not None: + self.newline() + opt_val472 = field471 + _t1269 = self.pretty_name(opt_val472) + _t1268 = _t1269 else: - _t1366 = None + _t1268 = None + self.newline() + field473 = unwrapped_fields470[1] + _t1270 = self.pretty_relation_id(field473) + self.dedent() + self.write(')') return None - def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: - result = [] - _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) - _t1372 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1373 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1374 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1375 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) - return result - - def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: - result = [] - - if (msg.partition_size is not None and msg.partition_size != 0): - _t1377 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1377,)) - _t1376 = None - else: - _t1376 = None - - if (msg.compression is not None and msg.compression != ''): - _t1379 = self._make_value_string(msg.compression) - result.append(('compression', _t1379,)) - _t1378 = None - else: - _t1378 = None - - if msg.syntax_header_row is not None: - _t1381 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1381,)) - _t1380 = None - else: - _t1380 = None - - if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): - _t1383 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1383,)) - _t1382 = None - else: - _t1382 = None - - if (msg.syntax_delim is not None and msg.syntax_delim != ','): - _t1385 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1385,)) - _t1384 = None - else: - _t1384 = None - - if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): - _t1387 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1387,)) - _t1386 = None - else: - _t1386 = None - - if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): - _t1389 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1389,)) - _t1388 = None - else: - _t1388 = None - return result + def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: + def _t1271(_dollar_dollar): + return _dollar_dollar.csv_config + _t1272 = _t1271(msg) + fields474 = _t1272 + unwrapped_fields475 = fields474 + self.write('(') + self.write('export') + self.indent() + self.newline() + _t1273 = self.pretty_export_csv_config(unwrapped_fields475) + self.dedent() + self.write(')') + return None - def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: - name = self.relation_id_to_string(msg) - if name != '': - return name + def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: + def _t1274(_dollar_dollar): + _t1275 = self.deconstruct_export_csv_config(_dollar_dollar) + return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1275,) + _t1276 = _t1274(msg) + fields476 = _t1276 + unwrapped_fields477 = fields476 + self.write('(') + self.write('export_csv_config') + self.indent() + self.newline() + field478 = unwrapped_fields477[0] + _t1277 = self.pretty_export_csv_path(field478) + self.newline() + field479 = unwrapped_fields477[1] + _t1278 = self.pretty_export_csv_columns(field479) + self.newline() + field480 = unwrapped_fields477[2] + _t1279 = self.pretty_config_dict(field480) + self.dedent() + self.write(')') return None - def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: - name = self.relation_id_to_string(msg) - if name == '': - return self.relation_id_to_uint128(msg) + def pretty_export_csv_path(self, msg: str) -> Optional[Never]: + def _t1280(_dollar_dollar): + return _dollar_dollar + _t1281 = _t1280(msg) + fields481 = _t1281 + unwrapped_fields482 = fields481 + self.write('(') + self.write('path') + self.indent() + self.newline() + self.write(self.format_string_value(unwrapped_fields482)) + self.dedent() + self.write(')') return None - def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - return (abs.vars, [],) + def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: + def _t1282(_dollar_dollar): + return _dollar_dollar + _t1283 = _t1282(msg) + fields483 = _t1283 + unwrapped_fields484 = fields483 + self.write('(') + self.write('columns') + self.indent() + if not len(unwrapped_fields484) == 0: + self.newline() + for i486, elem485 in enumerate(unwrapped_fields484): + + if (i486 > 0): + self.newline() + _t1284 = None + else: + _t1284 = None + _t1285 = self.pretty_export_csv_column(elem485) + self.dedent() + self.write(')') + return None - def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - n = len(abs.vars) - key_end = (n - value_arity) - return (abs.vars[0:key_end], abs.vars[key_end:n],) + def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: + def _t1286(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.column_data,) + _t1287 = _t1286(msg) + fields487 = _t1287 + unwrapped_fields488 = fields487 + self.write('(') + self.write('column') + self.indent() + self.newline() + field489 = unwrapped_fields488[0] + self.write(self.format_string_value(field489)) + self.newline() + field490 = unwrapped_fields488[1] + _t1288 = self.pretty_relation_id(field490) + self.dedent() + self.write(')') + return None def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io) printer.pretty_transaction(msg) + printer.newline() return printer.get_output() - diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 302aa36c..097c31cf 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -21,7 +21,7 @@ # # Deconstruct actions use `$N = expr` assignments to extract RHS element # values from the LHS value ($$). If omitted, the default is the identity -# deconstruct. Use `assert COND` to guard the deconstructor: if any assert +# deconstruct. Use `deconstruct if COND:` to guard the deconstructor: if the # condition fails, the deconstructor returns None, signaling that this rule # does not match the LHS value. # @@ -182,8 +182,8 @@ transaction : "(" "transaction" configure? sync? epoch* ")" construct: $$ = transactions.Transaction(epochs=$5, configure=builtin.unwrap_option_or($3, default_configure()), sync=$4) deconstruct: - $3: Optional[transactions.Configure] = $$.configure if not is_default_configure($$.configure) else None - $4: Optional[transactions.Sync] = $$.sync # TODO: if sync.fragments is not empty else None + $3: Optional[transactions.Configure] = $$.configure if builtin.has_proto_field($$, "configure") else None + $4: Optional[transactions.Sync] = $$.sync if builtin.has_proto_field($$, "sync") else None $5: List[transactions.Epoch] = $$.epochs configure @@ -204,50 +204,41 @@ config_key_value value : date construct: $$ = logic.Value(date_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'date_value') + deconstruct if builtin.has_proto_field($$, 'date_value'): $1: logic.DateValue = $$.date_value | datetime construct: $$ = logic.Value(datetime_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'datetime_value') + deconstruct if builtin.has_proto_field($$, 'datetime_value'): $1: logic.DateTimeValue = $$.datetime_value | STRING construct: $$ = logic.Value(string_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'string_value') + deconstruct if builtin.has_proto_field($$, 'string_value'): $1: String = $$.string_value | INT construct: $$ = logic.Value(int_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'int_value') + deconstruct if builtin.has_proto_field($$, 'int_value'): $1: Int64 = $$.int_value | FLOAT construct: $$ = logic.Value(float_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'float_value') + deconstruct if builtin.has_proto_field($$, 'float_value'): $1: Float64 = $$.float_value | UINT128 construct: $$ = logic.Value(uint128_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'uint128_value') + deconstruct if builtin.has_proto_field($$, 'uint128_value'): $1: logic.UInt128Value = $$.uint128_value | INT128 construct: $$ = logic.Value(int128_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'int128_value') + deconstruct if builtin.has_proto_field($$, 'int128_value'): $1: logic.Int128Value = $$.int128_value | DECIMAL construct: $$ = logic.Value(decimal_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'decimal_value') + deconstruct if builtin.has_proto_field($$, 'decimal_value'): $1: logic.DecimalValue = $$.decimal_value | "missing" construct: $$ = logic.Value(missing_value=logic.MissingValue()) | boolean_value construct: $$ = logic.Value(boolean_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'boolean_value') + deconstruct if builtin.has_proto_field($$, 'boolean_value'): $1: Boolean = $$.boolean_value date @@ -273,6 +264,7 @@ datetime boolean_value : "true" construct: $$ = True + deconstruct if $$: | "false" construct: $$ = False @@ -299,18 +291,15 @@ epoch_writes write : define construct: $$ = transactions.Write(define=$1) - deconstruct: - assert builtin.has_proto_field($$, 'define') + deconstruct if builtin.has_proto_field($$, 'define'): $1: transactions.Define = $$.define | undefine construct: $$ = transactions.Write(undefine=$1) - deconstruct: - assert builtin.has_proto_field($$, 'undefine') + deconstruct if builtin.has_proto_field($$, 'undefine'): $1: transactions.Undefine = $$.undefine | context construct: $$ = transactions.Write(context=$1) - deconstruct: - assert builtin.has_proto_field($$, 'context') + deconstruct if builtin.has_proto_field($$, 'context'): $1: transactions.Context = $$.context define @@ -335,23 +324,19 @@ new_fragment_id declaration : def construct: $$ = logic.Declaration(def=$1) - deconstruct: - assert builtin.has_proto_field($$, 'def') + deconstruct if builtin.has_proto_field($$, 'def'): $1: logic.Def = $$.def | algorithm construct: $$ = logic.Declaration(algorithm=$1) - deconstruct: - assert builtin.has_proto_field($$, 'algorithm') + deconstruct if builtin.has_proto_field($$, 'algorithm'): $1: logic.Algorithm = $$.algorithm | constraint construct: $$ = logic.Declaration(constraint=$1) - deconstruct: - assert builtin.has_proto_field($$, 'constraint') + deconstruct if builtin.has_proto_field($$, 'constraint'): $1: logic.Constraint = $$.constraint | data construct: $$ = logic.Declaration(data=$1) - deconstruct: - assert builtin.has_proto_field($$, 'data') + deconstruct if builtin.has_proto_field($$, 'data'): $1: logic.Data = $$.data def @@ -394,58 +379,47 @@ binding type : unspecified_type construct: $$ = logic.Type(unspecified_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'unspecified_type') + deconstruct if builtin.has_proto_field($$, 'unspecified_type'): $1: logic.UnspecifiedType = $$.unspecified_type | string_type construct: $$ = logic.Type(string_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'string_type') + deconstruct if builtin.has_proto_field($$, 'string_type'): $1: logic.StringType = $$.string_type | int_type construct: $$ = logic.Type(int_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'int_type') + deconstruct if builtin.has_proto_field($$, 'int_type'): $1: logic.IntType = $$.int_type | float_type construct: $$ = logic.Type(float_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'float_type') + deconstruct if builtin.has_proto_field($$, 'float_type'): $1: logic.FloatType = $$.float_type | uint128_type construct: $$ = logic.Type(uint128_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'uint128_type') + deconstruct if builtin.has_proto_field($$, 'uint128_type'): $1: logic.UInt128Type = $$.uint128_type | int128_type construct: $$ = logic.Type(int128_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'int128_type') + deconstruct if builtin.has_proto_field($$, 'int128_type'): $1: logic.Int128Type = $$.int128_type | date_type construct: $$ = logic.Type(date_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'date_type') + deconstruct if builtin.has_proto_field($$, 'date_type'): $1: logic.DateType = $$.date_type | datetime_type construct: $$ = logic.Type(datetime_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'datetime_type') + deconstruct if builtin.has_proto_field($$, 'datetime_type'): $1: logic.DateTimeType = $$.datetime_type | missing_type construct: $$ = logic.Type(missing_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'missing_type') + deconstruct if builtin.has_proto_field($$, 'missing_type'): $1: logic.MissingType = $$.missing_type | decimal_type construct: $$ = logic.Type(decimal_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'decimal_type') + deconstruct if builtin.has_proto_field($$, 'decimal_type'): $1: logic.DecimalType = $$.decimal_type | boolean_type construct: $$ = logic.Type(boolean_type=$1) - deconstruct: - assert builtin.has_proto_field($$, 'boolean_type') + deconstruct if builtin.has_proto_field($$, 'boolean_type'): $1: logic.BooleanType = $$.boolean_type unspecified_type @@ -501,68 +475,55 @@ value_bindings formula : true construct: $$ = logic.Formula(conjunction=$1) - deconstruct: - assert builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args) + deconstruct if builtin.has_proto_field($$, 'conjunction') and builtin.is_empty($$.conjunction.args): $1: logic.Conjunction = $$.conjunction | false construct: $$ = logic.Formula(disjunction=$1) - deconstruct: - assert builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args) + deconstruct if builtin.has_proto_field($$, 'disjunction') and builtin.is_empty($$.disjunction.args): $1: logic.Disjunction = $$.disjunction | exists construct: $$ = logic.Formula(exists=$1) - deconstruct: - assert builtin.has_proto_field($$, 'exists') + deconstruct if builtin.has_proto_field($$, 'exists'): $1: logic.Exists = $$.exists | reduce construct: $$ = logic.Formula(reduce=$1) - deconstruct: - assert builtin.has_proto_field($$, 'reduce') + deconstruct if builtin.has_proto_field($$, 'reduce'): $1: logic.Reduce = $$.reduce | conjunction construct: $$ = logic.Formula(conjunction=$1) - deconstruct: - assert builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args) + deconstruct if builtin.has_proto_field($$, 'conjunction') and not builtin.is_empty($$.conjunction.args): $1: logic.Conjunction = $$.conjunction | disjunction construct: $$ = logic.Formula(disjunction=$1) - deconstruct: - assert builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args) + deconstruct if builtin.has_proto_field($$, 'disjunction') and not builtin.is_empty($$.disjunction.args): $1: logic.Disjunction = $$.disjunction | not construct: $$ = logic.Formula(not=$1) - deconstruct: - assert builtin.has_proto_field($$, 'not') + deconstruct if builtin.has_proto_field($$, 'not'): $1: logic.Not = $$.not | ffi construct: $$ = logic.Formula(ffi=$1) - deconstruct: - assert builtin.has_proto_field($$, 'ffi') + deconstruct if builtin.has_proto_field($$, 'ffi'): $1: logic.FFI = $$.ffi | atom construct: $$ = logic.Formula(atom=$1) - deconstruct: - assert builtin.has_proto_field($$, 'atom') + deconstruct if builtin.has_proto_field($$, 'atom'): $1: logic.Atom = $$.atom | pragma construct: $$ = logic.Formula(pragma=$1) - deconstruct: - assert builtin.has_proto_field($$, 'pragma') + deconstruct if builtin.has_proto_field($$, 'pragma'): $1: logic.Pragma = $$.pragma | primitive construct: $$ = logic.Formula(primitive=$1) - deconstruct: - assert builtin.has_proto_field($$, 'primitive') + deconstruct if builtin.has_proto_field($$, 'primitive'): $1: logic.Primitive = $$.primitive | rel_atom construct: $$ = logic.Formula(rel_atom=$1) - deconstruct: - assert builtin.has_proto_field($$, 'rel_atom') + deconstruct if builtin.has_proto_field($$, 'rel_atom'): $1: logic.RelAtom = $$.rel_atom | cast construct: $$ = logic.Formula(cast=$1) - deconstruct: - assert builtin.has_proto_field($$, 'cast') + deconstruct if builtin.has_proto_field($$, 'cast'): $1: logic.Cast = $$.cast true @@ -591,13 +552,11 @@ reduce term : var construct: $$ = logic.Term(var=$1) - deconstruct: - assert builtin.has_proto_field($$, 'var') + deconstruct if builtin.has_proto_field($$, 'var'): $1: logic.Var = $$.var | constant construct: $$ = logic.Term(constant=$1) - deconstruct: - assert builtin.has_proto_field($$, 'constant') + deconstruct if builtin.has_proto_field($$, 'constant'): $1: logic.Value = $$.constant var @@ -673,48 +632,42 @@ primitive eq : "(" "=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_eq", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) - deconstruct: - assert $$.name == "rel_primitive_eq" + deconstruct if $$.name == "rel_primitive_eq": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term lt : "(" "<" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) - deconstruct: - assert $$.name == "rel_primitive_lt_monotype" + deconstruct if $$.name == "rel_primitive_lt_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term lt_eq : "(" "<=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_lt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) - deconstruct: - assert $$.name == "rel_primitive_lt_eq_monotype" + deconstruct if $$.name == "rel_primitive_lt_eq_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term gt : "(" ">" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) - deconstruct: - assert $$.name == "rel_primitive_gt_monotype" + deconstruct if $$.name == "rel_primitive_gt_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term gt_eq : "(" ">=" term term ")" construct: $$ = logic.Primitive(name="rel_primitive_gt_eq_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4)]) - deconstruct: - assert $$.name == "rel_primitive_gt_eq_monotype" + deconstruct if $$.name == "rel_primitive_gt_eq_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term add : "(" "+" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_add_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) - deconstruct: - assert $$.name == "rel_primitive_add_monotype" + deconstruct if $$.name == "rel_primitive_add_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term $5: logic.Term = $$.terms[2].term @@ -722,8 +675,7 @@ add minus : "(" "-" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_subtract_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) - deconstruct: - assert $$.name == "rel_primitive_subtract_monotype" + deconstruct if $$.name == "rel_primitive_subtract_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term $5: logic.Term = $$.terms[2].term @@ -731,8 +683,7 @@ minus multiply : "(" "*" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_multiply_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) - deconstruct: - assert $$.name == "rel_primitive_multiply_monotype" + deconstruct if $$.name == "rel_primitive_multiply_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term $5: logic.Term = $$.terms[2].term @@ -740,8 +691,7 @@ multiply divide : "(" "/" term term term ")" construct: $$ = logic.Primitive(name="rel_primitive_divide_monotype", terms=[logic.RelTerm(term=$3), logic.RelTerm(term=$4), logic.RelTerm(term=$5)]) - deconstruct: - assert $$.name == "rel_primitive_divide_monotype" + deconstruct if $$.name == "rel_primitive_divide_monotype": $3: logic.Term = $$.terms[0].term $4: logic.Term = $$.terms[1].term $5: logic.Term = $$.terms[2].term @@ -749,13 +699,11 @@ divide rel_term : specialized_value construct: $$ = logic.RelTerm(specialized_value=$1) - deconstruct: - assert builtin.has_proto_field($$, 'specialized_value') + deconstruct if builtin.has_proto_field($$, 'specialized_value'): $1: logic.Value = $$.specialized_value | term construct: $$ = logic.RelTerm(term=$1) - deconstruct: - assert builtin.has_proto_field($$, 'term') + deconstruct if builtin.has_proto_field($$, 'term'): $1: logic.Term = $$.term specialized_value @@ -800,13 +748,11 @@ script construct : loop construct: $$ = logic.Construct(loop=$1) - deconstruct: - assert builtin.has_proto_field($$, 'loop') + deconstruct if builtin.has_proto_field($$, 'loop'): $1: logic.Loop = $$.loop | instruction construct: $$ = logic.Construct(instruction=$1) - deconstruct: - assert builtin.has_proto_field($$, 'instruction') + deconstruct if builtin.has_proto_field($$, 'instruction'): $1: logic.Instruction = $$.instruction loop @@ -822,28 +768,23 @@ init instruction : assign construct: $$ = logic.Instruction(assign=$1) - deconstruct: - assert builtin.has_proto_field($$, 'assign') + deconstruct if builtin.has_proto_field($$, 'assign'): $1: logic.Assign = $$.assign | upsert construct: $$ = logic.Instruction(upsert=$1) - deconstruct: - assert builtin.has_proto_field($$, 'upsert') + deconstruct if builtin.has_proto_field($$, 'upsert'): $1: logic.Upsert = $$.upsert | break construct: $$ = logic.Instruction(break=$1) - deconstruct: - assert builtin.has_proto_field($$, 'break') + deconstruct if builtin.has_proto_field($$, 'break'): $1: logic.Break = $$.break | monoid_def construct: $$ = logic.Instruction(monoid_def=$1) - deconstruct: - assert builtin.has_proto_field($$, 'monoid_def') + deconstruct if builtin.has_proto_field($$, 'monoid_def'): $1: logic.MonoidDef = $$.monoid_def | monus_def construct: $$ = logic.Instruction(monus_def=$1) - deconstruct: - assert builtin.has_proto_field($$, 'monus_def') + deconstruct if builtin.has_proto_field($$, 'monus_def'): $1: logic.MonusDef = $$.monus_def assign @@ -889,23 +830,19 @@ monoid_def monoid : or_monoid construct: $$ = logic.Monoid(or_monoid=$1) - deconstruct: - assert builtin.has_proto_field($$, 'or_monoid') + deconstruct if builtin.has_proto_field($$, 'or_monoid'): $1: logic.OrMonoid = $$.or_monoid | min_monoid construct: $$ = logic.Monoid(min_monoid=$1) - deconstruct: - assert builtin.has_proto_field($$, 'min_monoid') + deconstruct if builtin.has_proto_field($$, 'min_monoid'): $1: logic.MinMonoid = $$.min_monoid | max_monoid construct: $$ = logic.Monoid(max_monoid=$1) - deconstruct: - assert builtin.has_proto_field($$, 'max_monoid') + deconstruct if builtin.has_proto_field($$, 'max_monoid'): $1: logic.MaxMonoid = $$.max_monoid | sum_monoid construct: $$ = logic.Monoid(sum_monoid=$1) - deconstruct: - assert builtin.has_proto_field($$, 'sum_monoid') + deconstruct if builtin.has_proto_field($$, 'sum_monoid'): $1: logic.SumMonoid = $$.sum_monoid or_monoid @@ -954,18 +891,15 @@ functional_dependency_values data : rel_edb construct: $$ = logic.Data(rel_edb=$1) - deconstruct: - assert builtin.has_proto_field($$, 'rel_edb') + deconstruct if builtin.has_proto_field($$, 'rel_edb'): $1: logic.RelEDB = $$.rel_edb | betree_relation construct: $$ = logic.Data(betree_relation=$1) - deconstruct: - assert builtin.has_proto_field($$, 'betree_relation') + deconstruct if builtin.has_proto_field($$, 'betree_relation'): $1: logic.BeTreeRelation = $$.betree_relation | csv_data construct: $$ = logic.Data(csv_data=$1) - deconstruct: - assert builtin.has_proto_field($$, 'csv_data') + deconstruct if builtin.has_proto_field($$, 'csv_data'): $1: logic.CSVData = $$.csv_data rel_edb_path @@ -1060,28 +994,23 @@ epoch_reads read : demand construct: $$ = transactions.Read(demand=$1) - deconstruct: - assert builtin.has_proto_field($$, 'demand') + deconstruct if builtin.has_proto_field($$, 'demand'): $1: transactions.Demand = $$.demand | output construct: $$ = transactions.Read(output=$1) - deconstruct: - assert builtin.has_proto_field($$, 'output') + deconstruct if builtin.has_proto_field($$, 'output'): $1: transactions.Output = $$.output | what_if construct: $$ = transactions.Read(what_if=$1) - deconstruct: - assert builtin.has_proto_field($$, 'what_if') + deconstruct if builtin.has_proto_field($$, 'what_if'): $1: transactions.WhatIf = $$.what_if | abort construct: $$ = transactions.Read(abort=$1) - deconstruct: - assert builtin.has_proto_field($$, 'abort') + deconstruct if builtin.has_proto_field($$, 'abort'): $1: transactions.Abort = $$.abort | export construct: $$ = transactions.Read(export=$1) - deconstruct: - assert builtin.has_proto_field($$, 'export') + deconstruct if builtin.has_proto_field($$, 'export'): $1: transactions.Export = $$.export demand @@ -1090,10 +1019,10 @@ demand deconstruct: $3: logic.RelationId = $$.relation_id output - : "(" "output" name? relation_id ")" - construct: $$ = transactions.Output(name=builtin.unwrap_option_or($3, "output"), relation_id=$4) + : "(" "output" name relation_id ")" + construct: $$ = transactions.Output(name=$3, relation_id=$4) deconstruct: - $3: Optional[String] = $$.name if $$.name != "output" else None + $3: String = $$.name $4: logic.RelationId = $$.relation_id what_if @@ -1363,14 +1292,13 @@ def is_default_configure(cfg: transactions.Configure) -> bool: def deconstruct_configure(msg: transactions.Configure) -> List[Tuple[String, logic.Value]]: result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() - if msg.semantics_version != 0: - builtin.list_push(result, builtin.tuple("semantics_version", _make_value_int64(msg.semantics_version))) if msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("auto"))) elif msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("all"))) elif msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("off"))) + builtin.list_push(result, builtin.tuple("semantics_version", _make_value_int64(msg.semantics_version))) return result @@ -1431,8 +1359,10 @@ def deconstruct_betree_info_config(msg: logic.BeTreeInfo) -> List[Tuple[String, _maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.max_pivots) _maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.max_deltas) _maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.max_leaf) - _maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.root_pageid) - _maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.inline_data) + if builtin.has_proto_field(msg.relation_locator, "root_pageid"): + _maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.root_pageid) + if builtin.has_proto_field(msg.relation_locator, "inline_data"): + _maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.inline_data) _maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.element_count) _maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.tree_height) return result diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index b664a180..2a6fc7e1 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -272,6 +272,9 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, stmts: List[TargetExpr] = [] field_idx = 0 + NO_TRAILING_SPACE = {'(', '[', ':', '#', '::'} + NO_LEADING_SPACE = {')', ']', '}', '::'} + # Detect S-expression pattern: first element is "(", second is a keyword literal is_sexp = (len(elems) >= 2 and isinstance(elems[0], LitTerminal) and elems[0].name == '(' @@ -280,28 +283,68 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, # Count non-literal elements to determine if fields_var is a tuple or single value non_lit_count = sum(1 for e in elems if not isinstance(e, LitTerminal)) + # Track the previous element's literal name for spacing decisions + prev_lit_name: Optional[str] = None + for i, elem in enumerate(elems): - # In non-S-expression mode, add space between elements - if not is_sexp and stmts: - stmts.append(Call(make_builtin('write_io'), [Lit(' ')])) + is_optional_or_star = isinstance(elem, (Option, Star)) + + # Compute leading whitespace for this element + leading_ws: List[TargetExpr] = [] + if isinstance(elem, LitTerminal): + # Non-sexp spacing before literals + if not is_sexp and stmts: + cur_lit_name = elem.name + suppress = False + if prev_lit_name in NO_TRAILING_SPACE: + suppress = True + if cur_lit_name in NO_LEADING_SPACE: + suppress = True + if not suppress: + stmts.append(Call(make_builtin('write_io'), [Lit(' ')])) + else: + if is_sexp: + # Sexp spacing: newline before each non-literal + # (indent is emitted unconditionally after the keyword) + leading_ws = [Call(make_builtin('newline_io'), [])] + elif stmts: + # Non-sexp spacing between elements + cur_lit_name = None + suppress = False + if prev_lit_name in NO_TRAILING_SPACE: + suppress = True + if not suppress: + leading_ws = [Call(make_builtin('write_io'), [Lit(' ')])] if isinstance(elem, LitTerminal): is_keyword = is_sexp and i == 1 + # For sexp closing paren, emit dedent if we indented + if is_sexp and elem.name == ')' and non_lit_count > 0: + stmts.append(Call(make_builtin('dedent_io'), [])) stmts.append(_format_literal(elem, is_sexp_keyword=is_keyword)) + # After sexp keyword, emit indent (always, not conditional on Option) + if is_keyword and non_lit_count > 0: + stmts.append(Call(make_builtin('indent_io'), [])) + prev_lit_name = elem.name else: - # Insert newline between consecutive non-literal elements - if stmts and field_idx > 0 and is_sexp: - stmts.append(Call(make_builtin('newline_io'), [])) + # For non-optional, non-star elements, emit spacing unconditionally + if not is_optional_or_star: + stmts.extend(leading_ws) + prev_lit_name = None # Extract field from tuple or use directly if non_lit_count > 1 and isinstance(fields_var.type, TupleType): elem_type = fields_var.type.elements[field_idx] elem_var = Var(gensym('field'), elem_type) elem_expr = GetElement(fields_var, field_idx) - pretty_elem = _pretty_print_element(elem, elem_var, grammar, proto_messages) + pretty_elem = _pretty_print_element( + elem, elem_var, grammar, proto_messages, + leading_ws=leading_ws if is_optional_or_star else []) stmts.append(Let(elem_var, elem_expr, pretty_elem)) else: - stmts.append(_pretty_print_element(elem, fields_var, grammar, proto_messages)) + stmts.append(_pretty_print_element( + elem, fields_var, grammar, proto_messages, + leading_ws=leading_ws if is_optional_or_star else [])) field_idx += 1 if not stmts: @@ -313,24 +356,33 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, def _pretty_print_element(elem: Rhs, var: Var, grammar: GrammarLike, - proto_messages: Optional[Dict]) -> TargetExpr: - """Pretty print a single RHS element given its value.""" + proto_messages: Optional[Dict], + leading_ws: Optional[List[TargetExpr]] = None) -> TargetExpr: + """Pretty print a single RHS element given its value. + + Args: + leading_ws: Whitespace expressions to emit before the element, + but only if the element produces output (used for Option/Star). + """ if isinstance(elem, NamedTerminal): formatted = _format_terminal(elem, var) return Call(make_builtin('write_io'), [formatted]) elif isinstance(elem, Nonterminal): return Call(PrintNonterminal(elem), [var]) elif isinstance(elem, Option): - return _generate_pretty_option_from_field(elem, var, grammar, proto_messages) + return _generate_pretty_option_from_field( + elem, var, grammar, proto_messages, leading_ws=leading_ws or []) elif isinstance(elem, Star): - return _generate_pretty_star_from_field(elem, var, grammar, proto_messages) + return _generate_pretty_star_from_field( + elem, var, grammar, proto_messages, leading_ws=leading_ws or []) else: return Call(make_builtin('write_io'), [Lit(f'<{type(elem).__name__}>')]) def _generate_pretty_option_from_field(rhs: Option, field_var: Var, grammar: GrammarLike, - proto_messages: Optional[Dict]) -> TargetExpr: + proto_messages: Optional[Dict], + leading_ws: Optional[List[TargetExpr]] = None) -> TargetExpr: """Generate pretty printing for an optional field.""" has_value = Call(make_builtin('is_some'), [field_var]) @@ -351,16 +403,22 @@ def _generate_pretty_option_from_field(rhs: Option, field_var: Var, else: pretty_inner = Call(make_builtin('write_io'), [Call(make_builtin('to_string'), [value_var])]) + then_body: TargetExpr = Let(value_var, value_expr, pretty_inner) + # Include leading whitespace inside the conditional + if leading_ws: + then_body = Seq(list(leading_ws) + [then_body]) + return IfElse( has_value, - Let(value_var, value_expr, pretty_inner), + then_body, Lit(None) ) def _generate_pretty_star_from_field(rhs: Star, field_var: Var, grammar: GrammarLike, - proto_messages: Optional[Dict]) -> TargetExpr: + proto_messages: Optional[Dict], + leading_ws: Optional[List[TargetExpr]] = None) -> TargetExpr: """Generate pretty printing for a repeated field.""" list_type = field_var.type if isinstance(list_type, ListType): @@ -390,7 +448,17 @@ def _generate_pretty_star_from_field(rhs: Star, field_var: Var, pretty_with_spacing = _optimize_if_else_with_common_tail(pretty_with_spacing) - return ForeachEnumerated(index_var, elem_var, field_var, pretty_with_spacing) + loop_body: TargetExpr = ForeachEnumerated(index_var, elem_var, field_var, pretty_with_spacing) + + # Include leading whitespace inside an is_empty guard + if leading_ws: + loop_body = IfElse( + Call(make_builtin('not'), [Call(make_builtin('is_empty'), [field_var])]), + Seq(list(leading_ws) + [loop_body]), + Lit(None) + ) + + return loop_body def _format_literal(lit: LitTerminal, is_sexp_keyword: bool = False) -> TargetExpr: @@ -402,17 +470,9 @@ def _format_literal(lit: LitTerminal, is_sexp_keyword: bool = False) -> TargetEx if lit.name == '(': return Call(make_builtin('write_io'), [Lit('(')]) elif lit.name == ')': - return Seq([ - Call(make_builtin('dedent_io'), []), - Call(make_builtin('write_io'), [Lit(')')]), - Call(make_builtin('newline_io'), []), - ]) + return Call(make_builtin('write_io'), [Lit(')')]) elif is_sexp_keyword: - return Seq([ - Call(make_builtin('write_io'), [Lit(lit.name)]), - Call(make_builtin('newline_io'), []), - Call(make_builtin('indent_io'), []), - ]) + return Call(make_builtin('write_io'), [Lit(lit.name)]) else: return Call(make_builtin('write_io'), [Lit(lit.name)]) diff --git a/python-tools/src/meta/templates/pretty_printer.py.template b/python-tools/src/meta/templates/pretty_printer.py.template index a4ec6dd2..d24962ef 100644 --- a/python-tools/src/meta/templates/pretty_printer.py.template +++ b/python-tools/src/meta/templates/pretty_printer.py.template @@ -81,7 +81,7 @@ class PrettyPrinter: def format_uint128(self, msg) -> str: """Format a UInt128Value protobuf message as a hex string.""" value = (msg.high << 64) | msg.low - return f"0x{{value:032x}}" + return f"0x{{value:x}}" def fragment_id_to_string(self, msg) -> str: """Convert FragmentId to string representation.""" @@ -95,7 +95,7 @@ class PrettyPrinter: def relation_id_to_string(self, msg): """Convert RelationId to string representation using debug info.""" - return self._debug_info.get((msg.id_low, msg.id_high)) + return self._debug_info.get((msg.id_low, msg.id_high), "") def relation_id_to_int(self, msg): """Convert RelationId to int if it fits in signed 64-bit range.""" @@ -123,4 +123,5 @@ def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io) printer.pretty_{start_name}(msg) + printer.newline() return printer.get_output() diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 15f23d93..be1636d7 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -24,7 +24,7 @@ from .grammar import Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence from .target import ( - TargetType, BaseType, MessageType, EnumType, ListType, OptionType, TupleType, DictType, FunctionType, VarType, + TargetType, BaseType, MessageType, EnumType, ListType, OptionType, TupleType, DictType, FunctionType, TargetExpr, Var, Lit, NamedFun, NewMessage, EnumValue, Call, Lambda, Let, IfElse, Seq, ListExpr, GetElement, GetField, FunDef, OneOf, Assign, Return ) @@ -585,7 +585,8 @@ def parse_action(text: str, rhs: Rhs, ctx: 'TypeContext', line: Optional[int] = def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', - ctx: 'TypeContext', line: Optional[int] = None) -> Lambda: + ctx: 'TypeContext', line: Optional[int] = None, + guard: Optional[str] = None) -> Lambda: """Parse a deconstruct action and return a Lambda. Deconstruct actions assign to $1, $2, ... for each non-literal RHS element, @@ -606,6 +607,7 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', rhs: The RHS of the rule (used for validation) ctx: Type context line: Line number for error messages + guard: Optional guard expression from 'deconstruct if COND:' Returns: Lambda expression with one parameter of lhs_type @@ -615,7 +617,7 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', text = text.strip() # Default identity: deconstruct returns $$ unchanged - if text == '$$': + if text == '$$' and guard is None: msg_param = Var("_dollar_dollar", lhs_type) return Lambda([msg_param], lhs_type, msg_param) @@ -634,19 +636,20 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', except SyntaxError as e: raise YaccGrammarError(f"Syntax error in deconstruct action: {e}", line) - # Extract assert conditions, side-effects, and $N assignments from the AST + # Extract side-effects and $N assignments from the AST # assignments maps 1-indexed $N to the expression AST node assignments: Dict[int, ast.expr] = {} # type_annotations maps 1-indexed $N to the declared TargetType (if any) type_annotations: Dict[int, TargetType] = {} - assert_conditions: List[ast.expr] = [] side_effects: List[ast.expr] = [] extra_vars: Dict[str, TargetType] = {"_dollar_dollar": lhs_type} for stmt in tree.body: if isinstance(stmt, ast.Assert): - assert_conditions.append(stmt.test) - continue + raise YaccGrammarError( + "assert in deconstruct blocks is no longer supported. " + "Use 'deconstruct if COND:' syntax instead.", + line) if isinstance(stmt, ast.Expr): side_effects.append(stmt.value) continue @@ -664,7 +667,7 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', type_annotations[dollar_idx] = _annotation_to_type(stmt.annotation, line or 0) continue raise YaccGrammarError( - f"Deconstruct actions must be assert, side-effect expressions, " + f"Deconstruct actions must be side-effect expressions " f"or $N = expr assignments. Got: {ast.dump(stmt)}", line) @@ -703,43 +706,23 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', expr = _convert_node_with_vars(assignments[idx], param_info, empty_params, ctx, line, extra_vars) converted.append(expr) - # Type-check: inferred expression types must be compatible with declared types - unknown_type = BaseType("Unknown") - for i, idx in enumerate(sorted(assignments.keys())): - if idx in type_annotations: - declared_type = type_annotations[idx] - inferred_type = _infer_type(converted[i], line, ctx) - # Skip check when inferred type is Unknown or a type variable - if inferred_type == unknown_type or isinstance(inferred_type, VarType): - continue - # T <: Optional[T]: non-None means "present" for optional RHS elements - # Optional[T] <: T: None encodes match failure, handled by framework - compatible = (is_subtype(inferred_type, declared_type) - or (isinstance(declared_type, OptionType) - and is_subtype(inferred_type, declared_type.element_type)) - or (isinstance(inferred_type, OptionType) - and is_subtype(inferred_type.element_type, declared_type))) - if not compatible: - raise YaccGrammarError( - f"Type mismatch in deconstruct ${idx}: " - f"declared {declared_type}, but expression has type {inferred_type}", - line) - # Convert side-effect expressions to target IR side_effect_exprs: List[TargetExpr] = [] for se_node in side_effects: se_expr = _convert_node_with_vars(se_node, param_info, empty_params, ctx, line, extra_vars) side_effect_exprs.append(se_expr) - # Build body from assert conditions and assignments - if assert_conditions: - # Convert assert conditions to target IR - conditions: List[TargetExpr] = [] - for cond_node in assert_conditions: - cond_expr = _convert_node_with_vars(cond_node, param_info, empty_params, ctx, line, extra_vars) - conditions.append(cond_expr) + # Build body from guard and assignments + if guard is not None: + # Parse the guard expression + guard_preprocessed = preprocess_action(guard) + try: + guard_tree = ast.parse(guard_preprocessed, mode='eval') + except SyntaxError as e: + raise YaccGrammarError(f"Syntax error in deconstruct guard: {e}", line) + guard_expr = _convert_node_with_vars(guard_tree.body, param_info, empty_params, ctx, line, extra_vars) - # Build guarded body: if all conditions met, return Some(vals); else None + # Build guarded body: if guard met, return Some(vals); else None if len(converted) == 1: success_body: TargetExpr = Call(_make_builtin('some'), [converted[0]]) inner_type = _infer_type(converted[0], line, ctx) @@ -749,24 +732,25 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', element_types = [_infer_type(c, line, ctx) for c in converted] inner_type = TupleType(tuple(element_types)) - # Combine conditions with 'and' - combined_cond = conditions[0] - for c in conditions[1:]: - combined_cond = Call(_make_builtin('and'), [combined_cond, c]) + # Wrap with side-effects if any (before the guard check) + if side_effect_exprs: + success_body = Seq(tuple(side_effect_exprs) + (success_body,)) - body: TargetExpr = IfElse(combined_cond, success_body, Lit(None)) + body: TargetExpr = IfElse(guard_expr, success_body, Lit(None)) return_type: TargetType = OptionType(inner_type) elif len(converted) == 1: body = converted[0] return_type = _infer_type(body, line, ctx) + # Wrap with side-effects if any + if side_effect_exprs: + body = Seq(tuple(side_effect_exprs) + (body,)) else: body = Call(_make_builtin('tuple'), converted) element_types = [_infer_type(c, line, ctx) for c in converted] return_type = TupleType(tuple(element_types)) - - # Wrap with side-effects if any - if side_effect_exprs: - body = Seq(tuple(side_effect_exprs) + (body,)) + # Wrap with side-effects if any + if side_effect_exprs: + body = Seq(tuple(side_effect_exprs) + (body,)) return Lambda([msg_param], return_type, body) diff --git a/python-tools/src/meta/yacc_parser.py b/python-tools/src/meta/yacc_parser.py index 714346e6..b0baf0bb 100644 --- a/python-tools/src/meta/yacc_parser.py +++ b/python-tools/src/meta/yacc_parser.py @@ -381,6 +381,7 @@ def parse_rules(lines: List[str], start_line: int, ctx: TypeContext) -> Tuple[Li current_rhs_lines: List[str] = [] # Accumulate RHS lines current_action_lines: List[str] = [] # Accumulate action lines current_deconstruct_lines: List[str] = [] # Accumulate deconstruct lines + current_deconstruct_guard: Optional[str] = None # Guard expression from 'deconstruct if COND:' current_alt_start_line: int = 0 in_action: bool = False in_deconstruct: bool = False @@ -388,16 +389,17 @@ def parse_rules(lines: List[str], start_line: int, ctx: TypeContext) -> Tuple[Li def flush_alternative(): """Process accumulated alternative.""" - nonlocal current_rhs_lines, current_action_lines, current_deconstruct_lines, in_action, in_deconstruct + nonlocal current_rhs_lines, current_action_lines, current_deconstruct_lines, current_deconstruct_guard, in_action, in_deconstruct if current_rhs_lines and current_lhs is not None and current_lhs_type is not None: rhs_text = '\n'.join(current_rhs_lines) action_text = '\n'.join(current_action_lines) deconstruct_text = '\n'.join(current_deconstruct_lines) - rule = _parse_alternative(current_lhs, current_lhs_type, rhs_text, action_text, deconstruct_text, ctx, current_alt_start_line) + rule = _parse_alternative(current_lhs, current_lhs_type, rhs_text, action_text, deconstruct_text, ctx, current_alt_start_line, deconstruct_guard=current_deconstruct_guard) rules.append(rule) current_rhs_lines = [] current_action_lines = [] current_deconstruct_lines = [] + current_deconstruct_guard = None in_action = False in_deconstruct = False @@ -432,7 +434,7 @@ def flush_alternative(): # If we're in a deconstruct block, check if we should exit if in_deconstruct: - if indent <= action_base_indent and not stripped.startswith('deconstruct:'): + if indent <= action_base_indent and not stripped.startswith('deconstruct'): in_deconstruct = False # Don't consume this line, process it below else: @@ -488,15 +490,29 @@ def flush_alternative(): in_action = True current_action_lines = [] - elif stripped.startswith('deconstruct:'): - # Start of deconstruct action + elif stripped.startswith('deconstruct'): + # Start of deconstruct action: "deconstruct:" or "deconstruct if COND:" action_base_indent = indent - rest = stripped[len('deconstruct:'):].strip() - if rest: - current_deconstruct_lines = [rest] - else: + deconstruct_rest = stripped[len('deconstruct'):].strip() + if deconstruct_rest.startswith('if '): + # Guard syntax: "deconstruct if COND:" + if not deconstruct_rest.endswith(':'): + raise YaccGrammarError("deconstruct guard must end with ':'", line_num) + guard_text = deconstruct_rest[3:-1].strip() # between 'if ' and ':' + current_deconstruct_guard = guard_text in_deconstruct = True current_deconstruct_lines = [] + elif deconstruct_rest.startswith(':'): + # Standard syntax: "deconstruct:" or "deconstruct: expr" + rest = deconstruct_rest[1:].strip() + current_deconstruct_guard = None + if rest: + current_deconstruct_lines = [rest] + else: + in_deconstruct = True + current_deconstruct_lines = [] + else: + raise YaccGrammarError(f"Invalid deconstruct syntax: {stripped}", line_num) elif line and line[0].isspace() and current_rhs_lines: # Continuation of RHS (indented line, not yet in action) @@ -529,7 +545,8 @@ def _find_non_literal_indices(rhs: Rhs) -> List[int]: def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, action_text: str, deconstruct_text: str, - ctx: TypeContext, line: int) -> Rule: + ctx: TypeContext, line: int, + deconstruct_guard: Optional[str] = None) -> Rule: """Parse a single rule alternative. Args: @@ -540,6 +557,7 @@ def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, deconstruct_text: The deconstruct action text (from deconstruct: block) ctx: Type context line: Line number for error messages + deconstruct_guard: Optional guard expression from 'deconstruct if COND:' """ from .yacc_action_parser import parse_deconstruct_action @@ -569,7 +587,9 @@ def _parse_alternative(lhs_name: str, lhs_type: TargetType, rhs_text: str, # Parse deconstruct action: explicit if provided, otherwise default to identity ($$) if deconstruct_text: - deconstructor = parse_deconstruct_action(deconstruct_text, lhs_type, rhs, ctx, line) + deconstructor = parse_deconstruct_action(deconstruct_text, lhs_type, rhs, ctx, line, guard=deconstruct_guard) + elif deconstruct_guard: + deconstructor = parse_deconstruct_action("$$", lhs_type, rhs, ctx, line, guard=deconstruct_guard) else: deconstructor = parse_deconstruct_action("$$", lhs_type, rhs, ctx, line) From 8afea9ab2ed6eb2ea20ebd6ed6cb223f09745e1f Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 13:50:36 +0100 Subject: [PATCH 05/25] Cleanups --- python-tools/src/lqp/cli.py | 7 +- python-tools/src/meta/cli.py | 16 ++-- python-tools/src/meta/codegen_julia.py | 120 ++++++++++++------------ python-tools/src/meta/codegen_python.py | 98 +++++++------------ python-tools/src/meta/grammar.y | 2 +- python-tools/src/meta/pretty_gen.py | 25 +---- 6 files changed, 113 insertions(+), 155 deletions(-) diff --git a/python-tools/src/lqp/cli.py b/python-tools/src/lqp/cli.py index c25efba1..dc96d8a1 100644 --- a/python-tools/src/lqp/cli.py +++ b/python-tools/src/lqp/cli.py @@ -181,8 +181,8 @@ def main(): sys.stdout.write(pretty_print_proto(lqp_proto)) return - assert filename.endswith(".lqp"), \ - f"The input {filename} does not seem to be an LQP or bin file" + if not filename.endswith(".lqp"): + arg_parser.error(f"The input {filename} does not seem to be an LQP or bin file") if args.pretty: lqp_proto = parse_lqp_to_proto(filename, use_generated, validate) @@ -190,7 +190,8 @@ def main(): return if args.out: - assert not (args.bin and args.json), "Cannot specify both --bin and --json with --out option" + if args.bin and args.json: + arg_parser.error("Cannot specify both --bin and --json with --out option") basename = os.path.splitext(filename)[0] diff --git a/python-tools/src/meta/cli.py b/python-tools/src/meta/cli.py index c976789b..413b5069 100644 --- a/python-tools/src/meta/cli.py +++ b/python-tools/src/meta/cli.py @@ -140,6 +140,14 @@ def run(args) -> int: # Transform messages dict from {name: ProtoMessage} to {(module, name): ProtoMessage} proto_messages = {(msg.module, name): msg for name, msg in proto_parser.messages.items()} + def make_command_line(*extra_args): + """Build a reproducible command line using basenames to avoid embedding absolute paths.""" + parts = ["python -m meta.cli"] + parts += [f.name for f in args.proto_files] + parts += ["--grammar", args.grammar.name] + parts += list(extra_args) + return " ".join(parts) + # Load grammar rules from file (yacc format) grammar_config = load_yacc_grammar_file(grammar_path, proto_messages, proto_parser.enums) @@ -233,13 +241,7 @@ def run(args) -> int: output_text = "\n".join(output_lines) write_output(output_text, args.output, f"Generated printer IR written to {args.output}") elif args.printer == "python": - proto_messages = {(msg.module, name): msg for name, msg in proto_parser.messages.items()} - command_line = " ".join( - ["python -m meta.cli"] - + [str(f) for f in args.proto_files] - + ["--grammar", str(args.grammar)] - + ["--printer", args.printer] - ) + command_line = make_command_line("--printer", args.printer) from .pretty_gen_python import generate_pretty_printer_python output_text = generate_pretty_printer_python(grammar, command_line, proto_messages) write_output(output_text, args.output, f"Generated pretty printer written to {args.output}") diff --git a/python-tools/src/meta/codegen_julia.py b/python-tools/src/meta/codegen_julia.py index 77ec33c7..64fb4ab4 100644 --- a/python-tools/src/meta/codegen_julia.py +++ b/python-tools/src/meta/codegen_julia.py @@ -243,6 +243,28 @@ def gen_func_def_header(self, name: str, params: List[Tuple[str, str]], def gen_func_def_end(self) -> str: return "end" + def _generate_foreach_enumerated(self, expr, lines: List[str], indent: str) -> str: + """Override to adjust for Julia's 1-based enumerate. + + The IR generates guards like `index > 0` assuming 0-based indexing. + Julia's `enumerate` returns 1-based indices, so we use a raw index + variable and assign the 0-based version at the top of the loop body. + """ + from .target import ForeachEnumerated + assert isinstance(expr, ForeachEnumerated) + collection_code = self.generate_lines(expr.collection, lines, indent) + assert collection_code is not None + index_name = self.escape_identifier(expr.index_var.name) + var_name = self.escape_identifier(expr.var.name) + + raw_index = gensym('i') + lines.append(f"{indent}for ({raw_index}, {var_name}) in enumerate({collection_code})") + body_indent = indent + self.indent_str + lines.append(f"{body_indent}{index_name} = {raw_index} - 1") + self.generate_lines(expr.body, lines, body_indent) + lines.append(f"{indent}end") + return self.gen_none() + def _generate_get_element(self, expr: GetElement, lines: List[str], indent: str) -> str: """Julia uses 1-based indexing.""" tuple_code = self.generate_lines(expr.tuple_expr, lines, indent) @@ -377,7 +399,7 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ lines.append(f"{indent}{self.gen_assignment(tmp, f'OneOf({field_symbol}, {field_value})', is_declaration=True)}") return tmp - # Check for parse/print nonterminal or NamedFun calls - need to add parser as first argument + # Check for parse/print nonterminal or NamedFun calls - need to add receiver as first argument if isinstance(expr.func, (ParseNonterminal, PrintNonterminal, NamedFun)): f = self.generate_lines(expr.func, lines, indent) args: List[str] = [] @@ -385,8 +407,9 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ arg_code = self.generate_lines(arg, lines, indent) assert arg_code is not None, "Function argument should not contain a return" args.append(arg_code) - # Prepend parser as first argument - all_args = ["parser"] + args + # PrintNonterminal uses "pp" (PrettyPrinter), others use "parser" + receiver = "pp" if isinstance(expr.func, PrintNonterminal) else "parser" + all_args = [receiver] + args args_code = ', '.join(all_args) if self._is_void_expr(expr): lines.append(f"{indent}{f}({args_code})") @@ -406,56 +429,51 @@ def _generate_oneof(self, expr: OneOf, lines: List[str], indent: str) -> str: """ raise ValueError(f"OneOf should only appear in Call(OneOf(...), [value]) pattern: {expr}") - def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: - """Generate a parse method definition.""" - func_name = f"parse_{expr.nonterminal.name}" - - params = ["parser::Parser"] - for param in expr.params: + def _generate_julia_function(self, func_name: str, first_param: str, params, body, + return_type, indent: str) -> str: + """Generate a Julia function definition with a typed first parameter. + + Args: + func_name: The function name. + first_param: The first parameter string (e.g. "parser::Parser"). + params: List of Param objects (each with .name and .type). + body: The function body expression, or None for an empty body. + return_type: The return type, or None. + indent: Indentation prefix. + """ + typed_params = [first_param] + for param in params: escaped_name = self.escape_identifier(param.name) type_hint = self.gen_type(param.type) - params.append(f"{escaped_name}::{type_hint}") - - params_str = ', '.join(params) + typed_params.append(f"{escaped_name}::{type_hint}") - ret_hint = f"::{self.gen_type(expr.return_type)}" if expr.return_type else "" + params_str = ', '.join(typed_params) + ret_hint = f"::{self.gen_type(return_type)}" if return_type else "" - if expr.body is None: - body_code = f"{indent} nothing" + if body is None: + body_code = f"{indent}{self.indent_str}{self.gen_empty_body()}" else: body_lines: List[str] = [] - body_inner = self.generate_lines(expr.body, body_lines, indent + " ") - # Only add return if the body didn't already return + body_inner = self.generate_lines(body, body_lines, indent + self.indent_str) if body_inner is not None: - body_lines.append(f"{indent} return {body_inner}") + body_lines.append(f"{indent}{self.indent_str}{self.gen_return(body_inner)}") body_code = "\n".join(body_lines) return f"{indent}function {func_name}({params_str}){ret_hint}\n{body_code}\n{indent}end" + def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: + """Generate a parse method definition.""" + return self._generate_julia_function( + f"parse_{expr.nonterminal.name}", "parser::Parser", + expr.params, expr.body, expr.return_type, indent + ) + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: """Generate a pretty-print function definition.""" - func_name = f"pretty_{expr.nonterminal.name}" - - params = ["pp::PrettyPrinter"] - for param in expr.params: - escaped_name = self.escape_identifier(param.name) - type_hint = self.gen_type(param.type) - params.append(f"{escaped_name}::{type_hint}") - - params_str = ', '.join(params) - - ret_hint = f"::{self.gen_type(expr.return_type)}" if expr.return_type else "" - - if expr.body is None: - body_code = f"{indent} nothing" - else: - body_lines: List[str] = [] - body_inner = self.generate_lines(expr.body, body_lines, indent + " ") - if body_inner is not None: - body_lines.append(f"{indent} return {body_inner}") - body_code = "\n".join(body_lines) - - return f"{indent}function {func_name}({params_str}){ret_hint}\n{body_code}\n{indent}end" + return self._generate_julia_function( + f"pretty_{expr.nonterminal.name}", "pp::PrettyPrinter", + expr.params, expr.body, expr.return_type, indent + ) def format_literal_token_spec(self, escaped_literal: str) -> str: return f' ("LITERAL", r"{escaped_literal}", identity),' @@ -469,24 +487,10 @@ def format_command_line_comment(self, command_line: str) -> str: def generate_method_def(self, expr: FunDef, indent: str) -> str: """Generate a function definition with parser as first parameter.""" - func_name = self.escape_identifier(expr.name) - params = [(self.escape_identifier(p.name), self.gen_type(p.type)) for p in expr.params] - params = [("parser", "Parser")] + params - ret_type = self.gen_type(expr.return_type) if expr.return_type else None - - header = self.gen_func_def_header(func_name, params, ret_type) - - if expr.body is None: - body_code = f"{indent}{self.indent_str}{self.gen_empty_body()}" - else: - lines: List[str] = [] - body_inner = self.generate_lines(expr.body, lines, indent + self.indent_str) - if body_inner is not None: - lines.append(f"{indent}{self.indent_str}{self.gen_return(body_inner)}") - body_code = "\n".join(lines) - - end = self.gen_func_def_end() - return f"{indent}{header}\n{body_code}\n{indent}{end}" + return self._generate_julia_function( + self.escape_identifier(expr.name), "parser::Parser", + expr.params, expr.body, expr.return_type, indent + ) def escape_identifier(name: str) -> str: """Escape a Julia identifier if it's a keyword.""" diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index 396f8509..d49a2eb9 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -68,16 +68,8 @@ def escape_keyword(self, name: str) -> str: # --- Field access --- - _PYTHON_KEYWORDS = frozenset({ - 'False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', - 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', - 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', - 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', - 'try', 'while', 'with', 'yield', - }) - def gen_field_access(self, obj_code: str, field_name: str) -> str: - if field_name in self._PYTHON_KEYWORDS: + if field_name in PYTHON_KEYWORDS: return f"getattr({obj_code}, {field_name!r})" return f"{obj_code}.{field_name}" @@ -295,54 +287,50 @@ def _build_message_field_map(self) -> dict: self._message_field_map = field_map return field_map - def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: - """Generate a parse method definition.""" - func_name = f"parse_{expr.nonterminal.name}" + def _generate_self_method(self, func_name: str, params, body, return_type, indent: str) -> str: + """Generate a method definition with `self` as first parameter. - params = [] - for param in expr.params: + Args: + func_name: The method name. + params: List of Param objects (each with .name and .type). + body: The method body expression, or None for an empty body. + return_type: The return type, or None. + indent: Indentation prefix. + """ + typed_params = [] + for param in params: escaped_name = self.escape_identifier(param.name) type_hint = self.gen_type(param.type) - params.append(f"{escaped_name}: {type_hint}") + typed_params.append(f"{escaped_name}: {type_hint}") - params_str = ', '.join(params) if params else '' + params_str = ', '.join(typed_params) if typed_params else '' if params_str: params_str = ', ' + params_str - ret_hint = f" -> {self.gen_type(expr.return_type)}" if expr.return_type else "" + ret_hint = f" -> {self.gen_type(return_type)}" if return_type else "" body_lines: List[str] = [] - body_inner = self.generate_lines(expr.body, body_lines, indent + " ") - # Only add return if the body didn't already return - if body_inner is not None: - body_lines.append(f"{indent} return {body_inner}") + if body is None: + body_lines.append(f"{indent} pass") + else: + body_inner = self.generate_lines(body, body_lines, indent + " ") + if body_inner is not None: + body_lines.append(f"{indent} return {body_inner}") body_code = "\n".join(body_lines) return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" + def _generate_parse_def(self, expr: ParseNonterminalDef, indent: str) -> str: + """Generate a parse method definition.""" + return self._generate_self_method( + f"parse_{expr.nonterminal.name}", expr.params, expr.body, expr.return_type, indent + ) + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: """Generate a pretty-print method definition.""" - func_name = f"pretty_{expr.nonterminal.name}" - - params = [] - for param in expr.params: - escaped_name = self.escape_identifier(param.name) - type_hint = self.gen_type(param.type) - params.append(f"{escaped_name}: {type_hint}") - - params_str = ', '.join(params) if params else '' - if params_str: - params_str = ', ' + params_str - - ret_hint = f" -> {self.gen_type(expr.return_type)}" if expr.return_type else "" - - body_lines: List[str] = [] - body_inner = self.generate_lines(expr.body, body_lines, indent + " ") - if body_inner is not None: - body_lines.append(f"{indent} return {body_inner}") - body_code = "\n".join(body_lines) - - return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" + return self._generate_self_method( + f"pretty_{expr.nonterminal.name}", expr.params, expr.body, expr.return_type, indent + ) # Parser generation settings parse_def_indent = " " @@ -358,29 +346,9 @@ def format_command_line_comment(self, command_line: str) -> str: def generate_method_def(self, expr: FunDef, indent: str) -> str: """Generate a function definition as an instance method.""" - func_name = self.escape_identifier(expr.name) - params = [] - for p in expr.params: - escaped_name = self.escape_identifier(p.name) - type_hint = self.gen_type(p.type) - params.append(f"{escaped_name}: {type_hint}") - - params_str = ', '.join(params) if params else '' - if params_str: - params_str = ', ' + params_str - - ret_hint = f" -> {self.gen_type(expr.return_type)}" if expr.return_type else "" - - body_lines: List[str] = [] - if expr.body is None: - body_lines.append(f"{indent} pass") - else: - body_inner = self.generate_lines(expr.body, body_lines, indent + " ") - if body_inner is not None: - body_lines.append(f"{indent} return {body_inner}") - body_code = "\n".join(body_lines) - - return f"{indent}def {func_name}(self{params_str}){ret_hint}:\n{body_code}" + return self._generate_self_method( + self.escape_identifier(expr.name), expr.params, expr.body, expr.return_type, indent + ) def escape_identifier(name: str) -> str: diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 097c31cf..c9bc8bfd 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -259,7 +259,7 @@ datetime $6: Int64 = builtin.int32_to_int64($$.hour) $7: Int64 = builtin.int32_to_int64($$.minute) $8: Int64 = builtin.int32_to_int64($$.second) - $9: Optional[Int64] = builtin.int32_to_int64($$.microsecond) + $9: Optional[Int64] = builtin.int32_to_int64($$.microsecond) if $$.microsecond != 0 else None boolean_value : "true" diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index 2a6fc7e1..5bbac2d6 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -321,7 +321,7 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, # For sexp closing paren, emit dedent if we indented if is_sexp and elem.name == ')' and non_lit_count > 0: stmts.append(Call(make_builtin('dedent_io'), [])) - stmts.append(_format_literal(elem, is_sexp_keyword=is_keyword)) + stmts.append(_format_literal(elem)) # After sexp keyword, emit indent (always, not conditional on Option) if is_keyword and non_lit_count > 0: stmts.append(Call(make_builtin('indent_io'), [])) @@ -461,20 +461,9 @@ def _generate_pretty_star_from_field(rhs: Star, field_var: Var, return loop_body -def _format_literal(lit: LitTerminal, is_sexp_keyword: bool = False) -> TargetExpr: - """Format a literal terminal for output. - - is_sexp_keyword: True if this literal is the keyword in an S-expression - (i.e., appears at position 1 in a "(keyword ...)" sequence). - """ - if lit.name == '(': - return Call(make_builtin('write_io'), [Lit('(')]) - elif lit.name == ')': - return Call(make_builtin('write_io'), [Lit(')')]) - elif is_sexp_keyword: - return Call(make_builtin('write_io'), [Lit(lit.name)]) - else: - return Call(make_builtin('write_io'), [Lit(lit.name)]) +def _format_literal(lit: LitTerminal) -> TargetExpr: + """Format a literal terminal for output.""" + return Call(make_builtin('write_io'), [Lit(lit.name)]) def _format_terminal(terminal: NamedTerminal, value_var: Var) -> TargetExpr: @@ -515,12 +504,6 @@ def _is_trivial_deconstruct(deconstructor: Lambda) -> bool: def _extract_trivial_deconstruct_result(deconstructor: Lambda, msg_param: Var) -> TargetExpr: """Extract the result expression from a trivial deconstructor.""" - body = deconstructor.body - if isinstance(body, Var) and body.name == 'msg': - return msg_param - if (isinstance(body, Call) and isinstance(body.func, Builtin) and - body.func.name == 'some' and len(body.args) == 1): - return msg_param return msg_param From 21a3e074f99f863f5f0c004aacf4e807f1aa264c Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 14:07:31 +0100 Subject: [PATCH 06/25] Compile fixes --- Makefile | 17 +- go/src/parser.go | 509 ++- julia/LQPParser/src/parser.jl | 541 +++- .../src/relationalai/lqp/v1/fragments_pb.jl | 4 +- .../src/relationalai/lqp/v1/logic_pb.jl | 4 +- .../relationalai/lqp/v1/transactions_pb.jl | 4 +- python-tools/src/lqp/generated_parser.py | 553 +++- .../src/lqp/generated_pretty_printer.py | 2779 +++++++++-------- python-tools/src/meta/codegen_go.py | 48 +- 9 files changed, 2680 insertions(+), 1779 deletions(-) diff --git a/Makefile b/Makefile index 5f79e253..c14cb2be 100644 --- a/Makefile +++ b/Makefile @@ -116,14 +116,25 @@ force-parser-go: protobuf printers: printer-python printer-julia printer-go -printer-python: $(PY_PRINTER) +printer-python: protobuf $(PY_PRINTER) $(PY_PRINTER): $(PROTO_FILES) $(GRAMMAR) $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/generated_pretty_printer.py -printer-julia: +printer-julia: protobuf @echo "Pretty printer generation for Julia is not yet implemented." -printer-go: +printer-go: protobuf + @echo "Pretty printer generation for Go is not yet implemented." + +force-printers: force-printer-python force-printer-julia force-printer-go + +force-printer-python: protobuf + $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/generated_pretty_printer.py + +force-printer-julia: protobuf + @echo "Pretty printer generation for Julia is not yet implemented." + +force-printer-go: protobuf @echo "Pretty printer generation for Go is not yet implemented." # ---------- testing ---------- diff --git a/go/src/parser.go b/go/src/parser.go index 71ede2b0..6530a698 100644 --- a/go/src/parser.go +++ b/go/src/parser.go @@ -700,68 +700,68 @@ func (p *Parser) _try_extract_value_string_list(value *pb.Value) []string { func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig { config := dictFromList(config_dict) - _t957 := p._extract_value_int64(dictGetValue(config, "csv_header_row"), 1) - header_row := _t957 - _t958 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) - skip := _t958 - _t959 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") - new_line := _t959 - _t960 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") - delimiter := _t960 - _t961 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") - quotechar := _t961 - _t962 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") - escapechar := _t962 - _t963 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") - comment := _t963 - _t964 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) - missing_strings := _t964 - _t965 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") - decimal_separator := _t965 - _t966 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") - encoding := _t966 - _t967 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") - compression := _t967 - _t968 := &pb.CSVConfig{HeaderRow: int32(header_row), Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} - return _t968 + _t956 := p._extract_value_int64(dictGetValue(config, "csv_header_row"), 1) + header_row := _t956 + _t957 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) + skip := _t957 + _t958 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") + new_line := _t958 + _t959 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") + delimiter := _t959 + _t960 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") + quotechar := _t960 + _t961 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") + escapechar := _t961 + _t962 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") + comment := _t962 + _t963 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) + missing_strings := _t963 + _t964 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") + decimal_separator := _t964 + _t965 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") + encoding := _t965 + _t966 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") + compression := _t966 + _t967 := &pb.CSVConfig{HeaderRow: int32(header_row), Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} + return _t967 } func (p *Parser) construct_betree_info(key_types []*pb.Type, value_types []*pb.Type, config_dict [][]interface{}) *pb.BeTreeInfo { config := dictFromList(config_dict) - _t969 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) - epsilon := _t969 - _t970 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) - max_pivots := _t970 - _t971 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) - max_deltas := _t971 - _t972 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) - max_leaf := _t972 - _t973 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} - storage_config := _t973 - _t974 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) - root_pageid := _t974 - _t975 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) - inline_data := _t975 - _t976 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) - element_count := _t976 - _t977 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) - tree_height := _t977 - _t978 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} + _t968 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) + epsilon := _t968 + _t969 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) + max_pivots := _t969 + _t970 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) + max_deltas := _t970 + _t971 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) + max_leaf := _t971 + _t972 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} + storage_config := _t972 + _t973 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) + root_pageid := _t973 + _t974 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) + inline_data := _t974 + _t975 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) + element_count := _t975 + _t976 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) + tree_height := _t976 + _t977 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} if root_pageid != nil { - _t978.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} + _t977.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} } else { - _t978.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} + _t977.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} } - relation_locator := _t978 - _t979 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} - return _t979 + relation_locator := _t977 + _t978 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} + return _t978 } func (p *Parser) default_configure() *pb.Configure { - _t980 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} - ivm_config := _t980 - _t981 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} - return _t981 + _t979 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} + ivm_config := _t979 + _t980 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} + return _t980 } func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure { @@ -783,34 +783,317 @@ func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure } } } - _t982 := &pb.IVMConfig{Level: maintenance_level} - ivm_config := _t982 - _t983 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) - semantics_version := _t983 - _t984 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} - return _t984 + _t981 := &pb.IVMConfig{Level: maintenance_level} + ivm_config := _t981 + _t982 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) + semantics_version := _t982 + _t983 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} + return _t983 } func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, config_dict [][]interface{}) *pb.ExportCSVConfig { config := dictFromList(config_dict) - _t985 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) - partition_size := _t985 - _t986 := p._extract_value_string(dictGetValue(config, "compression"), "") - compression := _t986 - _t987 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) - syntax_header_row := _t987 - _t988 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") - syntax_missing_string := _t988 - _t989 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") - syntax_delim := _t989 - _t990 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") - syntax_quotechar := _t990 - _t991 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") - syntax_escapechar := _t991 - _t992 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptrInt64(partition_size), Compression: ptrString(compression), SyntaxHeaderRow: ptrBool(syntax_header_row), SyntaxMissingString: ptrString(syntax_missing_string), SyntaxDelim: ptrString(syntax_delim), SyntaxQuotechar: ptrString(syntax_quotechar), SyntaxEscapechar: ptrString(syntax_escapechar)} + _t984 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) + partition_size := _t984 + _t985 := p._extract_value_string(dictGetValue(config, "compression"), "") + compression := _t985 + _t986 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) + syntax_header_row := _t986 + _t987 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") + syntax_missing_string := _t987 + _t988 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") + syntax_delim := _t988 + _t989 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") + syntax_quotechar := _t989 + _t990 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") + syntax_escapechar := _t990 + _t991 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptrInt64(partition_size), Compression: ptrString(compression), SyntaxHeaderRow: ptrBool(syntax_header_row), SyntaxMissingString: ptrString(syntax_missing_string), SyntaxDelim: ptrString(syntax_delim), SyntaxQuotechar: ptrString(syntax_quotechar), SyntaxEscapechar: ptrString(syntax_escapechar)} + return _t991 +} + +func (p *Parser) _make_value_int64(v int64) *pb.Value { + _t992 := &pb.Value{} + _t992.Value = &pb.Value_IntValue{IntValue: v} return _t992 } +func (p *Parser) _make_value_float64(v float64) *pb.Value { + _t993 := &pb.Value{} + _t993.Value = &pb.Value_FloatValue{FloatValue: v} + return _t993 +} + +func (p *Parser) _make_value_string(v string) *pb.Value { + _t994 := &pb.Value{} + _t994.Value = &pb.Value_StringValue{StringValue: v} + return _t994 +} + +func (p *Parser) _make_value_boolean(v bool) *pb.Value { + _t995 := &pb.Value{} + _t995.Value = &pb.Value_BooleanValue{BooleanValue: v} + return _t995 +} + +func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { + _t996 := &pb.Value{} + _t996.Value = &pb.Value_Uint128Value{Uint128Value: v} + return _t996 +} + +func (p *Parser) is_default_configure(cfg *pb.Configure) bool { + if cfg.GetSemanticsVersion() != 0 { + return false + } + if cfg.ivm_config.GetLevel() != pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { + return false + } + return true +} + +func (p *Parser) deconstruct_configure(msg *pb.Configure) [][]interface{} { + result := [][]interface{}{} + var _t997 interface{} + if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_AUTO { + _t998 := p._make_value_string("auto") + result = append(result, []interface{}{"ivm.maintenance_level", _t998}) + _t997 = nil + } else { + var _t999 interface{} + if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_ALL { + _t1000 := p._make_value_string("all") + result = append(result, []interface{}{"ivm.maintenance_level", _t1000}) + _t999 = nil + } else { + var _t1001 interface{} + if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { + _t1002 := p._make_value_string("off") + result = append(result, []interface{}{"ivm.maintenance_level", _t1002}) + _t1001 = nil + } + _t999 = _t1001 + } + _t997 = _t999 + } + _t1003 := p._make_value_int64(msg.GetSemanticsVersion()) + result = append(result, []interface{}{"semantics_version", _t1003}) + return result +} + +func (p *Parser) deconstruct_csv_config(msg *pb.CSVConfig) [][]interface{} { + result := [][]interface{}{} + var _t1004 interface{} + if msg.GetHeaderRow() != 1 { + _t1005 := p.int32_to_int64(msg.GetHeaderRow()) + _t1006 := p._make_value_int64(_t1005) + result = append(result, []interface{}{"csv_header_row", _t1006}) + _t1004 = nil + } + var _t1007 interface{} + if msg.GetSkip() != 0 { + _t1008 := p._make_value_int64(msg.GetSkip()) + result = append(result, []interface{}{"csv_skip", _t1008}) + _t1007 = nil + } + var _t1009 interface{} + if msg.GetNewLine() != "" { + _t1010 := p._make_value_string(msg.GetNewLine()) + result = append(result, []interface{}{"csv_new_line", _t1010}) + _t1009 = nil + } + var _t1011 interface{} + if msg.GetDelimiter() != "," { + _t1012 := p._make_value_string(msg.GetDelimiter()) + result = append(result, []interface{}{"csv_delimiter", _t1012}) + _t1011 = nil + } + var _t1013 interface{} + if msg.GetQuotechar() != "\"" { + _t1014 := p._make_value_string(msg.GetQuotechar()) + result = append(result, []interface{}{"csv_quotechar", _t1014}) + _t1013 = nil + } + var _t1015 interface{} + if msg.GetEscapechar() != "\"" { + _t1016 := p._make_value_string(msg.GetEscapechar()) + result = append(result, []interface{}{"csv_escapechar", _t1016}) + _t1015 = nil + } + var _t1017 interface{} + if msg.GetComment() != "" { + _t1018 := p._make_value_string(msg.GetComment()) + result = append(result, []interface{}{"csv_comment", _t1018}) + _t1017 = nil + } + _t1019 := p.is_empty(msg.GetMissingStrings()) + var _t1020 interface{} + if !_t1019 { + _t1021 := p._make_value_string(msg.GetMissingStrings()[0].(string)) + result = append(result, []interface{}{"csv_missing_strings", _t1021}) + _t1020 = nil + } + var _t1022 interface{} + if msg.GetDecimalSeparator() != "." { + _t1023 := p._make_value_string(msg.GetDecimalSeparator()) + result = append(result, []interface{}{"csv_decimal_separator", _t1023}) + _t1022 = nil + } + var _t1024 interface{} + if msg.GetEncoding() != "utf-8" { + _t1025 := p._make_value_string(msg.GetEncoding()) + result = append(result, []interface{}{"csv_encoding", _t1025}) + _t1024 = nil + } + var _t1026 interface{} + if msg.GetCompression() != "auto" { + _t1027 := p._make_value_string(msg.GetCompression()) + result = append(result, []interface{}{"csv_compression", _t1027}) + _t1026 = nil + } + return result +} + +func (p *Parser) _maybe_push_float64(result [][]interface{}, key string, val *float64) interface{} { + var _t1028 interface{} + if val != nil { + _t1029 := p._make_value_float64(*val) + result = append(result, []interface{}{key, _t1029}) + _t1028 = nil + } + return nil +} + +func (p *Parser) _maybe_push_int64(result [][]interface{}, key string, val *int64) interface{} { + var _t1030 interface{} + if val != nil { + _t1031 := p._make_value_int64(*val) + result = append(result, []interface{}{key, _t1031}) + _t1030 = nil + } + return nil +} + +func (p *Parser) _maybe_push_uint128(result [][]interface{}, key string, val *pb.UInt128Value) interface{} { + var _t1032 interface{} + if val != nil { + _t1033 := p._make_value_uint128(val) + result = append(result, []interface{}{key, _t1033}) + _t1032 = nil + } + return nil +} + +func (p *Parser) _maybe_push_bytes_as_string(result [][]interface{}, key string, val []byte) interface{} { + var _t1034 interface{} + if val != nil { + _t1035 := p.decode_string(val) + _t1036 := p._make_value_string(_t1035) + result = append(result, []interface{}{key, _t1036}) + _t1034 = nil + } + return nil +} + +func (p *Parser) deconstruct_betree_info_config(msg *pb.BeTreeInfo) [][]interface{} { + result := [][]interface{}{} + _t1037 := p._maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.GetEpsilon()) + _t1038 := p._maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.GetMaxPivots()) + _t1039 := p._maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.GetMaxDeltas()) + _t1040 := p._maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.GetMaxLeaf()) + var _t1041 interface{} + if hasProtoField(msg.GetRelationLocator(), "root_pageid") { + _t1042 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.GetRootPageid()) + _t1041 = _t1042 + } + var _t1043 interface{} + if hasProtoField(msg.GetRelationLocator(), "inline_data") { + _t1044 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.GetInlineData()) + _t1043 = _t1044 + } + _t1045 := p._maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.GetElementCount()) + _t1046 := p._maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.GetTreeHeight()) + return result +} + +func (p *Parser) deconstruct_export_csv_config(msg *pb.ExportCSVConfig) [][]interface{} { + result := [][]interface{}{} + var _t1047 interface{} + if (msg.GetPartitionSize() != nil && *msg.GetPartitionSize() != 0) { + _t1048 := p._make_value_int64(*msg.GetPartitionSize()) + result = append(result, []interface{}{"partition_size", _t1048}) + _t1047 = nil + } + var _t1049 interface{} + if (msg.GetCompression() != nil && *msg.GetCompression() != "") { + _t1050 := p._make_value_string(*msg.GetCompression()) + result = append(result, []interface{}{"compression", _t1050}) + _t1049 = nil + } + var _t1051 interface{} + if msg.GetSyntaxHeaderRow() != nil { + _t1052 := p._make_value_boolean(*msg.GetSyntaxHeaderRow()) + result = append(result, []interface{}{"syntax_header_row", _t1052}) + _t1051 = nil + } + var _t1053 interface{} + if (msg.GetSyntaxMissingString() != nil && *msg.GetSyntaxMissingString() != "") { + _t1054 := p._make_value_string(*msg.GetSyntaxMissingString()) + result = append(result, []interface{}{"syntax_missing_string", _t1054}) + _t1053 = nil + } + var _t1055 interface{} + if (msg.GetSyntaxDelim() != nil && *msg.GetSyntaxDelim() != ",") { + _t1056 := p._make_value_string(*msg.GetSyntaxDelim()) + result = append(result, []interface{}{"syntax_delim", _t1056}) + _t1055 = nil + } + var _t1057 interface{} + if (msg.GetSyntaxQuotechar() != nil && *msg.GetSyntaxQuotechar() != "\"") { + _t1058 := p._make_value_string(*msg.GetSyntaxQuotechar()) + result = append(result, []interface{}{"syntax_quotechar", _t1058}) + _t1057 = nil + } + var _t1059 interface{} + if (msg.GetSyntaxEscapechar() != nil && *msg.GetSyntaxEscapechar() != "\\") { + _t1060 := p._make_value_string(*msg.GetSyntaxEscapechar()) + result = append(result, []interface{}{"syntax_escapechar", _t1060}) + _t1059 = nil + } + return result +} + +func (p *Parser) deconstruct_relation_id_string(msg *pb.RelationId) *string { + _t1061 := p.relation_id_to_string(msg) + name := _t1061 + if name != "" { + return ptr(name) + } + return nil +} + +func (p *Parser) deconstruct_relation_id_uint128(msg *pb.RelationId) *pb.UInt128Value { + _t1062 := p.relation_id_to_string(msg) + name := _t1062 + if name == "" { + _t1063 := p.relation_id_to_uint128(msg) + return _t1063 + } + return nil +} + +func (p *Parser) deconstruct_bindings(abs *pb.Abstraction) []interface{} { + return []interface{}{abs.GetVars(), []*pb.Binding{}} +} + +func (p *Parser) deconstruct_bindings_with_arity(abs *pb.Abstraction, value_arity int64) []interface{} { + n := int64(len(abs.GetVars())) + _t1064 := p.subtract(n, value_arity) + key_end := _t1064 + _t1065 := p.list_slice(abs.GetVars(), 0, key_end) + _t1066 := p.list_slice(abs.GetVars(), key_end, n) + return []interface{}{_t1065, _t1066} +} + // --- Parse functions --- func (p *Parser) parse_transaction() *pb.Transaction { @@ -3708,70 +3991,66 @@ func (p *Parser) parse_demand() *pb.Demand { func (p *Parser) parse_output() *pb.Output { p.consumeLiteral("(") p.consumeLiteral("output") - var _t937 *string - if (p.matchLookaheadLiteral(":", 0) && p.matchLookaheadTerminal("SYMBOL", 1)) { - _t938 := p.parse_name() - _t937 = ptr(_t938) - } + _t937 := p.parse_name() name336 := _t937 - _t939 := p.parse_relation_id() - relation_id337 := _t939 + _t938 := p.parse_relation_id() + relation_id337 := _t938 p.consumeLiteral(")") - _t940 := &pb.Output{Name: deref(name336, "output"), RelationId: relation_id337} - return _t940 + _t939 := &pb.Output{Name: name336, RelationId: relation_id337} + return _t939 } func (p *Parser) parse_what_if() *pb.WhatIf { p.consumeLiteral("(") p.consumeLiteral("what_if") - _t941 := p.parse_name() - name338 := _t941 - _t942 := p.parse_epoch() - epoch339 := _t942 + _t940 := p.parse_name() + name338 := _t940 + _t941 := p.parse_epoch() + epoch339 := _t941 p.consumeLiteral(")") - _t943 := &pb.WhatIf{Branch: name338, Epoch: epoch339} - return _t943 + _t942 := &pb.WhatIf{Branch: name338, Epoch: epoch339} + return _t942 } func (p *Parser) parse_abort() *pb.Abort { p.consumeLiteral("(") p.consumeLiteral("abort") - var _t944 *string + var _t943 *string if (p.matchLookaheadLiteral(":", 0) && p.matchLookaheadTerminal("SYMBOL", 1)) { - _t945 := p.parse_name() - _t944 = ptr(_t945) + _t944 := p.parse_name() + _t943 = ptr(_t944) } - name340 := _t944 - _t946 := p.parse_relation_id() - relation_id341 := _t946 + name340 := _t943 + _t945 := p.parse_relation_id() + relation_id341 := _t945 p.consumeLiteral(")") - _t947 := &pb.Abort{Name: deref(name340, "abort"), RelationId: relation_id341} - return _t947 + _t946 := &pb.Abort{Name: deref(name340, "abort"), RelationId: relation_id341} + return _t946 } func (p *Parser) parse_export() *pb.Export { p.consumeLiteral("(") p.consumeLiteral("export") - _t948 := p.parse_export_csv_config() - export_csv_config342 := _t948 + _t947 := p.parse_export_csv_config() + export_csv_config342 := _t947 p.consumeLiteral(")") - _t949 := &pb.Export{} - _t949.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config342} - return _t949 + _t948 := &pb.Export{} + _t948.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config342} + return _t948 } func (p *Parser) parse_export_csv_config() *pb.ExportCSVConfig { p.consumeLiteral("(") p.consumeLiteral("export_csv_config") - _t950 := p.parse_export_csv_path() - export_csv_path343 := _t950 - _t951 := p.parse_export_csv_columns() - export_csv_columns344 := _t951 - _t952 := p.parse_config_dict() - config_dict345 := _t952 + _t949 := p.parse_export_csv_path() + export_csv_path343 := _t949 + _t950 := p.parse_export_csv_columns() + export_csv_columns344 := _t950 + _t951 := p.parse_config_dict() + config_dict345 := _t951 p.consumeLiteral(")") - _t953 := p.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) - return _t953 + _t952 := p.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) + return _t952 } func (p *Parser) parse_export_csv_path() string { @@ -3788,8 +4067,8 @@ func (p *Parser) parse_export_csv_columns() []*pb.ExportCSVColumn { xs347 := []*pb.ExportCSVColumn{} cond348 := p.matchLookaheadLiteral("(", 0) for cond348 { - _t954 := p.parse_export_csv_column() - item349 := _t954 + _t953 := p.parse_export_csv_column() + item349 := _t953 xs347 = append(xs347, item349) cond348 = p.matchLookaheadLiteral("(", 0) } @@ -3802,11 +4081,11 @@ func (p *Parser) parse_export_csv_column() *pb.ExportCSVColumn { p.consumeLiteral("(") p.consumeLiteral("column") string351 := p.consumeTerminal("STRING").Value.AsString() - _t955 := p.parse_relation_id() - relation_id352 := _t955 + _t954 := p.parse_relation_id() + relation_id352 := _t954 p.consumeLiteral(")") - _t956 := &pb.ExportCSVColumn{ColumnName: string351, ColumnData: relation_id352} - return _t956 + _t955 := &pb.ExportCSVColumn{ColumnName: string351, ColumnData: relation_id352} + return _t955 } diff --git a/julia/LQPParser/src/parser.jl b/julia/LQPParser/src/parser.jl index 8113b51c..420f64e5 100644 --- a/julia/LQPParser/src/parser.jl +++ b/julia/LQPParser/src/parser.jl @@ -418,63 +418,63 @@ end function construct_csv_config(parser::Parser, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.CSVConfig config = Dict(config_dict) - _t946 = _extract_value_int64(parser, get(config, "csv_header_row", nothing), 1) - header_row = _t946 - _t947 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) - skip = _t947 - _t948 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") - new_line = _t948 - _t949 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") - delimiter = _t949 - _t950 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") - quotechar = _t950 - _t951 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") - escapechar = _t951 - _t952 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") - comment = _t952 - _t953 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) - missing_strings = _t953 - _t954 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") - decimal_separator = _t954 - _t955 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") - encoding = _t955 - _t956 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") - compression = _t956 - _t957 = Proto.CSVConfig(header_row=Int32(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t957 + _t945 = _extract_value_int64(parser, get(config, "csv_header_row", nothing), 1) + header_row = _t945 + _t946 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) + skip = _t946 + _t947 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") + new_line = _t947 + _t948 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") + delimiter = _t948 + _t949 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") + quotechar = _t949 + _t950 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") + escapechar = _t950 + _t951 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") + comment = _t951 + _t952 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) + missing_strings = _t952 + _t953 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") + decimal_separator = _t953 + _t954 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") + encoding = _t954 + _t955 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") + compression = _t955 + _t956 = Proto.CSVConfig(header_row=Int32(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t956 end function construct_betree_info(parser::Parser, key_types::Vector{Proto.var"#Type"}, value_types::Vector{Proto.var"#Type"}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.BeTreeInfo config = Dict(config_dict) - _t958 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) - epsilon = _t958 - _t959 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) - max_pivots = _t959 - _t960 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) - max_deltas = _t960 - _t961 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) - max_leaf = _t961 - _t962 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t962 - _t963 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) - root_pageid = _t963 - _t964 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) - inline_data = _t964 - _t965 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) - element_count = _t965 - _t966 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) - tree_height = _t966 - _t967 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) - relation_locator = _t967 - _t968 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t968 + _t957 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) + epsilon = _t957 + _t958 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) + max_pivots = _t958 + _t959 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) + max_deltas = _t959 + _t960 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) + max_leaf = _t960 + _t961 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t961 + _t962 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) + root_pageid = _t962 + _t963 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) + inline_data = _t963 + _t964 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) + element_count = _t964 + _t965 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) + tree_height = _t965 + _t966 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) + relation_locator = _t966 + _t967 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t967 end function default_configure(parser::Parser)::Proto.Configure - _t969 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t969 - _t970 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) - return _t970 + _t968 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t968 + _t969 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) + return _t969 end function construct_configure(parser::Parser, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.Configure @@ -496,34 +496,353 @@ function construct_configure(parser::Parser, config_dict::Vector{Tuple{String, P end end end - _t971 = Proto.IVMConfig(level=maintenance_level) - ivm_config = _t971 - _t972 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) - semantics_version = _t972 - _t973 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t973 + _t970 = Proto.IVMConfig(level=maintenance_level) + ivm_config = _t970 + _t971 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) + semantics_version = _t971 + _t972 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t972 end function export_csv_config(parser::Parser, path::String, columns::Vector{Proto.ExportCSVColumn}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.ExportCSVConfig config = Dict(config_dict) - _t974 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) - partition_size = _t974 - _t975 = _extract_value_string(parser, get(config, "compression", nothing), "") - compression = _t975 - _t976 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) - syntax_header_row = _t976 - _t977 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") - syntax_missing_string = _t977 - _t978 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") - syntax_delim = _t978 - _t979 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") - syntax_quotechar = _t979 - _t980 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") - syntax_escapechar = _t980 - _t981 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + _t973 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) + partition_size = _t973 + _t974 = _extract_value_string(parser, get(config, "compression", nothing), "") + compression = _t974 + _t975 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) + syntax_header_row = _t975 + _t976 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") + syntax_missing_string = _t976 + _t977 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") + syntax_delim = _t977 + _t978 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") + syntax_quotechar = _t978 + _t979 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") + syntax_escapechar = _t979 + _t980 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t980 +end + +function _make_value_int64(parser::Parser, v::Int64)::Proto.Value + _t981 = Proto.Value(value=OneOf(:int_value, v)) return _t981 end +function _make_value_float64(parser::Parser, v::Float64)::Proto.Value + _t982 = Proto.Value(value=OneOf(:float_value, v)) + return _t982 +end + +function _make_value_string(parser::Parser, v::String)::Proto.Value + _t983 = Proto.Value(value=OneOf(:string_value, v)) + return _t983 +end + +function _make_value_boolean(parser::Parser, v::Bool)::Proto.Value + _t984 = Proto.Value(value=OneOf(:boolean_value, v)) + return _t984 +end + +function _make_value_uint128(parser::Parser, v::Proto.UInt128Value)::Proto.Value + _t985 = Proto.Value(value=OneOf(:uint128_value, v)) + return _t985 +end + +function is_default_configure(parser::Parser, cfg::Proto.Configure)::Bool + if cfg.semantics_version != 0 + return false + end + if cfg.ivm_config.level != Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + return false + end + return true +end + +function deconstruct_configure(parser::Parser, msg::Proto.Configure)::Vector{Tuple{String, Proto.Value}} + result = Tuple{String, Proto.Value}[] + + if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO + _t987 = _make_value_string(parser, "auto") + push!(result, ("ivm.maintenance_level", _t987,)) + _t986 = nothing + else + + if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_ALL + _t989 = _make_value_string(parser, "all") + push!(result, ("ivm.maintenance_level", _t989,)) + _t988 = nothing + else + + if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + _t991 = _make_value_string(parser, "off") + push!(result, ("ivm.maintenance_level", _t991,)) + _t990 = nothing + else + _t990 = nothing + end + _t988 = _t990 + end + _t986 = _t988 + end + _t992 = _make_value_int64(parser, msg.semantics_version) + push!(result, ("semantics_version", _t992,)) + return result +end + +function deconstruct_csv_config(parser::Parser, msg::Proto.CSVConfig)::Vector{Tuple{String, Proto.Value}} + result = Tuple{String, Proto.Value}[] + + if msg.header_row != 1 + _t994 = _make_value_int64(parser, Int64(msg.header_row)) + push!(result, ("csv_header_row", _t994,)) + _t993 = nothing + else + _t993 = nothing + end + + if msg.skip != 0 + _t996 = _make_value_int64(parser, msg.skip) + push!(result, ("csv_skip", _t996,)) + _t995 = nothing + else + _t995 = nothing + end + + if msg.new_line != "" + _t998 = _make_value_string(parser, msg.new_line) + push!(result, ("csv_new_line", _t998,)) + _t997 = nothing + else + _t997 = nothing + end + + if msg.delimiter != "," + _t1000 = _make_value_string(parser, msg.delimiter) + push!(result, ("csv_delimiter", _t1000,)) + _t999 = nothing + else + _t999 = nothing + end + + if msg.quotechar != "\"" + _t1002 = _make_value_string(parser, msg.quotechar) + push!(result, ("csv_quotechar", _t1002,)) + _t1001 = nothing + else + _t1001 = nothing + end + + if msg.escapechar != "\"" + _t1004 = _make_value_string(parser, msg.escapechar) + push!(result, ("csv_escapechar", _t1004,)) + _t1003 = nothing + else + _t1003 = nothing + end + + if msg.comment != "" + _t1006 = _make_value_string(parser, msg.comment) + push!(result, ("csv_comment", _t1006,)) + _t1005 = nothing + else + _t1005 = nothing + end + + if !isempty(msg.missing_strings) + _t1008 = _make_value_string(parser, msg.missing_strings[1]) + push!(result, ("csv_missing_strings", _t1008,)) + _t1007 = nothing + else + _t1007 = nothing + end + + if msg.decimal_separator != "." + _t1010 = _make_value_string(parser, msg.decimal_separator) + push!(result, ("csv_decimal_separator", _t1010,)) + _t1009 = nothing + else + _t1009 = nothing + end + + if msg.encoding != "utf-8" + _t1012 = _make_value_string(parser, msg.encoding) + push!(result, ("csv_encoding", _t1012,)) + _t1011 = nothing + else + _t1011 = nothing + end + + if msg.compression != "auto" + _t1014 = _make_value_string(parser, msg.compression) + push!(result, ("csv_compression", _t1014,)) + _t1013 = nothing + else + _t1013 = nothing + end + return result +end + +function _maybe_push_float64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Float64})::Nothing + + if !isnothing(val) + _t1016 = _make_value_float64(parser, val) + push!(result, (key, _t1016,)) + _t1015 = nothing + else + _t1015 = nothing + end + return nothing +end + +function _maybe_push_int64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Int64})::Nothing + + if !isnothing(val) + _t1018 = _make_value_int64(parser, val) + push!(result, (key, _t1018,)) + _t1017 = nothing + else + _t1017 = nothing + end + return nothing +end + +function _maybe_push_uint128(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Proto.UInt128Value})::Nothing + + if !isnothing(val) + _t1020 = _make_value_uint128(parser, val) + push!(result, (key, _t1020,)) + _t1019 = nothing + else + _t1019 = nothing + end + return nothing +end + +function _maybe_push_bytes_as_string(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Vector{UInt8}})::Nothing + + if !isnothing(val) + _t1022 = _make_value_string(parser, String(val)) + push!(result, (key, _t1022,)) + _t1021 = nothing + else + _t1021 = nothing + end + return nothing +end + +function deconstruct_betree_info_config(parser::Parser, msg::Proto.BeTreeInfo)::Vector{Tuple{String, Proto.Value}} + result = Tuple{String, Proto.Value}[] + _t1023 = _maybe_push_float64(parser, result, "betree_config_epsilon", msg.storage_config.epsilon) + _t1024 = _maybe_push_int64(parser, result, "betree_config_max_pivots", msg.storage_config.max_pivots) + _t1025 = _maybe_push_int64(parser, result, "betree_config_max_deltas", msg.storage_config.max_deltas) + _t1026 = _maybe_push_int64(parser, result, "betree_config_max_leaf", msg.storage_config.max_leaf) + + if _has_proto_field(msg.relation_locator, Symbol("root_pageid")) + _t1028 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) + _t1027 = _t1028 + else + _t1027 = nothing + end + + if _has_proto_field(msg.relation_locator, Symbol("inline_data")) + _t1030 = _maybe_push_bytes_as_string(parser, result, "betree_locator_inline_data", _get_oneof_field(msg.relation_locator, :inline_data)) + _t1029 = _t1030 + else + _t1029 = nothing + end + _t1031 = _maybe_push_int64(parser, result, "betree_locator_element_count", msg.relation_locator.element_count) + _t1032 = _maybe_push_int64(parser, result, "betree_locator_tree_height", msg.relation_locator.tree_height) + return result +end + +function deconstruct_export_csv_config(parser::Parser, msg::Proto.ExportCSVConfig)::Vector{Tuple{String, Proto.Value}} + result = Tuple{String, Proto.Value}[] + + if (!isnothing(msg.partition_size) && msg.partition_size != 0) + _t1034 = _make_value_int64(parser, msg.partition_size) + push!(result, ("partition_size", _t1034,)) + _t1033 = nothing + else + _t1033 = nothing + end + + if (!isnothing(msg.compression) && msg.compression != "") + _t1036 = _make_value_string(parser, msg.compression) + push!(result, ("compression", _t1036,)) + _t1035 = nothing + else + _t1035 = nothing + end + + if !isnothing(msg.syntax_header_row) + _t1038 = _make_value_boolean(parser, msg.syntax_header_row) + push!(result, ("syntax_header_row", _t1038,)) + _t1037 = nothing + else + _t1037 = nothing + end + + if (!isnothing(msg.syntax_missing_string) && msg.syntax_missing_string != "") + _t1040 = _make_value_string(parser, msg.syntax_missing_string) + push!(result, ("syntax_missing_string", _t1040,)) + _t1039 = nothing + else + _t1039 = nothing + end + + if (!isnothing(msg.syntax_delim) && msg.syntax_delim != ",") + _t1042 = _make_value_string(parser, msg.syntax_delim) + push!(result, ("syntax_delim", _t1042,)) + _t1041 = nothing + else + _t1041 = nothing + end + + if (!isnothing(msg.syntax_quotechar) && msg.syntax_quotechar != "\"") + _t1044 = _make_value_string(parser, msg.syntax_quotechar) + push!(result, ("syntax_quotechar", _t1044,)) + _t1043 = nothing + else + _t1043 = nothing + end + + if (!isnothing(msg.syntax_escapechar) && msg.syntax_escapechar != "\\") + _t1046 = _make_value_string(parser, msg.syntax_escapechar) + push!(result, ("syntax_escapechar", _t1046,)) + _t1045 = nothing + else + _t1045 = nothing + end + return result +end + +function deconstruct_relation_id_string(parser::Parser, msg::Proto.RelationId)::Union{Nothing, String} + name = relation_id_to_string(pp, msg) + if name != "" + return name + end + return nothing +end + +function deconstruct_relation_id_uint128(parser::Parser, msg::Proto.RelationId)::Union{Nothing, Proto.UInt128Value} + name = relation_id_to_string(pp, msg) + if name == "" + return relation_id_to_uint128(pp, msg) + end + return nothing +end + +function deconstruct_bindings(parser::Parser, abs::Proto.Abstraction)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} + return (abs.vars, Proto.Binding[],) +end + +function deconstruct_bindings_with_arity(parser::Parser, abs::Proto.Abstraction, value_arity::Int64)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} + n = length(abs.vars) + key_end = (n - value_arity) + return (abs.vars[0:key_end], abs.vars[key_end:n],) +end + # --- Parse functions --- function parse_transaction(parser::Parser)::Proto.Transaction @@ -3318,31 +3637,25 @@ end function parse_output(parser::Parser)::Proto.Output consume_literal!(parser, "(") consume_literal!(parser, "output") - - if (match_lookahead_literal(parser, ":", 0) && match_lookahead_terminal(parser, "SYMBOL", 1)) - _t927 = parse_name(parser) - _t926 = _t927 - else - _t926 = nothing - end + _t926 = parse_name(parser) name336 = _t926 - _t928 = parse_relation_id(parser) - relation_id337 = _t928 + _t927 = parse_relation_id(parser) + relation_id337 = _t927 consume_literal!(parser, ")") - _t929 = Proto.Output(name=(!isnothing(name336) ? name336 : "output"), relation_id=relation_id337) - return _t929 + _t928 = Proto.Output(name=name336, relation_id=relation_id337) + return _t928 end function parse_what_if(parser::Parser)::Proto.WhatIf consume_literal!(parser, "(") consume_literal!(parser, "what_if") - _t930 = parse_name(parser) - name338 = _t930 - _t931 = parse_epoch(parser) - epoch339 = _t931 + _t929 = parse_name(parser) + name338 = _t929 + _t930 = parse_epoch(parser) + epoch339 = _t930 consume_literal!(parser, ")") - _t932 = Proto.WhatIf(branch=name338, epoch=epoch339) - return _t932 + _t931 = Proto.WhatIf(branch=name338, epoch=epoch339) + return _t931 end function parse_abort(parser::Parser)::Proto.Abort @@ -3350,41 +3663,41 @@ function parse_abort(parser::Parser)::Proto.Abort consume_literal!(parser, "abort") if (match_lookahead_literal(parser, ":", 0) && match_lookahead_terminal(parser, "SYMBOL", 1)) - _t934 = parse_name(parser) - _t933 = _t934 + _t933 = parse_name(parser) + _t932 = _t933 else - _t933 = nothing + _t932 = nothing end - name340 = _t933 - _t935 = parse_relation_id(parser) - relation_id341 = _t935 + name340 = _t932 + _t934 = parse_relation_id(parser) + relation_id341 = _t934 consume_literal!(parser, ")") - _t936 = Proto.Abort(name=(!isnothing(name340) ? name340 : "abort"), relation_id=relation_id341) - return _t936 + _t935 = Proto.Abort(name=(!isnothing(name340) ? name340 : "abort"), relation_id=relation_id341) + return _t935 end function parse_export(parser::Parser)::Proto.Export consume_literal!(parser, "(") consume_literal!(parser, "export") - _t937 = parse_export_csv_config(parser) - export_csv_config342 = _t937 + _t936 = parse_export_csv_config(parser) + export_csv_config342 = _t936 consume_literal!(parser, ")") - _t938 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config342)) - return _t938 + _t937 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config342)) + return _t937 end function parse_export_csv_config(parser::Parser)::Proto.ExportCSVConfig consume_literal!(parser, "(") consume_literal!(parser, "export_csv_config") - _t939 = parse_export_csv_path(parser) - export_csv_path343 = _t939 - _t940 = parse_export_csv_columns(parser) - export_csv_columns344 = _t940 - _t941 = parse_config_dict(parser) - config_dict345 = _t941 + _t938 = parse_export_csv_path(parser) + export_csv_path343 = _t938 + _t939 = parse_export_csv_columns(parser) + export_csv_columns344 = _t939 + _t940 = parse_config_dict(parser) + config_dict345 = _t940 consume_literal!(parser, ")") - _t942 = export_csv_config(parser, export_csv_path343, export_csv_columns344, config_dict345) - return _t942 + _t941 = export_csv_config(parser, export_csv_path343, export_csv_columns344, config_dict345) + return _t941 end function parse_export_csv_path(parser::Parser)::String @@ -3401,8 +3714,8 @@ function parse_export_csv_columns(parser::Parser)::Vector{Proto.ExportCSVColumn} xs347 = Proto.ExportCSVColumn[] cond348 = match_lookahead_literal(parser, "(", 0) while cond348 - _t943 = parse_export_csv_column(parser) - item349 = _t943 + _t942 = parse_export_csv_column(parser) + item349 = _t942 push!(xs347, item349) cond348 = match_lookahead_literal(parser, "(", 0) end @@ -3415,11 +3728,11 @@ function parse_export_csv_column(parser::Parser)::Proto.ExportCSVColumn consume_literal!(parser, "(") consume_literal!(parser, "column") string351 = consume_terminal!(parser, "STRING") - _t944 = parse_relation_id(parser) - relation_id352 = _t944 + _t943 = parse_relation_id(parser) + relation_id352 = _t943 consume_literal!(parser, ")") - _t945 = Proto.ExportCSVColumn(column_name=string351, column_data=relation_id352) - return _t945 + _t944 = Proto.ExportCSVColumn(column_name=string351, column_data=relation_id352) + return _t944 end diff --git a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl index 66f84a84..c44c359e 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl @@ -1,5 +1,5 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-09T13:12:21.756 -# original file: /Users/nystrom/rai/nn-meta-12-go-tools/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:55.085 +# original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) import ProtoBuf as PB using ProtoBuf: OneOf diff --git a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl index 0c1c977a..ea49a9d0 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl @@ -1,5 +1,5 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-09T13:12:21.246 -# original file: /Users/nystrom/rai/nn-meta-12-go-tools/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:54.593 +# original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) import ProtoBuf as PB using ProtoBuf: OneOf diff --git a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl index f5f53363..3efd0157 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl @@ -1,5 +1,5 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-09T13:12:21.756 -# original file: /Users/nystrom/rai/nn-meta-12-go-tools/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:55.086 +# original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) import ProtoBuf as PB using ProtoBuf: OneOf diff --git a/python-tools/src/lqp/generated_parser.py b/python-tools/src/lqp/generated_parser.py index df700250..2df62ccd 100644 --- a/python-tools/src/lqp/generated_parser.py +++ b/python-tools/src/lqp/generated_parser.py @@ -269,147 +269,130 @@ def construct_fragment(self, fragment_id: fragments_pb2.FragmentId, declarations # --- Helper functions --- - @staticmethod - def _extract_value_int64(value: Optional[logic_pb2.Value], default: int) -> int: + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: if (value is not None and value.HasField('int_value')): return value.int_value return default - @staticmethod - def _extract_value_float64(value: Optional[logic_pb2.Value], default: float) -> float: + def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: if (value is not None and value.HasField('float_value')): return value.float_value return default - @staticmethod - def _extract_value_string(value: Optional[logic_pb2.Value], default: str) -> str: + def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: if (value is not None and value.HasField('string_value')): return value.string_value return default - @staticmethod - def _extract_value_boolean(value: Optional[logic_pb2.Value], default: bool) -> bool: + def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: if (value is not None and value.HasField('boolean_value')): return value.boolean_value return default - @staticmethod - def _extract_value_bytes(value: Optional[logic_pb2.Value], default: bytes) -> bytes: + def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: if (value is not None and value.HasField('string_value')): return value.string_value.encode() return default - @staticmethod - def _extract_value_uint128(value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: if (value is not None and value.HasField('uint128_value')): return value.uint128_value return default - @staticmethod - def _extract_value_string_list(value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: if (value is not None and value.HasField('string_value')): return [value.string_value] return default - @staticmethod - def _try_extract_value_int64(value: Optional[logic_pb2.Value]) -> Optional[int]: + def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: if (value is not None and value.HasField('int_value')): return value.int_value return None - @staticmethod - def _try_extract_value_float64(value: Optional[logic_pb2.Value]) -> Optional[float]: + def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: if (value is not None and value.HasField('float_value')): return value.float_value return None - @staticmethod - def _try_extract_value_string(value: Optional[logic_pb2.Value]) -> Optional[str]: + def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: if (value is not None and value.HasField('string_value')): return value.string_value return None - @staticmethod - def _try_extract_value_bytes(value: Optional[logic_pb2.Value]) -> Optional[bytes]: + def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: if (value is not None and value.HasField('string_value')): return value.string_value.encode() return None - @staticmethod - def _try_extract_value_uint128(value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: if (value is not None and value.HasField('uint128_value')): return value.uint128_value return None - @staticmethod - def _try_extract_value_string_list(value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: if (value is not None and value.HasField('string_value')): return [value.string_value] return None - @staticmethod - def construct_csv_config(config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t946 = Parser._extract_value_int64(config.get('csv_header_row'), 1) - header_row = _t946 - _t947 = Parser._extract_value_int64(config.get('csv_skip'), 0) - skip = _t947 - _t948 = Parser._extract_value_string(config.get('csv_new_line'), '') - new_line = _t948 - _t949 = Parser._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t949 - _t950 = Parser._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t950 - _t951 = Parser._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t951 - _t952 = Parser._extract_value_string(config.get('csv_comment'), '') - comment = _t952 - _t953 = Parser._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t953 - _t954 = Parser._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t954 - _t955 = Parser._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t955 - _t956 = Parser._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t956 - _t957 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t957 - - @staticmethod - def construct_betree_info(key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + _t945 = Parser._extract_value_int64(config.get('csv_header_row'), 1) + header_row = _t945 + _t946 = Parser._extract_value_int64(config.get('csv_skip'), 0) + skip = _t946 + _t947 = Parser._extract_value_string(config.get('csv_new_line'), '') + new_line = _t947 + _t948 = Parser._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t948 + _t949 = Parser._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t949 + _t950 = Parser._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t950 + _t951 = Parser._extract_value_string(config.get('csv_comment'), '') + comment = _t951 + _t952 = Parser._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t952 + _t953 = Parser._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t953 + _t954 = Parser._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t954 + _t955 = Parser._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t955 + _t956 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t956 + + def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t958 = Parser._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t958 - _t959 = Parser._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t959 - _t960 = Parser._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t960 - _t961 = Parser._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t961 - _t962 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t962 - _t963 = Parser._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t963 - _t964 = Parser._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t964 - _t965 = Parser._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t965 - _t966 = Parser._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t966 - _t967 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t967 - _t968 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t968 - - @staticmethod - def default_configure() -> transactions_pb2.Configure: - _t969 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t969 - _t970 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t970 - - @staticmethod - def construct_configure(config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + _t957 = Parser._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t957 + _t958 = Parser._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t958 + _t959 = Parser._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t959 + _t960 = Parser._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t960 + _t961 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t961 + _t962 = Parser._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t962 + _t963 = Parser._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t963 + _t964 = Parser._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t964 + _t965 = Parser._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t965 + _t966 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t966 + _t967 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t967 + + def default_configure(self) -> transactions_pb2.Configure: + _t968 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t968 + _t969 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t969 + + def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) maintenance_level_val = config.get('ivm.maintenance_level') maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF @@ -424,33 +407,302 @@ def construct_configure(config_dict: list[tuple[str, logic_pb2.Value]]) -> trans maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t971 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t971 - _t972 = Parser._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t972 - _t973 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t973 - - @staticmethod - def export_csv_config(path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + _t970 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t970 + _t971 = Parser._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t971 + _t972 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t972 + + def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t974 = Parser._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t974 - _t975 = Parser._extract_value_string(config.get('compression'), '') - compression = _t975 - _t976 = Parser._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t976 - _t977 = Parser._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t977 - _t978 = Parser._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t978 - _t979 = Parser._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t979 - _t980 = Parser._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t980 - _t981 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + _t973 = Parser._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t973 + _t974 = Parser._extract_value_string(config.get('compression'), '') + compression = _t974 + _t975 = Parser._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t975 + _t976 = Parser._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t976 + _t977 = Parser._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t977 + _t978 = Parser._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t978 + _t979 = Parser._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t979 + _t980 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t980 + + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t981 = logic_pb2.Value(int_value=v) return _t981 + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t982 = logic_pb2.Value(float_value=v) + return _t982 + + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t983 = logic_pb2.Value(string_value=v) + return _t983 + + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t984 = logic_pb2.Value(boolean_value=v) + return _t984 + + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t985 = logic_pb2.Value(uint128_value=v) + return _t985 + + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: + if cfg.semantics_version != 0: + return False + if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + return False + return True + + def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: + _t987 = Parser._make_value_string('auto') + result.append(('ivm.maintenance_level', _t987,)) + _t986 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: + _t989 = Parser._make_value_string('all') + result.append(('ivm.maintenance_level', _t989,)) + _t988 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + _t991 = Parser._make_value_string('off') + result.append(('ivm.maintenance_level', _t991,)) + _t990 = None + else: + _t990 = None + _t988 = _t990 + _t986 = _t988 + _t992 = Parser._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t992,)) + return result + + def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.header_row != 1: + _t994 = Parser._make_value_int64(int(msg.header_row)) + result.append(('csv_header_row', _t994,)) + _t993 = None + else: + _t993 = None + + if msg.skip != 0: + _t996 = Parser._make_value_int64(msg.skip) + result.append(('csv_skip', _t996,)) + _t995 = None + else: + _t995 = None + + if msg.new_line != '': + _t998 = Parser._make_value_string(msg.new_line) + result.append(('csv_new_line', _t998,)) + _t997 = None + else: + _t997 = None + + if msg.delimiter != ',': + _t1000 = Parser._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1000,)) + _t999 = None + else: + _t999 = None + + if msg.quotechar != '"': + _t1002 = Parser._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1002,)) + _t1001 = None + else: + _t1001 = None + + if msg.escapechar != '"': + _t1004 = Parser._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1004,)) + _t1003 = None + else: + _t1003 = None + + if msg.comment != '': + _t1006 = Parser._make_value_string(msg.comment) + result.append(('csv_comment', _t1006,)) + _t1005 = None + else: + _t1005 = None + + if not len(msg.missing_strings) == 0: + _t1008 = Parser._make_value_string(msg.missing_strings[0]) + result.append(('csv_missing_strings', _t1008,)) + _t1007 = None + else: + _t1007 = None + + if msg.decimal_separator != '.': + _t1010 = Parser._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1010,)) + _t1009 = None + else: + _t1009 = None + + if msg.encoding != 'utf-8': + _t1012 = Parser._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1012,)) + _t1011 = None + else: + _t1011 = None + + if msg.compression != 'auto': + _t1014 = Parser._make_value_string(msg.compression) + result.append(('csv_compression', _t1014,)) + _t1013 = None + else: + _t1013 = None + return result + + def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: + + if val is not None: + _t1016 = Parser._make_value_float64(val) + result.append((key, _t1016,)) + _t1015 = None + else: + _t1015 = None + return None + + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: + + if val is not None: + _t1018 = Parser._make_value_int64(val) + result.append((key, _t1018,)) + _t1017 = None + else: + _t1017 = None + return None + + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + + if val is not None: + _t1020 = Parser._make_value_uint128(val) + result.append((key, _t1020,)) + _t1019 = None + else: + _t1019 = None + return None + + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + _t1022 = Parser._make_value_string(val.decode('utf-8')) + result.append((key, _t1022,)) + _t1021 = None + else: + _t1021 = None + return None + + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: + result = [] + _t1023 = Parser._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1024 = Parser._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1025 = Parser._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1026 = Parser._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + + if msg.relation_locator.HasField('root_pageid'): + _t1028 = Parser._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1027 = _t1028 + else: + _t1027 = None + + if msg.relation_locator.HasField('inline_data'): + _t1030 = Parser._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1029 = _t1030 + else: + _t1029 = None + _t1031 = Parser._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1032 = Parser._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return result + + def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if (msg.partition_size is not None and msg.partition_size != 0): + _t1034 = Parser._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1034,)) + _t1033 = None + else: + _t1033 = None + + if (msg.compression is not None and msg.compression != ''): + _t1036 = Parser._make_value_string(msg.compression) + result.append(('compression', _t1036,)) + _t1035 = None + else: + _t1035 = None + + if msg.syntax_header_row is not None: + _t1038 = Parser._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1038,)) + _t1037 = None + else: + _t1037 = None + + if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + _t1040 = Parser._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1040,)) + _t1039 = None + else: + _t1039 = None + + if (msg.syntax_delim is not None and msg.syntax_delim != ','): + _t1042 = Parser._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1042,)) + _t1041 = None + else: + _t1041 = None + + if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + _t1044 = Parser._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1044,)) + _t1043 = None + else: + _t1043 = None + + if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + _t1046 = Parser._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1046,)) + _t1045 = None + else: + _t1045 = None + return result + + def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: + name = self.relation_id_to_string(msg) + if name != '': + return name + return None + + def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: + name = self.relation_id_to_string(msg) + if name == '': + return self.relation_id_to_uint128(msg) + return None + + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + return (abs.vars, [],) + + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + n = len(abs.vars) + key_end = (n - value_arity) + return (abs.vars[0:key_end], abs.vars[key_end:n],) + # --- Parse methods --- def parse_transaction(self) -> transactions_pb2.Transaction: @@ -2894,67 +3146,62 @@ def parse_demand(self) -> transactions_pb2.Demand: def parse_output(self) -> transactions_pb2.Output: self.consume_literal('(') self.consume_literal('output') - - if (self.match_lookahead_literal(':', 0) and self.match_lookahead_terminal('SYMBOL', 1)): - _t927 = self.parse_name() - _t926 = _t927 - else: - _t926 = None + _t926 = self.parse_name() name336 = _t926 - _t928 = self.parse_relation_id() - relation_id337 = _t928 + _t927 = self.parse_relation_id() + relation_id337 = _t927 self.consume_literal(')') - _t929 = transactions_pb2.Output(name=(name336 if name336 is not None else 'output'), relation_id=relation_id337) - return _t929 + _t928 = transactions_pb2.Output(name=name336, relation_id=relation_id337) + return _t928 def parse_what_if(self) -> transactions_pb2.WhatIf: self.consume_literal('(') self.consume_literal('what_if') - _t930 = self.parse_name() - name338 = _t930 - _t931 = self.parse_epoch() - epoch339 = _t931 + _t929 = self.parse_name() + name338 = _t929 + _t930 = self.parse_epoch() + epoch339 = _t930 self.consume_literal(')') - _t932 = transactions_pb2.WhatIf(branch=name338, epoch=epoch339) - return _t932 + _t931 = transactions_pb2.WhatIf(branch=name338, epoch=epoch339) + return _t931 def parse_abort(self) -> transactions_pb2.Abort: self.consume_literal('(') self.consume_literal('abort') if (self.match_lookahead_literal(':', 0) and self.match_lookahead_terminal('SYMBOL', 1)): - _t934 = self.parse_name() - _t933 = _t934 + _t933 = self.parse_name() + _t932 = _t933 else: - _t933 = None - name340 = _t933 - _t935 = self.parse_relation_id() - relation_id341 = _t935 + _t932 = None + name340 = _t932 + _t934 = self.parse_relation_id() + relation_id341 = _t934 self.consume_literal(')') - _t936 = transactions_pb2.Abort(name=(name340 if name340 is not None else 'abort'), relation_id=relation_id341) - return _t936 + _t935 = transactions_pb2.Abort(name=(name340 if name340 is not None else 'abort'), relation_id=relation_id341) + return _t935 def parse_export(self) -> transactions_pb2.Export: self.consume_literal('(') self.consume_literal('export') - _t937 = self.parse_export_csv_config() - export_csv_config342 = _t937 + _t936 = self.parse_export_csv_config() + export_csv_config342 = _t936 self.consume_literal(')') - _t938 = transactions_pb2.Export(csv_config=export_csv_config342) - return _t938 + _t937 = transactions_pb2.Export(csv_config=export_csv_config342) + return _t937 def parse_export_csv_config(self) -> transactions_pb2.ExportCSVConfig: self.consume_literal('(') self.consume_literal('export_csv_config') - _t939 = self.parse_export_csv_path() - export_csv_path343 = _t939 - _t940 = self.parse_export_csv_columns() - export_csv_columns344 = _t940 - _t941 = self.parse_config_dict() - config_dict345 = _t941 + _t938 = self.parse_export_csv_path() + export_csv_path343 = _t938 + _t939 = self.parse_export_csv_columns() + export_csv_columns344 = _t939 + _t940 = self.parse_config_dict() + config_dict345 = _t940 self.consume_literal(')') - _t942 = Parser.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) - return _t942 + _t941 = Parser.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) + return _t941 def parse_export_csv_path(self) -> str: self.consume_literal('(') @@ -2969,8 +3216,8 @@ def parse_export_csv_columns(self) -> list[transactions_pb2.ExportCSVColumn]: xs347 = [] cond348 = self.match_lookahead_literal('(', 0) while cond348: - _t943 = self.parse_export_csv_column() - item349 = _t943 + _t942 = self.parse_export_csv_column() + item349 = _t942 xs347.append(item349) cond348 = self.match_lookahead_literal('(', 0) export_csv_columns350 = xs347 @@ -2981,11 +3228,11 @@ def parse_export_csv_column(self) -> transactions_pb2.ExportCSVColumn: self.consume_literal('(') self.consume_literal('column') string351 = self.consume_terminal('STRING') - _t944 = self.parse_relation_id() - relation_id352 = _t944 + _t943 = self.parse_relation_id() + relation_id352 = _t943 self.consume_literal(')') - _t945 = transactions_pb2.ExportCSVColumn(column_name=string351, column_data=relation_id352) - return _t945 + _t944 = transactions_pb2.ExportCSVColumn(column_name=string351, column_data=relation_id352) + return _t944 def parse(input_str: str) -> Any: diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py index d2f3e30b..e113fde2 100644 --- a/python-tools/src/lqp/generated_pretty_printer.py +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -6,7 +6,7 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. -Command: python -m meta.cli /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto --grammar src/meta/grammar.y --printer python +Command: python -m meta.cli fragments.proto logic.proto transactions.proto --grammar grammar.y --printer python """ from io import StringIO @@ -184,61 +184,61 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t1289 = self._extract_value_int64(config.get('csv_header_row'), 1) - header_row = _t1289 - _t1290 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t1290 - _t1291 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t1291 - _t1292 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t1292 - _t1293 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t1293 - _t1294 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t1294 - _t1295 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t1295 - _t1296 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t1296 - _t1297 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t1297 - _t1298 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t1298 - _t1299 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t1299 - _t1300 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1300 + _t1290 = self._extract_value_int64(config.get('csv_header_row'), 1) + header_row = _t1290 + _t1291 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1291 + _t1292 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1292 + _t1293 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1293 + _t1294 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1294 + _t1295 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1295 + _t1296 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1296 + _t1297 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1297 + _t1298 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1298 + _t1299 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1299 + _t1300 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1300 + _t1301 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1301 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t1301 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t1301 - _t1302 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t1302 - _t1303 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t1303 - _t1304 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t1304 - _t1305 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1305 - _t1306 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t1306 - _t1307 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t1307 - _t1308 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t1308 - _t1309 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t1309 - _t1310 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1310 - _t1311 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1311 + _t1302 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1302 + _t1303 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1303 + _t1304 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1304 + _t1305 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1305 + _t1306 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1306 + _t1307 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1307 + _t1308 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1308 + _t1309 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1309 + _t1310 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1310 + _t1311 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1311 + _t1312 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1312 def default_configure(self) -> transactions_pb2.Configure: - _t1312 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1312 - _t1313 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1313 + _t1313 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1313 + _t1314 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1314 def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -255,51 +255,51 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1314 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1314 - _t1315 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t1315 - _t1316 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1316 + _t1315 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1315 + _t1316 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1316 + _t1317 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1317 def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t1317 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t1317 - _t1318 = self._extract_value_string(config.get('compression'), '') - compression = _t1318 - _t1319 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t1319 - _t1320 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t1320 - _t1321 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t1321 - _t1322 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t1322 - _t1323 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t1323 - _t1324 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1324 + _t1318 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1318 + _t1319 = self._extract_value_string(config.get('compression'), '') + compression = _t1319 + _t1320 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1320 + _t1321 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1321 + _t1322 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1322 + _t1323 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1323 + _t1324 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1324 + _t1325 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1325 def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t1325 = logic_pb2.Value(int_value=v) - return _t1325 + _t1326 = logic_pb2.Value(int_value=v) + return _t1326 def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t1326 = logic_pb2.Value(float_value=v) - return _t1326 + _t1327 = logic_pb2.Value(float_value=v) + return _t1327 def _make_value_string(self, v: str) -> logic_pb2.Value: - _t1327 = logic_pb2.Value(string_value=v) - return _t1327 + _t1328 = logic_pb2.Value(string_value=v) + return _t1328 def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t1328 = logic_pb2.Value(boolean_value=v) - return _t1328 + _t1329 = logic_pb2.Value(boolean_value=v) + return _t1329 def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1329 = logic_pb2.Value(uint128_value=v) - return _t1329 + _t1330 = logic_pb2.Value(uint128_value=v) + return _t1330 def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: @@ -312,223 +312,223 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1331 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1331,)) - _t1330 = None + _t1332 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1332,)) + _t1331 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1333 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1333,)) - _t1332 = None + _t1334 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1334,)) + _t1333 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1335 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1335,)) - _t1334 = None + _t1336 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1336,)) + _t1335 = None else: - _t1334 = None - _t1332 = _t1334 - _t1330 = _t1332 - _t1336 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1336,)) + _t1335 = None + _t1333 = _t1335 + _t1331 = _t1333 + _t1337 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1337,)) return result def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] if msg.header_row != 1: - _t1338 = self._make_value_int64(int(msg.header_row)) - result.append(('csv_header_row', _t1338,)) - _t1337 = None + _t1339 = self._make_value_int64(int(msg.header_row)) + result.append(('csv_header_row', _t1339,)) + _t1338 = None else: - _t1337 = None + _t1338 = None if msg.skip != 0: - _t1340 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1340,)) - _t1339 = None + _t1341 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1341,)) + _t1340 = None else: - _t1339 = None + _t1340 = None if msg.new_line != '': - _t1342 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1342,)) - _t1341 = None + _t1343 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1343,)) + _t1342 = None else: - _t1341 = None + _t1342 = None if msg.delimiter != ',': - _t1344 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1344,)) - _t1343 = None + _t1345 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1345,)) + _t1344 = None else: - _t1343 = None + _t1344 = None if msg.quotechar != '"': - _t1346 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1346,)) - _t1345 = None + _t1347 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1347,)) + _t1346 = None else: - _t1345 = None + _t1346 = None if msg.escapechar != '"': - _t1348 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1348,)) - _t1347 = None + _t1349 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1349,)) + _t1348 = None else: - _t1347 = None + _t1348 = None if msg.comment != '': - _t1350 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1350,)) - _t1349 = None + _t1351 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1351,)) + _t1350 = None else: - _t1349 = None + _t1350 = None if not len(msg.missing_strings) == 0: - _t1352 = self._make_value_string(msg.missing_strings[0]) - result.append(('csv_missing_strings', _t1352,)) - _t1351 = None + _t1353 = self._make_value_string(msg.missing_strings[0]) + result.append(('csv_missing_strings', _t1353,)) + _t1352 = None else: - _t1351 = None + _t1352 = None if msg.decimal_separator != '.': - _t1354 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1354,)) - _t1353 = None + _t1355 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1355,)) + _t1354 = None else: - _t1353 = None + _t1354 = None if msg.encoding != 'utf-8': - _t1356 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1356,)) - _t1355 = None + _t1357 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1357,)) + _t1356 = None else: - _t1355 = None + _t1356 = None if msg.compression != 'auto': - _t1358 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1358,)) - _t1357 = None + _t1359 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1359,)) + _t1358 = None else: - _t1357 = None + _t1358 = None return result def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: - _t1360 = self._make_value_float64(val) - result.append((key, _t1360,)) - _t1359 = None + _t1361 = self._make_value_float64(val) + result.append((key, _t1361,)) + _t1360 = None else: - _t1359 = None + _t1360 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: - _t1362 = self._make_value_int64(val) - result.append((key, _t1362,)) - _t1361 = None + _t1363 = self._make_value_int64(val) + result.append((key, _t1363,)) + _t1362 = None else: - _t1361 = None + _t1362 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: - _t1364 = self._make_value_uint128(val) - result.append((key, _t1364,)) - _t1363 = None + _t1365 = self._make_value_uint128(val) + result.append((key, _t1365,)) + _t1364 = None else: - _t1363 = None + _t1364 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: - _t1366 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1366,)) - _t1365 = None + _t1367 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1367,)) + _t1366 = None else: - _t1365 = None + _t1366 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1367 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1368 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1369 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1370 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1372 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1371 = _t1372 + _t1373 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1372 = _t1373 else: - _t1371 = None + _t1372 = None if msg.relation_locator.HasField('inline_data'): - _t1374 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1373 = _t1374 + _t1375 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1374 = _t1375 else: - _t1373 = None - _t1375 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1376 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1374 = None + _t1376 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1377 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return result def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] if (msg.partition_size is not None and msg.partition_size != 0): - _t1378 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1378,)) - _t1377 = None + _t1379 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1379,)) + _t1378 = None else: - _t1377 = None + _t1378 = None if (msg.compression is not None and msg.compression != ''): - _t1380 = self._make_value_string(msg.compression) - result.append(('compression', _t1380,)) - _t1379 = None + _t1381 = self._make_value_string(msg.compression) + result.append(('compression', _t1381,)) + _t1380 = None else: - _t1379 = None + _t1380 = None if msg.syntax_header_row is not None: - _t1382 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1382,)) - _t1381 = None + _t1383 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1383,)) + _t1382 = None else: - _t1381 = None + _t1382 = None if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): - _t1384 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1384,)) - _t1383 = None + _t1385 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1385,)) + _t1384 = None else: - _t1383 = None + _t1384 = None if (msg.syntax_delim is not None and msg.syntax_delim != ','): - _t1386 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1386,)) - _t1385 = None + _t1387 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1387,)) + _t1386 = None else: - _t1385 = None + _t1386 = None if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): - _t1388 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1388,)) - _t1387 = None + _t1389 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1389,)) + _t1388 = None else: - _t1387 = None + _t1388 = None if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): - _t1390 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1390,)) - _t1389 = None + _t1391 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1391,)) + _t1390 = None else: - _t1389 = None + _t1390 = None return result def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: @@ -823,9 +823,14 @@ def _t553(_dollar_dollar): def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: def _t555(_dollar_dollar): - return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), int(_dollar_dollar.microsecond),) - _t556 = _t555(msg) - fields35 = _t556 + + if _dollar_dollar.microsecond != 0: + _t556 = int(_dollar_dollar.microsecond) + else: + _t556 = None + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), _t556,) + _t557 = _t555(msg) + fields35 = _t557 unwrapped_fields36 = fields35 self.write('(') self.write('datetime') @@ -854,42 +859,42 @@ def _t555(_dollar_dollar): self.newline() opt_val44 = field43 self.write(str(opt_val44)) - _t557 = None + _t558 = None else: - _t557 = None + _t558 = None self.dedent() self.write(')') return None def pretty_boolean_value(self, msg: bool) -> Optional[Never]: - def _t558(_dollar_dollar): + def _t559(_dollar_dollar): if _dollar_dollar: - _t559 = () + _t560 = () else: - _t559 = None - return _t559 - _t560 = _t558(msg) - deconstruct_result47 = _t560 + _t560 = None + return _t560 + _t561 = _t559(msg) + deconstruct_result47 = _t561 if deconstruct_result47 is not None: self.write('true') - _t561 = None + _t562 = None else: - def _t562(_dollar_dollar): + def _t563(_dollar_dollar): return _dollar_dollar - _t563 = _t562(msg) - fields45 = _t563 + _t564 = _t563(msg) + fields45 = _t564 unwrapped_fields46 = fields45 self.write('false') - _t561 = None - return _t561 + _t562 = None + return _t562 def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: - def _t564(_dollar_dollar): + def _t565(_dollar_dollar): return _dollar_dollar.fragments - _t565 = _t564(msg) - fields48 = _t565 + _t566 = _t565(msg) + fields48 = _t566 unwrapped_fields49 = fields48 self.write('(') self.write('sync') @@ -900,39 +905,39 @@ def _t564(_dollar_dollar): if (i51 > 0): self.newline() - _t566 = None + _t567 = None else: - _t566 = None - _t567 = self.pretty_fragment_id(elem50) + _t567 = None + _t568 = self.pretty_fragment_id(elem50) self.dedent() self.write(')') return None def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t568(_dollar_dollar): + def _t569(_dollar_dollar): return self.fragment_id_to_string(_dollar_dollar) - _t569 = _t568(msg) - fields52 = _t569 + _t570 = _t569(msg) + fields52 = _t570 unwrapped_fields53 = fields52 self.write(':') self.write(unwrapped_fields53) return None def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: - def _t570(_dollar_dollar): + def _t571(_dollar_dollar): if not len(_dollar_dollar.writes) == 0: - _t571 = _dollar_dollar.writes + _t572 = _dollar_dollar.writes else: - _t571 = None + _t572 = None if not len(_dollar_dollar.reads) == 0: - _t572 = _dollar_dollar.reads + _t573 = _dollar_dollar.reads else: - _t572 = None - return (_t571, _t572,) - _t573 = _t570(msg) - fields54 = _t573 + _t573 = None + return (_t572, _t573,) + _t574 = _t571(msg) + fields54 = _t574 unwrapped_fields55 = fields54 self.write('(') self.write('epoch') @@ -942,28 +947,28 @@ def _t570(_dollar_dollar): if field56 is not None: self.newline() opt_val57 = field56 - _t575 = self.pretty_epoch_writes(opt_val57) - _t574 = _t575 + _t576 = self.pretty_epoch_writes(opt_val57) + _t575 = _t576 else: - _t574 = None + _t575 = None field58 = unwrapped_fields55[1] if field58 is not None: self.newline() opt_val59 = field58 - _t577 = self.pretty_epoch_reads(opt_val59) - _t576 = _t577 + _t578 = self.pretty_epoch_reads(opt_val59) + _t577 = _t578 else: - _t576 = None + _t577 = None self.dedent() self.write(')') return None def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: - def _t578(_dollar_dollar): + def _t579(_dollar_dollar): return _dollar_dollar - _t579 = _t578(msg) - fields60 = _t579 + _t580 = _t579(msg) + fields60 = _t580 unwrapped_fields61 = fields60 self.write('(') self.write('writes') @@ -974,90 +979,90 @@ def _t578(_dollar_dollar): if (i63 > 0): self.newline() - _t580 = None + _t581 = None else: - _t580 = None - _t581 = self.pretty_write(elem62) + _t581 = None + _t582 = self.pretty_write(elem62) self.dedent() self.write(')') return None def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: - def _t582(_dollar_dollar): + def _t583(_dollar_dollar): if _dollar_dollar.HasField('define'): - _t583 = _dollar_dollar.define + _t584 = _dollar_dollar.define else: - _t583 = None - return _t583 - _t584 = _t582(msg) - deconstruct_result66 = _t584 + _t584 = None + return _t584 + _t585 = _t583(msg) + deconstruct_result66 = _t585 if deconstruct_result66 is not None: - _t586 = self.pretty_define(deconstruct_result66) - _t585 = _t586 + _t587 = self.pretty_define(deconstruct_result66) + _t586 = _t587 else: - def _t587(_dollar_dollar): + def _t588(_dollar_dollar): if _dollar_dollar.HasField('undefine'): - _t588 = _dollar_dollar.undefine + _t589 = _dollar_dollar.undefine else: - _t588 = None - return _t588 - _t589 = _t587(msg) - deconstruct_result65 = _t589 + _t589 = None + return _t589 + _t590 = _t588(msg) + deconstruct_result65 = _t590 if deconstruct_result65 is not None: - _t591 = self.pretty_undefine(deconstruct_result65) - _t590 = _t591 + _t592 = self.pretty_undefine(deconstruct_result65) + _t591 = _t592 else: - def _t592(_dollar_dollar): + def _t593(_dollar_dollar): if _dollar_dollar.HasField('context'): - _t593 = _dollar_dollar.context + _t594 = _dollar_dollar.context else: - _t593 = None - return _t593 - _t594 = _t592(msg) - deconstruct_result64 = _t594 + _t594 = None + return _t594 + _t595 = _t593(msg) + deconstruct_result64 = _t595 if deconstruct_result64 is not None: - _t596 = self.pretty_context(deconstruct_result64) - _t595 = _t596 + _t597 = self.pretty_context(deconstruct_result64) + _t596 = _t597 else: raise ParseError('No matching rule for write') - _t590 = _t595 - _t585 = _t590 - return _t585 + _t591 = _t596 + _t586 = _t591 + return _t586 def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: - def _t597(_dollar_dollar): + def _t598(_dollar_dollar): return _dollar_dollar.fragment - _t598 = _t597(msg) - fields67 = _t598 + _t599 = _t598(msg) + fields67 = _t599 unwrapped_fields68 = fields67 self.write('(') self.write('define') self.indent() self.newline() - _t599 = self.pretty_fragment(unwrapped_fields68) + _t600 = self.pretty_fragment(unwrapped_fields68) self.dedent() self.write(')') return None def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: - def _t600(_dollar_dollar): - _t601 = self.start_pretty_fragment(_dollar_dollar) + def _t601(_dollar_dollar): + _t602 = self.start_pretty_fragment(_dollar_dollar) return (_dollar_dollar.id, _dollar_dollar.declarations,) - _t602 = _t600(msg) - fields69 = _t602 + _t603 = _t601(msg) + fields69 = _t603 unwrapped_fields70 = fields69 self.write('(') self.write('fragment') self.indent() self.newline() field71 = unwrapped_fields70[0] - _t603 = self.pretty_new_fragment_id(field71) + _t604 = self.pretty_new_fragment_id(field71) field72 = unwrapped_fields70[1] if not len(field72) == 0: self.newline() @@ -1065,171 +1070,171 @@ def _t600(_dollar_dollar): if (i74 > 0): self.newline() - _t604 = None + _t605 = None else: - _t604 = None - _t605 = self.pretty_declaration(elem73) + _t605 = None + _t606 = self.pretty_declaration(elem73) self.dedent() self.write(')') return None def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t606(_dollar_dollar): + def _t607(_dollar_dollar): return _dollar_dollar - _t607 = _t606(msg) - fields75 = _t607 + _t608 = _t607(msg) + fields75 = _t608 unwrapped_fields76 = fields75 - _t608 = self.pretty_fragment_id(unwrapped_fields76) - return _t608 + _t609 = self.pretty_fragment_id(unwrapped_fields76) + return _t609 def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: - def _t609(_dollar_dollar): + def _t610(_dollar_dollar): if _dollar_dollar.HasField('def'): - _t610 = getattr(_dollar_dollar, 'def') + _t611 = getattr(_dollar_dollar, 'def') else: - _t610 = None - return _t610 - _t611 = _t609(msg) - deconstruct_result80 = _t611 + _t611 = None + return _t611 + _t612 = _t610(msg) + deconstruct_result80 = _t612 if deconstruct_result80 is not None: - _t613 = self.pretty_def(deconstruct_result80) - _t612 = _t613 + _t614 = self.pretty_def(deconstruct_result80) + _t613 = _t614 else: - def _t614(_dollar_dollar): + def _t615(_dollar_dollar): if _dollar_dollar.HasField('algorithm'): - _t615 = _dollar_dollar.algorithm + _t616 = _dollar_dollar.algorithm else: - _t615 = None - return _t615 - _t616 = _t614(msg) - deconstruct_result79 = _t616 + _t616 = None + return _t616 + _t617 = _t615(msg) + deconstruct_result79 = _t617 if deconstruct_result79 is not None: - _t618 = self.pretty_algorithm(deconstruct_result79) - _t617 = _t618 + _t619 = self.pretty_algorithm(deconstruct_result79) + _t618 = _t619 else: - def _t619(_dollar_dollar): + def _t620(_dollar_dollar): if _dollar_dollar.HasField('constraint'): - _t620 = _dollar_dollar.constraint + _t621 = _dollar_dollar.constraint else: - _t620 = None - return _t620 - _t621 = _t619(msg) - deconstruct_result78 = _t621 + _t621 = None + return _t621 + _t622 = _t620(msg) + deconstruct_result78 = _t622 if deconstruct_result78 is not None: - _t623 = self.pretty_constraint(deconstruct_result78) - _t622 = _t623 + _t624 = self.pretty_constraint(deconstruct_result78) + _t623 = _t624 else: - def _t624(_dollar_dollar): + def _t625(_dollar_dollar): if _dollar_dollar.HasField('data'): - _t625 = _dollar_dollar.data + _t626 = _dollar_dollar.data else: - _t625 = None - return _t625 - _t626 = _t624(msg) - deconstruct_result77 = _t626 + _t626 = None + return _t626 + _t627 = _t625(msg) + deconstruct_result77 = _t627 if deconstruct_result77 is not None: - _t628 = self.pretty_data(deconstruct_result77) - _t627 = _t628 + _t629 = self.pretty_data(deconstruct_result77) + _t628 = _t629 else: raise ParseError('No matching rule for declaration') - _t622 = _t627 - _t617 = _t622 - _t612 = _t617 - return _t612 + _t623 = _t628 + _t618 = _t623 + _t613 = _t618 + return _t613 def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: - def _t629(_dollar_dollar): + def _t630(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t630 = _dollar_dollar.attrs + _t631 = _dollar_dollar.attrs else: - _t630 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t630,) - _t631 = _t629(msg) - fields81 = _t631 + _t631 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t631,) + _t632 = _t630(msg) + fields81 = _t632 unwrapped_fields82 = fields81 self.write('(') self.write('def') self.indent() self.newline() field83 = unwrapped_fields82[0] - _t632 = self.pretty_relation_id(field83) + _t633 = self.pretty_relation_id(field83) self.newline() field84 = unwrapped_fields82[1] - _t633 = self.pretty_abstraction(field84) + _t634 = self.pretty_abstraction(field84) field85 = unwrapped_fields82[2] if field85 is not None: self.newline() opt_val86 = field85 - _t635 = self.pretty_attrs(opt_val86) - _t634 = _t635 + _t636 = self.pretty_attrs(opt_val86) + _t635 = _t636 else: - _t634 = None + _t635 = None self.dedent() self.write(')') return None def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: - def _t636(_dollar_dollar): - _t637 = self.deconstruct_relation_id_string(_dollar_dollar) - return _t637 - _t638 = _t636(msg) - deconstruct_result88 = _t638 + def _t637(_dollar_dollar): + _t638 = self.deconstruct_relation_id_string(_dollar_dollar) + return _t638 + _t639 = _t637(msg) + deconstruct_result88 = _t639 if deconstruct_result88 is not None: self.write(':') self.write(deconstruct_result88) - _t639 = None + _t640 = None else: - def _t640(_dollar_dollar): - _t641 = self.deconstruct_relation_id_uint128(_dollar_dollar) - return _t641 - _t642 = _t640(msg) - deconstruct_result87 = _t642 + def _t641(_dollar_dollar): + _t642 = self.deconstruct_relation_id_uint128(_dollar_dollar) + return _t642 + _t643 = _t641(msg) + deconstruct_result87 = _t643 if deconstruct_result87 is not None: self.write(self.format_uint128(deconstruct_result87)) - _t643 = None + _t644 = None else: raise ParseError('No matching rule for relation_id') - _t639 = _t643 - return _t639 + _t640 = _t644 + return _t640 def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: - def _t644(_dollar_dollar): - _t645 = self.deconstruct_bindings(_dollar_dollar) - return (_t645, _dollar_dollar.value,) - _t646 = _t644(msg) - fields89 = _t646 + def _t645(_dollar_dollar): + _t646 = self.deconstruct_bindings(_dollar_dollar) + return (_t646, _dollar_dollar.value,) + _t647 = _t645(msg) + fields89 = _t647 unwrapped_fields90 = fields89 self.write('(') field91 = unwrapped_fields90[0] - _t647 = self.pretty_bindings(field91) + _t648 = self.pretty_bindings(field91) self.write(' ') field92 = unwrapped_fields90[1] - _t648 = self.pretty_formula(field92) + _t649 = self.pretty_formula(field92) self.write(')') return None def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: - def _t649(_dollar_dollar): + def _t650(_dollar_dollar): if not len(_dollar_dollar[1]) == 0: - _t650 = _dollar_dollar[1] + _t651 = _dollar_dollar[1] else: - _t650 = None - return (_dollar_dollar[0], _t650,) - _t651 = _t649(msg) - fields93 = _t651 + _t651 = None + return (_dollar_dollar[0], _t651,) + _t652 = _t650(msg) + fields93 = _t652 unwrapped_fields94 = fields93 self.write('[') field95 = unwrapped_fields94[0] @@ -1237,289 +1242,289 @@ def _t649(_dollar_dollar): if (i97 > 0): self.newline() - _t652 = None + _t653 = None else: - _t652 = None - _t653 = self.pretty_binding(elem96) + _t653 = None + _t654 = self.pretty_binding(elem96) field98 = unwrapped_fields94[1] if field98 is not None: self.write(' ') opt_val99 = field98 - _t655 = self.pretty_value_bindings(opt_val99) - _t654 = _t655 + _t656 = self.pretty_value_bindings(opt_val99) + _t655 = _t656 else: - _t654 = None + _t655 = None self.write(']') return None def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: - def _t656(_dollar_dollar): + def _t657(_dollar_dollar): return (_dollar_dollar.var.name, _dollar_dollar.type,) - _t657 = _t656(msg) - fields100 = _t657 + _t658 = _t657(msg) + fields100 = _t658 unwrapped_fields101 = fields100 field102 = unwrapped_fields101[0] self.write(field102) self.write('::') field103 = unwrapped_fields101[1] - _t658 = self.pretty_type(field103) - return _t658 + _t659 = self.pretty_type(field103) + return _t659 def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: - def _t659(_dollar_dollar): + def _t660(_dollar_dollar): if _dollar_dollar.HasField('unspecified_type'): - _t660 = _dollar_dollar.unspecified_type + _t661 = _dollar_dollar.unspecified_type else: - _t660 = None - return _t660 - _t661 = _t659(msg) - deconstruct_result114 = _t661 + _t661 = None + return _t661 + _t662 = _t660(msg) + deconstruct_result114 = _t662 if deconstruct_result114 is not None: - _t663 = self.pretty_unspecified_type(deconstruct_result114) - _t662 = _t663 + _t664 = self.pretty_unspecified_type(deconstruct_result114) + _t663 = _t664 else: - def _t664(_dollar_dollar): + def _t665(_dollar_dollar): if _dollar_dollar.HasField('string_type'): - _t665 = _dollar_dollar.string_type + _t666 = _dollar_dollar.string_type else: - _t665 = None - return _t665 - _t666 = _t664(msg) - deconstruct_result113 = _t666 + _t666 = None + return _t666 + _t667 = _t665(msg) + deconstruct_result113 = _t667 if deconstruct_result113 is not None: - _t668 = self.pretty_string_type(deconstruct_result113) - _t667 = _t668 + _t669 = self.pretty_string_type(deconstruct_result113) + _t668 = _t669 else: - def _t669(_dollar_dollar): + def _t670(_dollar_dollar): if _dollar_dollar.HasField('int_type'): - _t670 = _dollar_dollar.int_type + _t671 = _dollar_dollar.int_type else: - _t670 = None - return _t670 - _t671 = _t669(msg) - deconstruct_result112 = _t671 + _t671 = None + return _t671 + _t672 = _t670(msg) + deconstruct_result112 = _t672 if deconstruct_result112 is not None: - _t673 = self.pretty_int_type(deconstruct_result112) - _t672 = _t673 + _t674 = self.pretty_int_type(deconstruct_result112) + _t673 = _t674 else: - def _t674(_dollar_dollar): + def _t675(_dollar_dollar): if _dollar_dollar.HasField('float_type'): - _t675 = _dollar_dollar.float_type + _t676 = _dollar_dollar.float_type else: - _t675 = None - return _t675 - _t676 = _t674(msg) - deconstruct_result111 = _t676 + _t676 = None + return _t676 + _t677 = _t675(msg) + deconstruct_result111 = _t677 if deconstruct_result111 is not None: - _t678 = self.pretty_float_type(deconstruct_result111) - _t677 = _t678 + _t679 = self.pretty_float_type(deconstruct_result111) + _t678 = _t679 else: - def _t679(_dollar_dollar): + def _t680(_dollar_dollar): if _dollar_dollar.HasField('uint128_type'): - _t680 = _dollar_dollar.uint128_type + _t681 = _dollar_dollar.uint128_type else: - _t680 = None - return _t680 - _t681 = _t679(msg) - deconstruct_result110 = _t681 + _t681 = None + return _t681 + _t682 = _t680(msg) + deconstruct_result110 = _t682 if deconstruct_result110 is not None: - _t683 = self.pretty_uint128_type(deconstruct_result110) - _t682 = _t683 + _t684 = self.pretty_uint128_type(deconstruct_result110) + _t683 = _t684 else: - def _t684(_dollar_dollar): + def _t685(_dollar_dollar): if _dollar_dollar.HasField('int128_type'): - _t685 = _dollar_dollar.int128_type + _t686 = _dollar_dollar.int128_type else: - _t685 = None - return _t685 - _t686 = _t684(msg) - deconstruct_result109 = _t686 + _t686 = None + return _t686 + _t687 = _t685(msg) + deconstruct_result109 = _t687 if deconstruct_result109 is not None: - _t688 = self.pretty_int128_type(deconstruct_result109) - _t687 = _t688 + _t689 = self.pretty_int128_type(deconstruct_result109) + _t688 = _t689 else: - def _t689(_dollar_dollar): + def _t690(_dollar_dollar): if _dollar_dollar.HasField('date_type'): - _t690 = _dollar_dollar.date_type + _t691 = _dollar_dollar.date_type else: - _t690 = None - return _t690 - _t691 = _t689(msg) - deconstruct_result108 = _t691 + _t691 = None + return _t691 + _t692 = _t690(msg) + deconstruct_result108 = _t692 if deconstruct_result108 is not None: - _t693 = self.pretty_date_type(deconstruct_result108) - _t692 = _t693 + _t694 = self.pretty_date_type(deconstruct_result108) + _t693 = _t694 else: - def _t694(_dollar_dollar): + def _t695(_dollar_dollar): if _dollar_dollar.HasField('datetime_type'): - _t695 = _dollar_dollar.datetime_type + _t696 = _dollar_dollar.datetime_type else: - _t695 = None - return _t695 - _t696 = _t694(msg) - deconstruct_result107 = _t696 + _t696 = None + return _t696 + _t697 = _t695(msg) + deconstruct_result107 = _t697 if deconstruct_result107 is not None: - _t698 = self.pretty_datetime_type(deconstruct_result107) - _t697 = _t698 + _t699 = self.pretty_datetime_type(deconstruct_result107) + _t698 = _t699 else: - def _t699(_dollar_dollar): + def _t700(_dollar_dollar): if _dollar_dollar.HasField('missing_type'): - _t700 = _dollar_dollar.missing_type + _t701 = _dollar_dollar.missing_type else: - _t700 = None - return _t700 - _t701 = _t699(msg) - deconstruct_result106 = _t701 + _t701 = None + return _t701 + _t702 = _t700(msg) + deconstruct_result106 = _t702 if deconstruct_result106 is not None: - _t703 = self.pretty_missing_type(deconstruct_result106) - _t702 = _t703 + _t704 = self.pretty_missing_type(deconstruct_result106) + _t703 = _t704 else: - def _t704(_dollar_dollar): + def _t705(_dollar_dollar): if _dollar_dollar.HasField('decimal_type'): - _t705 = _dollar_dollar.decimal_type + _t706 = _dollar_dollar.decimal_type else: - _t705 = None - return _t705 - _t706 = _t704(msg) - deconstruct_result105 = _t706 + _t706 = None + return _t706 + _t707 = _t705(msg) + deconstruct_result105 = _t707 if deconstruct_result105 is not None: - _t708 = self.pretty_decimal_type(deconstruct_result105) - _t707 = _t708 + _t709 = self.pretty_decimal_type(deconstruct_result105) + _t708 = _t709 else: - def _t709(_dollar_dollar): + def _t710(_dollar_dollar): if _dollar_dollar.HasField('boolean_type'): - _t710 = _dollar_dollar.boolean_type + _t711 = _dollar_dollar.boolean_type else: - _t710 = None - return _t710 - _t711 = _t709(msg) - deconstruct_result104 = _t711 + _t711 = None + return _t711 + _t712 = _t710(msg) + deconstruct_result104 = _t712 if deconstruct_result104 is not None: - _t713 = self.pretty_boolean_type(deconstruct_result104) - _t712 = _t713 + _t714 = self.pretty_boolean_type(deconstruct_result104) + _t713 = _t714 else: raise ParseError('No matching rule for type') - _t707 = _t712 - _t702 = _t707 - _t697 = _t702 - _t692 = _t697 - _t687 = _t692 - _t682 = _t687 - _t677 = _t682 - _t672 = _t677 - _t667 = _t672 - _t662 = _t667 - return _t662 + _t708 = _t713 + _t703 = _t708 + _t698 = _t703 + _t693 = _t698 + _t688 = _t693 + _t683 = _t688 + _t678 = _t683 + _t673 = _t678 + _t668 = _t673 + _t663 = _t668 + return _t663 def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: - def _t714(_dollar_dollar): + def _t715(_dollar_dollar): return _dollar_dollar - _t715 = _t714(msg) - fields115 = _t715 + _t716 = _t715(msg) + fields115 = _t716 unwrapped_fields116 = fields115 self.write('UNKNOWN') return None def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: - def _t716(_dollar_dollar): + def _t717(_dollar_dollar): return _dollar_dollar - _t717 = _t716(msg) - fields117 = _t717 + _t718 = _t717(msg) + fields117 = _t718 unwrapped_fields118 = fields117 self.write('STRING') return None def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: - def _t718(_dollar_dollar): + def _t719(_dollar_dollar): return _dollar_dollar - _t719 = _t718(msg) - fields119 = _t719 + _t720 = _t719(msg) + fields119 = _t720 unwrapped_fields120 = fields119 self.write('INT') return None def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: - def _t720(_dollar_dollar): + def _t721(_dollar_dollar): return _dollar_dollar - _t721 = _t720(msg) - fields121 = _t721 + _t722 = _t721(msg) + fields121 = _t722 unwrapped_fields122 = fields121 self.write('FLOAT') return None def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: - def _t722(_dollar_dollar): + def _t723(_dollar_dollar): return _dollar_dollar - _t723 = _t722(msg) - fields123 = _t723 + _t724 = _t723(msg) + fields123 = _t724 unwrapped_fields124 = fields123 self.write('UINT128') return None def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: - def _t724(_dollar_dollar): + def _t725(_dollar_dollar): return _dollar_dollar - _t725 = _t724(msg) - fields125 = _t725 + _t726 = _t725(msg) + fields125 = _t726 unwrapped_fields126 = fields125 self.write('INT128') return None def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: - def _t726(_dollar_dollar): + def _t727(_dollar_dollar): return _dollar_dollar - _t727 = _t726(msg) - fields127 = _t727 + _t728 = _t727(msg) + fields127 = _t728 unwrapped_fields128 = fields127 self.write('DATE') return None def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: - def _t728(_dollar_dollar): + def _t729(_dollar_dollar): return _dollar_dollar - _t729 = _t728(msg) - fields129 = _t729 + _t730 = _t729(msg) + fields129 = _t730 unwrapped_fields130 = fields129 self.write('DATETIME') return None def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: - def _t730(_dollar_dollar): + def _t731(_dollar_dollar): return _dollar_dollar - _t731 = _t730(msg) - fields131 = _t731 + _t732 = _t731(msg) + fields131 = _t732 unwrapped_fields132 = fields131 self.write('MISSING') return None def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: - def _t732(_dollar_dollar): + def _t733(_dollar_dollar): return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) - _t733 = _t732(msg) - fields133 = _t733 + _t734 = _t733(msg) + fields133 = _t734 unwrapped_fields134 = fields133 self.write('(') self.write('DECIMAL') @@ -1535,19 +1540,19 @@ def _t732(_dollar_dollar): return None def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: - def _t734(_dollar_dollar): + def _t735(_dollar_dollar): return _dollar_dollar - _t735 = _t734(msg) - fields137 = _t735 + _t736 = _t735(msg) + fields137 = _t736 unwrapped_fields138 = fields137 self.write('BOOLEAN') return None def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: - def _t736(_dollar_dollar): + def _t737(_dollar_dollar): return _dollar_dollar - _t737 = _t736(msg) - fields139 = _t737 + _t738 = _t737(msg) + fields139 = _t738 unwrapped_fields140 = fields139 self.write('|') if not len(unwrapped_fields140) == 0: @@ -1556,215 +1561,215 @@ def _t736(_dollar_dollar): if (i142 > 0): self.newline() - _t738 = None + _t739 = None else: - _t738 = None - _t739 = self.pretty_binding(elem141) + _t739 = None + _t740 = self.pretty_binding(elem141) return None def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: - def _t740(_dollar_dollar): + def _t741(_dollar_dollar): if (_dollar_dollar.HasField('conjunction') and len(_dollar_dollar.conjunction.args) == 0): - _t741 = _dollar_dollar.conjunction + _t742 = _dollar_dollar.conjunction else: - _t741 = None - return _t741 - _t742 = _t740(msg) - deconstruct_result155 = _t742 + _t742 = None + return _t742 + _t743 = _t741(msg) + deconstruct_result155 = _t743 if deconstruct_result155 is not None: - _t744 = self.pretty_true(deconstruct_result155) - _t743 = _t744 + _t745 = self.pretty_true(deconstruct_result155) + _t744 = _t745 else: - def _t745(_dollar_dollar): + def _t746(_dollar_dollar): if (_dollar_dollar.HasField('disjunction') and len(_dollar_dollar.disjunction.args) == 0): - _t746 = _dollar_dollar.disjunction + _t747 = _dollar_dollar.disjunction else: - _t746 = None - return _t746 - _t747 = _t745(msg) - deconstruct_result154 = _t747 + _t747 = None + return _t747 + _t748 = _t746(msg) + deconstruct_result154 = _t748 if deconstruct_result154 is not None: - _t749 = self.pretty_false(deconstruct_result154) - _t748 = _t749 + _t750 = self.pretty_false(deconstruct_result154) + _t749 = _t750 else: - def _t750(_dollar_dollar): + def _t751(_dollar_dollar): if _dollar_dollar.HasField('exists'): - _t751 = _dollar_dollar.exists + _t752 = _dollar_dollar.exists else: - _t751 = None - return _t751 - _t752 = _t750(msg) - deconstruct_result153 = _t752 + _t752 = None + return _t752 + _t753 = _t751(msg) + deconstruct_result153 = _t753 if deconstruct_result153 is not None: - _t754 = self.pretty_exists(deconstruct_result153) - _t753 = _t754 + _t755 = self.pretty_exists(deconstruct_result153) + _t754 = _t755 else: - def _t755(_dollar_dollar): + def _t756(_dollar_dollar): if _dollar_dollar.HasField('reduce'): - _t756 = _dollar_dollar.reduce + _t757 = _dollar_dollar.reduce else: - _t756 = None - return _t756 - _t757 = _t755(msg) - deconstruct_result152 = _t757 + _t757 = None + return _t757 + _t758 = _t756(msg) + deconstruct_result152 = _t758 if deconstruct_result152 is not None: - _t759 = self.pretty_reduce(deconstruct_result152) - _t758 = _t759 + _t760 = self.pretty_reduce(deconstruct_result152) + _t759 = _t760 else: - def _t760(_dollar_dollar): + def _t761(_dollar_dollar): if (_dollar_dollar.HasField('conjunction') and not len(_dollar_dollar.conjunction.args) == 0): - _t761 = _dollar_dollar.conjunction + _t762 = _dollar_dollar.conjunction else: - _t761 = None - return _t761 - _t762 = _t760(msg) - deconstruct_result151 = _t762 + _t762 = None + return _t762 + _t763 = _t761(msg) + deconstruct_result151 = _t763 if deconstruct_result151 is not None: - _t764 = self.pretty_conjunction(deconstruct_result151) - _t763 = _t764 + _t765 = self.pretty_conjunction(deconstruct_result151) + _t764 = _t765 else: - def _t765(_dollar_dollar): + def _t766(_dollar_dollar): if (_dollar_dollar.HasField('disjunction') and not len(_dollar_dollar.disjunction.args) == 0): - _t766 = _dollar_dollar.disjunction + _t767 = _dollar_dollar.disjunction else: - _t766 = None - return _t766 - _t767 = _t765(msg) - deconstruct_result150 = _t767 + _t767 = None + return _t767 + _t768 = _t766(msg) + deconstruct_result150 = _t768 if deconstruct_result150 is not None: - _t769 = self.pretty_disjunction(deconstruct_result150) - _t768 = _t769 + _t770 = self.pretty_disjunction(deconstruct_result150) + _t769 = _t770 else: - def _t770(_dollar_dollar): + def _t771(_dollar_dollar): if _dollar_dollar.HasField('not'): - _t771 = getattr(_dollar_dollar, 'not') + _t772 = getattr(_dollar_dollar, 'not') else: - _t771 = None - return _t771 - _t772 = _t770(msg) - deconstruct_result149 = _t772 + _t772 = None + return _t772 + _t773 = _t771(msg) + deconstruct_result149 = _t773 if deconstruct_result149 is not None: - _t774 = self.pretty_not(deconstruct_result149) - _t773 = _t774 + _t775 = self.pretty_not(deconstruct_result149) + _t774 = _t775 else: - def _t775(_dollar_dollar): + def _t776(_dollar_dollar): if _dollar_dollar.HasField('ffi'): - _t776 = _dollar_dollar.ffi + _t777 = _dollar_dollar.ffi else: - _t776 = None - return _t776 - _t777 = _t775(msg) - deconstruct_result148 = _t777 + _t777 = None + return _t777 + _t778 = _t776(msg) + deconstruct_result148 = _t778 if deconstruct_result148 is not None: - _t779 = self.pretty_ffi(deconstruct_result148) - _t778 = _t779 + _t780 = self.pretty_ffi(deconstruct_result148) + _t779 = _t780 else: - def _t780(_dollar_dollar): + def _t781(_dollar_dollar): if _dollar_dollar.HasField('atom'): - _t781 = _dollar_dollar.atom + _t782 = _dollar_dollar.atom else: - _t781 = None - return _t781 - _t782 = _t780(msg) - deconstruct_result147 = _t782 + _t782 = None + return _t782 + _t783 = _t781(msg) + deconstruct_result147 = _t783 if deconstruct_result147 is not None: - _t784 = self.pretty_atom(deconstruct_result147) - _t783 = _t784 + _t785 = self.pretty_atom(deconstruct_result147) + _t784 = _t785 else: - def _t785(_dollar_dollar): + def _t786(_dollar_dollar): if _dollar_dollar.HasField('pragma'): - _t786 = _dollar_dollar.pragma + _t787 = _dollar_dollar.pragma else: - _t786 = None - return _t786 - _t787 = _t785(msg) - deconstruct_result146 = _t787 + _t787 = None + return _t787 + _t788 = _t786(msg) + deconstruct_result146 = _t788 if deconstruct_result146 is not None: - _t789 = self.pretty_pragma(deconstruct_result146) - _t788 = _t789 + _t790 = self.pretty_pragma(deconstruct_result146) + _t789 = _t790 else: - def _t790(_dollar_dollar): + def _t791(_dollar_dollar): if _dollar_dollar.HasField('primitive'): - _t791 = _dollar_dollar.primitive + _t792 = _dollar_dollar.primitive else: - _t791 = None - return _t791 - _t792 = _t790(msg) - deconstruct_result145 = _t792 + _t792 = None + return _t792 + _t793 = _t791(msg) + deconstruct_result145 = _t793 if deconstruct_result145 is not None: - _t794 = self.pretty_primitive(deconstruct_result145) - _t793 = _t794 + _t795 = self.pretty_primitive(deconstruct_result145) + _t794 = _t795 else: - def _t795(_dollar_dollar): + def _t796(_dollar_dollar): if _dollar_dollar.HasField('rel_atom'): - _t796 = _dollar_dollar.rel_atom + _t797 = _dollar_dollar.rel_atom else: - _t796 = None - return _t796 - _t797 = _t795(msg) - deconstruct_result144 = _t797 + _t797 = None + return _t797 + _t798 = _t796(msg) + deconstruct_result144 = _t798 if deconstruct_result144 is not None: - _t799 = self.pretty_rel_atom(deconstruct_result144) - _t798 = _t799 + _t800 = self.pretty_rel_atom(deconstruct_result144) + _t799 = _t800 else: - def _t800(_dollar_dollar): + def _t801(_dollar_dollar): if _dollar_dollar.HasField('cast'): - _t801 = _dollar_dollar.cast + _t802 = _dollar_dollar.cast else: - _t801 = None - return _t801 - _t802 = _t800(msg) - deconstruct_result143 = _t802 + _t802 = None + return _t802 + _t803 = _t801(msg) + deconstruct_result143 = _t803 if deconstruct_result143 is not None: - _t804 = self.pretty_cast(deconstruct_result143) - _t803 = _t804 + _t805 = self.pretty_cast(deconstruct_result143) + _t804 = _t805 else: raise ParseError('No matching rule for formula') - _t798 = _t803 - _t793 = _t798 - _t788 = _t793 - _t783 = _t788 - _t778 = _t783 - _t773 = _t778 - _t768 = _t773 - _t763 = _t768 - _t758 = _t763 - _t753 = _t758 - _t748 = _t753 - _t743 = _t748 - return _t743 + _t799 = _t804 + _t794 = _t799 + _t789 = _t794 + _t784 = _t789 + _t779 = _t784 + _t774 = _t779 + _t769 = _t774 + _t764 = _t769 + _t759 = _t764 + _t754 = _t759 + _t749 = _t754 + _t744 = _t749 + return _t744 def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t805(_dollar_dollar): + def _t806(_dollar_dollar): return _dollar_dollar - _t806 = _t805(msg) - fields156 = _t806 + _t807 = _t806(msg) + fields156 = _t807 unwrapped_fields157 = fields156 self.write('(') self.write('true') @@ -1772,10 +1777,10 @@ def _t805(_dollar_dollar): return None def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t807(_dollar_dollar): + def _t808(_dollar_dollar): return _dollar_dollar - _t808 = _t807(msg) - fields158 = _t808 + _t809 = _t808(msg) + fields158 = _t809 unwrapped_fields159 = fields158 self.write('(') self.write('false') @@ -1783,52 +1788,52 @@ def _t807(_dollar_dollar): return None def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: - def _t809(_dollar_dollar): - _t810 = self.deconstruct_bindings(_dollar_dollar.body) - return (_t810, _dollar_dollar.body.value,) - _t811 = _t809(msg) - fields160 = _t811 + def _t810(_dollar_dollar): + _t811 = self.deconstruct_bindings(_dollar_dollar.body) + return (_t811, _dollar_dollar.body.value,) + _t812 = _t810(msg) + fields160 = _t812 unwrapped_fields161 = fields160 self.write('(') self.write('exists') self.indent() self.newline() field162 = unwrapped_fields161[0] - _t812 = self.pretty_bindings(field162) + _t813 = self.pretty_bindings(field162) self.newline() field163 = unwrapped_fields161[1] - _t813 = self.pretty_formula(field163) + _t814 = self.pretty_formula(field163) self.dedent() self.write(')') return None def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: - def _t814(_dollar_dollar): + def _t815(_dollar_dollar): return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) - _t815 = _t814(msg) - fields164 = _t815 + _t816 = _t815(msg) + fields164 = _t816 unwrapped_fields165 = fields164 self.write('(') self.write('reduce') self.indent() self.newline() field166 = unwrapped_fields165[0] - _t816 = self.pretty_abstraction(field166) + _t817 = self.pretty_abstraction(field166) self.newline() field167 = unwrapped_fields165[1] - _t817 = self.pretty_abstraction(field167) + _t818 = self.pretty_abstraction(field167) self.newline() field168 = unwrapped_fields165[2] - _t818 = self.pretty_terms(field168) + _t819 = self.pretty_terms(field168) self.dedent() self.write(')') return None def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: - def _t819(_dollar_dollar): + def _t820(_dollar_dollar): return _dollar_dollar - _t820 = _t819(msg) - fields169 = _t820 + _t821 = _t820(msg) + fields169 = _t821 unwrapped_fields170 = fields169 self.write('(') self.write('terms') @@ -1839,70 +1844,70 @@ def _t819(_dollar_dollar): if (i172 > 0): self.newline() - _t821 = None + _t822 = None else: - _t821 = None - _t822 = self.pretty_term(elem171) + _t822 = None + _t823 = self.pretty_term(elem171) self.dedent() self.write(')') return None def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: - def _t823(_dollar_dollar): + def _t824(_dollar_dollar): if _dollar_dollar.HasField('var'): - _t824 = _dollar_dollar.var + _t825 = _dollar_dollar.var else: - _t824 = None - return _t824 - _t825 = _t823(msg) - deconstruct_result174 = _t825 + _t825 = None + return _t825 + _t826 = _t824(msg) + deconstruct_result174 = _t826 if deconstruct_result174 is not None: - _t827 = self.pretty_var(deconstruct_result174) - _t826 = _t827 + _t828 = self.pretty_var(deconstruct_result174) + _t827 = _t828 else: - def _t828(_dollar_dollar): + def _t829(_dollar_dollar): if _dollar_dollar.HasField('constant'): - _t829 = _dollar_dollar.constant + _t830 = _dollar_dollar.constant else: - _t829 = None - return _t829 - _t830 = _t828(msg) - deconstruct_result173 = _t830 + _t830 = None + return _t830 + _t831 = _t829(msg) + deconstruct_result173 = _t831 if deconstruct_result173 is not None: - _t832 = self.pretty_constant(deconstruct_result173) - _t831 = _t832 + _t833 = self.pretty_constant(deconstruct_result173) + _t832 = _t833 else: raise ParseError('No matching rule for term') - _t826 = _t831 - return _t826 + _t827 = _t832 + return _t827 def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: - def _t833(_dollar_dollar): + def _t834(_dollar_dollar): return _dollar_dollar.name - _t834 = _t833(msg) - fields175 = _t834 + _t835 = _t834(msg) + fields175 = _t835 unwrapped_fields176 = fields175 self.write(unwrapped_fields176) return None def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t835(_dollar_dollar): + def _t836(_dollar_dollar): return _dollar_dollar - _t836 = _t835(msg) - fields177 = _t836 + _t837 = _t836(msg) + fields177 = _t837 unwrapped_fields178 = fields177 - _t837 = self.pretty_value(unwrapped_fields178) - return _t837 + _t838 = self.pretty_value(unwrapped_fields178) + return _t838 def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t838(_dollar_dollar): + def _t839(_dollar_dollar): return _dollar_dollar.args - _t839 = _t838(msg) - fields179 = _t839 + _t840 = _t839(msg) + fields179 = _t840 unwrapped_fields180 = fields179 self.write('(') self.write('and') @@ -1913,19 +1918,19 @@ def _t838(_dollar_dollar): if (i182 > 0): self.newline() - _t840 = None + _t841 = None else: - _t840 = None - _t841 = self.pretty_formula(elem181) + _t841 = None + _t842 = self.pretty_formula(elem181) self.dedent() self.write(')') return None def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t842(_dollar_dollar): + def _t843(_dollar_dollar): return _dollar_dollar.args - _t843 = _t842(msg) - fields183 = _t843 + _t844 = _t843(msg) + fields183 = _t844 unwrapped_fields184 = fields183 self.write('(') self.write('or') @@ -1936,66 +1941,66 @@ def _t842(_dollar_dollar): if (i186 > 0): self.newline() - _t844 = None + _t845 = None else: - _t844 = None - _t845 = self.pretty_formula(elem185) + _t845 = None + _t846 = self.pretty_formula(elem185) self.dedent() self.write(')') return None def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: - def _t846(_dollar_dollar): + def _t847(_dollar_dollar): return _dollar_dollar.arg - _t847 = _t846(msg) - fields187 = _t847 + _t848 = _t847(msg) + fields187 = _t848 unwrapped_fields188 = fields187 self.write('(') self.write('not') self.indent() self.newline() - _t848 = self.pretty_formula(unwrapped_fields188) + _t849 = self.pretty_formula(unwrapped_fields188) self.dedent() self.write(')') return None def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: - def _t849(_dollar_dollar): + def _t850(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) - _t850 = _t849(msg) - fields189 = _t850 + _t851 = _t850(msg) + fields189 = _t851 unwrapped_fields190 = fields189 self.write('(') self.write('ffi') self.indent() self.newline() field191 = unwrapped_fields190[0] - _t851 = self.pretty_name(field191) + _t852 = self.pretty_name(field191) self.newline() field192 = unwrapped_fields190[1] - _t852 = self.pretty_ffi_args(field192) + _t853 = self.pretty_ffi_args(field192) self.newline() field193 = unwrapped_fields190[2] - _t853 = self.pretty_terms(field193) + _t854 = self.pretty_terms(field193) self.dedent() self.write(')') return None def pretty_name(self, msg: str) -> Optional[Never]: - def _t854(_dollar_dollar): + def _t855(_dollar_dollar): return _dollar_dollar - _t855 = _t854(msg) - fields194 = _t855 + _t856 = _t855(msg) + fields194 = _t856 unwrapped_fields195 = fields194 self.write(':') self.write(unwrapped_fields195) return None def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: - def _t856(_dollar_dollar): + def _t857(_dollar_dollar): return _dollar_dollar - _t857 = _t856(msg) - fields196 = _t857 + _t858 = _t857(msg) + fields196 = _t858 unwrapped_fields197 = fields196 self.write('(') self.write('args') @@ -2006,26 +2011,26 @@ def _t856(_dollar_dollar): if (i199 > 0): self.newline() - _t858 = None + _t859 = None else: - _t858 = None - _t859 = self.pretty_abstraction(elem198) + _t859 = None + _t860 = self.pretty_abstraction(elem198) self.dedent() self.write(')') return None def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: - def _t860(_dollar_dollar): + def _t861(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t861 = _t860(msg) - fields200 = _t861 + _t862 = _t861(msg) + fields200 = _t862 unwrapped_fields201 = fields200 self.write('(') self.write('atom') self.indent() self.newline() field202 = unwrapped_fields201[0] - _t862 = self.pretty_relation_id(field202) + _t863 = self.pretty_relation_id(field202) field203 = unwrapped_fields201[1] if not len(field203) == 0: self.newline() @@ -2033,26 +2038,26 @@ def _t860(_dollar_dollar): if (i205 > 0): self.newline() - _t863 = None + _t864 = None else: - _t863 = None - _t864 = self.pretty_term(elem204) + _t864 = None + _t865 = self.pretty_term(elem204) self.dedent() self.write(')') return None def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: - def _t865(_dollar_dollar): + def _t866(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t866 = _t865(msg) - fields206 = _t866 + _t867 = _t866(msg) + fields206 = _t867 unwrapped_fields207 = fields206 self.write('(') self.write('pragma') self.indent() self.newline() field208 = unwrapped_fields207[0] - _t867 = self.pretty_name(field208) + _t868 = self.pretty_name(field208) field209 = unwrapped_fields207[1] if not len(field209) == 0: self.newline() @@ -2060,152 +2065,152 @@ def _t865(_dollar_dollar): if (i211 > 0): self.newline() - _t868 = None + _t869 = None else: - _t868 = None - _t869 = self.pretty_term(elem210) + _t869 = None + _t870 = self.pretty_term(elem210) self.dedent() self.write(')') return None def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t870(_dollar_dollar): + def _t871(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t871 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t872 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t871 = None - return _t871 - _t872 = _t870(msg) - guard_result226 = _t872 + _t872 = None + return _t872 + _t873 = _t871(msg) + guard_result226 = _t873 if guard_result226 is not None: - _t874 = self.pretty_eq(msg) - _t873 = _t874 + _t875 = self.pretty_eq(msg) + _t874 = _t875 else: - def _t875(_dollar_dollar): + def _t876(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t876 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t877 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t876 = None - return _t876 - _t877 = _t875(msg) - guard_result225 = _t877 + _t877 = None + return _t877 + _t878 = _t876(msg) + guard_result225 = _t878 if guard_result225 is not None: - _t879 = self.pretty_lt(msg) - _t878 = _t879 + _t880 = self.pretty_lt(msg) + _t879 = _t880 else: - def _t880(_dollar_dollar): + def _t881(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t881 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t882 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t881 = None - return _t881 - _t882 = _t880(msg) - guard_result224 = _t882 + _t882 = None + return _t882 + _t883 = _t881(msg) + guard_result224 = _t883 if guard_result224 is not None: - _t884 = self.pretty_lt_eq(msg) - _t883 = _t884 + _t885 = self.pretty_lt_eq(msg) + _t884 = _t885 else: - def _t885(_dollar_dollar): + def _t886(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t886 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t887 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t886 = None - return _t886 - _t887 = _t885(msg) - guard_result223 = _t887 + _t887 = None + return _t887 + _t888 = _t886(msg) + guard_result223 = _t888 if guard_result223 is not None: - _t889 = self.pretty_gt(msg) - _t888 = _t889 + _t890 = self.pretty_gt(msg) + _t889 = _t890 else: - def _t890(_dollar_dollar): + def _t891(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t891 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t892 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t891 = None - return _t891 - _t892 = _t890(msg) - guard_result222 = _t892 + _t892 = None + return _t892 + _t893 = _t891(msg) + guard_result222 = _t893 if guard_result222 is not None: - _t894 = self.pretty_gt_eq(msg) - _t893 = _t894 + _t895 = self.pretty_gt_eq(msg) + _t894 = _t895 else: - def _t895(_dollar_dollar): + def _t896(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t896 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t897 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t896 = None - return _t896 - _t897 = _t895(msg) - guard_result221 = _t897 + _t897 = None + return _t897 + _t898 = _t896(msg) + guard_result221 = _t898 if guard_result221 is not None: - _t899 = self.pretty_add(msg) - _t898 = _t899 + _t900 = self.pretty_add(msg) + _t899 = _t900 else: - def _t900(_dollar_dollar): + def _t901(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t901 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t902 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t901 = None - return _t901 - _t902 = _t900(msg) - guard_result220 = _t902 + _t902 = None + return _t902 + _t903 = _t901(msg) + guard_result220 = _t903 if guard_result220 is not None: - _t904 = self.pretty_minus(msg) - _t903 = _t904 + _t905 = self.pretty_minus(msg) + _t904 = _t905 else: - def _t905(_dollar_dollar): + def _t906(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t906 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t907 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t906 = None - return _t906 - _t907 = _t905(msg) - guard_result219 = _t907 + _t907 = None + return _t907 + _t908 = _t906(msg) + guard_result219 = _t908 if guard_result219 is not None: - _t909 = self.pretty_multiply(msg) - _t908 = _t909 + _t910 = self.pretty_multiply(msg) + _t909 = _t910 else: - def _t910(_dollar_dollar): + def _t911(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t911 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t912 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t911 = None - return _t911 - _t912 = _t910(msg) - guard_result218 = _t912 + _t912 = None + return _t912 + _t913 = _t911(msg) + guard_result218 = _t913 if guard_result218 is not None: - _t914 = self.pretty_divide(msg) - _t913 = _t914 + _t915 = self.pretty_divide(msg) + _t914 = _t915 else: - def _t915(_dollar_dollar): + def _t916(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t916 = _t915(msg) - fields212 = _t916 + _t917 = _t916(msg) + fields212 = _t917 unwrapped_fields213 = fields212 self.write('(') self.write('primitive') self.indent() self.newline() field214 = unwrapped_fields213[0] - _t917 = self.pretty_name(field214) + _t918 = self.pretty_name(field214) field215 = unwrapped_fields213[1] if not len(field215) == 0: self.newline() @@ -2213,306 +2218,306 @@ def _t915(_dollar_dollar): if (i217 > 0): self.newline() - _t918 = None + _t919 = None else: - _t918 = None - _t919 = self.pretty_rel_term(elem216) + _t919 = None + _t920 = self.pretty_rel_term(elem216) self.dedent() self.write(')') - _t913 = None - _t908 = _t913 - _t903 = _t908 - _t898 = _t903 - _t893 = _t898 - _t888 = _t893 - _t883 = _t888 - _t878 = _t883 - _t873 = _t878 - return _t873 + _t914 = None + _t909 = _t914 + _t904 = _t909 + _t899 = _t904 + _t894 = _t899 + _t889 = _t894 + _t884 = _t889 + _t879 = _t884 + _t874 = _t879 + return _t874 def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t920(_dollar_dollar): + def _t921(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_eq': - _t921 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t922 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t921 = None - return _t921 - _t922 = _t920(msg) - fields227 = _t922 + _t922 = None + return _t922 + _t923 = _t921(msg) + fields227 = _t923 unwrapped_fields228 = fields227 self.write('(') self.write('=') self.indent() self.newline() field229 = unwrapped_fields228[0] - _t923 = self.pretty_term(field229) + _t924 = self.pretty_term(field229) self.newline() field230 = unwrapped_fields228[1] - _t924 = self.pretty_term(field230) + _t925 = self.pretty_term(field230) self.dedent() self.write(')') return None def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t925(_dollar_dollar): + def _t926(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t926 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t927 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t926 = None - return _t926 - _t927 = _t925(msg) - fields231 = _t927 + _t927 = None + return _t927 + _t928 = _t926(msg) + fields231 = _t928 unwrapped_fields232 = fields231 self.write('(') self.write('<') self.indent() self.newline() field233 = unwrapped_fields232[0] - _t928 = self.pretty_term(field233) + _t929 = self.pretty_term(field233) self.newline() field234 = unwrapped_fields232[1] - _t929 = self.pretty_term(field234) + _t930 = self.pretty_term(field234) self.dedent() self.write(')') return None def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t930(_dollar_dollar): + def _t931(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t931 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t932 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t931 = None - return _t931 - _t932 = _t930(msg) - fields235 = _t932 + _t932 = None + return _t932 + _t933 = _t931(msg) + fields235 = _t933 unwrapped_fields236 = fields235 self.write('(') self.write('<=') self.indent() self.newline() field237 = unwrapped_fields236[0] - _t933 = self.pretty_term(field237) + _t934 = self.pretty_term(field237) self.newline() field238 = unwrapped_fields236[1] - _t934 = self.pretty_term(field238) + _t935 = self.pretty_term(field238) self.dedent() self.write(')') return None def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t935(_dollar_dollar): + def _t936(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t936 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t937 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t936 = None - return _t936 - _t937 = _t935(msg) - fields239 = _t937 + _t937 = None + return _t937 + _t938 = _t936(msg) + fields239 = _t938 unwrapped_fields240 = fields239 self.write('(') self.write('>') self.indent() self.newline() field241 = unwrapped_fields240[0] - _t938 = self.pretty_term(field241) + _t939 = self.pretty_term(field241) self.newline() field242 = unwrapped_fields240[1] - _t939 = self.pretty_term(field242) + _t940 = self.pretty_term(field242) self.dedent() self.write(')') return None def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t940(_dollar_dollar): + def _t941(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t941 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + _t942 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) else: - _t941 = None - return _t941 - _t942 = _t940(msg) - fields243 = _t942 + _t942 = None + return _t942 + _t943 = _t941(msg) + fields243 = _t943 unwrapped_fields244 = fields243 self.write('(') self.write('>=') self.indent() self.newline() field245 = unwrapped_fields244[0] - _t943 = self.pretty_term(field245) + _t944 = self.pretty_term(field245) self.newline() field246 = unwrapped_fields244[1] - _t944 = self.pretty_term(field246) + _t945 = self.pretty_term(field246) self.dedent() self.write(')') return None def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t945(_dollar_dollar): + def _t946(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t946 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t947 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t946 = None - return _t946 - _t947 = _t945(msg) - fields247 = _t947 + _t947 = None + return _t947 + _t948 = _t946(msg) + fields247 = _t948 unwrapped_fields248 = fields247 self.write('(') self.write('+') self.indent() self.newline() field249 = unwrapped_fields248[0] - _t948 = self.pretty_term(field249) + _t949 = self.pretty_term(field249) self.newline() field250 = unwrapped_fields248[1] - _t949 = self.pretty_term(field250) + _t950 = self.pretty_term(field250) self.newline() field251 = unwrapped_fields248[2] - _t950 = self.pretty_term(field251) + _t951 = self.pretty_term(field251) self.dedent() self.write(')') return None def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t951(_dollar_dollar): + def _t952(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t952 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t953 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t952 = None - return _t952 - _t953 = _t951(msg) - fields252 = _t953 + _t953 = None + return _t953 + _t954 = _t952(msg) + fields252 = _t954 unwrapped_fields253 = fields252 self.write('(') self.write('-') self.indent() self.newline() field254 = unwrapped_fields253[0] - _t954 = self.pretty_term(field254) + _t955 = self.pretty_term(field254) self.newline() field255 = unwrapped_fields253[1] - _t955 = self.pretty_term(field255) + _t956 = self.pretty_term(field255) self.newline() field256 = unwrapped_fields253[2] - _t956 = self.pretty_term(field256) + _t957 = self.pretty_term(field256) self.dedent() self.write(')') return None def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t957(_dollar_dollar): + def _t958(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t958 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t959 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t958 = None - return _t958 - _t959 = _t957(msg) - fields257 = _t959 + _t959 = None + return _t959 + _t960 = _t958(msg) + fields257 = _t960 unwrapped_fields258 = fields257 self.write('(') self.write('*') self.indent() self.newline() field259 = unwrapped_fields258[0] - _t960 = self.pretty_term(field259) + _t961 = self.pretty_term(field259) self.newline() field260 = unwrapped_fields258[1] - _t961 = self.pretty_term(field260) + _t962 = self.pretty_term(field260) self.newline() field261 = unwrapped_fields258[2] - _t962 = self.pretty_term(field261) + _t963 = self.pretty_term(field261) self.dedent() self.write(')') return None def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t963(_dollar_dollar): + def _t964(_dollar_dollar): if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t964 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + _t965 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) else: - _t964 = None - return _t964 - _t965 = _t963(msg) - fields262 = _t965 + _t965 = None + return _t965 + _t966 = _t964(msg) + fields262 = _t966 unwrapped_fields263 = fields262 self.write('(') self.write('/') self.indent() self.newline() field264 = unwrapped_fields263[0] - _t966 = self.pretty_term(field264) + _t967 = self.pretty_term(field264) self.newline() field265 = unwrapped_fields263[1] - _t967 = self.pretty_term(field265) + _t968 = self.pretty_term(field265) self.newline() field266 = unwrapped_fields263[2] - _t968 = self.pretty_term(field266) + _t969 = self.pretty_term(field266) self.dedent() self.write(')') return None def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: - def _t969(_dollar_dollar): + def _t970(_dollar_dollar): if _dollar_dollar.HasField('specialized_value'): - _t970 = _dollar_dollar.specialized_value + _t971 = _dollar_dollar.specialized_value else: - _t970 = None - return _t970 - _t971 = _t969(msg) - deconstruct_result268 = _t971 + _t971 = None + return _t971 + _t972 = _t970(msg) + deconstruct_result268 = _t972 if deconstruct_result268 is not None: - _t973 = self.pretty_specialized_value(deconstruct_result268) - _t972 = _t973 + _t974 = self.pretty_specialized_value(deconstruct_result268) + _t973 = _t974 else: - def _t974(_dollar_dollar): + def _t975(_dollar_dollar): if _dollar_dollar.HasField('term'): - _t975 = _dollar_dollar.term + _t976 = _dollar_dollar.term else: - _t975 = None - return _t975 - _t976 = _t974(msg) - deconstruct_result267 = _t976 + _t976 = None + return _t976 + _t977 = _t975(msg) + deconstruct_result267 = _t977 if deconstruct_result267 is not None: - _t978 = self.pretty_term(deconstruct_result267) - _t977 = _t978 + _t979 = self.pretty_term(deconstruct_result267) + _t978 = _t979 else: raise ParseError('No matching rule for rel_term') - _t972 = _t977 - return _t972 + _t973 = _t978 + return _t973 def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t979(_dollar_dollar): + def _t980(_dollar_dollar): return _dollar_dollar - _t980 = _t979(msg) - fields269 = _t980 + _t981 = _t980(msg) + fields269 = _t981 unwrapped_fields270 = fields269 self.write('#') - _t981 = self.pretty_value(unwrapped_fields270) - return _t981 + _t982 = self.pretty_value(unwrapped_fields270) + return _t982 def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: - def _t982(_dollar_dollar): + def _t983(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) - _t983 = _t982(msg) - fields271 = _t983 + _t984 = _t983(msg) + fields271 = _t984 unwrapped_fields272 = fields271 self.write('(') self.write('relatom') self.indent() self.newline() field273 = unwrapped_fields272[0] - _t984 = self.pretty_name(field273) + _t985 = self.pretty_name(field273) field274 = unwrapped_fields272[1] if not len(field274) == 0: self.newline() @@ -2520,38 +2525,38 @@ def _t982(_dollar_dollar): if (i276 > 0): self.newline() - _t985 = None + _t986 = None else: - _t985 = None - _t986 = self.pretty_rel_term(elem275) + _t986 = None + _t987 = self.pretty_rel_term(elem275) self.dedent() self.write(')') return None def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: - def _t987(_dollar_dollar): + def _t988(_dollar_dollar): return (_dollar_dollar.input, _dollar_dollar.result,) - _t988 = _t987(msg) - fields277 = _t988 + _t989 = _t988(msg) + fields277 = _t989 unwrapped_fields278 = fields277 self.write('(') self.write('cast') self.indent() self.newline() field279 = unwrapped_fields278[0] - _t989 = self.pretty_term(field279) + _t990 = self.pretty_term(field279) self.newline() field280 = unwrapped_fields278[1] - _t990 = self.pretty_term(field280) + _t991 = self.pretty_term(field280) self.dedent() self.write(')') return None def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: - def _t991(_dollar_dollar): + def _t992(_dollar_dollar): return _dollar_dollar - _t992 = _t991(msg) - fields281 = _t992 + _t993 = _t992(msg) + fields281 = _t993 unwrapped_fields282 = fields281 self.write('(') self.write('attrs') @@ -2562,26 +2567,26 @@ def _t991(_dollar_dollar): if (i284 > 0): self.newline() - _t993 = None + _t994 = None else: - _t993 = None - _t994 = self.pretty_attribute(elem283) + _t994 = None + _t995 = self.pretty_attribute(elem283) self.dedent() self.write(')') return None def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: - def _t995(_dollar_dollar): + def _t996(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args,) - _t996 = _t995(msg) - fields285 = _t996 + _t997 = _t996(msg) + fields285 = _t997 unwrapped_fields286 = fields285 self.write('(') self.write('attribute') self.indent() self.newline() field287 = unwrapped_fields286[0] - _t997 = self.pretty_name(field287) + _t998 = self.pretty_name(field287) field288 = unwrapped_fields286[1] if not len(field288) == 0: self.newline() @@ -2589,19 +2594,19 @@ def _t995(_dollar_dollar): if (i290 > 0): self.newline() - _t998 = None + _t999 = None else: - _t998 = None - _t999 = self.pretty_value(elem289) + _t999 = None + _t1000 = self.pretty_value(elem289) self.dedent() self.write(')') return None def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: - def _t1000(_dollar_dollar): + def _t1001(_dollar_dollar): return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) - _t1001 = _t1000(msg) - fields291 = _t1001 + _t1002 = _t1001(msg) + fields291 = _t1002 unwrapped_fields292 = fields291 self.write('(') self.write('algorithm') @@ -2613,22 +2618,22 @@ def _t1000(_dollar_dollar): if (i295 > 0): self.newline() - _t1002 = None + _t1003 = None else: - _t1002 = None - _t1003 = self.pretty_relation_id(elem294) + _t1003 = None + _t1004 = self.pretty_relation_id(elem294) self.newline() field296 = unwrapped_fields292[1] - _t1004 = self.pretty_script(field296) + _t1005 = self.pretty_script(field296) self.dedent() self.write(')') return None def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: - def _t1005(_dollar_dollar): + def _t1006(_dollar_dollar): return _dollar_dollar.constructs - _t1006 = _t1005(msg) - fields297 = _t1006 + _t1007 = _t1006(msg) + fields297 = _t1007 unwrapped_fields298 = fields297 self.write('(') self.write('script') @@ -2639,71 +2644,71 @@ def _t1005(_dollar_dollar): if (i300 > 0): self.newline() - _t1007 = None + _t1008 = None else: - _t1007 = None - _t1008 = self.pretty_construct(elem299) + _t1008 = None + _t1009 = self.pretty_construct(elem299) self.dedent() self.write(')') return None def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: - def _t1009(_dollar_dollar): + def _t1010(_dollar_dollar): if _dollar_dollar.HasField('loop'): - _t1010 = _dollar_dollar.loop + _t1011 = _dollar_dollar.loop else: - _t1010 = None - return _t1010 - _t1011 = _t1009(msg) - deconstruct_result302 = _t1011 + _t1011 = None + return _t1011 + _t1012 = _t1010(msg) + deconstruct_result302 = _t1012 if deconstruct_result302 is not None: - _t1013 = self.pretty_loop(deconstruct_result302) - _t1012 = _t1013 + _t1014 = self.pretty_loop(deconstruct_result302) + _t1013 = _t1014 else: - def _t1014(_dollar_dollar): + def _t1015(_dollar_dollar): if _dollar_dollar.HasField('instruction'): - _t1015 = _dollar_dollar.instruction + _t1016 = _dollar_dollar.instruction else: - _t1015 = None - return _t1015 - _t1016 = _t1014(msg) - deconstruct_result301 = _t1016 + _t1016 = None + return _t1016 + _t1017 = _t1015(msg) + deconstruct_result301 = _t1017 if deconstruct_result301 is not None: - _t1018 = self.pretty_instruction(deconstruct_result301) - _t1017 = _t1018 + _t1019 = self.pretty_instruction(deconstruct_result301) + _t1018 = _t1019 else: raise ParseError('No matching rule for construct') - _t1012 = _t1017 - return _t1012 + _t1013 = _t1018 + return _t1013 def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: - def _t1019(_dollar_dollar): + def _t1020(_dollar_dollar): return (_dollar_dollar.init, _dollar_dollar.body,) - _t1020 = _t1019(msg) - fields303 = _t1020 + _t1021 = _t1020(msg) + fields303 = _t1021 unwrapped_fields304 = fields303 self.write('(') self.write('loop') self.indent() self.newline() field305 = unwrapped_fields304[0] - _t1021 = self.pretty_init(field305) + _t1022 = self.pretty_init(field305) self.newline() field306 = unwrapped_fields304[1] - _t1022 = self.pretty_script(field306) + _t1023 = self.pretty_script(field306) self.dedent() self.write(')') return None def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: - def _t1023(_dollar_dollar): + def _t1024(_dollar_dollar): return _dollar_dollar - _t1024 = _t1023(msg) - fields307 = _t1024 + _t1025 = _t1024(msg) + fields307 = _t1025 unwrapped_fields308 = fields307 self.write('(') self.write('init') @@ -2714,311 +2719,311 @@ def _t1023(_dollar_dollar): if (i310 > 0): self.newline() - _t1025 = None + _t1026 = None else: - _t1025 = None - _t1026 = self.pretty_instruction(elem309) + _t1026 = None + _t1027 = self.pretty_instruction(elem309) self.dedent() self.write(')') return None def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: - def _t1027(_dollar_dollar): + def _t1028(_dollar_dollar): if _dollar_dollar.HasField('assign'): - _t1028 = _dollar_dollar.assign + _t1029 = _dollar_dollar.assign else: - _t1028 = None - return _t1028 - _t1029 = _t1027(msg) - deconstruct_result315 = _t1029 + _t1029 = None + return _t1029 + _t1030 = _t1028(msg) + deconstruct_result315 = _t1030 if deconstruct_result315 is not None: - _t1031 = self.pretty_assign(deconstruct_result315) - _t1030 = _t1031 + _t1032 = self.pretty_assign(deconstruct_result315) + _t1031 = _t1032 else: - def _t1032(_dollar_dollar): + def _t1033(_dollar_dollar): if _dollar_dollar.HasField('upsert'): - _t1033 = _dollar_dollar.upsert + _t1034 = _dollar_dollar.upsert else: - _t1033 = None - return _t1033 - _t1034 = _t1032(msg) - deconstruct_result314 = _t1034 + _t1034 = None + return _t1034 + _t1035 = _t1033(msg) + deconstruct_result314 = _t1035 if deconstruct_result314 is not None: - _t1036 = self.pretty_upsert(deconstruct_result314) - _t1035 = _t1036 + _t1037 = self.pretty_upsert(deconstruct_result314) + _t1036 = _t1037 else: - def _t1037(_dollar_dollar): + def _t1038(_dollar_dollar): if _dollar_dollar.HasField('break'): - _t1038 = getattr(_dollar_dollar, 'break') + _t1039 = getattr(_dollar_dollar, 'break') else: - _t1038 = None - return _t1038 - _t1039 = _t1037(msg) - deconstruct_result313 = _t1039 + _t1039 = None + return _t1039 + _t1040 = _t1038(msg) + deconstruct_result313 = _t1040 if deconstruct_result313 is not None: - _t1041 = self.pretty_break(deconstruct_result313) - _t1040 = _t1041 + _t1042 = self.pretty_break(deconstruct_result313) + _t1041 = _t1042 else: - def _t1042(_dollar_dollar): + def _t1043(_dollar_dollar): if _dollar_dollar.HasField('monoid_def'): - _t1043 = _dollar_dollar.monoid_def + _t1044 = _dollar_dollar.monoid_def else: - _t1043 = None - return _t1043 - _t1044 = _t1042(msg) - deconstruct_result312 = _t1044 + _t1044 = None + return _t1044 + _t1045 = _t1043(msg) + deconstruct_result312 = _t1045 if deconstruct_result312 is not None: - _t1046 = self.pretty_monoid_def(deconstruct_result312) - _t1045 = _t1046 + _t1047 = self.pretty_monoid_def(deconstruct_result312) + _t1046 = _t1047 else: - def _t1047(_dollar_dollar): + def _t1048(_dollar_dollar): if _dollar_dollar.HasField('monus_def'): - _t1048 = _dollar_dollar.monus_def + _t1049 = _dollar_dollar.monus_def else: - _t1048 = None - return _t1048 - _t1049 = _t1047(msg) - deconstruct_result311 = _t1049 + _t1049 = None + return _t1049 + _t1050 = _t1048(msg) + deconstruct_result311 = _t1050 if deconstruct_result311 is not None: - _t1051 = self.pretty_monus_def(deconstruct_result311) - _t1050 = _t1051 + _t1052 = self.pretty_monus_def(deconstruct_result311) + _t1051 = _t1052 else: raise ParseError('No matching rule for instruction') - _t1045 = _t1050 - _t1040 = _t1045 - _t1035 = _t1040 - _t1030 = _t1035 - return _t1030 + _t1046 = _t1051 + _t1041 = _t1046 + _t1036 = _t1041 + _t1031 = _t1036 + return _t1031 def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: - def _t1052(_dollar_dollar): + def _t1053(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1053 = _dollar_dollar.attrs + _t1054 = _dollar_dollar.attrs else: - _t1053 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1053,) - _t1054 = _t1052(msg) - fields316 = _t1054 + _t1054 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1054,) + _t1055 = _t1053(msg) + fields316 = _t1055 unwrapped_fields317 = fields316 self.write('(') self.write('assign') self.indent() self.newline() field318 = unwrapped_fields317[0] - _t1055 = self.pretty_relation_id(field318) + _t1056 = self.pretty_relation_id(field318) self.newline() field319 = unwrapped_fields317[1] - _t1056 = self.pretty_abstraction(field319) + _t1057 = self.pretty_abstraction(field319) field320 = unwrapped_fields317[2] if field320 is not None: self.newline() opt_val321 = field320 - _t1058 = self.pretty_attrs(opt_val321) - _t1057 = _t1058 + _t1059 = self.pretty_attrs(opt_val321) + _t1058 = _t1059 else: - _t1057 = None + _t1058 = None self.dedent() self.write(')') return None def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: - def _t1059(_dollar_dollar): + def _t1060(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1060 = _dollar_dollar.attrs + _t1061 = _dollar_dollar.attrs else: - _t1060 = None - return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1060,) - _t1061 = _t1059(msg) - fields322 = _t1061 + _t1061 = None + return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1061,) + _t1062 = _t1060(msg) + fields322 = _t1062 unwrapped_fields323 = fields322 self.write('(') self.write('upsert') self.indent() self.newline() field324 = unwrapped_fields323[0] - _t1062 = self.pretty_relation_id(field324) + _t1063 = self.pretty_relation_id(field324) self.newline() field325 = unwrapped_fields323[1] - _t1063 = self.pretty_abstraction_with_arity(field325) + _t1064 = self.pretty_abstraction_with_arity(field325) field326 = unwrapped_fields323[2] if field326 is not None: self.newline() opt_val327 = field326 - _t1065 = self.pretty_attrs(opt_val327) - _t1064 = _t1065 + _t1066 = self.pretty_attrs(opt_val327) + _t1065 = _t1066 else: - _t1064 = None + _t1065 = None self.dedent() self.write(')') return None def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: - def _t1066(_dollar_dollar): - _t1067 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) - return (_t1067, _dollar_dollar[0].value,) - _t1068 = _t1066(msg) - fields328 = _t1068 + def _t1067(_dollar_dollar): + _t1068 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) + return (_t1068, _dollar_dollar[0].value,) + _t1069 = _t1067(msg) + fields328 = _t1069 unwrapped_fields329 = fields328 self.write('(') field330 = unwrapped_fields329[0] - _t1069 = self.pretty_bindings(field330) + _t1070 = self.pretty_bindings(field330) self.write(' ') field331 = unwrapped_fields329[1] - _t1070 = self.pretty_formula(field331) + _t1071 = self.pretty_formula(field331) self.write(')') return None def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: - def _t1071(_dollar_dollar): + def _t1072(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1072 = _dollar_dollar.attrs + _t1073 = _dollar_dollar.attrs else: - _t1072 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1072,) - _t1073 = _t1071(msg) - fields332 = _t1073 + _t1073 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1073,) + _t1074 = _t1072(msg) + fields332 = _t1074 unwrapped_fields333 = fields332 self.write('(') self.write('break') self.indent() self.newline() field334 = unwrapped_fields333[0] - _t1074 = self.pretty_relation_id(field334) + _t1075 = self.pretty_relation_id(field334) self.newline() field335 = unwrapped_fields333[1] - _t1075 = self.pretty_abstraction(field335) + _t1076 = self.pretty_abstraction(field335) field336 = unwrapped_fields333[2] if field336 is not None: self.newline() opt_val337 = field336 - _t1077 = self.pretty_attrs(opt_val337) - _t1076 = _t1077 + _t1078 = self.pretty_attrs(opt_val337) + _t1077 = _t1078 else: - _t1076 = None + _t1077 = None self.dedent() self.write(')') return None def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: - def _t1078(_dollar_dollar): + def _t1079(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1079 = _dollar_dollar.attrs + _t1080 = _dollar_dollar.attrs else: - _t1079 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1079,) - _t1080 = _t1078(msg) - fields338 = _t1080 + _t1080 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1080,) + _t1081 = _t1079(msg) + fields338 = _t1081 unwrapped_fields339 = fields338 self.write('(') self.write('monoid') self.indent() self.newline() field340 = unwrapped_fields339[0] - _t1081 = self.pretty_monoid(field340) + _t1082 = self.pretty_monoid(field340) self.newline() field341 = unwrapped_fields339[1] - _t1082 = self.pretty_relation_id(field341) + _t1083 = self.pretty_relation_id(field341) self.newline() field342 = unwrapped_fields339[2] - _t1083 = self.pretty_abstraction_with_arity(field342) + _t1084 = self.pretty_abstraction_with_arity(field342) field343 = unwrapped_fields339[3] if field343 is not None: self.newline() opt_val344 = field343 - _t1085 = self.pretty_attrs(opt_val344) - _t1084 = _t1085 + _t1086 = self.pretty_attrs(opt_val344) + _t1085 = _t1086 else: - _t1084 = None + _t1085 = None self.dedent() self.write(')') return None def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: - def _t1086(_dollar_dollar): + def _t1087(_dollar_dollar): if _dollar_dollar.HasField('or_monoid'): - _t1087 = _dollar_dollar.or_monoid + _t1088 = _dollar_dollar.or_monoid else: - _t1087 = None - return _t1087 - _t1088 = _t1086(msg) - deconstruct_result348 = _t1088 + _t1088 = None + return _t1088 + _t1089 = _t1087(msg) + deconstruct_result348 = _t1089 if deconstruct_result348 is not None: - _t1090 = self.pretty_or_monoid(deconstruct_result348) - _t1089 = _t1090 + _t1091 = self.pretty_or_monoid(deconstruct_result348) + _t1090 = _t1091 else: - def _t1091(_dollar_dollar): + def _t1092(_dollar_dollar): if _dollar_dollar.HasField('min_monoid'): - _t1092 = _dollar_dollar.min_monoid + _t1093 = _dollar_dollar.min_monoid else: - _t1092 = None - return _t1092 - _t1093 = _t1091(msg) - deconstruct_result347 = _t1093 + _t1093 = None + return _t1093 + _t1094 = _t1092(msg) + deconstruct_result347 = _t1094 if deconstruct_result347 is not None: - _t1095 = self.pretty_min_monoid(deconstruct_result347) - _t1094 = _t1095 + _t1096 = self.pretty_min_monoid(deconstruct_result347) + _t1095 = _t1096 else: - def _t1096(_dollar_dollar): + def _t1097(_dollar_dollar): if _dollar_dollar.HasField('max_monoid'): - _t1097 = _dollar_dollar.max_monoid + _t1098 = _dollar_dollar.max_monoid else: - _t1097 = None - return _t1097 - _t1098 = _t1096(msg) - deconstruct_result346 = _t1098 + _t1098 = None + return _t1098 + _t1099 = _t1097(msg) + deconstruct_result346 = _t1099 if deconstruct_result346 is not None: - _t1100 = self.pretty_max_monoid(deconstruct_result346) - _t1099 = _t1100 + _t1101 = self.pretty_max_monoid(deconstruct_result346) + _t1100 = _t1101 else: - def _t1101(_dollar_dollar): + def _t1102(_dollar_dollar): if _dollar_dollar.HasField('sum_monoid'): - _t1102 = _dollar_dollar.sum_monoid + _t1103 = _dollar_dollar.sum_monoid else: - _t1102 = None - return _t1102 - _t1103 = _t1101(msg) - deconstruct_result345 = _t1103 + _t1103 = None + return _t1103 + _t1104 = _t1102(msg) + deconstruct_result345 = _t1104 if deconstruct_result345 is not None: - _t1105 = self.pretty_sum_monoid(deconstruct_result345) - _t1104 = _t1105 + _t1106 = self.pretty_sum_monoid(deconstruct_result345) + _t1105 = _t1106 else: raise ParseError('No matching rule for monoid') - _t1099 = _t1104 - _t1094 = _t1099 - _t1089 = _t1094 - return _t1089 + _t1100 = _t1105 + _t1095 = _t1100 + _t1090 = _t1095 + return _t1090 def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: - def _t1106(_dollar_dollar): + def _t1107(_dollar_dollar): return _dollar_dollar - _t1107 = _t1106(msg) - fields349 = _t1107 + _t1108 = _t1107(msg) + fields349 = _t1108 unwrapped_fields350 = fields349 self.write('(') self.write('or') @@ -3026,116 +3031,116 @@ def _t1106(_dollar_dollar): return None def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: - def _t1108(_dollar_dollar): + def _t1109(_dollar_dollar): return _dollar_dollar.type - _t1109 = _t1108(msg) - fields351 = _t1109 + _t1110 = _t1109(msg) + fields351 = _t1110 unwrapped_fields352 = fields351 self.write('(') self.write('min') self.indent() self.newline() - _t1110 = self.pretty_type(unwrapped_fields352) + _t1111 = self.pretty_type(unwrapped_fields352) self.dedent() self.write(')') return None def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: - def _t1111(_dollar_dollar): + def _t1112(_dollar_dollar): return _dollar_dollar.type - _t1112 = _t1111(msg) - fields353 = _t1112 + _t1113 = _t1112(msg) + fields353 = _t1113 unwrapped_fields354 = fields353 self.write('(') self.write('max') self.indent() self.newline() - _t1113 = self.pretty_type(unwrapped_fields354) + _t1114 = self.pretty_type(unwrapped_fields354) self.dedent() self.write(')') return None def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: - def _t1114(_dollar_dollar): + def _t1115(_dollar_dollar): return _dollar_dollar.type - _t1115 = _t1114(msg) - fields355 = _t1115 + _t1116 = _t1115(msg) + fields355 = _t1116 unwrapped_fields356 = fields355 self.write('(') self.write('sum') self.indent() self.newline() - _t1116 = self.pretty_type(unwrapped_fields356) + _t1117 = self.pretty_type(unwrapped_fields356) self.dedent() self.write(')') return None def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: - def _t1117(_dollar_dollar): + def _t1118(_dollar_dollar): if not len(_dollar_dollar.attrs) == 0: - _t1118 = _dollar_dollar.attrs + _t1119 = _dollar_dollar.attrs else: - _t1118 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1118,) - _t1119 = _t1117(msg) - fields357 = _t1119 + _t1119 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1119,) + _t1120 = _t1118(msg) + fields357 = _t1120 unwrapped_fields358 = fields357 self.write('(') self.write('monus') self.indent() self.newline() field359 = unwrapped_fields358[0] - _t1120 = self.pretty_monoid(field359) + _t1121 = self.pretty_monoid(field359) self.newline() field360 = unwrapped_fields358[1] - _t1121 = self.pretty_relation_id(field360) + _t1122 = self.pretty_relation_id(field360) self.newline() field361 = unwrapped_fields358[2] - _t1122 = self.pretty_abstraction_with_arity(field361) + _t1123 = self.pretty_abstraction_with_arity(field361) field362 = unwrapped_fields358[3] if field362 is not None: self.newline() opt_val363 = field362 - _t1124 = self.pretty_attrs(opt_val363) - _t1123 = _t1124 + _t1125 = self.pretty_attrs(opt_val363) + _t1124 = _t1125 else: - _t1123 = None + _t1124 = None self.dedent() self.write(')') return None def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: - def _t1125(_dollar_dollar): + def _t1126(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) - _t1126 = _t1125(msg) - fields364 = _t1126 + _t1127 = _t1126(msg) + fields364 = _t1127 unwrapped_fields365 = fields364 self.write('(') self.write('functional_dependency') self.indent() self.newline() field366 = unwrapped_fields365[0] - _t1127 = self.pretty_relation_id(field366) + _t1128 = self.pretty_relation_id(field366) self.newline() field367 = unwrapped_fields365[1] - _t1128 = self.pretty_abstraction(field367) + _t1129 = self.pretty_abstraction(field367) self.newline() field368 = unwrapped_fields365[2] - _t1129 = self.pretty_functional_dependency_keys(field368) + _t1130 = self.pretty_functional_dependency_keys(field368) self.newline() field369 = unwrapped_fields365[3] - _t1130 = self.pretty_functional_dependency_values(field369) + _t1131 = self.pretty_functional_dependency_values(field369) self.dedent() self.write(')') return None def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1131(_dollar_dollar): + def _t1132(_dollar_dollar): return _dollar_dollar - _t1132 = _t1131(msg) - fields370 = _t1132 + _t1133 = _t1132(msg) + fields370 = _t1133 unwrapped_fields371 = fields370 self.write('(') self.write('keys') @@ -3146,19 +3151,19 @@ def _t1131(_dollar_dollar): if (i373 > 0): self.newline() - _t1133 = None + _t1134 = None else: - _t1133 = None - _t1134 = self.pretty_var(elem372) + _t1134 = None + _t1135 = self.pretty_var(elem372) self.dedent() self.write(')') return None def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1135(_dollar_dollar): + def _t1136(_dollar_dollar): return _dollar_dollar - _t1136 = _t1135(msg) - fields374 = _t1136 + _t1137 = _t1136(msg) + fields374 = _t1137 unwrapped_fields375 = fields374 self.write('(') self.write('values') @@ -3169,167 +3174,167 @@ def _t1135(_dollar_dollar): if (i377 > 0): self.newline() - _t1137 = None + _t1138 = None else: - _t1137 = None - _t1138 = self.pretty_var(elem376) + _t1138 = None + _t1139 = self.pretty_var(elem376) self.dedent() self.write(')') return None def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: - def _t1139(_dollar_dollar): + def _t1140(_dollar_dollar): if _dollar_dollar.HasField('rel_edb'): - _t1140 = _dollar_dollar.rel_edb + _t1141 = _dollar_dollar.rel_edb else: - _t1140 = None - return _t1140 - _t1141 = _t1139(msg) - deconstruct_result380 = _t1141 + _t1141 = None + return _t1141 + _t1142 = _t1140(msg) + deconstruct_result380 = _t1142 if deconstruct_result380 is not None: - _t1143 = self.pretty_rel_edb(deconstruct_result380) - _t1142 = _t1143 + _t1144 = self.pretty_rel_edb(deconstruct_result380) + _t1143 = _t1144 else: - def _t1144(_dollar_dollar): + def _t1145(_dollar_dollar): if _dollar_dollar.HasField('betree_relation'): - _t1145 = _dollar_dollar.betree_relation + _t1146 = _dollar_dollar.betree_relation else: - _t1145 = None - return _t1145 - _t1146 = _t1144(msg) - deconstruct_result379 = _t1146 + _t1146 = None + return _t1146 + _t1147 = _t1145(msg) + deconstruct_result379 = _t1147 if deconstruct_result379 is not None: - _t1148 = self.pretty_betree_relation(deconstruct_result379) - _t1147 = _t1148 + _t1149 = self.pretty_betree_relation(deconstruct_result379) + _t1148 = _t1149 else: - def _t1149(_dollar_dollar): + def _t1150(_dollar_dollar): if _dollar_dollar.HasField('csv_data'): - _t1150 = _dollar_dollar.csv_data + _t1151 = _dollar_dollar.csv_data else: - _t1150 = None - return _t1150 - _t1151 = _t1149(msg) - deconstruct_result378 = _t1151 + _t1151 = None + return _t1151 + _t1152 = _t1150(msg) + deconstruct_result378 = _t1152 if deconstruct_result378 is not None: - _t1153 = self.pretty_csv_data(deconstruct_result378) - _t1152 = _t1153 + _t1154 = self.pretty_csv_data(deconstruct_result378) + _t1153 = _t1154 else: raise ParseError('No matching rule for data') - _t1147 = _t1152 - _t1142 = _t1147 - return _t1142 + _t1148 = _t1153 + _t1143 = _t1148 + return _t1143 def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: - def _t1154(_dollar_dollar): + def _t1155(_dollar_dollar): return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) - _t1155 = _t1154(msg) - fields381 = _t1155 + _t1156 = _t1155(msg) + fields381 = _t1156 unwrapped_fields382 = fields381 self.write('(') self.write('rel_edb') self.indent() self.newline() field383 = unwrapped_fields382[0] - _t1156 = self.pretty_relation_id(field383) + _t1157 = self.pretty_relation_id(field383) self.newline() field384 = unwrapped_fields382[1] - _t1157 = self.pretty_rel_edb_path(field384) + _t1158 = self.pretty_rel_edb_path(field384) self.newline() field385 = unwrapped_fields382[2] - _t1158 = self.pretty_rel_edb_types(field385) + _t1159 = self.pretty_rel_edb_types(field385) self.dedent() self.write(')') return None def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: - def _t1159(_dollar_dollar): + def _t1160(_dollar_dollar): return _dollar_dollar - _t1160 = _t1159(msg) - fields386 = _t1160 + _t1161 = _t1160(msg) + fields386 = _t1161 unwrapped_fields387 = fields386 self.write('[') for i389, elem388 in enumerate(unwrapped_fields387): if (i389 > 0): self.newline() - _t1161 = None + _t1162 = None else: - _t1161 = None + _t1162 = None self.write(self.format_string_value(elem388)) self.write(']') return None def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1162(_dollar_dollar): + def _t1163(_dollar_dollar): return _dollar_dollar - _t1163 = _t1162(msg) - fields390 = _t1163 + _t1164 = _t1163(msg) + fields390 = _t1164 unwrapped_fields391 = fields390 self.write('[') for i393, elem392 in enumerate(unwrapped_fields391): if (i393 > 0): self.newline() - _t1164 = None + _t1165 = None else: - _t1164 = None - _t1165 = self.pretty_type(elem392) + _t1165 = None + _t1166 = self.pretty_type(elem392) self.write(']') return None def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: - def _t1166(_dollar_dollar): + def _t1167(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_info,) - _t1167 = _t1166(msg) - fields394 = _t1167 + _t1168 = _t1167(msg) + fields394 = _t1168 unwrapped_fields395 = fields394 self.write('(') self.write('betree_relation') self.indent() self.newline() field396 = unwrapped_fields395[0] - _t1168 = self.pretty_relation_id(field396) + _t1169 = self.pretty_relation_id(field396) self.newline() field397 = unwrapped_fields395[1] - _t1169 = self.pretty_betree_info(field397) + _t1170 = self.pretty_betree_info(field397) self.dedent() self.write(')') return None def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: - def _t1170(_dollar_dollar): - _t1171 = self.deconstruct_betree_info_config(_dollar_dollar) - return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1171,) - _t1172 = _t1170(msg) - fields398 = _t1172 + def _t1171(_dollar_dollar): + _t1172 = self.deconstruct_betree_info_config(_dollar_dollar) + return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1172,) + _t1173 = _t1171(msg) + fields398 = _t1173 unwrapped_fields399 = fields398 self.write('(') self.write('betree_info') self.indent() self.newline() field400 = unwrapped_fields399[0] - _t1173 = self.pretty_betree_info_key_types(field400) + _t1174 = self.pretty_betree_info_key_types(field400) self.newline() field401 = unwrapped_fields399[1] - _t1174 = self.pretty_betree_info_value_types(field401) + _t1175 = self.pretty_betree_info_value_types(field401) self.newline() field402 = unwrapped_fields399[2] - _t1175 = self.pretty_config_dict(field402) + _t1176 = self.pretty_config_dict(field402) self.dedent() self.write(')') return None def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1176(_dollar_dollar): + def _t1177(_dollar_dollar): return _dollar_dollar - _t1177 = _t1176(msg) - fields403 = _t1177 + _t1178 = _t1177(msg) + fields403 = _t1178 unwrapped_fields404 = fields403 self.write('(') self.write('key_types') @@ -3340,19 +3345,19 @@ def _t1176(_dollar_dollar): if (i406 > 0): self.newline() - _t1178 = None + _t1179 = None else: - _t1178 = None - _t1179 = self.pretty_type(elem405) + _t1179 = None + _t1180 = self.pretty_type(elem405) self.dedent() self.write(')') return None def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1180(_dollar_dollar): + def _t1181(_dollar_dollar): return _dollar_dollar - _t1181 = _t1180(msg) - fields407 = _t1181 + _t1182 = _t1181(msg) + fields407 = _t1182 unwrapped_fields408 = fields407 self.write('(') self.write('value_types') @@ -3363,54 +3368,54 @@ def _t1180(_dollar_dollar): if (i410 > 0): self.newline() - _t1182 = None + _t1183 = None else: - _t1182 = None - _t1183 = self.pretty_type(elem409) + _t1183 = None + _t1184 = self.pretty_type(elem409) self.dedent() self.write(')') return None def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: - def _t1184(_dollar_dollar): + def _t1185(_dollar_dollar): return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) - _t1185 = _t1184(msg) - fields411 = _t1185 + _t1186 = _t1185(msg) + fields411 = _t1186 unwrapped_fields412 = fields411 self.write('(') self.write('csv_data') self.indent() self.newline() field413 = unwrapped_fields412[0] - _t1186 = self.pretty_csvlocator(field413) + _t1187 = self.pretty_csvlocator(field413) self.newline() field414 = unwrapped_fields412[1] - _t1187 = self.pretty_csv_config(field414) + _t1188 = self.pretty_csv_config(field414) self.newline() field415 = unwrapped_fields412[2] - _t1188 = self.pretty_csv_columns(field415) + _t1189 = self.pretty_csv_columns(field415) self.newline() field416 = unwrapped_fields412[3] - _t1189 = self.pretty_csv_asof(field416) + _t1190 = self.pretty_csv_asof(field416) self.dedent() self.write(')') return None def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: - def _t1190(_dollar_dollar): + def _t1191(_dollar_dollar): if not len(_dollar_dollar.paths) == 0: - _t1191 = _dollar_dollar.paths + _t1192 = _dollar_dollar.paths else: - _t1191 = None + _t1192 = None if _dollar_dollar.inline_data.decode('utf-8') != '': - _t1192 = _dollar_dollar.inline_data.decode('utf-8') + _t1193 = _dollar_dollar.inline_data.decode('utf-8') else: - _t1192 = None - return (_t1191, _t1192,) - _t1193 = _t1190(msg) - fields417 = _t1193 + _t1193 = None + return (_t1192, _t1193,) + _t1194 = _t1191(msg) + fields417 = _t1194 unwrapped_fields418 = fields417 self.write('(') self.write('csv_locator') @@ -3420,28 +3425,28 @@ def _t1190(_dollar_dollar): if field419 is not None: self.newline() opt_val420 = field419 - _t1195 = self.pretty_csv_locator_paths(opt_val420) - _t1194 = _t1195 + _t1196 = self.pretty_csv_locator_paths(opt_val420) + _t1195 = _t1196 else: - _t1194 = None + _t1195 = None field421 = unwrapped_fields418[1] if field421 is not None: self.newline() opt_val422 = field421 - _t1197 = self.pretty_csv_locator_inline_data(opt_val422) - _t1196 = _t1197 + _t1198 = self.pretty_csv_locator_inline_data(opt_val422) + _t1197 = _t1198 else: - _t1196 = None + _t1197 = None self.dedent() self.write(')') return None def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: - def _t1198(_dollar_dollar): + def _t1199(_dollar_dollar): return _dollar_dollar - _t1199 = _t1198(msg) - fields423 = _t1199 + _t1200 = _t1199(msg) + fields423 = _t1200 unwrapped_fields424 = fields423 self.write('(') self.write('paths') @@ -3452,19 +3457,19 @@ def _t1198(_dollar_dollar): if (i426 > 0): self.newline() - _t1200 = None + _t1201 = None else: - _t1200 = None + _t1201 = None self.write(self.format_string_value(elem425)) self.dedent() self.write(')') return None def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: - def _t1201(_dollar_dollar): + def _t1202(_dollar_dollar): return _dollar_dollar - _t1202 = _t1201(msg) - fields427 = _t1202 + _t1203 = _t1202(msg) + fields427 = _t1203 unwrapped_fields428 = fields427 self.write('(') self.write('inline_data') @@ -3476,26 +3481,26 @@ def _t1201(_dollar_dollar): return None def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: - def _t1203(_dollar_dollar): - _t1204 = self.deconstruct_csv_config(_dollar_dollar) - return _t1204 - _t1205 = _t1203(msg) - fields429 = _t1205 + def _t1204(_dollar_dollar): + _t1205 = self.deconstruct_csv_config(_dollar_dollar) + return _t1205 + _t1206 = _t1204(msg) + fields429 = _t1206 unwrapped_fields430 = fields429 self.write('(') self.write('csv_config') self.indent() self.newline() - _t1206 = self.pretty_config_dict(unwrapped_fields430) + _t1207 = self.pretty_config_dict(unwrapped_fields430) self.dedent() self.write(')') return None def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: - def _t1207(_dollar_dollar): + def _t1208(_dollar_dollar): return _dollar_dollar - _t1208 = _t1207(msg) - fields431 = _t1208 + _t1209 = _t1208(msg) + fields431 = _t1209 unwrapped_fields432 = fields431 self.write('(') self.write('columns') @@ -3506,19 +3511,19 @@ def _t1207(_dollar_dollar): if (i434 > 0): self.newline() - _t1209 = None + _t1210 = None else: - _t1209 = None - _t1210 = self.pretty_csv_column(elem433) + _t1210 = None + _t1211 = self.pretty_csv_column(elem433) self.dedent() self.write(')') return None def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: - def _t1211(_dollar_dollar): + def _t1212(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) - _t1212 = _t1211(msg) - fields435 = _t1212 + _t1213 = _t1212(msg) + fields435 = _t1213 unwrapped_fields436 = fields435 self.write('(') self.write('column') @@ -3528,7 +3533,7 @@ def _t1211(_dollar_dollar): self.write(self.format_string_value(field437)) self.newline() field438 = unwrapped_fields436[1] - _t1213 = self.pretty_relation_id(field438) + _t1214 = self.pretty_relation_id(field438) self.write('[') field439 = unwrapped_fields436[2] if not len(field439) == 0: @@ -3537,20 +3542,20 @@ def _t1211(_dollar_dollar): if (i441 > 0): self.newline() - _t1214 = None + _t1215 = None else: - _t1214 = None - _t1215 = self.pretty_type(elem440) + _t1215 = None + _t1216 = self.pretty_type(elem440) self.write(']') self.dedent() self.write(')') return None def pretty_csv_asof(self, msg: str) -> Optional[Never]: - def _t1216(_dollar_dollar): + def _t1217(_dollar_dollar): return _dollar_dollar - _t1217 = _t1216(msg) - fields442 = _t1217 + _t1218 = _t1217(msg) + fields442 = _t1218 unwrapped_fields443 = fields442 self.write('(') self.write('asof') @@ -3562,25 +3567,25 @@ def _t1216(_dollar_dollar): return None def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: - def _t1218(_dollar_dollar): + def _t1219(_dollar_dollar): return _dollar_dollar.fragment_id - _t1219 = _t1218(msg) - fields444 = _t1219 + _t1220 = _t1219(msg) + fields444 = _t1220 unwrapped_fields445 = fields444 self.write('(') self.write('undefine') self.indent() self.newline() - _t1220 = self.pretty_fragment_id(unwrapped_fields445) + _t1221 = self.pretty_fragment_id(unwrapped_fields445) self.dedent() self.write(')') return None def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: - def _t1221(_dollar_dollar): + def _t1222(_dollar_dollar): return _dollar_dollar.relations - _t1222 = _t1221(msg) - fields446 = _t1222 + _t1223 = _t1222(msg) + fields446 = _t1223 unwrapped_fields447 = fields446 self.write('(') self.write('context') @@ -3591,19 +3596,19 @@ def _t1221(_dollar_dollar): if (i449 > 0): self.newline() - _t1223 = None + _t1224 = None else: - _t1223 = None - _t1224 = self.pretty_relation_id(elem448) + _t1224 = None + _t1225 = self.pretty_relation_id(elem448) self.dedent() self.write(')') return None def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: - def _t1225(_dollar_dollar): + def _t1226(_dollar_dollar): return _dollar_dollar - _t1226 = _t1225(msg) - fields450 = _t1226 + _t1227 = _t1226(msg) + fields450 = _t1227 unwrapped_fields451 = fields450 self.write('(') self.write('reads') @@ -3614,155 +3619,155 @@ def _t1225(_dollar_dollar): if (i453 > 0): self.newline() - _t1227 = None + _t1228 = None else: - _t1227 = None - _t1228 = self.pretty_read(elem452) + _t1228 = None + _t1229 = self.pretty_read(elem452) self.dedent() self.write(')') return None def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: - def _t1229(_dollar_dollar): + def _t1230(_dollar_dollar): if _dollar_dollar.HasField('demand'): - _t1230 = _dollar_dollar.demand + _t1231 = _dollar_dollar.demand else: - _t1230 = None - return _t1230 - _t1231 = _t1229(msg) - deconstruct_result458 = _t1231 + _t1231 = None + return _t1231 + _t1232 = _t1230(msg) + deconstruct_result458 = _t1232 if deconstruct_result458 is not None: - _t1233 = self.pretty_demand(deconstruct_result458) - _t1232 = _t1233 + _t1234 = self.pretty_demand(deconstruct_result458) + _t1233 = _t1234 else: - def _t1234(_dollar_dollar): + def _t1235(_dollar_dollar): if _dollar_dollar.HasField('output'): - _t1235 = _dollar_dollar.output + _t1236 = _dollar_dollar.output else: - _t1235 = None - return _t1235 - _t1236 = _t1234(msg) - deconstruct_result457 = _t1236 + _t1236 = None + return _t1236 + _t1237 = _t1235(msg) + deconstruct_result457 = _t1237 if deconstruct_result457 is not None: - _t1238 = self.pretty_output(deconstruct_result457) - _t1237 = _t1238 + _t1239 = self.pretty_output(deconstruct_result457) + _t1238 = _t1239 else: - def _t1239(_dollar_dollar): + def _t1240(_dollar_dollar): if _dollar_dollar.HasField('what_if'): - _t1240 = _dollar_dollar.what_if + _t1241 = _dollar_dollar.what_if else: - _t1240 = None - return _t1240 - _t1241 = _t1239(msg) - deconstruct_result456 = _t1241 + _t1241 = None + return _t1241 + _t1242 = _t1240(msg) + deconstruct_result456 = _t1242 if deconstruct_result456 is not None: - _t1243 = self.pretty_what_if(deconstruct_result456) - _t1242 = _t1243 + _t1244 = self.pretty_what_if(deconstruct_result456) + _t1243 = _t1244 else: - def _t1244(_dollar_dollar): + def _t1245(_dollar_dollar): if _dollar_dollar.HasField('abort'): - _t1245 = _dollar_dollar.abort + _t1246 = _dollar_dollar.abort else: - _t1245 = None - return _t1245 - _t1246 = _t1244(msg) - deconstruct_result455 = _t1246 + _t1246 = None + return _t1246 + _t1247 = _t1245(msg) + deconstruct_result455 = _t1247 if deconstruct_result455 is not None: - _t1248 = self.pretty_abort(deconstruct_result455) - _t1247 = _t1248 + _t1249 = self.pretty_abort(deconstruct_result455) + _t1248 = _t1249 else: - def _t1249(_dollar_dollar): + def _t1250(_dollar_dollar): if _dollar_dollar.HasField('export'): - _t1250 = _dollar_dollar.export + _t1251 = _dollar_dollar.export else: - _t1250 = None - return _t1250 - _t1251 = _t1249(msg) - deconstruct_result454 = _t1251 + _t1251 = None + return _t1251 + _t1252 = _t1250(msg) + deconstruct_result454 = _t1252 if deconstruct_result454 is not None: - _t1253 = self.pretty_export(deconstruct_result454) - _t1252 = _t1253 + _t1254 = self.pretty_export(deconstruct_result454) + _t1253 = _t1254 else: raise ParseError('No matching rule for read') - _t1247 = _t1252 - _t1242 = _t1247 - _t1237 = _t1242 - _t1232 = _t1237 - return _t1232 + _t1248 = _t1253 + _t1243 = _t1248 + _t1238 = _t1243 + _t1233 = _t1238 + return _t1233 def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: - def _t1254(_dollar_dollar): + def _t1255(_dollar_dollar): return _dollar_dollar.relation_id - _t1255 = _t1254(msg) - fields459 = _t1255 + _t1256 = _t1255(msg) + fields459 = _t1256 unwrapped_fields460 = fields459 self.write('(') self.write('demand') self.indent() self.newline() - _t1256 = self.pretty_relation_id(unwrapped_fields460) + _t1257 = self.pretty_relation_id(unwrapped_fields460) self.dedent() self.write(')') return None def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: - def _t1257(_dollar_dollar): + def _t1258(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_id,) - _t1258 = _t1257(msg) - fields461 = _t1258 + _t1259 = _t1258(msg) + fields461 = _t1259 unwrapped_fields462 = fields461 self.write('(') self.write('output') self.indent() self.newline() field463 = unwrapped_fields462[0] - _t1259 = self.pretty_name(field463) + _t1260 = self.pretty_name(field463) self.newline() field464 = unwrapped_fields462[1] - _t1260 = self.pretty_relation_id(field464) + _t1261 = self.pretty_relation_id(field464) self.dedent() self.write(')') return None def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: - def _t1261(_dollar_dollar): + def _t1262(_dollar_dollar): return (_dollar_dollar.branch, _dollar_dollar.epoch,) - _t1262 = _t1261(msg) - fields465 = _t1262 + _t1263 = _t1262(msg) + fields465 = _t1263 unwrapped_fields466 = fields465 self.write('(') self.write('what_if') self.indent() self.newline() field467 = unwrapped_fields466[0] - _t1263 = self.pretty_name(field467) + _t1264 = self.pretty_name(field467) self.newline() field468 = unwrapped_fields466[1] - _t1264 = self.pretty_epoch(field468) + _t1265 = self.pretty_epoch(field468) self.dedent() self.write(')') return None def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: - def _t1265(_dollar_dollar): + def _t1266(_dollar_dollar): if _dollar_dollar.name != 'abort': - _t1266 = _dollar_dollar.name + _t1267 = _dollar_dollar.name else: - _t1266 = None - return (_t1266, _dollar_dollar.relation_id,) - _t1267 = _t1265(msg) - fields469 = _t1267 + _t1267 = None + return (_t1267, _dollar_dollar.relation_id,) + _t1268 = _t1266(msg) + fields469 = _t1268 unwrapped_fields470 = fields469 self.write('(') self.write('abort') @@ -3772,60 +3777,60 @@ def _t1265(_dollar_dollar): if field471 is not None: self.newline() opt_val472 = field471 - _t1269 = self.pretty_name(opt_val472) - _t1268 = _t1269 + _t1270 = self.pretty_name(opt_val472) + _t1269 = _t1270 else: - _t1268 = None + _t1269 = None self.newline() field473 = unwrapped_fields470[1] - _t1270 = self.pretty_relation_id(field473) + _t1271 = self.pretty_relation_id(field473) self.dedent() self.write(')') return None def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: - def _t1271(_dollar_dollar): + def _t1272(_dollar_dollar): return _dollar_dollar.csv_config - _t1272 = _t1271(msg) - fields474 = _t1272 + _t1273 = _t1272(msg) + fields474 = _t1273 unwrapped_fields475 = fields474 self.write('(') self.write('export') self.indent() self.newline() - _t1273 = self.pretty_export_csv_config(unwrapped_fields475) + _t1274 = self.pretty_export_csv_config(unwrapped_fields475) self.dedent() self.write(')') return None def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: - def _t1274(_dollar_dollar): - _t1275 = self.deconstruct_export_csv_config(_dollar_dollar) - return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1275,) - _t1276 = _t1274(msg) - fields476 = _t1276 + def _t1275(_dollar_dollar): + _t1276 = self.deconstruct_export_csv_config(_dollar_dollar) + return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1276,) + _t1277 = _t1275(msg) + fields476 = _t1277 unwrapped_fields477 = fields476 self.write('(') self.write('export_csv_config') self.indent() self.newline() field478 = unwrapped_fields477[0] - _t1277 = self.pretty_export_csv_path(field478) + _t1278 = self.pretty_export_csv_path(field478) self.newline() field479 = unwrapped_fields477[1] - _t1278 = self.pretty_export_csv_columns(field479) + _t1279 = self.pretty_export_csv_columns(field479) self.newline() field480 = unwrapped_fields477[2] - _t1279 = self.pretty_config_dict(field480) + _t1280 = self.pretty_config_dict(field480) self.dedent() self.write(')') return None def pretty_export_csv_path(self, msg: str) -> Optional[Never]: - def _t1280(_dollar_dollar): + def _t1281(_dollar_dollar): return _dollar_dollar - _t1281 = _t1280(msg) - fields481 = _t1281 + _t1282 = _t1281(msg) + fields481 = _t1282 unwrapped_fields482 = fields481 self.write('(') self.write('path') @@ -3837,10 +3842,10 @@ def _t1280(_dollar_dollar): return None def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: - def _t1282(_dollar_dollar): + def _t1283(_dollar_dollar): return _dollar_dollar - _t1283 = _t1282(msg) - fields483 = _t1283 + _t1284 = _t1283(msg) + fields483 = _t1284 unwrapped_fields484 = fields483 self.write('(') self.write('columns') @@ -3851,19 +3856,19 @@ def _t1282(_dollar_dollar): if (i486 > 0): self.newline() - _t1284 = None + _t1285 = None else: - _t1284 = None - _t1285 = self.pretty_export_csv_column(elem485) + _t1285 = None + _t1286 = self.pretty_export_csv_column(elem485) self.dedent() self.write(')') return None def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: - def _t1286(_dollar_dollar): + def _t1287(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.column_data,) - _t1287 = _t1286(msg) - fields487 = _t1287 + _t1288 = _t1287(msg) + fields487 = _t1288 unwrapped_fields488 = fields487 self.write('(') self.write('column') @@ -3873,7 +3878,7 @@ def _t1286(_dollar_dollar): self.write(self.format_string_value(field489)) self.newline() field490 = unwrapped_fields488[1] - _t1288 = self.pretty_relation_id(field490) + _t1289 = self.pretty_relation_id(field490) self.dedent() self.write(')') return None diff --git a/python-tools/src/meta/codegen_go.py b/python-tools/src/meta/codegen_go.py index c9d3c7e1..e53d81a0 100644 --- a/python-tools/src/meta/codegen_go.py +++ b/python-tools/src/meta/codegen_go.py @@ -10,7 +10,8 @@ from .codegen_templates import GO_TEMPLATES from .target import ( TargetExpr, Var, Symbol, NewMessage, OneOf, ListExpr, Call, Lambda, Let, - FunDef, VisitNonterminalDef, VisitNonterminal, GetElement, GetField, TargetType, + FunDef, VisitNonterminalDef, PrintNonterminalDef, VisitNonterminal, + GetElement, GetField, TargetType, ) from .gensym import gensym @@ -213,6 +214,9 @@ def gen_named_fun_ref(self, name: str) -> str: def gen_parse_nonterminal_ref(self, name: str) -> str: return f"p.parse_{name}" + def gen_pretty_nonterminal_ref(self, name: str) -> str: + return f"p.pretty_{name}" + # --- Type generation --- def gen_message_type(self, module: str, name: str) -> str: @@ -272,6 +276,15 @@ def gen_while_start(self, cond: str) -> str: def gen_while_end(self) -> str: return "}" + def gen_foreach_start(self, var: str, collection: str) -> str: + return f"for _, {var} := range {collection} {{" + + def gen_foreach_enumerated_start(self, index_var: str, var: str, collection: str) -> str: + return f"for {index_var}, {var} := range {collection} {{" + + def gen_foreach_end(self) -> str: + return "}" + def gen_empty_body(self) -> str: return "// empty" @@ -717,6 +730,39 @@ def _generate_parse_def(self, expr: VisitNonterminalDef, indent: str) -> str: end = self.gen_func_def_end() return f"{indent}{header}\n{body_code}\n{indent}{end}" + def _generate_pretty_def(self, expr: PrintNonterminalDef, indent: str) -> str: + """Generate a pretty-print method definition.""" + self.reset_declared_vars() + + func_name = f"pretty_{expr.nonterminal.name}" + + params = [] + for param in expr.params: + escaped_name = self.escape_identifier(param.name) + type_hint = self.gen_type(param.type) + params.append((escaped_name, type_hint)) + self.mark_declared(escaped_name) + + ret_type = self.gen_type(expr.return_type) if expr.return_type else "interface{}" + self.set_current_return_type(ret_type, expr.return_type) + + header = self.gen_func_def_header(func_name, params, ret_type, is_method=True) + + if expr.body is None: + zero = self._go_zero_values.get(ret_type, "nil") + body_code = f"{indent}{self.indent_str}return {zero}" + else: + body_lines: List[str] = [] + body_inner = self.generate_lines(expr.body, body_lines, indent + self.indent_str) + if body_inner is not None: + body_lines.append(f"{indent}{self.indent_str}return {body_inner}") + body_code = "\n".join(body_lines) + + self.set_current_return_type(None) + + end = self.gen_func_def_end() + return f"{indent}{header}\n{body_code}\n{indent}{end}" + def format_literal_token_spec(self, escaped_literal: str) -> str: return f'\t\t{{"LITERAL", regexp.MustCompile(`^{escaped_literal}`), func(s string) TokenValue {{ return stringTokenValue(s) }}}},' From c78e50598ea32bcf679aad918aa7773355761747 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 14:31:25 +0100 Subject: [PATCH 07/25] bug fixes --- .../src/relationalai/lqp/v1/fragments_pb.jl | 2 +- .../src/relationalai/lqp/v1/logic_pb.jl | 2 +- .../relationalai/lqp/v1/transactions_pb.jl | 2 +- python-tools/src/lqp/generated_parser.py | 183 +++++++++++------- python-tools/src/meta/codegen_python.py | 9 +- python-tools/src/meta/pretty_gen_python.py | 1 - .../src/meta/templates/parser.py.template | 8 + .../meta/templates/pretty_printer.py.template | 2 +- python-tools/tests/meta/test_codegen_go.py | 5 +- 9 files changed, 139 insertions(+), 75 deletions(-) diff --git a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl index c44c359e..1a758ef9 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:55.085 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.859 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl index ea49a9d0..6a562a05 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:54.593 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.359 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl index 3efd0157..ec334aa1 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:06:55.086 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.859 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) import ProtoBuf as PB diff --git a/python-tools/src/lqp/generated_parser.py b/python-tools/src/lqp/generated_parser.py index 2df62ccd..99379a74 100644 --- a/python-tools/src/lqp/generated_parser.py +++ b/python-tools/src/lqp/generated_parser.py @@ -267,119 +267,153 @@ def construct_fragment(self, fragment_id: fragments_pb2.FragmentId, declarations # Create and return Fragment return fragments_pb2.Fragment(id=fragment_id, declarations=declarations, debug_info=debug_info) + def relation_id_to_string(self, msg) -> str: + """Stub: only used in pretty printer.""" + raise NotImplementedError("relation_id_to_string is only available in PrettyPrinter") + + def relation_id_to_uint128(self, msg): + """Stub: only used in pretty printer.""" + raise NotImplementedError("relation_id_to_uint128 is only available in PrettyPrinter") + # --- Helper functions --- def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + assert value is not None if (value is not None and value.HasField('int_value')): + assert value is not None return value.int_value return default def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: + assert value is not None if (value is not None and value.HasField('float_value')): + assert value is not None return value.float_value return default def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value return default def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + assert value is not None if (value is not None and value.HasField('boolean_value')): + assert value is not None return value.boolean_value return default def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value.encode() return default def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + assert value is not None if (value is not None and value.HasField('uint128_value')): + assert value is not None return value.uint128_value return default def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return [value.string_value] return default def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + assert value is not None if (value is not None and value.HasField('int_value')): + assert value is not None return value.int_value return None def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + assert value is not None if (value is not None and value.HasField('float_value')): + assert value is not None return value.float_value return None def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value return None def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value.encode() return None def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + assert value is not None if (value is not None and value.HasField('uint128_value')): + assert value is not None return value.uint128_value return None def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return [value.string_value] return None def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t945 = Parser._extract_value_int64(config.get('csv_header_row'), 1) + _t945 = self._extract_value_int64(config.get('csv_header_row'), 1) header_row = _t945 - _t946 = Parser._extract_value_int64(config.get('csv_skip'), 0) + _t946 = self._extract_value_int64(config.get('csv_skip'), 0) skip = _t946 - _t947 = Parser._extract_value_string(config.get('csv_new_line'), '') + _t947 = self._extract_value_string(config.get('csv_new_line'), '') new_line = _t947 - _t948 = Parser._extract_value_string(config.get('csv_delimiter'), ',') + _t948 = self._extract_value_string(config.get('csv_delimiter'), ',') delimiter = _t948 - _t949 = Parser._extract_value_string(config.get('csv_quotechar'), '"') + _t949 = self._extract_value_string(config.get('csv_quotechar'), '"') quotechar = _t949 - _t950 = Parser._extract_value_string(config.get('csv_escapechar'), '"') + _t950 = self._extract_value_string(config.get('csv_escapechar'), '"') escapechar = _t950 - _t951 = Parser._extract_value_string(config.get('csv_comment'), '') + _t951 = self._extract_value_string(config.get('csv_comment'), '') comment = _t951 - _t952 = Parser._extract_value_string_list(config.get('csv_missing_strings'), []) + _t952 = self._extract_value_string_list(config.get('csv_missing_strings'), []) missing_strings = _t952 - _t953 = Parser._extract_value_string(config.get('csv_decimal_separator'), '.') + _t953 = self._extract_value_string(config.get('csv_decimal_separator'), '.') decimal_separator = _t953 - _t954 = Parser._extract_value_string(config.get('csv_encoding'), 'utf-8') + _t954 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') encoding = _t954 - _t955 = Parser._extract_value_string(config.get('csv_compression'), 'auto') + _t955 = self._extract_value_string(config.get('csv_compression'), 'auto') compression = _t955 _t956 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t956 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t957 = Parser._try_extract_value_float64(config.get('betree_config_epsilon')) + _t957 = self._try_extract_value_float64(config.get('betree_config_epsilon')) epsilon = _t957 - _t958 = Parser._try_extract_value_int64(config.get('betree_config_max_pivots')) + _t958 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) max_pivots = _t958 - _t959 = Parser._try_extract_value_int64(config.get('betree_config_max_deltas')) + _t959 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) max_deltas = _t959 - _t960 = Parser._try_extract_value_int64(config.get('betree_config_max_leaf')) + _t960 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) max_leaf = _t960 _t961 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) storage_config = _t961 - _t962 = Parser._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + _t962 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) root_pageid = _t962 - _t963 = Parser._try_extract_value_bytes(config.get('betree_locator_inline_data')) + _t963 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) inline_data = _t963 - _t964 = Parser._try_extract_value_int64(config.get('betree_locator_element_count')) + _t964 = self._try_extract_value_int64(config.get('betree_locator_element_count')) element_count = _t964 - _t965 = Parser._try_extract_value_int64(config.get('betree_locator_tree_height')) + _t965 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) tree_height = _t965 _t966 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) relation_locator = _t966 @@ -409,26 +443,26 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF _t970 = transactions_pb2.IVMConfig(level=maintenance_level) ivm_config = _t970 - _t971 = Parser._extract_value_int64(config.get('semantics_version'), 0) + _t971 = self._extract_value_int64(config.get('semantics_version'), 0) semantics_version = _t971 _t972 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) return _t972 def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t973 = Parser._extract_value_int64(config.get('partition_size'), 0) + _t973 = self._extract_value_int64(config.get('partition_size'), 0) partition_size = _t973 - _t974 = Parser._extract_value_string(config.get('compression'), '') + _t974 = self._extract_value_string(config.get('compression'), '') compression = _t974 - _t975 = Parser._extract_value_boolean(config.get('syntax_header_row'), True) + _t975 = self._extract_value_boolean(config.get('syntax_header_row'), True) syntax_header_row = _t975 - _t976 = Parser._extract_value_string(config.get('syntax_missing_string'), '') + _t976 = self._extract_value_string(config.get('syntax_missing_string'), '') syntax_missing_string = _t976 - _t977 = Parser._extract_value_string(config.get('syntax_delim'), ',') + _t977 = self._extract_value_string(config.get('syntax_delim'), ',') syntax_delim = _t977 - _t978 = Parser._extract_value_string(config.get('syntax_quotechar'), '"') + _t978 = self._extract_value_string(config.get('syntax_quotechar'), '"') syntax_quotechar = _t978 - _t979 = Parser._extract_value_string(config.get('syntax_escapechar'), '\\') + _t979 = self._extract_value_string(config.get('syntax_escapechar'), '\\') syntax_escapechar = _t979 _t980 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) return _t980 @@ -464,26 +498,26 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t987 = Parser._make_value_string('auto') + _t987 = self._make_value_string('auto') result.append(('ivm.maintenance_level', _t987,)) _t986 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t989 = Parser._make_value_string('all') + _t989 = self._make_value_string('all') result.append(('ivm.maintenance_level', _t989,)) _t988 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t991 = Parser._make_value_string('off') + _t991 = self._make_value_string('off') result.append(('ivm.maintenance_level', _t991,)) _t990 = None else: _t990 = None _t988 = _t990 _t986 = _t988 - _t992 = Parser._make_value_int64(msg.semantics_version) + _t992 = self._make_value_int64(msg.semantics_version) result.append(('semantics_version', _t992,)) return result @@ -491,77 +525,77 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo result = [] if msg.header_row != 1: - _t994 = Parser._make_value_int64(int(msg.header_row)) + _t994 = self._make_value_int64(int(msg.header_row)) result.append(('csv_header_row', _t994,)) _t993 = None else: _t993 = None if msg.skip != 0: - _t996 = Parser._make_value_int64(msg.skip) + _t996 = self._make_value_int64(msg.skip) result.append(('csv_skip', _t996,)) _t995 = None else: _t995 = None if msg.new_line != '': - _t998 = Parser._make_value_string(msg.new_line) + _t998 = self._make_value_string(msg.new_line) result.append(('csv_new_line', _t998,)) _t997 = None else: _t997 = None if msg.delimiter != ',': - _t1000 = Parser._make_value_string(msg.delimiter) + _t1000 = self._make_value_string(msg.delimiter) result.append(('csv_delimiter', _t1000,)) _t999 = None else: _t999 = None if msg.quotechar != '"': - _t1002 = Parser._make_value_string(msg.quotechar) + _t1002 = self._make_value_string(msg.quotechar) result.append(('csv_quotechar', _t1002,)) _t1001 = None else: _t1001 = None if msg.escapechar != '"': - _t1004 = Parser._make_value_string(msg.escapechar) + _t1004 = self._make_value_string(msg.escapechar) result.append(('csv_escapechar', _t1004,)) _t1003 = None else: _t1003 = None if msg.comment != '': - _t1006 = Parser._make_value_string(msg.comment) + _t1006 = self._make_value_string(msg.comment) result.append(('csv_comment', _t1006,)) _t1005 = None else: _t1005 = None if not len(msg.missing_strings) == 0: - _t1008 = Parser._make_value_string(msg.missing_strings[0]) + _t1008 = self._make_value_string(msg.missing_strings[0]) result.append(('csv_missing_strings', _t1008,)) _t1007 = None else: _t1007 = None if msg.decimal_separator != '.': - _t1010 = Parser._make_value_string(msg.decimal_separator) + _t1010 = self._make_value_string(msg.decimal_separator) result.append(('csv_decimal_separator', _t1010,)) _t1009 = None else: _t1009 = None if msg.encoding != 'utf-8': - _t1012 = Parser._make_value_string(msg.encoding) + _t1012 = self._make_value_string(msg.encoding) result.append(('csv_encoding', _t1012,)) _t1011 = None else: _t1011 = None if msg.compression != 'auto': - _t1014 = Parser._make_value_string(msg.compression) + _t1014 = self._make_value_string(msg.compression) result.append(('csv_compression', _t1014,)) _t1013 = None else: @@ -571,7 +605,8 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: - _t1016 = Parser._make_value_float64(val) + assert val is not None + _t1016 = self._make_value_float64(val) result.append((key, _t1016,)) _t1015 = None else: @@ -581,7 +616,8 @@ def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: - _t1018 = Parser._make_value_int64(val) + assert val is not None + _t1018 = self._make_value_int64(val) result.append((key, _t1018,)) _t1017 = None else: @@ -591,7 +627,8 @@ def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: - _t1020 = Parser._make_value_uint128(val) + assert val is not None + _t1020 = self._make_value_uint128(val) result.append((key, _t1020,)) _t1019 = None else: @@ -601,7 +638,8 @@ def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: - _t1022 = Parser._make_value_string(val.decode('utf-8')) + assert val is not None + _t1022 = self._make_value_string(val.decode('utf-8')) result.append((key, _t1022,)) _t1021 = None else: @@ -610,73 +648,86 @@ def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1023 = Parser._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1024 = Parser._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1025 = Parser._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1026 = Parser._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1023 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1024 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1025 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1026 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1028 = Parser._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1028 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) _t1027 = _t1028 else: _t1027 = None if msg.relation_locator.HasField('inline_data'): - _t1030 = Parser._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1030 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) _t1029 = _t1030 else: _t1029 = None - _t1031 = Parser._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1032 = Parser._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1031 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1032 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return result def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] + assert msg.partition_size is not None if (msg.partition_size is not None and msg.partition_size != 0): - _t1034 = Parser._make_value_int64(msg.partition_size) + assert msg.partition_size is not None + _t1034 = self._make_value_int64(msg.partition_size) result.append(('partition_size', _t1034,)) _t1033 = None else: _t1033 = None + assert msg.compression is not None if (msg.compression is not None and msg.compression != ''): - _t1036 = Parser._make_value_string(msg.compression) + assert msg.compression is not None + _t1036 = self._make_value_string(msg.compression) result.append(('compression', _t1036,)) _t1035 = None else: _t1035 = None if msg.syntax_header_row is not None: - _t1038 = Parser._make_value_boolean(msg.syntax_header_row) + assert msg.syntax_header_row is not None + _t1038 = self._make_value_boolean(msg.syntax_header_row) result.append(('syntax_header_row', _t1038,)) _t1037 = None else: _t1037 = None + assert msg.syntax_missing_string is not None if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): - _t1040 = Parser._make_value_string(msg.syntax_missing_string) + assert msg.syntax_missing_string is not None + _t1040 = self._make_value_string(msg.syntax_missing_string) result.append(('syntax_missing_string', _t1040,)) _t1039 = None else: _t1039 = None + assert msg.syntax_delim is not None if (msg.syntax_delim is not None and msg.syntax_delim != ','): - _t1042 = Parser._make_value_string(msg.syntax_delim) + assert msg.syntax_delim is not None + _t1042 = self._make_value_string(msg.syntax_delim) result.append(('syntax_delim', _t1042,)) _t1041 = None else: _t1041 = None + assert msg.syntax_quotechar is not None if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): - _t1044 = Parser._make_value_string(msg.syntax_quotechar) + assert msg.syntax_quotechar is not None + _t1044 = self._make_value_string(msg.syntax_quotechar) result.append(('syntax_quotechar', _t1044,)) _t1043 = None else: _t1043 = None + assert msg.syntax_escapechar is not None if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): - _t1046 = Parser._make_value_string(msg.syntax_escapechar) + assert msg.syntax_escapechar is not None + _t1046 = self._make_value_string(msg.syntax_escapechar) result.append(('syntax_escapechar', _t1046,)) _t1045 = None else: @@ -731,7 +782,7 @@ def parse_transaction(self) -> transactions_pb2.Transaction: cond3 = self.match_lookahead_literal('(', 0) epochs5 = xs2 self.consume_literal(')') - _t358 = Parser.default_configure() + _t358 = self.default_configure() _t359 = transactions_pb2.Transaction(epochs=epochs5, configure=(configure0 if configure0 is not None else _t358), sync=sync1) return _t359 @@ -741,7 +792,7 @@ def parse_configure(self) -> transactions_pb2.Configure: _t360 = self.parse_config_dict() config_dict6 = _t360 self.consume_literal(')') - _t361 = Parser.construct_configure(config_dict6) + _t361 = self.construct_configure(config_dict6) return _t361 def parse_config_dict(self) -> list[tuple[str, logic_pb2.Value]]: @@ -2885,7 +2936,7 @@ def parse_betree_info(self) -> logic_pb2.BeTreeInfo: _t878 = self.parse_config_dict() config_dict288 = _t878 self.consume_literal(')') - _t879 = Parser.construct_betree_info(betree_info_key_types286, betree_info_value_types287, config_dict288) + _t879 = self.construct_betree_info(betree_info_key_types286, betree_info_value_types287, config_dict288) return _t879 def parse_betree_info_key_types(self) -> list[logic_pb2.Type]: @@ -2978,7 +3029,7 @@ def parse_csv_config(self) -> logic_pb2.CSVConfig: _t892 = self.parse_config_dict() config_dict308 = _t892 self.consume_literal(')') - _t893 = Parser.construct_csv_config(config_dict308) + _t893 = self.construct_csv_config(config_dict308) return _t893 def parse_csv_columns(self) -> list[logic_pb2.CSVColumn]: @@ -3200,7 +3251,7 @@ def parse_export_csv_config(self) -> transactions_pb2.ExportCSVConfig: _t940 = self.parse_config_dict() config_dict345 = _t940 self.consume_literal(')') - _t941 = Parser.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) + _t941 = self.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) return _t941 def parse_export_csv_path(self) -> str: diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index d49a2eb9..846a8377 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -30,7 +30,7 @@ class PythonCodeGenerator(CodeGenerator): keywords = PYTHON_KEYWORDS indent_str = " " - named_fun_class = "Parser" + named_fun_class = "self" base_type_map = { 'Int32': 'int', @@ -52,6 +52,8 @@ def _register_builtins(self) -> None: self.register_builtins_from_templates(PYTHON_TEMPLATES) # Override tuple to handle empty and single-element cases correctly self.register_builtin("tuple", self._gen_tuple_builtin) + # Override unwrap_option to emit assert for type narrowing + self.register_builtin("unwrap_option", self._gen_unwrap_option_builtin) @staticmethod def _gen_tuple_builtin(args, lines, indent): @@ -63,6 +65,11 @@ def _gen_tuple_builtin(args, lines, indent): else: return BuiltinResult(f"({', '.join(args)},)", []) + @staticmethod + def _gen_unwrap_option_builtin(args, lines, indent): + from .codegen_base import BuiltinResult + return BuiltinResult(args[0], [f"{indent}assert {args[0]} is not None"]) + def escape_keyword(self, name: str) -> str: return f"{name}_" diff --git a/python-tools/src/meta/pretty_gen_python.py b/python-tools/src/meta/pretty_gen_python.py index ffa79a2a..00b0f5f7 100644 --- a/python-tools/src/meta/pretty_gen_python.py +++ b/python-tools/src/meta/pretty_gen_python.py @@ -22,7 +22,6 @@ def generate_pretty_printer_python(grammar: Grammar, command_line: Optional[str] template = _TEMPLATE_PATH.read_text() codegen = PythonCodeGenerator(proto_messages=proto_messages) - codegen.named_fun_class = "self" indent = " " defns = generate_pretty_functions(grammar, proto_messages) diff --git a/python-tools/src/meta/templates/parser.py.template b/python-tools/src/meta/templates/parser.py.template index b1373702..c10759fc 100644 --- a/python-tools/src/meta/templates/parser.py.template +++ b/python-tools/src/meta/templates/parser.py.template @@ -239,6 +239,14 @@ class Parser: # Create and return Fragment return fragments_pb2.Fragment(id=fragment_id, declarations=declarations, debug_info=debug_info) + def relation_id_to_string(self, msg) -> str: + """Stub: only used in pretty printer.""" + raise NotImplementedError("relation_id_to_string is only available in PrettyPrinter") + + def relation_id_to_uint128(self, msg): + """Stub: only used in pretty printer.""" + raise NotImplementedError("relation_id_to_uint128 is only available in PrettyPrinter") + # --- Helper functions --- {named_function_defns} diff --git a/python-tools/src/meta/templates/pretty_printer.py.template b/python-tools/src/meta/templates/pretty_printer.py.template index d24962ef..9e54e5ac 100644 --- a/python-tools/src/meta/templates/pretty_printer.py.template +++ b/python-tools/src/meta/templates/pretty_printer.py.template @@ -54,7 +54,7 @@ class PrettyPrinter: def format_decimal(self, msg) -> str: """Format a DecimalValue as '.d'.""" - int_val = (msg.value.high << 64) | msg.value.low + int_val: int = (msg.value.high << 64) | msg.value.low if msg.value.high & (1 << 63): int_val -= (1 << 128) sign = "" diff --git a/python-tools/tests/meta/test_codegen_go.py b/python-tools/tests/meta/test_codegen_go.py index 78ea49f2..7cce1803 100644 --- a/python-tools/tests/meta/test_codegen_go.py +++ b/python-tools/tests/meta/test_codegen_go.py @@ -3,7 +3,7 @@ from meta.target import ( Var, Lit, Symbol, NewMessage, ListExpr, Call, Let, - IfElse, Seq, While, Assign, Return, FunDef, VisitNonterminalDef, + IfElse, Seq, While, Assign, Return, FunDef, ParseNonterminalDef, BaseType, MessageType, ListType, OptionType, GetElement, ) from meta.target_builtins import make_builtin @@ -319,8 +319,7 @@ def test_go_visit_nonterminal_def_generation(): nt = Nonterminal("expr", MessageType("logic", "Expr")) reset_gensym() - parse_def = VisitNonterminalDef( - visitor_name="parse", + parse_def = ParseNonterminalDef( nonterminal=nt, params=[], return_type=MessageType("logic", "Expr"), From 831978f66e67b7dda1e954ae08810965e6f82f89 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 17:59:40 +0100 Subject: [PATCH 08/25] fixes. --- .../src/relationalai/lqp/v1/fragments_pb.jl | 2 +- .../src/relationalai/lqp/v1/logic_pb.jl | 2 +- .../relationalai/lqp/v1/transactions_pb.jl | 2 +- python-tools/src/lqp/generated_parser.py | 89 ++++----- .../src/lqp/generated_pretty_printer.py | 184 +++++++++++++++++- python-tools/src/meta/codegen_python.py | 2 +- python-tools/src/meta/grammar.y | 17 +- .../meta/templates/pretty_printer.py.template | 16 +- 8 files changed, 240 insertions(+), 74 deletions(-) diff --git a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl index 1a758ef9..dbb42a51 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.859 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:36.128 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl index 6a562a05..f663fba4 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.359 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:35.595 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl index ec334aa1..d7ac00a7 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T14:30:54.859 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:36.128 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) import ProtoBuf as PB diff --git a/python-tools/src/lqp/generated_parser.py b/python-tools/src/lqp/generated_parser.py index 99379a74..333b80ff 100644 --- a/python-tools/src/lqp/generated_parser.py +++ b/python-tools/src/lqp/generated_parser.py @@ -278,93 +278,93 @@ def relation_id_to_uint128(self, msg): # --- Helper functions --- def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None + assert value is not None if (value is not None and value.HasField('int_value')): - assert value is not None + assert value is not None return value.int_value return default def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: - assert value is not None + assert value is not None if (value is not None and value.HasField('float_value')): - assert value is not None + assert value is not None return value.float_value return default def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return value.string_value return default def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: - assert value is not None + assert value is not None if (value is not None and value.HasField('boolean_value')): - assert value is not None + assert value is not None return value.boolean_value return default def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return value.string_value.encode() return default def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: - assert value is not None + assert value is not None if (value is not None and value.HasField('uint128_value')): - assert value is not None + assert value is not None return value.uint128_value return default def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return [value.string_value] return default def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: - assert value is not None + assert value is not None if (value is not None and value.HasField('int_value')): - assert value is not None + assert value is not None return value.int_value return None def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: - assert value is not None + assert value is not None if (value is not None and value.HasField('float_value')): - assert value is not None + assert value is not None return value.float_value return None def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return value.string_value return None def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return value.string_value.encode() return None def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: - assert value is not None + assert value is not None if (value is not None and value.HasField('uint128_value')): - assert value is not None + assert value is not None return value.uint128_value return None def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: - assert value is not None + assert value is not None if (value is not None and value.HasField('string_value')): - assert value is not None + assert value is not None return [value.string_value] return None @@ -605,7 +605,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: - assert val is not None + assert val is not None _t1016 = self._make_value_float64(val) result.append((key, _t1016,)) _t1015 = None @@ -616,7 +616,7 @@ def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: - assert val is not None + assert val is not None _t1018 = self._make_value_int64(val) result.append((key, _t1018,)) _t1017 = None @@ -627,7 +627,7 @@ def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: - assert val is not None + assert val is not None _t1020 = self._make_value_uint128(val) result.append((key, _t1020,)) _t1019 = None @@ -638,7 +638,7 @@ def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: - assert val is not None + assert val is not None _t1022 = self._make_value_string(val.decode('utf-8')) result.append((key, _t1022,)) _t1021 = None @@ -670,19 +670,19 @@ def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tupl def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - assert msg.partition_size is not None + assert msg.partition_size is not None if (msg.partition_size is not None and msg.partition_size != 0): - assert msg.partition_size is not None + assert msg.partition_size is not None _t1034 = self._make_value_int64(msg.partition_size) result.append(('partition_size', _t1034,)) _t1033 = None else: _t1033 = None - assert msg.compression is not None + assert msg.compression is not None if (msg.compression is not None and msg.compression != ''): - assert msg.compression is not None + assert msg.compression is not None _t1036 = self._make_value_string(msg.compression) result.append(('compression', _t1036,)) _t1035 = None @@ -690,43 +690,43 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - _t1035 = None if msg.syntax_header_row is not None: - assert msg.syntax_header_row is not None + assert msg.syntax_header_row is not None _t1038 = self._make_value_boolean(msg.syntax_header_row) result.append(('syntax_header_row', _t1038,)) _t1037 = None else: _t1037 = None - assert msg.syntax_missing_string is not None + assert msg.syntax_missing_string is not None if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): - assert msg.syntax_missing_string is not None + assert msg.syntax_missing_string is not None _t1040 = self._make_value_string(msg.syntax_missing_string) result.append(('syntax_missing_string', _t1040,)) _t1039 = None else: _t1039 = None - assert msg.syntax_delim is not None + assert msg.syntax_delim is not None if (msg.syntax_delim is not None and msg.syntax_delim != ','): - assert msg.syntax_delim is not None + assert msg.syntax_delim is not None _t1042 = self._make_value_string(msg.syntax_delim) result.append(('syntax_delim', _t1042,)) _t1041 = None else: _t1041 = None - assert msg.syntax_quotechar is not None + assert msg.syntax_quotechar is not None if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): - assert msg.syntax_quotechar is not None + assert msg.syntax_quotechar is not None _t1044 = self._make_value_string(msg.syntax_quotechar) result.append(('syntax_quotechar', _t1044,)) _t1043 = None else: _t1043 = None - assert msg.syntax_escapechar is not None + assert msg.syntax_escapechar is not None if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): - assert msg.syntax_escapechar is not None + assert msg.syntax_escapechar is not None _t1046 = self._make_value_string(msg.syntax_escapechar) result.append(('syntax_escapechar', _t1046,)) _t1045 = None @@ -747,7 +747,8 @@ def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional return None def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - return (abs.vars, [],) + n = len(abs.vars) + return (abs.vars[0:n], [],) def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: n = len(abs.vars) diff --git a/python-tools/src/lqp/generated_pretty_printer.py b/python-tools/src/lqp/generated_pretty_printer.py index e113fde2..ea98ebf7 100644 --- a/python-tools/src/lqp/generated_pretty_printer.py +++ b/python-tools/src/lqp/generated_pretty_printer.py @@ -54,9 +54,9 @@ def get_output(self) -> str: return self.io.getvalue() return "" - def format_decimal(self, msg) -> str: + def format_decimal(self, msg: logic_pb2.DecimalValue) -> str: """Format a DecimalValue as '.d'.""" - int_val = (msg.value.high << 64) | msg.value.low + int_val: int = (msg.value.high << 64) | msg.value.low if msg.value.high & (1 << 63): int_val -= (1 << 128) sign = "" @@ -73,40 +73,40 @@ def format_decimal(self, msg) -> str: decimal_str = digits[:-scale] + "." + digits[-scale:] return sign + decimal_str + "d" + str(msg.precision) - def format_int128(self, msg) -> str: + def format_int128(self, msg: logic_pb2.Int128Value) -> str: """Format an Int128Value protobuf message as a string with i128 suffix.""" value = (msg.high << 64) | msg.low if msg.high & (1 << 63): value -= (1 << 128) return str(value) + "i128" - def format_uint128(self, msg) -> str: + def format_uint128(self, msg: logic_pb2.UInt128Value) -> str: """Format a UInt128Value protobuf message as a hex string.""" value = (msg.high << 64) | msg.low return f"0x{value:x}" - def fragment_id_to_string(self, msg) -> str: + def fragment_id_to_string(self, msg: fragments_pb2.FragmentId) -> str: """Convert FragmentId to string representation.""" return msg.id.decode('utf-8') if msg.id else "" - def start_pretty_fragment(self, msg) -> None: + def start_pretty_fragment(self, msg: fragments_pb2.Fragment) -> None: """Extract debug info from Fragment for relation ID lookup.""" debug_info = msg.debug_info for rid, name in zip(debug_info.ids, debug_info.orig_names): self._debug_info[(rid.id_low, rid.id_high)] = name - def relation_id_to_string(self, msg): + def relation_id_to_string(self, msg: logic_pb2.RelationId) -> str: """Convert RelationId to string representation using debug info.""" return self._debug_info.get((msg.id_low, msg.id_high), "") - def relation_id_to_int(self, msg): + def relation_id_to_int(self, msg: logic_pb2.RelationId) -> Optional[int]: """Convert RelationId to int if it fits in signed 64-bit range.""" value = (msg.id_high << 64) | msg.id_low if value <= 0x7FFFFFFFFFFFFFFF: return value return None - def relation_id_to_uint128(self, msg): + def relation_id_to_uint128(self, msg: logic_pb2.RelationId) -> logic_pb2.UInt128Value: """Convert RelationId to UInt128Value representation.""" return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) @@ -118,67 +118,93 @@ def format_string_value(self, s: str) -> str: # --- Helper functions --- def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + assert value is not None if (value is not None and value.HasField('int_value')): + assert value is not None return value.int_value return default def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: + assert value is not None if (value is not None and value.HasField('float_value')): + assert value is not None return value.float_value return default def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value return default def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + assert value is not None if (value is not None and value.HasField('boolean_value')): + assert value is not None return value.boolean_value return default def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value.encode() return default def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + assert value is not None if (value is not None and value.HasField('uint128_value')): + assert value is not None return value.uint128_value return default def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return [value.string_value] return default def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + assert value is not None if (value is not None and value.HasField('int_value')): + assert value is not None return value.int_value return None def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + assert value is not None if (value is not None and value.HasField('float_value')): + assert value is not None return value.float_value return None def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value return None def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return value.string_value.encode() return None def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + assert value is not None if (value is not None and value.HasField('uint128_value')): + assert value is not None return value.uint128_value return None def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + assert value is not None if (value is not None and value.HasField('string_value')): + assert value is not None return [value.string_value] return None @@ -419,6 +445,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: + assert val is not None _t1361 = self._make_value_float64(val) result.append((key, _t1361,)) _t1360 = None @@ -429,6 +456,7 @@ def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: + assert val is not None _t1363 = self._make_value_int64(val) result.append((key, _t1363,)) _t1362 = None @@ -439,6 +467,7 @@ def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: + assert val is not None _t1365 = self._make_value_uint128(val) result.append((key, _t1365,)) _t1364 = None @@ -449,6 +478,7 @@ def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: st def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: + assert val is not None _t1367 = self._make_value_string(val.decode('utf-8')) result.append((key, _t1367,)) _t1366 = None @@ -480,15 +510,19 @@ def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tupl def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] + assert msg.partition_size is not None if (msg.partition_size is not None and msg.partition_size != 0): + assert msg.partition_size is not None _t1379 = self._make_value_int64(msg.partition_size) result.append(('partition_size', _t1379,)) _t1378 = None else: _t1378 = None + assert msg.compression is not None if (msg.compression is not None and msg.compression != ''): + assert msg.compression is not None _t1381 = self._make_value_string(msg.compression) result.append(('compression', _t1381,)) _t1380 = None @@ -496,34 +530,43 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - _t1380 = None if msg.syntax_header_row is not None: + assert msg.syntax_header_row is not None _t1383 = self._make_value_boolean(msg.syntax_header_row) result.append(('syntax_header_row', _t1383,)) _t1382 = None else: _t1382 = None + assert msg.syntax_missing_string is not None if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + assert msg.syntax_missing_string is not None _t1385 = self._make_value_string(msg.syntax_missing_string) result.append(('syntax_missing_string', _t1385,)) _t1384 = None else: _t1384 = None + assert msg.syntax_delim is not None if (msg.syntax_delim is not None and msg.syntax_delim != ','): + assert msg.syntax_delim is not None _t1387 = self._make_value_string(msg.syntax_delim) result.append(('syntax_delim', _t1387,)) _t1386 = None else: _t1386 = None + assert msg.syntax_quotechar is not None if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + assert msg.syntax_quotechar is not None _t1389 = self._make_value_string(msg.syntax_quotechar) result.append(('syntax_quotechar', _t1389,)) _t1388 = None else: _t1388 = None + assert msg.syntax_escapechar is not None if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + assert msg.syntax_escapechar is not None _t1391 = self._make_value_string(msg.syntax_escapechar) result.append(('syntax_escapechar', _t1391,)) _t1390 = None @@ -544,7 +587,8 @@ def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional return None def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - return (abs.vars, [],) + n = len(abs.vars) + return (abs.vars[0:n], [],) def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: n = len(abs.vars) @@ -568,6 +612,7 @@ def _t491(_dollar_dollar): return (_t492, _t493, _dollar_dollar.epochs,) _t494 = _t491(msg) fields0 = _t494 + assert fields0 is not None unwrapped_fields1 = fields0 self.write('(') self.write('transaction') @@ -576,6 +621,7 @@ def _t491(_dollar_dollar): if field2 is not None: self.newline() + assert field2 is not None opt_val3 = field2 _t496 = self.pretty_configure(opt_val3) _t495 = _t496 @@ -585,6 +631,7 @@ def _t491(_dollar_dollar): if field4 is not None: self.newline() + assert field4 is not None opt_val5 = field4 _t498 = self.pretty_sync(opt_val5) _t497 = _t498 @@ -611,6 +658,7 @@ def _t501(_dollar_dollar): return _t502 _t503 = _t501(msg) fields9 = _t503 + assert fields9 is not None unwrapped_fields10 = fields9 self.write('(') self.write('configure') @@ -626,6 +674,7 @@ def _t505(_dollar_dollar): return _dollar_dollar _t506 = _t505(msg) fields11 = _t506 + assert fields11 is not None unwrapped_fields12 = fields11 self.write('{') if not len(unwrapped_fields12) == 0: @@ -646,6 +695,7 @@ def _t509(_dollar_dollar): return (_dollar_dollar[0], _dollar_dollar[1],) _t510 = _t509(msg) fields15 = _t510 + assert fields15 is not None unwrapped_fields16 = fields15 self.write(':') field17 = unwrapped_fields16[0] @@ -786,6 +836,7 @@ def _t551(_dollar_dollar): return _dollar_dollar _t552 = _t551(msg) fields19 = _t552 + assert fields19 is not None unwrapped_fields20 = fields19 self.write('missing') _t549 = None @@ -804,6 +855,7 @@ def _t553(_dollar_dollar): return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) _t554 = _t553(msg) fields30 = _t554 + assert fields30 is not None unwrapped_fields31 = fields30 self.write('(') self.write('date') @@ -831,6 +883,7 @@ def _t555(_dollar_dollar): return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), _t556,) _t557 = _t555(msg) fields35 = _t557 + assert fields35 is not None unwrapped_fields36 = fields35 self.write('(') self.write('datetime') @@ -857,6 +910,7 @@ def _t555(_dollar_dollar): if field43 is not None: self.newline() + assert field43 is not None opt_val44 = field43 self.write(str(opt_val44)) _t558 = None @@ -885,6 +939,7 @@ def _t563(_dollar_dollar): return _dollar_dollar _t564 = _t563(msg) fields45 = _t564 + assert fields45 is not None unwrapped_fields46 = fields45 self.write('false') _t562 = None @@ -895,6 +950,7 @@ def _t565(_dollar_dollar): return _dollar_dollar.fragments _t566 = _t565(msg) fields48 = _t566 + assert fields48 is not None unwrapped_fields49 = fields48 self.write('(') self.write('sync') @@ -918,6 +974,7 @@ def _t569(_dollar_dollar): return self.fragment_id_to_string(_dollar_dollar) _t570 = _t569(msg) fields52 = _t570 + assert fields52 is not None unwrapped_fields53 = fields52 self.write(':') self.write(unwrapped_fields53) @@ -938,6 +995,7 @@ def _t571(_dollar_dollar): return (_t572, _t573,) _t574 = _t571(msg) fields54 = _t574 + assert fields54 is not None unwrapped_fields55 = fields54 self.write('(') self.write('epoch') @@ -946,6 +1004,7 @@ def _t571(_dollar_dollar): if field56 is not None: self.newline() + assert field56 is not None opt_val57 = field56 _t576 = self.pretty_epoch_writes(opt_val57) _t575 = _t576 @@ -955,6 +1014,7 @@ def _t571(_dollar_dollar): if field58 is not None: self.newline() + assert field58 is not None opt_val59 = field58 _t578 = self.pretty_epoch_reads(opt_val59) _t577 = _t578 @@ -969,6 +1029,7 @@ def _t579(_dollar_dollar): return _dollar_dollar _t580 = _t579(msg) fields60 = _t580 + assert fields60 is not None unwrapped_fields61 = fields60 self.write('(') self.write('writes') @@ -1040,6 +1101,7 @@ def _t598(_dollar_dollar): return _dollar_dollar.fragment _t599 = _t598(msg) fields67 = _t599 + assert fields67 is not None unwrapped_fields68 = fields67 self.write('(') self.write('define') @@ -1056,6 +1118,7 @@ def _t601(_dollar_dollar): return (_dollar_dollar.id, _dollar_dollar.declarations,) _t603 = _t601(msg) fields69 = _t603 + assert fields69 is not None unwrapped_fields70 = fields69 self.write('(') self.write('fragment') @@ -1083,6 +1146,7 @@ def _t607(_dollar_dollar): return _dollar_dollar _t608 = _t607(msg) fields75 = _t608 + assert fields75 is not None unwrapped_fields76 = fields75 _t609 = self.pretty_fragment_id(unwrapped_fields76) return _t609 @@ -1160,6 +1224,7 @@ def _t630(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.body, _t631,) _t632 = _t630(msg) fields81 = _t632 + assert fields81 is not None unwrapped_fields82 = fields81 self.write('(') self.write('def') @@ -1174,6 +1239,7 @@ def _t630(_dollar_dollar): if field85 is not None: self.newline() + assert field85 is not None opt_val86 = field85 _t636 = self.pretty_attrs(opt_val86) _t635 = _t636 @@ -1215,6 +1281,7 @@ def _t645(_dollar_dollar): return (_t646, _dollar_dollar.value,) _t647 = _t645(msg) fields89 = _t647 + assert fields89 is not None unwrapped_fields90 = fields89 self.write('(') field91 = unwrapped_fields90[0] @@ -1235,6 +1302,7 @@ def _t650(_dollar_dollar): return (_dollar_dollar[0], _t651,) _t652 = _t650(msg) fields93 = _t652 + assert fields93 is not None unwrapped_fields94 = fields93 self.write('[') field95 = unwrapped_fields94[0] @@ -1250,6 +1318,7 @@ def _t650(_dollar_dollar): if field98 is not None: self.write(' ') + assert field98 is not None opt_val99 = field98 _t656 = self.pretty_value_bindings(opt_val99) _t655 = _t656 @@ -1263,6 +1332,7 @@ def _t657(_dollar_dollar): return (_dollar_dollar.var.name, _dollar_dollar.type,) _t658 = _t657(msg) fields100 = _t658 + assert fields100 is not None unwrapped_fields101 = fields100 field102 = unwrapped_fields101[0] self.write(field102) @@ -1444,6 +1514,7 @@ def _t715(_dollar_dollar): return _dollar_dollar _t716 = _t715(msg) fields115 = _t716 + assert fields115 is not None unwrapped_fields116 = fields115 self.write('UNKNOWN') return None @@ -1453,6 +1524,7 @@ def _t717(_dollar_dollar): return _dollar_dollar _t718 = _t717(msg) fields117 = _t718 + assert fields117 is not None unwrapped_fields118 = fields117 self.write('STRING') return None @@ -1462,6 +1534,7 @@ def _t719(_dollar_dollar): return _dollar_dollar _t720 = _t719(msg) fields119 = _t720 + assert fields119 is not None unwrapped_fields120 = fields119 self.write('INT') return None @@ -1471,6 +1544,7 @@ def _t721(_dollar_dollar): return _dollar_dollar _t722 = _t721(msg) fields121 = _t722 + assert fields121 is not None unwrapped_fields122 = fields121 self.write('FLOAT') return None @@ -1480,6 +1554,7 @@ def _t723(_dollar_dollar): return _dollar_dollar _t724 = _t723(msg) fields123 = _t724 + assert fields123 is not None unwrapped_fields124 = fields123 self.write('UINT128') return None @@ -1489,6 +1564,7 @@ def _t725(_dollar_dollar): return _dollar_dollar _t726 = _t725(msg) fields125 = _t726 + assert fields125 is not None unwrapped_fields126 = fields125 self.write('INT128') return None @@ -1498,6 +1574,7 @@ def _t727(_dollar_dollar): return _dollar_dollar _t728 = _t727(msg) fields127 = _t728 + assert fields127 is not None unwrapped_fields128 = fields127 self.write('DATE') return None @@ -1507,6 +1584,7 @@ def _t729(_dollar_dollar): return _dollar_dollar _t730 = _t729(msg) fields129 = _t730 + assert fields129 is not None unwrapped_fields130 = fields129 self.write('DATETIME') return None @@ -1516,6 +1594,7 @@ def _t731(_dollar_dollar): return _dollar_dollar _t732 = _t731(msg) fields131 = _t732 + assert fields131 is not None unwrapped_fields132 = fields131 self.write('MISSING') return None @@ -1525,6 +1604,7 @@ def _t733(_dollar_dollar): return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) _t734 = _t733(msg) fields133 = _t734 + assert fields133 is not None unwrapped_fields134 = fields133 self.write('(') self.write('DECIMAL') @@ -1544,6 +1624,7 @@ def _t735(_dollar_dollar): return _dollar_dollar _t736 = _t735(msg) fields137 = _t736 + assert fields137 is not None unwrapped_fields138 = fields137 self.write('BOOLEAN') return None @@ -1553,6 +1634,7 @@ def _t737(_dollar_dollar): return _dollar_dollar _t738 = _t737(msg) fields139 = _t738 + assert fields139 is not None unwrapped_fields140 = fields139 self.write('|') if not len(unwrapped_fields140) == 0: @@ -1770,6 +1852,7 @@ def _t806(_dollar_dollar): return _dollar_dollar _t807 = _t806(msg) fields156 = _t807 + assert fields156 is not None unwrapped_fields157 = fields156 self.write('(') self.write('true') @@ -1781,6 +1864,7 @@ def _t808(_dollar_dollar): return _dollar_dollar _t809 = _t808(msg) fields158 = _t809 + assert fields158 is not None unwrapped_fields159 = fields158 self.write('(') self.write('false') @@ -1793,6 +1877,7 @@ def _t810(_dollar_dollar): return (_t811, _dollar_dollar.body.value,) _t812 = _t810(msg) fields160 = _t812 + assert fields160 is not None unwrapped_fields161 = fields160 self.write('(') self.write('exists') @@ -1812,6 +1897,7 @@ def _t815(_dollar_dollar): return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) _t816 = _t815(msg) fields164 = _t816 + assert fields164 is not None unwrapped_fields165 = fields164 self.write('(') self.write('reduce') @@ -1834,6 +1920,7 @@ def _t820(_dollar_dollar): return _dollar_dollar _t821 = _t820(msg) fields169 = _t821 + assert fields169 is not None unwrapped_fields170 = fields169 self.write('(') self.write('terms') @@ -1890,6 +1977,7 @@ def _t834(_dollar_dollar): return _dollar_dollar.name _t835 = _t834(msg) fields175 = _t835 + assert fields175 is not None unwrapped_fields176 = fields175 self.write(unwrapped_fields176) return None @@ -1899,6 +1987,7 @@ def _t836(_dollar_dollar): return _dollar_dollar _t837 = _t836(msg) fields177 = _t837 + assert fields177 is not None unwrapped_fields178 = fields177 _t838 = self.pretty_value(unwrapped_fields178) return _t838 @@ -1908,6 +1997,7 @@ def _t839(_dollar_dollar): return _dollar_dollar.args _t840 = _t839(msg) fields179 = _t840 + assert fields179 is not None unwrapped_fields180 = fields179 self.write('(') self.write('and') @@ -1931,6 +2021,7 @@ def _t843(_dollar_dollar): return _dollar_dollar.args _t844 = _t843(msg) fields183 = _t844 + assert fields183 is not None unwrapped_fields184 = fields183 self.write('(') self.write('or') @@ -1954,6 +2045,7 @@ def _t847(_dollar_dollar): return _dollar_dollar.arg _t848 = _t847(msg) fields187 = _t848 + assert fields187 is not None unwrapped_fields188 = fields187 self.write('(') self.write('not') @@ -1969,6 +2061,7 @@ def _t850(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) _t851 = _t850(msg) fields189 = _t851 + assert fields189 is not None unwrapped_fields190 = fields189 self.write('(') self.write('ffi') @@ -1991,6 +2084,7 @@ def _t855(_dollar_dollar): return _dollar_dollar _t856 = _t855(msg) fields194 = _t856 + assert fields194 is not None unwrapped_fields195 = fields194 self.write(':') self.write(unwrapped_fields195) @@ -2001,6 +2095,7 @@ def _t857(_dollar_dollar): return _dollar_dollar _t858 = _t857(msg) fields196 = _t858 + assert fields196 is not None unwrapped_fields197 = fields196 self.write('(') self.write('args') @@ -2024,6 +2119,7 @@ def _t861(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t862 = _t861(msg) fields200 = _t862 + assert fields200 is not None unwrapped_fields201 = fields200 self.write('(') self.write('atom') @@ -2051,6 +2147,7 @@ def _t866(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t867 = _t866(msg) fields206 = _t867 + assert fields206 is not None unwrapped_fields207 = fields206 self.write('(') self.write('pragma') @@ -2204,6 +2301,7 @@ def _t916(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t917 = _t916(msg) fields212 = _t917 + assert fields212 is not None unwrapped_fields213 = fields212 self.write('(') self.write('primitive') @@ -2245,6 +2343,7 @@ def _t921(_dollar_dollar): return _t922 _t923 = _t921(msg) fields227 = _t923 + assert fields227 is not None unwrapped_fields228 = fields227 self.write('(') self.write('=') @@ -2269,6 +2368,7 @@ def _t926(_dollar_dollar): return _t927 _t928 = _t926(msg) fields231 = _t928 + assert fields231 is not None unwrapped_fields232 = fields231 self.write('(') self.write('<') @@ -2293,6 +2393,7 @@ def _t931(_dollar_dollar): return _t932 _t933 = _t931(msg) fields235 = _t933 + assert fields235 is not None unwrapped_fields236 = fields235 self.write('(') self.write('<=') @@ -2317,6 +2418,7 @@ def _t936(_dollar_dollar): return _t937 _t938 = _t936(msg) fields239 = _t938 + assert fields239 is not None unwrapped_fields240 = fields239 self.write('(') self.write('>') @@ -2341,6 +2443,7 @@ def _t941(_dollar_dollar): return _t942 _t943 = _t941(msg) fields243 = _t943 + assert fields243 is not None unwrapped_fields244 = fields243 self.write('(') self.write('>=') @@ -2365,6 +2468,7 @@ def _t946(_dollar_dollar): return _t947 _t948 = _t946(msg) fields247 = _t948 + assert fields247 is not None unwrapped_fields248 = fields247 self.write('(') self.write('+') @@ -2392,6 +2496,7 @@ def _t952(_dollar_dollar): return _t953 _t954 = _t952(msg) fields252 = _t954 + assert fields252 is not None unwrapped_fields253 = fields252 self.write('(') self.write('-') @@ -2419,6 +2524,7 @@ def _t958(_dollar_dollar): return _t959 _t960 = _t958(msg) fields257 = _t960 + assert fields257 is not None unwrapped_fields258 = fields257 self.write('(') self.write('*') @@ -2446,6 +2552,7 @@ def _t964(_dollar_dollar): return _t965 _t966 = _t964(msg) fields262 = _t966 + assert fields262 is not None unwrapped_fields263 = fields262 self.write('(') self.write('/') @@ -2501,6 +2608,7 @@ def _t980(_dollar_dollar): return _dollar_dollar _t981 = _t980(msg) fields269 = _t981 + assert fields269 is not None unwrapped_fields270 = fields269 self.write('#') _t982 = self.pretty_value(unwrapped_fields270) @@ -2511,6 +2619,7 @@ def _t983(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t984 = _t983(msg) fields271 = _t984 + assert fields271 is not None unwrapped_fields272 = fields271 self.write('(') self.write('relatom') @@ -2538,6 +2647,7 @@ def _t988(_dollar_dollar): return (_dollar_dollar.input, _dollar_dollar.result,) _t989 = _t988(msg) fields277 = _t989 + assert fields277 is not None unwrapped_fields278 = fields277 self.write('(') self.write('cast') @@ -2557,6 +2667,7 @@ def _t992(_dollar_dollar): return _dollar_dollar _t993 = _t992(msg) fields281 = _t993 + assert fields281 is not None unwrapped_fields282 = fields281 self.write('(') self.write('attrs') @@ -2580,6 +2691,7 @@ def _t996(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args,) _t997 = _t996(msg) fields285 = _t997 + assert fields285 is not None unwrapped_fields286 = fields285 self.write('(') self.write('attribute') @@ -2607,6 +2719,7 @@ def _t1001(_dollar_dollar): return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) _t1002 = _t1001(msg) fields291 = _t1002 + assert fields291 is not None unwrapped_fields292 = fields291 self.write('(') self.write('algorithm') @@ -2634,6 +2747,7 @@ def _t1006(_dollar_dollar): return _dollar_dollar.constructs _t1007 = _t1006(msg) fields297 = _t1007 + assert fields297 is not None unwrapped_fields298 = fields297 self.write('(') self.write('script') @@ -2690,6 +2804,7 @@ def _t1020(_dollar_dollar): return (_dollar_dollar.init, _dollar_dollar.body,) _t1021 = _t1020(msg) fields303 = _t1021 + assert fields303 is not None unwrapped_fields304 = fields303 self.write('(') self.write('loop') @@ -2709,6 +2824,7 @@ def _t1024(_dollar_dollar): return _dollar_dollar _t1025 = _t1024(msg) fields307 = _t1025 + assert fields307 is not None unwrapped_fields308 = fields307 self.write('(') self.write('init') @@ -2815,6 +2931,7 @@ def _t1053(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.body, _t1054,) _t1055 = _t1053(msg) fields316 = _t1055 + assert fields316 is not None unwrapped_fields317 = fields316 self.write('(') self.write('assign') @@ -2829,6 +2946,7 @@ def _t1053(_dollar_dollar): if field320 is not None: self.newline() + assert field320 is not None opt_val321 = field320 _t1059 = self.pretty_attrs(opt_val321) _t1058 = _t1059 @@ -2848,6 +2966,7 @@ def _t1060(_dollar_dollar): return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1061,) _t1062 = _t1060(msg) fields322 = _t1062 + assert fields322 is not None unwrapped_fields323 = fields322 self.write('(') self.write('upsert') @@ -2862,6 +2981,7 @@ def _t1060(_dollar_dollar): if field326 is not None: self.newline() + assert field326 is not None opt_val327 = field326 _t1066 = self.pretty_attrs(opt_val327) _t1065 = _t1066 @@ -2877,6 +2997,7 @@ def _t1067(_dollar_dollar): return (_t1068, _dollar_dollar[0].value,) _t1069 = _t1067(msg) fields328 = _t1069 + assert fields328 is not None unwrapped_fields329 = fields328 self.write('(') field330 = unwrapped_fields329[0] @@ -2897,6 +3018,7 @@ def _t1072(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.body, _t1073,) _t1074 = _t1072(msg) fields332 = _t1074 + assert fields332 is not None unwrapped_fields333 = fields332 self.write('(') self.write('break') @@ -2911,6 +3033,7 @@ def _t1072(_dollar_dollar): if field336 is not None: self.newline() + assert field336 is not None opt_val337 = field336 _t1078 = self.pretty_attrs(opt_val337) _t1077 = _t1078 @@ -2930,6 +3053,7 @@ def _t1079(_dollar_dollar): return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1080,) _t1081 = _t1079(msg) fields338 = _t1081 + assert fields338 is not None unwrapped_fields339 = fields338 self.write('(') self.write('monoid') @@ -2947,6 +3071,7 @@ def _t1079(_dollar_dollar): if field343 is not None: self.newline() + assert field343 is not None opt_val344 = field343 _t1086 = self.pretty_attrs(opt_val344) _t1085 = _t1086 @@ -3024,6 +3149,7 @@ def _t1107(_dollar_dollar): return _dollar_dollar _t1108 = _t1107(msg) fields349 = _t1108 + assert fields349 is not None unwrapped_fields350 = fields349 self.write('(') self.write('or') @@ -3035,6 +3161,7 @@ def _t1109(_dollar_dollar): return _dollar_dollar.type _t1110 = _t1109(msg) fields351 = _t1110 + assert fields351 is not None unwrapped_fields352 = fields351 self.write('(') self.write('min') @@ -3050,6 +3177,7 @@ def _t1112(_dollar_dollar): return _dollar_dollar.type _t1113 = _t1112(msg) fields353 = _t1113 + assert fields353 is not None unwrapped_fields354 = fields353 self.write('(') self.write('max') @@ -3065,6 +3193,7 @@ def _t1115(_dollar_dollar): return _dollar_dollar.type _t1116 = _t1115(msg) fields355 = _t1116 + assert fields355 is not None unwrapped_fields356 = fields355 self.write('(') self.write('sum') @@ -3085,6 +3214,7 @@ def _t1118(_dollar_dollar): return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1119,) _t1120 = _t1118(msg) fields357 = _t1120 + assert fields357 is not None unwrapped_fields358 = fields357 self.write('(') self.write('monus') @@ -3102,6 +3232,7 @@ def _t1118(_dollar_dollar): if field362 is not None: self.newline() + assert field362 is not None opt_val363 = field362 _t1125 = self.pretty_attrs(opt_val363) _t1124 = _t1125 @@ -3116,6 +3247,7 @@ def _t1126(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) _t1127 = _t1126(msg) fields364 = _t1127 + assert fields364 is not None unwrapped_fields365 = fields364 self.write('(') self.write('functional_dependency') @@ -3141,6 +3273,7 @@ def _t1132(_dollar_dollar): return _dollar_dollar _t1133 = _t1132(msg) fields370 = _t1133 + assert fields370 is not None unwrapped_fields371 = fields370 self.write('(') self.write('keys') @@ -3164,6 +3297,7 @@ def _t1136(_dollar_dollar): return _dollar_dollar _t1137 = _t1136(msg) fields374 = _t1137 + assert fields374 is not None unwrapped_fields375 = fields374 self.write('(') self.write('values') @@ -3235,6 +3369,7 @@ def _t1155(_dollar_dollar): return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) _t1156 = _t1155(msg) fields381 = _t1156 + assert fields381 is not None unwrapped_fields382 = fields381 self.write('(') self.write('rel_edb') @@ -3257,6 +3392,7 @@ def _t1160(_dollar_dollar): return _dollar_dollar _t1161 = _t1160(msg) fields386 = _t1161 + assert fields386 is not None unwrapped_fields387 = fields386 self.write('[') for i389, elem388 in enumerate(unwrapped_fields387): @@ -3275,6 +3411,7 @@ def _t1163(_dollar_dollar): return _dollar_dollar _t1164 = _t1163(msg) fields390 = _t1164 + assert fields390 is not None unwrapped_fields391 = fields390 self.write('[') for i393, elem392 in enumerate(unwrapped_fields391): @@ -3293,6 +3430,7 @@ def _t1167(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_info,) _t1168 = _t1167(msg) fields394 = _t1168 + assert fields394 is not None unwrapped_fields395 = fields394 self.write('(') self.write('betree_relation') @@ -3313,6 +3451,7 @@ def _t1171(_dollar_dollar): return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1172,) _t1173 = _t1171(msg) fields398 = _t1173 + assert fields398 is not None unwrapped_fields399 = fields398 self.write('(') self.write('betree_info') @@ -3335,6 +3474,7 @@ def _t1177(_dollar_dollar): return _dollar_dollar _t1178 = _t1177(msg) fields403 = _t1178 + assert fields403 is not None unwrapped_fields404 = fields403 self.write('(') self.write('key_types') @@ -3358,6 +3498,7 @@ def _t1181(_dollar_dollar): return _dollar_dollar _t1182 = _t1181(msg) fields407 = _t1182 + assert fields407 is not None unwrapped_fields408 = fields407 self.write('(') self.write('value_types') @@ -3381,6 +3522,7 @@ def _t1185(_dollar_dollar): return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) _t1186 = _t1185(msg) fields411 = _t1186 + assert fields411 is not None unwrapped_fields412 = fields411 self.write('(') self.write('csv_data') @@ -3416,6 +3558,7 @@ def _t1191(_dollar_dollar): return (_t1192, _t1193,) _t1194 = _t1191(msg) fields417 = _t1194 + assert fields417 is not None unwrapped_fields418 = fields417 self.write('(') self.write('csv_locator') @@ -3424,6 +3567,7 @@ def _t1191(_dollar_dollar): if field419 is not None: self.newline() + assert field419 is not None opt_val420 = field419 _t1196 = self.pretty_csv_locator_paths(opt_val420) _t1195 = _t1196 @@ -3433,6 +3577,7 @@ def _t1191(_dollar_dollar): if field421 is not None: self.newline() + assert field421 is not None opt_val422 = field421 _t1198 = self.pretty_csv_locator_inline_data(opt_val422) _t1197 = _t1198 @@ -3447,6 +3592,7 @@ def _t1199(_dollar_dollar): return _dollar_dollar _t1200 = _t1199(msg) fields423 = _t1200 + assert fields423 is not None unwrapped_fields424 = fields423 self.write('(') self.write('paths') @@ -3470,6 +3616,7 @@ def _t1202(_dollar_dollar): return _dollar_dollar _t1203 = _t1202(msg) fields427 = _t1203 + assert fields427 is not None unwrapped_fields428 = fields427 self.write('(') self.write('inline_data') @@ -3486,6 +3633,7 @@ def _t1204(_dollar_dollar): return _t1205 _t1206 = _t1204(msg) fields429 = _t1206 + assert fields429 is not None unwrapped_fields430 = fields429 self.write('(') self.write('csv_config') @@ -3501,6 +3649,7 @@ def _t1208(_dollar_dollar): return _dollar_dollar _t1209 = _t1208(msg) fields431 = _t1209 + assert fields431 is not None unwrapped_fields432 = fields431 self.write('(') self.write('columns') @@ -3524,6 +3673,7 @@ def _t1212(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) _t1213 = _t1212(msg) fields435 = _t1213 + assert fields435 is not None unwrapped_fields436 = fields435 self.write('(') self.write('column') @@ -3556,6 +3706,7 @@ def _t1217(_dollar_dollar): return _dollar_dollar _t1218 = _t1217(msg) fields442 = _t1218 + assert fields442 is not None unwrapped_fields443 = fields442 self.write('(') self.write('asof') @@ -3571,6 +3722,7 @@ def _t1219(_dollar_dollar): return _dollar_dollar.fragment_id _t1220 = _t1219(msg) fields444 = _t1220 + assert fields444 is not None unwrapped_fields445 = fields444 self.write('(') self.write('undefine') @@ -3586,6 +3738,7 @@ def _t1222(_dollar_dollar): return _dollar_dollar.relations _t1223 = _t1222(msg) fields446 = _t1223 + assert fields446 is not None unwrapped_fields447 = fields446 self.write('(') self.write('context') @@ -3609,6 +3762,7 @@ def _t1226(_dollar_dollar): return _dollar_dollar _t1227 = _t1226(msg) fields450 = _t1227 + assert fields450 is not None unwrapped_fields451 = fields450 self.write('(') self.write('reads') @@ -3710,6 +3864,7 @@ def _t1255(_dollar_dollar): return _dollar_dollar.relation_id _t1256 = _t1255(msg) fields459 = _t1256 + assert fields459 is not None unwrapped_fields460 = fields459 self.write('(') self.write('demand') @@ -3725,6 +3880,7 @@ def _t1258(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_id,) _t1259 = _t1258(msg) fields461 = _t1259 + assert fields461 is not None unwrapped_fields462 = fields461 self.write('(') self.write('output') @@ -3744,6 +3900,7 @@ def _t1262(_dollar_dollar): return (_dollar_dollar.branch, _dollar_dollar.epoch,) _t1263 = _t1262(msg) fields465 = _t1263 + assert fields465 is not None unwrapped_fields466 = fields465 self.write('(') self.write('what_if') @@ -3768,6 +3925,7 @@ def _t1266(_dollar_dollar): return (_t1267, _dollar_dollar.relation_id,) _t1268 = _t1266(msg) fields469 = _t1268 + assert fields469 is not None unwrapped_fields470 = fields469 self.write('(') self.write('abort') @@ -3776,6 +3934,7 @@ def _t1266(_dollar_dollar): if field471 is not None: self.newline() + assert field471 is not None opt_val472 = field471 _t1270 = self.pretty_name(opt_val472) _t1269 = _t1270 @@ -3793,6 +3952,7 @@ def _t1272(_dollar_dollar): return _dollar_dollar.csv_config _t1273 = _t1272(msg) fields474 = _t1273 + assert fields474 is not None unwrapped_fields475 = fields474 self.write('(') self.write('export') @@ -3809,6 +3969,7 @@ def _t1275(_dollar_dollar): return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1276,) _t1277 = _t1275(msg) fields476 = _t1277 + assert fields476 is not None unwrapped_fields477 = fields476 self.write('(') self.write('export_csv_config') @@ -3831,6 +3992,7 @@ def _t1281(_dollar_dollar): return _dollar_dollar _t1282 = _t1281(msg) fields481 = _t1282 + assert fields481 is not None unwrapped_fields482 = fields481 self.write('(') self.write('path') @@ -3846,6 +4008,7 @@ def _t1283(_dollar_dollar): return _dollar_dollar _t1284 = _t1283(msg) fields483 = _t1284 + assert fields483 is not None unwrapped_fields484 = fields483 self.write('(') self.write('columns') @@ -3869,6 +4032,7 @@ def _t1287(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.column_data,) _t1288 = _t1287(msg) fields487 = _t1288 + assert fields487 is not None unwrapped_fields488 = fields487 self.write('(') self.write('column') diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index 846a8377..86be5345 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -68,7 +68,7 @@ def _gen_tuple_builtin(args, lines, indent): @staticmethod def _gen_unwrap_option_builtin(args, lines, indent): from .codegen_base import BuiltinResult - return BuiltinResult(args[0], [f"{indent}assert {args[0]} is not None"]) + return BuiltinResult(args[0], [f"assert {args[0]} is not None"]) def escape_keyword(self, name: str) -> str: return f"{name}_" diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index c9bc8bfd..1ede4c90 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -1252,13 +1252,13 @@ def export_csv_config( return transactions.ExportCSVConfig( path=path, data_columns=columns, - partition_size=builtin.to_ptr_int64(partition_size), - compression=builtin.to_ptr_string(compression), - syntax_header_row=builtin.to_ptr_bool(syntax_header_row), - syntax_missing_string=builtin.to_ptr_string(syntax_missing_string), - syntax_delim=builtin.to_ptr_string(syntax_delim), - syntax_quotechar=builtin.to_ptr_string(syntax_quotechar), - syntax_escapechar=builtin.to_ptr_string(syntax_escapechar), + partition_size=builtin.some(partition_size), + compression=builtin.some(compression), + syntax_header_row=builtin.some(syntax_header_row), + syntax_missing_string=builtin.some(syntax_missing_string), + syntax_delim=builtin.some(syntax_delim), + syntax_quotechar=builtin.some(syntax_quotechar), + syntax_escapechar=builtin.some(syntax_escapechar), ) @@ -1402,7 +1402,8 @@ def deconstruct_relation_id_uint128(msg: logic.RelationId) -> Optional[logic.UIn def deconstruct_bindings(abs: logic.Abstraction) -> Tuple[List[logic.Binding], List[logic.Binding]]: - return builtin.tuple(abs.vars, list[logic.Binding]()) + n: int = builtin.length(abs.vars) + return builtin.tuple(builtin.list_slice(abs.vars, 0, n), list[logic.Binding]()) def deconstruct_bindings_with_arity(abs: logic.Abstraction, value_arity: int) -> Tuple[List[logic.Binding], List[logic.Binding]]: diff --git a/python-tools/src/meta/templates/pretty_printer.py.template b/python-tools/src/meta/templates/pretty_printer.py.template index 9e54e5ac..925e8bcd 100644 --- a/python-tools/src/meta/templates/pretty_printer.py.template +++ b/python-tools/src/meta/templates/pretty_printer.py.template @@ -52,7 +52,7 @@ class PrettyPrinter: return self.io.getvalue() return "" - def format_decimal(self, msg) -> str: + def format_decimal(self, msg: logic_pb2.DecimalValue) -> str: """Format a DecimalValue as '.d'.""" int_val: int = (msg.value.high << 64) | msg.value.low if msg.value.high & (1 << 63): @@ -71,40 +71,40 @@ class PrettyPrinter: decimal_str = digits[:-scale] + "." + digits[-scale:] return sign + decimal_str + "d" + str(msg.precision) - def format_int128(self, msg) -> str: + def format_int128(self, msg: logic_pb2.Int128Value) -> str: """Format an Int128Value protobuf message as a string with i128 suffix.""" value = (msg.high << 64) | msg.low if msg.high & (1 << 63): value -= (1 << 128) return str(value) + "i128" - def format_uint128(self, msg) -> str: + def format_uint128(self, msg: logic_pb2.UInt128Value) -> str: """Format a UInt128Value protobuf message as a hex string.""" value = (msg.high << 64) | msg.low return f"0x{{value:x}}" - def fragment_id_to_string(self, msg) -> str: + def fragment_id_to_string(self, msg: fragments_pb2.FragmentId) -> str: """Convert FragmentId to string representation.""" return msg.id.decode('utf-8') if msg.id else "" - def start_pretty_fragment(self, msg) -> None: + def start_pretty_fragment(self, msg: fragments_pb2.Fragment) -> None: """Extract debug info from Fragment for relation ID lookup.""" debug_info = msg.debug_info for rid, name in zip(debug_info.ids, debug_info.orig_names): self._debug_info[(rid.id_low, rid.id_high)] = name - def relation_id_to_string(self, msg): + def relation_id_to_string(self, msg: logic_pb2.RelationId) -> str: """Convert RelationId to string representation using debug info.""" return self._debug_info.get((msg.id_low, msg.id_high), "") - def relation_id_to_int(self, msg): + def relation_id_to_int(self, msg: logic_pb2.RelationId) -> Optional[int]: """Convert RelationId to int if it fits in signed 64-bit range.""" value = (msg.id_high << 64) | msg.id_low if value <= 0x7FFFFFFFFFFFFFFF: return value return None - def relation_id_to_uint128(self, msg): + def relation_id_to_uint128(self, msg: logic_pb2.RelationId) -> logic_pb2.UInt128Value: """Convert RelationId to UInt128Value representation.""" return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) From fc07c5e2285d2131acc2dd4c7a628da13d83ce28 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 18:02:41 +0100 Subject: [PATCH 09/25] fix imports --- python-tools/src/lqp/cli.py | 2 +- python-tools/tests/test_generated_pretty_printer.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python-tools/src/lqp/cli.py b/python-tools/src/lqp/cli.py index 586ed760..e8a1f56f 100644 --- a/python-tools/src/lqp/cli.py +++ b/python-tools/src/lqp/cli.py @@ -49,7 +49,7 @@ def read_bin_to_proto(filename): def pretty_print_proto(lqp_proto): """Pretty-print a protobuf message and return the string.""" - from lqp.generated_pretty_printer import pretty + from lqp.gen.pretty import pretty return pretty(lqp_proto) diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index 78d03002..ce264351 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -12,8 +12,8 @@ from lqp.parser import parse_lqp from lqp.emit import ir_to_proto -from lqp.generated_pretty_printer import pretty -from lqp.generated_parser import parse as generated_parse +from lqp.gen.pretty import pretty +from lqp.gen.parser import parse as generated_parse from lqp.cli import read_bin_to_proto import lqp.print as lqp_print From f86c44f90fe9c709399c14cf92a9de94316fd6ab Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 18:04:36 +0100 Subject: [PATCH 10/25] fix Makefile --- Makefile | 6 +++--- go/src/parser.go | 16 +++++++++------- julia/LQPParser/src/parser.jl | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 80cfb2cf..d5514eed 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ JL_PARSER := julia/LQPParser/src/parser.jl GO_PARSER := go/src/parser.go # Generated pretty printer outputs -PY_PRINTER := python-tools/src/lqp/generated_pretty_printer.py +PY_PRINTER := python-tools/src/lqp/gen/pretty.py JL_PRINTER := julia/LQPParser/src/pretty_printer.jl GO_PRINTER := go/src/pretty_printer.go @@ -118,7 +118,7 @@ printers: printer-python printer-julia printer-go printer-python: protobuf $(PY_PRINTER) $(PY_PRINTER): $(PROTO_FILES) $(GRAMMAR) - $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/generated_pretty_printer.py + $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/gen/pretty.py printer-julia: protobuf @echo "Pretty printer generation for Julia is not yet implemented." @@ -129,7 +129,7 @@ printer-go: protobuf force-printers: force-printer-python force-printer-julia force-printer-go force-printer-python: protobuf - $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/generated_pretty_printer.py + $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/gen/pretty.py force-printer-julia: protobuf @echo "Pretty printer generation for Julia is not yet implemented." diff --git a/go/src/parser.go b/go/src/parser.go index 6530a698..4d7cfe49 100644 --- a/go/src/parser.go +++ b/go/src/parser.go @@ -807,7 +807,7 @@ func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, c syntax_quotechar := _t989 _t990 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") syntax_escapechar := _t990 - _t991 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptrInt64(partition_size), Compression: ptrString(compression), SyntaxHeaderRow: ptrBool(syntax_header_row), SyntaxMissingString: ptrString(syntax_missing_string), SyntaxDelim: ptrString(syntax_delim), SyntaxQuotechar: ptrString(syntax_quotechar), SyntaxEscapechar: ptrString(syntax_escapechar)} + _t991 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} return _t991 } @@ -1082,16 +1082,18 @@ func (p *Parser) deconstruct_relation_id_uint128(msg *pb.RelationId) *pb.UInt128 } func (p *Parser) deconstruct_bindings(abs *pb.Abstraction) []interface{} { - return []interface{}{abs.GetVars(), []*pb.Binding{}} + n := int64(len(abs.GetVars())) + _t1064 := p.list_slice(abs.GetVars(), 0, n) + return []interface{}{_t1064, []*pb.Binding{}} } func (p *Parser) deconstruct_bindings_with_arity(abs *pb.Abstraction, value_arity int64) []interface{} { n := int64(len(abs.GetVars())) - _t1064 := p.subtract(n, value_arity) - key_end := _t1064 - _t1065 := p.list_slice(abs.GetVars(), 0, key_end) - _t1066 := p.list_slice(abs.GetVars(), key_end, n) - return []interface{}{_t1065, _t1066} + _t1065 := p.subtract(n, value_arity) + key_end := _t1065 + _t1066 := p.list_slice(abs.GetVars(), 0, key_end) + _t1067 := p.list_slice(abs.GetVars(), key_end, n) + return []interface{}{_t1066, _t1067} } // --- Parse functions --- diff --git a/julia/LQPParser/src/parser.jl b/julia/LQPParser/src/parser.jl index 420f64e5..81a19df6 100644 --- a/julia/LQPParser/src/parser.jl +++ b/julia/LQPParser/src/parser.jl @@ -834,7 +834,8 @@ function deconstruct_relation_id_uint128(parser::Parser, msg::Proto.RelationId): end function deconstruct_bindings(parser::Parser, abs::Proto.Abstraction)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} - return (abs.vars, Proto.Binding[],) + n = length(abs.vars) + return (abs.vars[0:n], Proto.Binding[],) end function deconstruct_bindings_with_arity(parser::Parser, abs::Proto.Abstraction, value_arity::Int64)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} From 4dc33bad4dbc34311bbcb79fd038babea39cf1bf Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 18:05:18 +0100 Subject: [PATCH 11/25] generated pretty printer --- python-tools/src/lqp/gen/pretty.py | 4056 ++++++++++++++++++++++++++++ 1 file changed, 4056 insertions(+) create mode 100644 python-tools/src/lqp/gen/pretty.py diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py new file mode 100644 index 00000000..ea98ebf7 --- /dev/null +++ b/python-tools/src/lqp/gen/pretty.py @@ -0,0 +1,4056 @@ +""" +Auto-generated pretty printer. + +Generated from protobuf specifications. +Do not modify this file! If you need to modify the pretty printer, edit the generator code +in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. + + +Command: python -m meta.cli fragments.proto logic.proto transactions.proto --grammar grammar.y --printer python +""" + +from io import StringIO +from typing import Any, IO, Never, Optional + +from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 + + +class ParseError(Exception): + pass + + +class PrettyPrinter: + """Pretty printer for protobuf messages.""" + + def __init__(self, io: Optional[IO[str]] = None): + self.io = io if io is not None else StringIO() + self.indent_level = 0 + self.at_line_start = True + self._debug_info: dict[tuple[int, int], str] = {} + + def write(self, s: str) -> None: + """Write a string to the output, with indentation at line start.""" + if self.at_line_start and s.strip(): + self.io.write(' ' * self.indent_level) + self.at_line_start = False + self.io.write(s) + + def newline(self) -> None: + """Write a newline to the output.""" + self.io.write('\n') + self.at_line_start = True + + def indent(self, delta: int = 1) -> None: + """Increase indentation level.""" + self.indent_level += delta + + def dedent(self, delta: int = 1) -> None: + """Decrease indentation level.""" + self.indent_level = max(0, self.indent_level - delta) + + def get_output(self) -> str: + """Get the accumulated output as a string.""" + if isinstance(self.io, StringIO): + return self.io.getvalue() + return "" + + def format_decimal(self, msg: logic_pb2.DecimalValue) -> str: + """Format a DecimalValue as '.d'.""" + int_val: int = (msg.value.high << 64) | msg.value.low + if msg.value.high & (1 << 63): + int_val -= (1 << 128) + sign = "" + if int_val < 0: + sign = "-" + int_val = -int_val + digits = str(int_val) + scale = msg.scale + if scale <= 0: + decimal_str = digits + "." + "0" * (-scale) + elif scale >= len(digits): + decimal_str = "0." + "0" * (scale - len(digits)) + digits + else: + decimal_str = digits[:-scale] + "." + digits[-scale:] + return sign + decimal_str + "d" + str(msg.precision) + + def format_int128(self, msg: logic_pb2.Int128Value) -> str: + """Format an Int128Value protobuf message as a string with i128 suffix.""" + value = (msg.high << 64) | msg.low + if msg.high & (1 << 63): + value -= (1 << 128) + return str(value) + "i128" + + def format_uint128(self, msg: logic_pb2.UInt128Value) -> str: + """Format a UInt128Value protobuf message as a hex string.""" + value = (msg.high << 64) | msg.low + return f"0x{value:x}" + + def fragment_id_to_string(self, msg: fragments_pb2.FragmentId) -> str: + """Convert FragmentId to string representation.""" + return msg.id.decode('utf-8') if msg.id else "" + + def start_pretty_fragment(self, msg: fragments_pb2.Fragment) -> None: + """Extract debug info from Fragment for relation ID lookup.""" + debug_info = msg.debug_info + for rid, name in zip(debug_info.ids, debug_info.orig_names): + self._debug_info[(rid.id_low, rid.id_high)] = name + + def relation_id_to_string(self, msg: logic_pb2.RelationId) -> str: + """Convert RelationId to string representation using debug info.""" + return self._debug_info.get((msg.id_low, msg.id_high), "") + + def relation_id_to_int(self, msg: logic_pb2.RelationId) -> Optional[int]: + """Convert RelationId to int if it fits in signed 64-bit range.""" + value = (msg.id_high << 64) | msg.id_low + if value <= 0x7FFFFFFFFFFFFFFF: + return value + return None + + def relation_id_to_uint128(self, msg: logic_pb2.RelationId) -> logic_pb2.UInt128Value: + """Convert RelationId to UInt128Value representation.""" + return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) + + def format_string_value(self, s: str) -> str: + """Format a string value with double quotes for LQP output.""" + escaped = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t') + return '"' + escaped + '"' + + # --- Helper functions --- + + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + assert value is not None + if (value is not None and value.HasField('int_value')): + assert value is not None + return value.int_value + return default + + def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: + assert value is not None + if (value is not None and value.HasField('float_value')): + assert value is not None + return value.float_value + return default + + def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return value.string_value + return default + + def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + assert value is not None + if (value is not None and value.HasField('boolean_value')): + assert value is not None + return value.boolean_value + return default + + def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return value.string_value.encode() + return default + + def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: + assert value is not None + if (value is not None and value.HasField('uint128_value')): + assert value is not None + return value.uint128_value + return default + + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return [value.string_value] + return default + + def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + assert value is not None + if (value is not None and value.HasField('int_value')): + assert value is not None + return value.int_value + return None + + def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + assert value is not None + if (value is not None and value.HasField('float_value')): + assert value is not None + return value.float_value + return None + + def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return value.string_value + return None + + def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return value.string_value.encode() + return None + + def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + assert value is not None + if (value is not None and value.HasField('uint128_value')): + assert value is not None + return value.uint128_value + return None + + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + assert value is not None + if (value is not None and value.HasField('string_value')): + assert value is not None + return [value.string_value] + return None + + def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + config = dict(config_dict) + _t1290 = self._extract_value_int64(config.get('csv_header_row'), 1) + header_row = _t1290 + _t1291 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1291 + _t1292 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1292 + _t1293 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1293 + _t1294 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1294 + _t1295 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1295 + _t1296 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1296 + _t1297 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1297 + _t1298 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1298 + _t1299 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1299 + _t1300 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1300 + _t1301 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1301 + + def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + config = dict(config_dict) + _t1302 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1302 + _t1303 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1303 + _t1304 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1304 + _t1305 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1305 + _t1306 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1306 + _t1307 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1307 + _t1308 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1308 + _t1309 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1309 + _t1310 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1310 + _t1311 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1311 + _t1312 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1312 + + def default_configure(self) -> transactions_pb2.Configure: + _t1313 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1313 + _t1314 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1314 + + def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + config = dict(config_dict) + maintenance_level_val = config.get('ivm.maintenance_level') + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + if (maintenance_level_val is not None and maintenance_level_val.HasField('string_value')): + if maintenance_level_val.string_value == 'off': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + else: + if maintenance_level_val.string_value == 'auto': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO + else: + if maintenance_level_val.string_value == 'all': + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL + else: + maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF + _t1315 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1315 + _t1316 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1316 + _t1317 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1317 + + def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + config = dict(config_dict) + _t1318 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1318 + _t1319 = self._extract_value_string(config.get('compression'), '') + compression = _t1319 + _t1320 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1320 + _t1321 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1321 + _t1322 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1322 + _t1323 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1323 + _t1324 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1324 + _t1325 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1325 + + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t1326 = logic_pb2.Value(int_value=v) + return _t1326 + + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t1327 = logic_pb2.Value(float_value=v) + return _t1327 + + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t1328 = logic_pb2.Value(string_value=v) + return _t1328 + + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t1329 = logic_pb2.Value(boolean_value=v) + return _t1329 + + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t1330 = logic_pb2.Value(uint128_value=v) + return _t1330 + + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: + if cfg.semantics_version != 0: + return False + if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + return False + return True + + def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: + _t1332 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1332,)) + _t1331 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: + _t1334 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1334,)) + _t1333 = None + else: + + if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: + _t1336 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1336,)) + _t1335 = None + else: + _t1335 = None + _t1333 = _t1335 + _t1331 = _t1333 + _t1337 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1337,)) + return result + + def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + + if msg.header_row != 1: + _t1339 = self._make_value_int64(int(msg.header_row)) + result.append(('csv_header_row', _t1339,)) + _t1338 = None + else: + _t1338 = None + + if msg.skip != 0: + _t1341 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1341,)) + _t1340 = None + else: + _t1340 = None + + if msg.new_line != '': + _t1343 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1343,)) + _t1342 = None + else: + _t1342 = None + + if msg.delimiter != ',': + _t1345 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1345,)) + _t1344 = None + else: + _t1344 = None + + if msg.quotechar != '"': + _t1347 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1347,)) + _t1346 = None + else: + _t1346 = None + + if msg.escapechar != '"': + _t1349 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1349,)) + _t1348 = None + else: + _t1348 = None + + if msg.comment != '': + _t1351 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1351,)) + _t1350 = None + else: + _t1350 = None + + if not len(msg.missing_strings) == 0: + _t1353 = self._make_value_string(msg.missing_strings[0]) + result.append(('csv_missing_strings', _t1353,)) + _t1352 = None + else: + _t1352 = None + + if msg.decimal_separator != '.': + _t1355 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1355,)) + _t1354 = None + else: + _t1354 = None + + if msg.encoding != 'utf-8': + _t1357 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1357,)) + _t1356 = None + else: + _t1356 = None + + if msg.compression != 'auto': + _t1359 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1359,)) + _t1358 = None + else: + _t1358 = None + return result + + def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: + + if val is not None: + assert val is not None + _t1361 = self._make_value_float64(val) + result.append((key, _t1361,)) + _t1360 = None + else: + _t1360 = None + return None + + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: + + if val is not None: + assert val is not None + _t1363 = self._make_value_int64(val) + result.append((key, _t1363,)) + _t1362 = None + else: + _t1362 = None + return None + + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + + if val is not None: + assert val is not None + _t1365 = self._make_value_uint128(val) + result.append((key, _t1365,)) + _t1364 = None + else: + _t1364 = None + return None + + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + assert val is not None + _t1367 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1367,)) + _t1366 = None + else: + _t1366 = None + return None + + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: + result = [] + _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + + if msg.relation_locator.HasField('root_pageid'): + _t1373 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1372 = _t1373 + else: + _t1372 = None + + if msg.relation_locator.HasField('inline_data'): + _t1375 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1374 = _t1375 + else: + _t1374 = None + _t1376 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1377 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return result + + def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: + result = [] + assert msg.partition_size is not None + + if (msg.partition_size is not None and msg.partition_size != 0): + assert msg.partition_size is not None + _t1379 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1379,)) + _t1378 = None + else: + _t1378 = None + assert msg.compression is not None + + if (msg.compression is not None and msg.compression != ''): + assert msg.compression is not None + _t1381 = self._make_value_string(msg.compression) + result.append(('compression', _t1381,)) + _t1380 = None + else: + _t1380 = None + + if msg.syntax_header_row is not None: + assert msg.syntax_header_row is not None + _t1383 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1383,)) + _t1382 = None + else: + _t1382 = None + assert msg.syntax_missing_string is not None + + if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + assert msg.syntax_missing_string is not None + _t1385 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1385,)) + _t1384 = None + else: + _t1384 = None + assert msg.syntax_delim is not None + + if (msg.syntax_delim is not None and msg.syntax_delim != ','): + assert msg.syntax_delim is not None + _t1387 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1387,)) + _t1386 = None + else: + _t1386 = None + assert msg.syntax_quotechar is not None + + if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + assert msg.syntax_quotechar is not None + _t1389 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1389,)) + _t1388 = None + else: + _t1388 = None + assert msg.syntax_escapechar is not None + + if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + assert msg.syntax_escapechar is not None + _t1391 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1391,)) + _t1390 = None + else: + _t1390 = None + return result + + def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: + name = self.relation_id_to_string(msg) + if name != '': + return name + return None + + def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: + name = self.relation_id_to_string(msg) + if name == '': + return self.relation_id_to_uint128(msg) + return None + + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + n = len(abs.vars) + return (abs.vars[0:n], [],) + + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + n = len(abs.vars) + key_end = (n - value_arity) + return (abs.vars[0:key_end], abs.vars[key_end:n],) + + # --- Pretty-print methods --- + + def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: + def _t491(_dollar_dollar): + + if _dollar_dollar.HasField('configure'): + _t492 = _dollar_dollar.configure + else: + _t492 = None + + if _dollar_dollar.HasField('sync'): + _t493 = _dollar_dollar.sync + else: + _t493 = None + return (_t492, _t493, _dollar_dollar.epochs,) + _t494 = _t491(msg) + fields0 = _t494 + assert fields0 is not None + unwrapped_fields1 = fields0 + self.write('(') + self.write('transaction') + self.indent() + field2 = unwrapped_fields1[0] + + if field2 is not None: + self.newline() + assert field2 is not None + opt_val3 = field2 + _t496 = self.pretty_configure(opt_val3) + _t495 = _t496 + else: + _t495 = None + field4 = unwrapped_fields1[1] + + if field4 is not None: + self.newline() + assert field4 is not None + opt_val5 = field4 + _t498 = self.pretty_sync(opt_val5) + _t497 = _t498 + else: + _t497 = None + field6 = unwrapped_fields1[2] + if not len(field6) == 0: + self.newline() + for i8, elem7 in enumerate(field6): + + if (i8 > 0): + self.newline() + _t499 = None + else: + _t499 = None + _t500 = self.pretty_epoch(elem7) + self.dedent() + self.write(')') + return None + + def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: + def _t501(_dollar_dollar): + _t502 = self.deconstruct_configure(_dollar_dollar) + return _t502 + _t503 = _t501(msg) + fields9 = _t503 + assert fields9 is not None + unwrapped_fields10 = fields9 + self.write('(') + self.write('configure') + self.indent() + self.newline() + _t504 = self.pretty_config_dict(unwrapped_fields10) + self.dedent() + self.write(')') + return None + + def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: + def _t505(_dollar_dollar): + return _dollar_dollar + _t506 = _t505(msg) + fields11 = _t506 + assert fields11 is not None + unwrapped_fields12 = fields11 + self.write('{') + if not len(unwrapped_fields12) == 0: + self.write(' ') + for i14, elem13 in enumerate(unwrapped_fields12): + + if (i14 > 0): + self.newline() + _t507 = None + else: + _t507 = None + _t508 = self.pretty_config_key_value(elem13) + self.write('}') + return None + + def pretty_config_key_value(self, msg: tuple[str, logic_pb2.Value]) -> Optional[Never]: + def _t509(_dollar_dollar): + return (_dollar_dollar[0], _dollar_dollar[1],) + _t510 = _t509(msg) + fields15 = _t510 + assert fields15 is not None + unwrapped_fields16 = fields15 + self.write(':') + field17 = unwrapped_fields16[0] + self.write(field17) + self.write(' ') + field18 = unwrapped_fields16[1] + _t511 = self.pretty_value(field18) + return _t511 + + def pretty_value(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t512(_dollar_dollar): + + if _dollar_dollar.HasField('date_value'): + _t513 = _dollar_dollar.date_value + else: + _t513 = None + return _t513 + _t514 = _t512(msg) + deconstruct_result29 = _t514 + + if deconstruct_result29 is not None: + _t516 = self.pretty_date(deconstruct_result29) + _t515 = _t516 + else: + def _t517(_dollar_dollar): + + if _dollar_dollar.HasField('datetime_value'): + _t518 = _dollar_dollar.datetime_value + else: + _t518 = None + return _t518 + _t519 = _t517(msg) + deconstruct_result28 = _t519 + + if deconstruct_result28 is not None: + _t521 = self.pretty_datetime(deconstruct_result28) + _t520 = _t521 + else: + def _t522(_dollar_dollar): + + if _dollar_dollar.HasField('string_value'): + _t523 = _dollar_dollar.string_value + else: + _t523 = None + return _t523 + _t524 = _t522(msg) + deconstruct_result27 = _t524 + + if deconstruct_result27 is not None: + self.write(self.format_string_value(deconstruct_result27)) + _t525 = None + else: + def _t526(_dollar_dollar): + + if _dollar_dollar.HasField('int_value'): + _t527 = _dollar_dollar.int_value + else: + _t527 = None + return _t527 + _t528 = _t526(msg) + deconstruct_result26 = _t528 + + if deconstruct_result26 is not None: + self.write(str(deconstruct_result26)) + _t529 = None + else: + def _t530(_dollar_dollar): + + if _dollar_dollar.HasField('float_value'): + _t531 = _dollar_dollar.float_value + else: + _t531 = None + return _t531 + _t532 = _t530(msg) + deconstruct_result25 = _t532 + + if deconstruct_result25 is not None: + self.write(str(deconstruct_result25)) + _t533 = None + else: + def _t534(_dollar_dollar): + + if _dollar_dollar.HasField('uint128_value'): + _t535 = _dollar_dollar.uint128_value + else: + _t535 = None + return _t535 + _t536 = _t534(msg) + deconstruct_result24 = _t536 + + if deconstruct_result24 is not None: + self.write(self.format_uint128(deconstruct_result24)) + _t537 = None + else: + def _t538(_dollar_dollar): + + if _dollar_dollar.HasField('int128_value'): + _t539 = _dollar_dollar.int128_value + else: + _t539 = None + return _t539 + _t540 = _t538(msg) + deconstruct_result23 = _t540 + + if deconstruct_result23 is not None: + self.write(self.format_int128(deconstruct_result23)) + _t541 = None + else: + def _t542(_dollar_dollar): + + if _dollar_dollar.HasField('decimal_value'): + _t543 = _dollar_dollar.decimal_value + else: + _t543 = None + return _t543 + _t544 = _t542(msg) + deconstruct_result22 = _t544 + + if deconstruct_result22 is not None: + self.write(self.format_decimal(deconstruct_result22)) + _t545 = None + else: + def _t546(_dollar_dollar): + + if _dollar_dollar.HasField('boolean_value'): + _t547 = _dollar_dollar.boolean_value + else: + _t547 = None + return _t547 + _t548 = _t546(msg) + deconstruct_result21 = _t548 + + if deconstruct_result21 is not None: + _t550 = self.pretty_boolean_value(deconstruct_result21) + _t549 = _t550 + else: + def _t551(_dollar_dollar): + return _dollar_dollar + _t552 = _t551(msg) + fields19 = _t552 + assert fields19 is not None + unwrapped_fields20 = fields19 + self.write('missing') + _t549 = None + _t545 = _t549 + _t541 = _t545 + _t537 = _t541 + _t533 = _t537 + _t529 = _t533 + _t525 = _t529 + _t520 = _t525 + _t515 = _t520 + return _t515 + + def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: + def _t553(_dollar_dollar): + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) + _t554 = _t553(msg) + fields30 = _t554 + assert fields30 is not None + unwrapped_fields31 = fields30 + self.write('(') + self.write('date') + self.indent() + self.newline() + field32 = unwrapped_fields31[0] + self.write(str(field32)) + self.newline() + field33 = unwrapped_fields31[1] + self.write(str(field33)) + self.newline() + field34 = unwrapped_fields31[2] + self.write(str(field34)) + self.dedent() + self.write(')') + return None + + def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: + def _t555(_dollar_dollar): + + if _dollar_dollar.microsecond != 0: + _t556 = int(_dollar_dollar.microsecond) + else: + _t556 = None + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), _t556,) + _t557 = _t555(msg) + fields35 = _t557 + assert fields35 is not None + unwrapped_fields36 = fields35 + self.write('(') + self.write('datetime') + self.indent() + self.newline() + field37 = unwrapped_fields36[0] + self.write(str(field37)) + self.newline() + field38 = unwrapped_fields36[1] + self.write(str(field38)) + self.newline() + field39 = unwrapped_fields36[2] + self.write(str(field39)) + self.newline() + field40 = unwrapped_fields36[3] + self.write(str(field40)) + self.newline() + field41 = unwrapped_fields36[4] + self.write(str(field41)) + self.newline() + field42 = unwrapped_fields36[5] + self.write(str(field42)) + field43 = unwrapped_fields36[6] + + if field43 is not None: + self.newline() + assert field43 is not None + opt_val44 = field43 + self.write(str(opt_val44)) + _t558 = None + else: + _t558 = None + self.dedent() + self.write(')') + return None + + def pretty_boolean_value(self, msg: bool) -> Optional[Never]: + def _t559(_dollar_dollar): + + if _dollar_dollar: + _t560 = () + else: + _t560 = None + return _t560 + _t561 = _t559(msg) + deconstruct_result47 = _t561 + + if deconstruct_result47 is not None: + self.write('true') + _t562 = None + else: + def _t563(_dollar_dollar): + return _dollar_dollar + _t564 = _t563(msg) + fields45 = _t564 + assert fields45 is not None + unwrapped_fields46 = fields45 + self.write('false') + _t562 = None + return _t562 + + def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: + def _t565(_dollar_dollar): + return _dollar_dollar.fragments + _t566 = _t565(msg) + fields48 = _t566 + assert fields48 is not None + unwrapped_fields49 = fields48 + self.write('(') + self.write('sync') + self.indent() + if not len(unwrapped_fields49) == 0: + self.newline() + for i51, elem50 in enumerate(unwrapped_fields49): + + if (i51 > 0): + self.newline() + _t567 = None + else: + _t567 = None + _t568 = self.pretty_fragment_id(elem50) + self.dedent() + self.write(')') + return None + + def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: + def _t569(_dollar_dollar): + return self.fragment_id_to_string(_dollar_dollar) + _t570 = _t569(msg) + fields52 = _t570 + assert fields52 is not None + unwrapped_fields53 = fields52 + self.write(':') + self.write(unwrapped_fields53) + return None + + def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: + def _t571(_dollar_dollar): + + if not len(_dollar_dollar.writes) == 0: + _t572 = _dollar_dollar.writes + else: + _t572 = None + + if not len(_dollar_dollar.reads) == 0: + _t573 = _dollar_dollar.reads + else: + _t573 = None + return (_t572, _t573,) + _t574 = _t571(msg) + fields54 = _t574 + assert fields54 is not None + unwrapped_fields55 = fields54 + self.write('(') + self.write('epoch') + self.indent() + field56 = unwrapped_fields55[0] + + if field56 is not None: + self.newline() + assert field56 is not None + opt_val57 = field56 + _t576 = self.pretty_epoch_writes(opt_val57) + _t575 = _t576 + else: + _t575 = None + field58 = unwrapped_fields55[1] + + if field58 is not None: + self.newline() + assert field58 is not None + opt_val59 = field58 + _t578 = self.pretty_epoch_reads(opt_val59) + _t577 = _t578 + else: + _t577 = None + self.dedent() + self.write(')') + return None + + def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: + def _t579(_dollar_dollar): + return _dollar_dollar + _t580 = _t579(msg) + fields60 = _t580 + assert fields60 is not None + unwrapped_fields61 = fields60 + self.write('(') + self.write('writes') + self.indent() + if not len(unwrapped_fields61) == 0: + self.newline() + for i63, elem62 in enumerate(unwrapped_fields61): + + if (i63 > 0): + self.newline() + _t581 = None + else: + _t581 = None + _t582 = self.pretty_write(elem62) + self.dedent() + self.write(')') + return None + + def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: + def _t583(_dollar_dollar): + + if _dollar_dollar.HasField('define'): + _t584 = _dollar_dollar.define + else: + _t584 = None + return _t584 + _t585 = _t583(msg) + deconstruct_result66 = _t585 + + if deconstruct_result66 is not None: + _t587 = self.pretty_define(deconstruct_result66) + _t586 = _t587 + else: + def _t588(_dollar_dollar): + + if _dollar_dollar.HasField('undefine'): + _t589 = _dollar_dollar.undefine + else: + _t589 = None + return _t589 + _t590 = _t588(msg) + deconstruct_result65 = _t590 + + if deconstruct_result65 is not None: + _t592 = self.pretty_undefine(deconstruct_result65) + _t591 = _t592 + else: + def _t593(_dollar_dollar): + + if _dollar_dollar.HasField('context'): + _t594 = _dollar_dollar.context + else: + _t594 = None + return _t594 + _t595 = _t593(msg) + deconstruct_result64 = _t595 + + if deconstruct_result64 is not None: + _t597 = self.pretty_context(deconstruct_result64) + _t596 = _t597 + else: + raise ParseError('No matching rule for write') + _t591 = _t596 + _t586 = _t591 + return _t586 + + def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: + def _t598(_dollar_dollar): + return _dollar_dollar.fragment + _t599 = _t598(msg) + fields67 = _t599 + assert fields67 is not None + unwrapped_fields68 = fields67 + self.write('(') + self.write('define') + self.indent() + self.newline() + _t600 = self.pretty_fragment(unwrapped_fields68) + self.dedent() + self.write(')') + return None + + def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: + def _t601(_dollar_dollar): + _t602 = self.start_pretty_fragment(_dollar_dollar) + return (_dollar_dollar.id, _dollar_dollar.declarations,) + _t603 = _t601(msg) + fields69 = _t603 + assert fields69 is not None + unwrapped_fields70 = fields69 + self.write('(') + self.write('fragment') + self.indent() + self.newline() + field71 = unwrapped_fields70[0] + _t604 = self.pretty_new_fragment_id(field71) + field72 = unwrapped_fields70[1] + if not len(field72) == 0: + self.newline() + for i74, elem73 in enumerate(field72): + + if (i74 > 0): + self.newline() + _t605 = None + else: + _t605 = None + _t606 = self.pretty_declaration(elem73) + self.dedent() + self.write(')') + return None + + def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: + def _t607(_dollar_dollar): + return _dollar_dollar + _t608 = _t607(msg) + fields75 = _t608 + assert fields75 is not None + unwrapped_fields76 = fields75 + _t609 = self.pretty_fragment_id(unwrapped_fields76) + return _t609 + + def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: + def _t610(_dollar_dollar): + + if _dollar_dollar.HasField('def'): + _t611 = getattr(_dollar_dollar, 'def') + else: + _t611 = None + return _t611 + _t612 = _t610(msg) + deconstruct_result80 = _t612 + + if deconstruct_result80 is not None: + _t614 = self.pretty_def(deconstruct_result80) + _t613 = _t614 + else: + def _t615(_dollar_dollar): + + if _dollar_dollar.HasField('algorithm'): + _t616 = _dollar_dollar.algorithm + else: + _t616 = None + return _t616 + _t617 = _t615(msg) + deconstruct_result79 = _t617 + + if deconstruct_result79 is not None: + _t619 = self.pretty_algorithm(deconstruct_result79) + _t618 = _t619 + else: + def _t620(_dollar_dollar): + + if _dollar_dollar.HasField('constraint'): + _t621 = _dollar_dollar.constraint + else: + _t621 = None + return _t621 + _t622 = _t620(msg) + deconstruct_result78 = _t622 + + if deconstruct_result78 is not None: + _t624 = self.pretty_constraint(deconstruct_result78) + _t623 = _t624 + else: + def _t625(_dollar_dollar): + + if _dollar_dollar.HasField('data'): + _t626 = _dollar_dollar.data + else: + _t626 = None + return _t626 + _t627 = _t625(msg) + deconstruct_result77 = _t627 + + if deconstruct_result77 is not None: + _t629 = self.pretty_data(deconstruct_result77) + _t628 = _t629 + else: + raise ParseError('No matching rule for declaration') + _t623 = _t628 + _t618 = _t623 + _t613 = _t618 + return _t613 + + def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: + def _t630(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t631 = _dollar_dollar.attrs + else: + _t631 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t631,) + _t632 = _t630(msg) + fields81 = _t632 + assert fields81 is not None + unwrapped_fields82 = fields81 + self.write('(') + self.write('def') + self.indent() + self.newline() + field83 = unwrapped_fields82[0] + _t633 = self.pretty_relation_id(field83) + self.newline() + field84 = unwrapped_fields82[1] + _t634 = self.pretty_abstraction(field84) + field85 = unwrapped_fields82[2] + + if field85 is not None: + self.newline() + assert field85 is not None + opt_val86 = field85 + _t636 = self.pretty_attrs(opt_val86) + _t635 = _t636 + else: + _t635 = None + self.dedent() + self.write(')') + return None + + def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: + def _t637(_dollar_dollar): + _t638 = self.deconstruct_relation_id_string(_dollar_dollar) + return _t638 + _t639 = _t637(msg) + deconstruct_result88 = _t639 + + if deconstruct_result88 is not None: + self.write(':') + self.write(deconstruct_result88) + _t640 = None + else: + def _t641(_dollar_dollar): + _t642 = self.deconstruct_relation_id_uint128(_dollar_dollar) + return _t642 + _t643 = _t641(msg) + deconstruct_result87 = _t643 + + if deconstruct_result87 is not None: + self.write(self.format_uint128(deconstruct_result87)) + _t644 = None + else: + raise ParseError('No matching rule for relation_id') + _t640 = _t644 + return _t640 + + def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: + def _t645(_dollar_dollar): + _t646 = self.deconstruct_bindings(_dollar_dollar) + return (_t646, _dollar_dollar.value,) + _t647 = _t645(msg) + fields89 = _t647 + assert fields89 is not None + unwrapped_fields90 = fields89 + self.write('(') + field91 = unwrapped_fields90[0] + _t648 = self.pretty_bindings(field91) + self.write(' ') + field92 = unwrapped_fields90[1] + _t649 = self.pretty_formula(field92) + self.write(')') + return None + + def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: + def _t650(_dollar_dollar): + + if not len(_dollar_dollar[1]) == 0: + _t651 = _dollar_dollar[1] + else: + _t651 = None + return (_dollar_dollar[0], _t651,) + _t652 = _t650(msg) + fields93 = _t652 + assert fields93 is not None + unwrapped_fields94 = fields93 + self.write('[') + field95 = unwrapped_fields94[0] + for i97, elem96 in enumerate(field95): + + if (i97 > 0): + self.newline() + _t653 = None + else: + _t653 = None + _t654 = self.pretty_binding(elem96) + field98 = unwrapped_fields94[1] + + if field98 is not None: + self.write(' ') + assert field98 is not None + opt_val99 = field98 + _t656 = self.pretty_value_bindings(opt_val99) + _t655 = _t656 + else: + _t655 = None + self.write(']') + return None + + def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: + def _t657(_dollar_dollar): + return (_dollar_dollar.var.name, _dollar_dollar.type,) + _t658 = _t657(msg) + fields100 = _t658 + assert fields100 is not None + unwrapped_fields101 = fields100 + field102 = unwrapped_fields101[0] + self.write(field102) + self.write('::') + field103 = unwrapped_fields101[1] + _t659 = self.pretty_type(field103) + return _t659 + + def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: + def _t660(_dollar_dollar): + + if _dollar_dollar.HasField('unspecified_type'): + _t661 = _dollar_dollar.unspecified_type + else: + _t661 = None + return _t661 + _t662 = _t660(msg) + deconstruct_result114 = _t662 + + if deconstruct_result114 is not None: + _t664 = self.pretty_unspecified_type(deconstruct_result114) + _t663 = _t664 + else: + def _t665(_dollar_dollar): + + if _dollar_dollar.HasField('string_type'): + _t666 = _dollar_dollar.string_type + else: + _t666 = None + return _t666 + _t667 = _t665(msg) + deconstruct_result113 = _t667 + + if deconstruct_result113 is not None: + _t669 = self.pretty_string_type(deconstruct_result113) + _t668 = _t669 + else: + def _t670(_dollar_dollar): + + if _dollar_dollar.HasField('int_type'): + _t671 = _dollar_dollar.int_type + else: + _t671 = None + return _t671 + _t672 = _t670(msg) + deconstruct_result112 = _t672 + + if deconstruct_result112 is not None: + _t674 = self.pretty_int_type(deconstruct_result112) + _t673 = _t674 + else: + def _t675(_dollar_dollar): + + if _dollar_dollar.HasField('float_type'): + _t676 = _dollar_dollar.float_type + else: + _t676 = None + return _t676 + _t677 = _t675(msg) + deconstruct_result111 = _t677 + + if deconstruct_result111 is not None: + _t679 = self.pretty_float_type(deconstruct_result111) + _t678 = _t679 + else: + def _t680(_dollar_dollar): + + if _dollar_dollar.HasField('uint128_type'): + _t681 = _dollar_dollar.uint128_type + else: + _t681 = None + return _t681 + _t682 = _t680(msg) + deconstruct_result110 = _t682 + + if deconstruct_result110 is not None: + _t684 = self.pretty_uint128_type(deconstruct_result110) + _t683 = _t684 + else: + def _t685(_dollar_dollar): + + if _dollar_dollar.HasField('int128_type'): + _t686 = _dollar_dollar.int128_type + else: + _t686 = None + return _t686 + _t687 = _t685(msg) + deconstruct_result109 = _t687 + + if deconstruct_result109 is not None: + _t689 = self.pretty_int128_type(deconstruct_result109) + _t688 = _t689 + else: + def _t690(_dollar_dollar): + + if _dollar_dollar.HasField('date_type'): + _t691 = _dollar_dollar.date_type + else: + _t691 = None + return _t691 + _t692 = _t690(msg) + deconstruct_result108 = _t692 + + if deconstruct_result108 is not None: + _t694 = self.pretty_date_type(deconstruct_result108) + _t693 = _t694 + else: + def _t695(_dollar_dollar): + + if _dollar_dollar.HasField('datetime_type'): + _t696 = _dollar_dollar.datetime_type + else: + _t696 = None + return _t696 + _t697 = _t695(msg) + deconstruct_result107 = _t697 + + if deconstruct_result107 is not None: + _t699 = self.pretty_datetime_type(deconstruct_result107) + _t698 = _t699 + else: + def _t700(_dollar_dollar): + + if _dollar_dollar.HasField('missing_type'): + _t701 = _dollar_dollar.missing_type + else: + _t701 = None + return _t701 + _t702 = _t700(msg) + deconstruct_result106 = _t702 + + if deconstruct_result106 is not None: + _t704 = self.pretty_missing_type(deconstruct_result106) + _t703 = _t704 + else: + def _t705(_dollar_dollar): + + if _dollar_dollar.HasField('decimal_type'): + _t706 = _dollar_dollar.decimal_type + else: + _t706 = None + return _t706 + _t707 = _t705(msg) + deconstruct_result105 = _t707 + + if deconstruct_result105 is not None: + _t709 = self.pretty_decimal_type(deconstruct_result105) + _t708 = _t709 + else: + def _t710(_dollar_dollar): + + if _dollar_dollar.HasField('boolean_type'): + _t711 = _dollar_dollar.boolean_type + else: + _t711 = None + return _t711 + _t712 = _t710(msg) + deconstruct_result104 = _t712 + + if deconstruct_result104 is not None: + _t714 = self.pretty_boolean_type(deconstruct_result104) + _t713 = _t714 + else: + raise ParseError('No matching rule for type') + _t708 = _t713 + _t703 = _t708 + _t698 = _t703 + _t693 = _t698 + _t688 = _t693 + _t683 = _t688 + _t678 = _t683 + _t673 = _t678 + _t668 = _t673 + _t663 = _t668 + return _t663 + + def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: + def _t715(_dollar_dollar): + return _dollar_dollar + _t716 = _t715(msg) + fields115 = _t716 + assert fields115 is not None + unwrapped_fields116 = fields115 + self.write('UNKNOWN') + return None + + def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: + def _t717(_dollar_dollar): + return _dollar_dollar + _t718 = _t717(msg) + fields117 = _t718 + assert fields117 is not None + unwrapped_fields118 = fields117 + self.write('STRING') + return None + + def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: + def _t719(_dollar_dollar): + return _dollar_dollar + _t720 = _t719(msg) + fields119 = _t720 + assert fields119 is not None + unwrapped_fields120 = fields119 + self.write('INT') + return None + + def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: + def _t721(_dollar_dollar): + return _dollar_dollar + _t722 = _t721(msg) + fields121 = _t722 + assert fields121 is not None + unwrapped_fields122 = fields121 + self.write('FLOAT') + return None + + def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: + def _t723(_dollar_dollar): + return _dollar_dollar + _t724 = _t723(msg) + fields123 = _t724 + assert fields123 is not None + unwrapped_fields124 = fields123 + self.write('UINT128') + return None + + def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: + def _t725(_dollar_dollar): + return _dollar_dollar + _t726 = _t725(msg) + fields125 = _t726 + assert fields125 is not None + unwrapped_fields126 = fields125 + self.write('INT128') + return None + + def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: + def _t727(_dollar_dollar): + return _dollar_dollar + _t728 = _t727(msg) + fields127 = _t728 + assert fields127 is not None + unwrapped_fields128 = fields127 + self.write('DATE') + return None + + def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: + def _t729(_dollar_dollar): + return _dollar_dollar + _t730 = _t729(msg) + fields129 = _t730 + assert fields129 is not None + unwrapped_fields130 = fields129 + self.write('DATETIME') + return None + + def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: + def _t731(_dollar_dollar): + return _dollar_dollar + _t732 = _t731(msg) + fields131 = _t732 + assert fields131 is not None + unwrapped_fields132 = fields131 + self.write('MISSING') + return None + + def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: + def _t733(_dollar_dollar): + return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) + _t734 = _t733(msg) + fields133 = _t734 + assert fields133 is not None + unwrapped_fields134 = fields133 + self.write('(') + self.write('DECIMAL') + self.indent() + self.newline() + field135 = unwrapped_fields134[0] + self.write(str(field135)) + self.newline() + field136 = unwrapped_fields134[1] + self.write(str(field136)) + self.dedent() + self.write(')') + return None + + def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: + def _t735(_dollar_dollar): + return _dollar_dollar + _t736 = _t735(msg) + fields137 = _t736 + assert fields137 is not None + unwrapped_fields138 = fields137 + self.write('BOOLEAN') + return None + + def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: + def _t737(_dollar_dollar): + return _dollar_dollar + _t738 = _t737(msg) + fields139 = _t738 + assert fields139 is not None + unwrapped_fields140 = fields139 + self.write('|') + if not len(unwrapped_fields140) == 0: + self.write(' ') + for i142, elem141 in enumerate(unwrapped_fields140): + + if (i142 > 0): + self.newline() + _t739 = None + else: + _t739 = None + _t740 = self.pretty_binding(elem141) + return None + + def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: + def _t741(_dollar_dollar): + + if (_dollar_dollar.HasField('conjunction') and len(_dollar_dollar.conjunction.args) == 0): + _t742 = _dollar_dollar.conjunction + else: + _t742 = None + return _t742 + _t743 = _t741(msg) + deconstruct_result155 = _t743 + + if deconstruct_result155 is not None: + _t745 = self.pretty_true(deconstruct_result155) + _t744 = _t745 + else: + def _t746(_dollar_dollar): + + if (_dollar_dollar.HasField('disjunction') and len(_dollar_dollar.disjunction.args) == 0): + _t747 = _dollar_dollar.disjunction + else: + _t747 = None + return _t747 + _t748 = _t746(msg) + deconstruct_result154 = _t748 + + if deconstruct_result154 is not None: + _t750 = self.pretty_false(deconstruct_result154) + _t749 = _t750 + else: + def _t751(_dollar_dollar): + + if _dollar_dollar.HasField('exists'): + _t752 = _dollar_dollar.exists + else: + _t752 = None + return _t752 + _t753 = _t751(msg) + deconstruct_result153 = _t753 + + if deconstruct_result153 is not None: + _t755 = self.pretty_exists(deconstruct_result153) + _t754 = _t755 + else: + def _t756(_dollar_dollar): + + if _dollar_dollar.HasField('reduce'): + _t757 = _dollar_dollar.reduce + else: + _t757 = None + return _t757 + _t758 = _t756(msg) + deconstruct_result152 = _t758 + + if deconstruct_result152 is not None: + _t760 = self.pretty_reduce(deconstruct_result152) + _t759 = _t760 + else: + def _t761(_dollar_dollar): + + if (_dollar_dollar.HasField('conjunction') and not len(_dollar_dollar.conjunction.args) == 0): + _t762 = _dollar_dollar.conjunction + else: + _t762 = None + return _t762 + _t763 = _t761(msg) + deconstruct_result151 = _t763 + + if deconstruct_result151 is not None: + _t765 = self.pretty_conjunction(deconstruct_result151) + _t764 = _t765 + else: + def _t766(_dollar_dollar): + + if (_dollar_dollar.HasField('disjunction') and not len(_dollar_dollar.disjunction.args) == 0): + _t767 = _dollar_dollar.disjunction + else: + _t767 = None + return _t767 + _t768 = _t766(msg) + deconstruct_result150 = _t768 + + if deconstruct_result150 is not None: + _t770 = self.pretty_disjunction(deconstruct_result150) + _t769 = _t770 + else: + def _t771(_dollar_dollar): + + if _dollar_dollar.HasField('not'): + _t772 = getattr(_dollar_dollar, 'not') + else: + _t772 = None + return _t772 + _t773 = _t771(msg) + deconstruct_result149 = _t773 + + if deconstruct_result149 is not None: + _t775 = self.pretty_not(deconstruct_result149) + _t774 = _t775 + else: + def _t776(_dollar_dollar): + + if _dollar_dollar.HasField('ffi'): + _t777 = _dollar_dollar.ffi + else: + _t777 = None + return _t777 + _t778 = _t776(msg) + deconstruct_result148 = _t778 + + if deconstruct_result148 is not None: + _t780 = self.pretty_ffi(deconstruct_result148) + _t779 = _t780 + else: + def _t781(_dollar_dollar): + + if _dollar_dollar.HasField('atom'): + _t782 = _dollar_dollar.atom + else: + _t782 = None + return _t782 + _t783 = _t781(msg) + deconstruct_result147 = _t783 + + if deconstruct_result147 is not None: + _t785 = self.pretty_atom(deconstruct_result147) + _t784 = _t785 + else: + def _t786(_dollar_dollar): + + if _dollar_dollar.HasField('pragma'): + _t787 = _dollar_dollar.pragma + else: + _t787 = None + return _t787 + _t788 = _t786(msg) + deconstruct_result146 = _t788 + + if deconstruct_result146 is not None: + _t790 = self.pretty_pragma(deconstruct_result146) + _t789 = _t790 + else: + def _t791(_dollar_dollar): + + if _dollar_dollar.HasField('primitive'): + _t792 = _dollar_dollar.primitive + else: + _t792 = None + return _t792 + _t793 = _t791(msg) + deconstruct_result145 = _t793 + + if deconstruct_result145 is not None: + _t795 = self.pretty_primitive(deconstruct_result145) + _t794 = _t795 + else: + def _t796(_dollar_dollar): + + if _dollar_dollar.HasField('rel_atom'): + _t797 = _dollar_dollar.rel_atom + else: + _t797 = None + return _t797 + _t798 = _t796(msg) + deconstruct_result144 = _t798 + + if deconstruct_result144 is not None: + _t800 = self.pretty_rel_atom(deconstruct_result144) + _t799 = _t800 + else: + def _t801(_dollar_dollar): + + if _dollar_dollar.HasField('cast'): + _t802 = _dollar_dollar.cast + else: + _t802 = None + return _t802 + _t803 = _t801(msg) + deconstruct_result143 = _t803 + + if deconstruct_result143 is not None: + _t805 = self.pretty_cast(deconstruct_result143) + _t804 = _t805 + else: + raise ParseError('No matching rule for formula') + _t799 = _t804 + _t794 = _t799 + _t789 = _t794 + _t784 = _t789 + _t779 = _t784 + _t774 = _t779 + _t769 = _t774 + _t764 = _t769 + _t759 = _t764 + _t754 = _t759 + _t749 = _t754 + _t744 = _t749 + return _t744 + + def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: + def _t806(_dollar_dollar): + return _dollar_dollar + _t807 = _t806(msg) + fields156 = _t807 + assert fields156 is not None + unwrapped_fields157 = fields156 + self.write('(') + self.write('true') + self.write(')') + return None + + def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: + def _t808(_dollar_dollar): + return _dollar_dollar + _t809 = _t808(msg) + fields158 = _t809 + assert fields158 is not None + unwrapped_fields159 = fields158 + self.write('(') + self.write('false') + self.write(')') + return None + + def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: + def _t810(_dollar_dollar): + _t811 = self.deconstruct_bindings(_dollar_dollar.body) + return (_t811, _dollar_dollar.body.value,) + _t812 = _t810(msg) + fields160 = _t812 + assert fields160 is not None + unwrapped_fields161 = fields160 + self.write('(') + self.write('exists') + self.indent() + self.newline() + field162 = unwrapped_fields161[0] + _t813 = self.pretty_bindings(field162) + self.newline() + field163 = unwrapped_fields161[1] + _t814 = self.pretty_formula(field163) + self.dedent() + self.write(')') + return None + + def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: + def _t815(_dollar_dollar): + return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) + _t816 = _t815(msg) + fields164 = _t816 + assert fields164 is not None + unwrapped_fields165 = fields164 + self.write('(') + self.write('reduce') + self.indent() + self.newline() + field166 = unwrapped_fields165[0] + _t817 = self.pretty_abstraction(field166) + self.newline() + field167 = unwrapped_fields165[1] + _t818 = self.pretty_abstraction(field167) + self.newline() + field168 = unwrapped_fields165[2] + _t819 = self.pretty_terms(field168) + self.dedent() + self.write(')') + return None + + def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: + def _t820(_dollar_dollar): + return _dollar_dollar + _t821 = _t820(msg) + fields169 = _t821 + assert fields169 is not None + unwrapped_fields170 = fields169 + self.write('(') + self.write('terms') + self.indent() + if not len(unwrapped_fields170) == 0: + self.newline() + for i172, elem171 in enumerate(unwrapped_fields170): + + if (i172 > 0): + self.newline() + _t822 = None + else: + _t822 = None + _t823 = self.pretty_term(elem171) + self.dedent() + self.write(')') + return None + + def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: + def _t824(_dollar_dollar): + + if _dollar_dollar.HasField('var'): + _t825 = _dollar_dollar.var + else: + _t825 = None + return _t825 + _t826 = _t824(msg) + deconstruct_result174 = _t826 + + if deconstruct_result174 is not None: + _t828 = self.pretty_var(deconstruct_result174) + _t827 = _t828 + else: + def _t829(_dollar_dollar): + + if _dollar_dollar.HasField('constant'): + _t830 = _dollar_dollar.constant + else: + _t830 = None + return _t830 + _t831 = _t829(msg) + deconstruct_result173 = _t831 + + if deconstruct_result173 is not None: + _t833 = self.pretty_constant(deconstruct_result173) + _t832 = _t833 + else: + raise ParseError('No matching rule for term') + _t827 = _t832 + return _t827 + + def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: + def _t834(_dollar_dollar): + return _dollar_dollar.name + _t835 = _t834(msg) + fields175 = _t835 + assert fields175 is not None + unwrapped_fields176 = fields175 + self.write(unwrapped_fields176) + return None + + def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t836(_dollar_dollar): + return _dollar_dollar + _t837 = _t836(msg) + fields177 = _t837 + assert fields177 is not None + unwrapped_fields178 = fields177 + _t838 = self.pretty_value(unwrapped_fields178) + return _t838 + + def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: + def _t839(_dollar_dollar): + return _dollar_dollar.args + _t840 = _t839(msg) + fields179 = _t840 + assert fields179 is not None + unwrapped_fields180 = fields179 + self.write('(') + self.write('and') + self.indent() + if not len(unwrapped_fields180) == 0: + self.newline() + for i182, elem181 in enumerate(unwrapped_fields180): + + if (i182 > 0): + self.newline() + _t841 = None + else: + _t841 = None + _t842 = self.pretty_formula(elem181) + self.dedent() + self.write(')') + return None + + def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: + def _t843(_dollar_dollar): + return _dollar_dollar.args + _t844 = _t843(msg) + fields183 = _t844 + assert fields183 is not None + unwrapped_fields184 = fields183 + self.write('(') + self.write('or') + self.indent() + if not len(unwrapped_fields184) == 0: + self.newline() + for i186, elem185 in enumerate(unwrapped_fields184): + + if (i186 > 0): + self.newline() + _t845 = None + else: + _t845 = None + _t846 = self.pretty_formula(elem185) + self.dedent() + self.write(')') + return None + + def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: + def _t847(_dollar_dollar): + return _dollar_dollar.arg + _t848 = _t847(msg) + fields187 = _t848 + assert fields187 is not None + unwrapped_fields188 = fields187 + self.write('(') + self.write('not') + self.indent() + self.newline() + _t849 = self.pretty_formula(unwrapped_fields188) + self.dedent() + self.write(')') + return None + + def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: + def _t850(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) + _t851 = _t850(msg) + fields189 = _t851 + assert fields189 is not None + unwrapped_fields190 = fields189 + self.write('(') + self.write('ffi') + self.indent() + self.newline() + field191 = unwrapped_fields190[0] + _t852 = self.pretty_name(field191) + self.newline() + field192 = unwrapped_fields190[1] + _t853 = self.pretty_ffi_args(field192) + self.newline() + field193 = unwrapped_fields190[2] + _t854 = self.pretty_terms(field193) + self.dedent() + self.write(')') + return None + + def pretty_name(self, msg: str) -> Optional[Never]: + def _t855(_dollar_dollar): + return _dollar_dollar + _t856 = _t855(msg) + fields194 = _t856 + assert fields194 is not None + unwrapped_fields195 = fields194 + self.write(':') + self.write(unwrapped_fields195) + return None + + def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: + def _t857(_dollar_dollar): + return _dollar_dollar + _t858 = _t857(msg) + fields196 = _t858 + assert fields196 is not None + unwrapped_fields197 = fields196 + self.write('(') + self.write('args') + self.indent() + if not len(unwrapped_fields197) == 0: + self.newline() + for i199, elem198 in enumerate(unwrapped_fields197): + + if (i199 > 0): + self.newline() + _t859 = None + else: + _t859 = None + _t860 = self.pretty_abstraction(elem198) + self.dedent() + self.write(')') + return None + + def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: + def _t861(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t862 = _t861(msg) + fields200 = _t862 + assert fields200 is not None + unwrapped_fields201 = fields200 + self.write('(') + self.write('atom') + self.indent() + self.newline() + field202 = unwrapped_fields201[0] + _t863 = self.pretty_relation_id(field202) + field203 = unwrapped_fields201[1] + if not len(field203) == 0: + self.newline() + for i205, elem204 in enumerate(field203): + + if (i205 > 0): + self.newline() + _t864 = None + else: + _t864 = None + _t865 = self.pretty_term(elem204) + self.dedent() + self.write(')') + return None + + def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: + def _t866(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t867 = _t866(msg) + fields206 = _t867 + assert fields206 is not None + unwrapped_fields207 = fields206 + self.write('(') + self.write('pragma') + self.indent() + self.newline() + field208 = unwrapped_fields207[0] + _t868 = self.pretty_name(field208) + field209 = unwrapped_fields207[1] + if not len(field209) == 0: + self.newline() + for i211, elem210 in enumerate(field209): + + if (i211 > 0): + self.newline() + _t869 = None + else: + _t869 = None + _t870 = self.pretty_term(elem210) + self.dedent() + self.write(')') + return None + + def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t871(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_eq': + _t872 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t872 = None + return _t872 + _t873 = _t871(msg) + guard_result226 = _t873 + + if guard_result226 is not None: + _t875 = self.pretty_eq(msg) + _t874 = _t875 + else: + def _t876(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_monotype': + _t877 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t877 = None + return _t877 + _t878 = _t876(msg) + guard_result225 = _t878 + + if guard_result225 is not None: + _t880 = self.pretty_lt(msg) + _t879 = _t880 + else: + def _t881(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': + _t882 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t882 = None + return _t882 + _t883 = _t881(msg) + guard_result224 = _t883 + + if guard_result224 is not None: + _t885 = self.pretty_lt_eq(msg) + _t884 = _t885 + else: + def _t886(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_monotype': + _t887 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t887 = None + return _t887 + _t888 = _t886(msg) + guard_result223 = _t888 + + if guard_result223 is not None: + _t890 = self.pretty_gt(msg) + _t889 = _t890 + else: + def _t891(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': + _t892 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t892 = None + return _t892 + _t893 = _t891(msg) + guard_result222 = _t893 + + if guard_result222 is not None: + _t895 = self.pretty_gt_eq(msg) + _t894 = _t895 + else: + def _t896(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_add_monotype': + _t897 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t897 = None + return _t897 + _t898 = _t896(msg) + guard_result221 = _t898 + + if guard_result221 is not None: + _t900 = self.pretty_add(msg) + _t899 = _t900 + else: + def _t901(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_subtract_monotype': + _t902 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t902 = None + return _t902 + _t903 = _t901(msg) + guard_result220 = _t903 + + if guard_result220 is not None: + _t905 = self.pretty_minus(msg) + _t904 = _t905 + else: + def _t906(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_multiply_monotype': + _t907 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t907 = None + return _t907 + _t908 = _t906(msg) + guard_result219 = _t908 + + if guard_result219 is not None: + _t910 = self.pretty_multiply(msg) + _t909 = _t910 + else: + def _t911(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_divide_monotype': + _t912 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t912 = None + return _t912 + _t913 = _t911(msg) + guard_result218 = _t913 + + if guard_result218 is not None: + _t915 = self.pretty_divide(msg) + _t914 = _t915 + else: + def _t916(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t917 = _t916(msg) + fields212 = _t917 + assert fields212 is not None + unwrapped_fields213 = fields212 + self.write('(') + self.write('primitive') + self.indent() + self.newline() + field214 = unwrapped_fields213[0] + _t918 = self.pretty_name(field214) + field215 = unwrapped_fields213[1] + if not len(field215) == 0: + self.newline() + for i217, elem216 in enumerate(field215): + + if (i217 > 0): + self.newline() + _t919 = None + else: + _t919 = None + _t920 = self.pretty_rel_term(elem216) + self.dedent() + self.write(')') + _t914 = None + _t909 = _t914 + _t904 = _t909 + _t899 = _t904 + _t894 = _t899 + _t889 = _t894 + _t884 = _t889 + _t879 = _t884 + _t874 = _t879 + return _t874 + + def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t921(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_eq': + _t922 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t922 = None + return _t922 + _t923 = _t921(msg) + fields227 = _t923 + assert fields227 is not None + unwrapped_fields228 = fields227 + self.write('(') + self.write('=') + self.indent() + self.newline() + field229 = unwrapped_fields228[0] + _t924 = self.pretty_term(field229) + self.newline() + field230 = unwrapped_fields228[1] + _t925 = self.pretty_term(field230) + self.dedent() + self.write(')') + return None + + def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t926(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_monotype': + _t927 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t927 = None + return _t927 + _t928 = _t926(msg) + fields231 = _t928 + assert fields231 is not None + unwrapped_fields232 = fields231 + self.write('(') + self.write('<') + self.indent() + self.newline() + field233 = unwrapped_fields232[0] + _t929 = self.pretty_term(field233) + self.newline() + field234 = unwrapped_fields232[1] + _t930 = self.pretty_term(field234) + self.dedent() + self.write(')') + return None + + def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t931(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': + _t932 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t932 = None + return _t932 + _t933 = _t931(msg) + fields235 = _t933 + assert fields235 is not None + unwrapped_fields236 = fields235 + self.write('(') + self.write('<=') + self.indent() + self.newline() + field237 = unwrapped_fields236[0] + _t934 = self.pretty_term(field237) + self.newline() + field238 = unwrapped_fields236[1] + _t935 = self.pretty_term(field238) + self.dedent() + self.write(')') + return None + + def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t936(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_monotype': + _t937 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t937 = None + return _t937 + _t938 = _t936(msg) + fields239 = _t938 + assert fields239 is not None + unwrapped_fields240 = fields239 + self.write('(') + self.write('>') + self.indent() + self.newline() + field241 = unwrapped_fields240[0] + _t939 = self.pretty_term(field241) + self.newline() + field242 = unwrapped_fields240[1] + _t940 = self.pretty_term(field242) + self.dedent() + self.write(')') + return None + + def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t941(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': + _t942 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) + else: + _t942 = None + return _t942 + _t943 = _t941(msg) + fields243 = _t943 + assert fields243 is not None + unwrapped_fields244 = fields243 + self.write('(') + self.write('>=') + self.indent() + self.newline() + field245 = unwrapped_fields244[0] + _t944 = self.pretty_term(field245) + self.newline() + field246 = unwrapped_fields244[1] + _t945 = self.pretty_term(field246) + self.dedent() + self.write(')') + return None + + def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t946(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_add_monotype': + _t947 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t947 = None + return _t947 + _t948 = _t946(msg) + fields247 = _t948 + assert fields247 is not None + unwrapped_fields248 = fields247 + self.write('(') + self.write('+') + self.indent() + self.newline() + field249 = unwrapped_fields248[0] + _t949 = self.pretty_term(field249) + self.newline() + field250 = unwrapped_fields248[1] + _t950 = self.pretty_term(field250) + self.newline() + field251 = unwrapped_fields248[2] + _t951 = self.pretty_term(field251) + self.dedent() + self.write(')') + return None + + def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t952(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_subtract_monotype': + _t953 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t953 = None + return _t953 + _t954 = _t952(msg) + fields252 = _t954 + assert fields252 is not None + unwrapped_fields253 = fields252 + self.write('(') + self.write('-') + self.indent() + self.newline() + field254 = unwrapped_fields253[0] + _t955 = self.pretty_term(field254) + self.newline() + field255 = unwrapped_fields253[1] + _t956 = self.pretty_term(field255) + self.newline() + field256 = unwrapped_fields253[2] + _t957 = self.pretty_term(field256) + self.dedent() + self.write(')') + return None + + def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t958(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_multiply_monotype': + _t959 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t959 = None + return _t959 + _t960 = _t958(msg) + fields257 = _t960 + assert fields257 is not None + unwrapped_fields258 = fields257 + self.write('(') + self.write('*') + self.indent() + self.newline() + field259 = unwrapped_fields258[0] + _t961 = self.pretty_term(field259) + self.newline() + field260 = unwrapped_fields258[1] + _t962 = self.pretty_term(field260) + self.newline() + field261 = unwrapped_fields258[2] + _t963 = self.pretty_term(field261) + self.dedent() + self.write(')') + return None + + def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: + def _t964(_dollar_dollar): + + if _dollar_dollar.name == 'rel_primitive_divide_monotype': + _t965 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) + else: + _t965 = None + return _t965 + _t966 = _t964(msg) + fields262 = _t966 + assert fields262 is not None + unwrapped_fields263 = fields262 + self.write('(') + self.write('/') + self.indent() + self.newline() + field264 = unwrapped_fields263[0] + _t967 = self.pretty_term(field264) + self.newline() + field265 = unwrapped_fields263[1] + _t968 = self.pretty_term(field265) + self.newline() + field266 = unwrapped_fields263[2] + _t969 = self.pretty_term(field266) + self.dedent() + self.write(')') + return None + + def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: + def _t970(_dollar_dollar): + + if _dollar_dollar.HasField('specialized_value'): + _t971 = _dollar_dollar.specialized_value + else: + _t971 = None + return _t971 + _t972 = _t970(msg) + deconstruct_result268 = _t972 + + if deconstruct_result268 is not None: + _t974 = self.pretty_specialized_value(deconstruct_result268) + _t973 = _t974 + else: + def _t975(_dollar_dollar): + + if _dollar_dollar.HasField('term'): + _t976 = _dollar_dollar.term + else: + _t976 = None + return _t976 + _t977 = _t975(msg) + deconstruct_result267 = _t977 + + if deconstruct_result267 is not None: + _t979 = self.pretty_term(deconstruct_result267) + _t978 = _t979 + else: + raise ParseError('No matching rule for rel_term') + _t973 = _t978 + return _t973 + + def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: + def _t980(_dollar_dollar): + return _dollar_dollar + _t981 = _t980(msg) + fields269 = _t981 + assert fields269 is not None + unwrapped_fields270 = fields269 + self.write('#') + _t982 = self.pretty_value(unwrapped_fields270) + return _t982 + + def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: + def _t983(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.terms,) + _t984 = _t983(msg) + fields271 = _t984 + assert fields271 is not None + unwrapped_fields272 = fields271 + self.write('(') + self.write('relatom') + self.indent() + self.newline() + field273 = unwrapped_fields272[0] + _t985 = self.pretty_name(field273) + field274 = unwrapped_fields272[1] + if not len(field274) == 0: + self.newline() + for i276, elem275 in enumerate(field274): + + if (i276 > 0): + self.newline() + _t986 = None + else: + _t986 = None + _t987 = self.pretty_rel_term(elem275) + self.dedent() + self.write(')') + return None + + def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: + def _t988(_dollar_dollar): + return (_dollar_dollar.input, _dollar_dollar.result,) + _t989 = _t988(msg) + fields277 = _t989 + assert fields277 is not None + unwrapped_fields278 = fields277 + self.write('(') + self.write('cast') + self.indent() + self.newline() + field279 = unwrapped_fields278[0] + _t990 = self.pretty_term(field279) + self.newline() + field280 = unwrapped_fields278[1] + _t991 = self.pretty_term(field280) + self.dedent() + self.write(')') + return None + + def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: + def _t992(_dollar_dollar): + return _dollar_dollar + _t993 = _t992(msg) + fields281 = _t993 + assert fields281 is not None + unwrapped_fields282 = fields281 + self.write('(') + self.write('attrs') + self.indent() + if not len(unwrapped_fields282) == 0: + self.newline() + for i284, elem283 in enumerate(unwrapped_fields282): + + if (i284 > 0): + self.newline() + _t994 = None + else: + _t994 = None + _t995 = self.pretty_attribute(elem283) + self.dedent() + self.write(')') + return None + + def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: + def _t996(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.args,) + _t997 = _t996(msg) + fields285 = _t997 + assert fields285 is not None + unwrapped_fields286 = fields285 + self.write('(') + self.write('attribute') + self.indent() + self.newline() + field287 = unwrapped_fields286[0] + _t998 = self.pretty_name(field287) + field288 = unwrapped_fields286[1] + if not len(field288) == 0: + self.newline() + for i290, elem289 in enumerate(field288): + + if (i290 > 0): + self.newline() + _t999 = None + else: + _t999 = None + _t1000 = self.pretty_value(elem289) + self.dedent() + self.write(')') + return None + + def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: + def _t1001(_dollar_dollar): + return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) + _t1002 = _t1001(msg) + fields291 = _t1002 + assert fields291 is not None + unwrapped_fields292 = fields291 + self.write('(') + self.write('algorithm') + self.indent() + field293 = unwrapped_fields292[0] + if not len(field293) == 0: + self.newline() + for i295, elem294 in enumerate(field293): + + if (i295 > 0): + self.newline() + _t1003 = None + else: + _t1003 = None + _t1004 = self.pretty_relation_id(elem294) + self.newline() + field296 = unwrapped_fields292[1] + _t1005 = self.pretty_script(field296) + self.dedent() + self.write(')') + return None + + def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: + def _t1006(_dollar_dollar): + return _dollar_dollar.constructs + _t1007 = _t1006(msg) + fields297 = _t1007 + assert fields297 is not None + unwrapped_fields298 = fields297 + self.write('(') + self.write('script') + self.indent() + if not len(unwrapped_fields298) == 0: + self.newline() + for i300, elem299 in enumerate(unwrapped_fields298): + + if (i300 > 0): + self.newline() + _t1008 = None + else: + _t1008 = None + _t1009 = self.pretty_construct(elem299) + self.dedent() + self.write(')') + return None + + def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: + def _t1010(_dollar_dollar): + + if _dollar_dollar.HasField('loop'): + _t1011 = _dollar_dollar.loop + else: + _t1011 = None + return _t1011 + _t1012 = _t1010(msg) + deconstruct_result302 = _t1012 + + if deconstruct_result302 is not None: + _t1014 = self.pretty_loop(deconstruct_result302) + _t1013 = _t1014 + else: + def _t1015(_dollar_dollar): + + if _dollar_dollar.HasField('instruction'): + _t1016 = _dollar_dollar.instruction + else: + _t1016 = None + return _t1016 + _t1017 = _t1015(msg) + deconstruct_result301 = _t1017 + + if deconstruct_result301 is not None: + _t1019 = self.pretty_instruction(deconstruct_result301) + _t1018 = _t1019 + else: + raise ParseError('No matching rule for construct') + _t1013 = _t1018 + return _t1013 + + def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: + def _t1020(_dollar_dollar): + return (_dollar_dollar.init, _dollar_dollar.body,) + _t1021 = _t1020(msg) + fields303 = _t1021 + assert fields303 is not None + unwrapped_fields304 = fields303 + self.write('(') + self.write('loop') + self.indent() + self.newline() + field305 = unwrapped_fields304[0] + _t1022 = self.pretty_init(field305) + self.newline() + field306 = unwrapped_fields304[1] + _t1023 = self.pretty_script(field306) + self.dedent() + self.write(')') + return None + + def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: + def _t1024(_dollar_dollar): + return _dollar_dollar + _t1025 = _t1024(msg) + fields307 = _t1025 + assert fields307 is not None + unwrapped_fields308 = fields307 + self.write('(') + self.write('init') + self.indent() + if not len(unwrapped_fields308) == 0: + self.newline() + for i310, elem309 in enumerate(unwrapped_fields308): + + if (i310 > 0): + self.newline() + _t1026 = None + else: + _t1026 = None + _t1027 = self.pretty_instruction(elem309) + self.dedent() + self.write(')') + return None + + def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: + def _t1028(_dollar_dollar): + + if _dollar_dollar.HasField('assign'): + _t1029 = _dollar_dollar.assign + else: + _t1029 = None + return _t1029 + _t1030 = _t1028(msg) + deconstruct_result315 = _t1030 + + if deconstruct_result315 is not None: + _t1032 = self.pretty_assign(deconstruct_result315) + _t1031 = _t1032 + else: + def _t1033(_dollar_dollar): + + if _dollar_dollar.HasField('upsert'): + _t1034 = _dollar_dollar.upsert + else: + _t1034 = None + return _t1034 + _t1035 = _t1033(msg) + deconstruct_result314 = _t1035 + + if deconstruct_result314 is not None: + _t1037 = self.pretty_upsert(deconstruct_result314) + _t1036 = _t1037 + else: + def _t1038(_dollar_dollar): + + if _dollar_dollar.HasField('break'): + _t1039 = getattr(_dollar_dollar, 'break') + else: + _t1039 = None + return _t1039 + _t1040 = _t1038(msg) + deconstruct_result313 = _t1040 + + if deconstruct_result313 is not None: + _t1042 = self.pretty_break(deconstruct_result313) + _t1041 = _t1042 + else: + def _t1043(_dollar_dollar): + + if _dollar_dollar.HasField('monoid_def'): + _t1044 = _dollar_dollar.monoid_def + else: + _t1044 = None + return _t1044 + _t1045 = _t1043(msg) + deconstruct_result312 = _t1045 + + if deconstruct_result312 is not None: + _t1047 = self.pretty_monoid_def(deconstruct_result312) + _t1046 = _t1047 + else: + def _t1048(_dollar_dollar): + + if _dollar_dollar.HasField('monus_def'): + _t1049 = _dollar_dollar.monus_def + else: + _t1049 = None + return _t1049 + _t1050 = _t1048(msg) + deconstruct_result311 = _t1050 + + if deconstruct_result311 is not None: + _t1052 = self.pretty_monus_def(deconstruct_result311) + _t1051 = _t1052 + else: + raise ParseError('No matching rule for instruction') + _t1046 = _t1051 + _t1041 = _t1046 + _t1036 = _t1041 + _t1031 = _t1036 + return _t1031 + + def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: + def _t1053(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t1054 = _dollar_dollar.attrs + else: + _t1054 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1054,) + _t1055 = _t1053(msg) + fields316 = _t1055 + assert fields316 is not None + unwrapped_fields317 = fields316 + self.write('(') + self.write('assign') + self.indent() + self.newline() + field318 = unwrapped_fields317[0] + _t1056 = self.pretty_relation_id(field318) + self.newline() + field319 = unwrapped_fields317[1] + _t1057 = self.pretty_abstraction(field319) + field320 = unwrapped_fields317[2] + + if field320 is not None: + self.newline() + assert field320 is not None + opt_val321 = field320 + _t1059 = self.pretty_attrs(opt_val321) + _t1058 = _t1059 + else: + _t1058 = None + self.dedent() + self.write(')') + return None + + def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: + def _t1060(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t1061 = _dollar_dollar.attrs + else: + _t1061 = None + return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1061,) + _t1062 = _t1060(msg) + fields322 = _t1062 + assert fields322 is not None + unwrapped_fields323 = fields322 + self.write('(') + self.write('upsert') + self.indent() + self.newline() + field324 = unwrapped_fields323[0] + _t1063 = self.pretty_relation_id(field324) + self.newline() + field325 = unwrapped_fields323[1] + _t1064 = self.pretty_abstraction_with_arity(field325) + field326 = unwrapped_fields323[2] + + if field326 is not None: + self.newline() + assert field326 is not None + opt_val327 = field326 + _t1066 = self.pretty_attrs(opt_val327) + _t1065 = _t1066 + else: + _t1065 = None + self.dedent() + self.write(')') + return None + + def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: + def _t1067(_dollar_dollar): + _t1068 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) + return (_t1068, _dollar_dollar[0].value,) + _t1069 = _t1067(msg) + fields328 = _t1069 + assert fields328 is not None + unwrapped_fields329 = fields328 + self.write('(') + field330 = unwrapped_fields329[0] + _t1070 = self.pretty_bindings(field330) + self.write(' ') + field331 = unwrapped_fields329[1] + _t1071 = self.pretty_formula(field331) + self.write(')') + return None + + def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: + def _t1072(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t1073 = _dollar_dollar.attrs + else: + _t1073 = None + return (_dollar_dollar.name, _dollar_dollar.body, _t1073,) + _t1074 = _t1072(msg) + fields332 = _t1074 + assert fields332 is not None + unwrapped_fields333 = fields332 + self.write('(') + self.write('break') + self.indent() + self.newline() + field334 = unwrapped_fields333[0] + _t1075 = self.pretty_relation_id(field334) + self.newline() + field335 = unwrapped_fields333[1] + _t1076 = self.pretty_abstraction(field335) + field336 = unwrapped_fields333[2] + + if field336 is not None: + self.newline() + assert field336 is not None + opt_val337 = field336 + _t1078 = self.pretty_attrs(opt_val337) + _t1077 = _t1078 + else: + _t1077 = None + self.dedent() + self.write(')') + return None + + def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: + def _t1079(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t1080 = _dollar_dollar.attrs + else: + _t1080 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1080,) + _t1081 = _t1079(msg) + fields338 = _t1081 + assert fields338 is not None + unwrapped_fields339 = fields338 + self.write('(') + self.write('monoid') + self.indent() + self.newline() + field340 = unwrapped_fields339[0] + _t1082 = self.pretty_monoid(field340) + self.newline() + field341 = unwrapped_fields339[1] + _t1083 = self.pretty_relation_id(field341) + self.newline() + field342 = unwrapped_fields339[2] + _t1084 = self.pretty_abstraction_with_arity(field342) + field343 = unwrapped_fields339[3] + + if field343 is not None: + self.newline() + assert field343 is not None + opt_val344 = field343 + _t1086 = self.pretty_attrs(opt_val344) + _t1085 = _t1086 + else: + _t1085 = None + self.dedent() + self.write(')') + return None + + def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: + def _t1087(_dollar_dollar): + + if _dollar_dollar.HasField('or_monoid'): + _t1088 = _dollar_dollar.or_monoid + else: + _t1088 = None + return _t1088 + _t1089 = _t1087(msg) + deconstruct_result348 = _t1089 + + if deconstruct_result348 is not None: + _t1091 = self.pretty_or_monoid(deconstruct_result348) + _t1090 = _t1091 + else: + def _t1092(_dollar_dollar): + + if _dollar_dollar.HasField('min_monoid'): + _t1093 = _dollar_dollar.min_monoid + else: + _t1093 = None + return _t1093 + _t1094 = _t1092(msg) + deconstruct_result347 = _t1094 + + if deconstruct_result347 is not None: + _t1096 = self.pretty_min_monoid(deconstruct_result347) + _t1095 = _t1096 + else: + def _t1097(_dollar_dollar): + + if _dollar_dollar.HasField('max_monoid'): + _t1098 = _dollar_dollar.max_monoid + else: + _t1098 = None + return _t1098 + _t1099 = _t1097(msg) + deconstruct_result346 = _t1099 + + if deconstruct_result346 is not None: + _t1101 = self.pretty_max_monoid(deconstruct_result346) + _t1100 = _t1101 + else: + def _t1102(_dollar_dollar): + + if _dollar_dollar.HasField('sum_monoid'): + _t1103 = _dollar_dollar.sum_monoid + else: + _t1103 = None + return _t1103 + _t1104 = _t1102(msg) + deconstruct_result345 = _t1104 + + if deconstruct_result345 is not None: + _t1106 = self.pretty_sum_monoid(deconstruct_result345) + _t1105 = _t1106 + else: + raise ParseError('No matching rule for monoid') + _t1100 = _t1105 + _t1095 = _t1100 + _t1090 = _t1095 + return _t1090 + + def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: + def _t1107(_dollar_dollar): + return _dollar_dollar + _t1108 = _t1107(msg) + fields349 = _t1108 + assert fields349 is not None + unwrapped_fields350 = fields349 + self.write('(') + self.write('or') + self.write(')') + return None + + def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: + def _t1109(_dollar_dollar): + return _dollar_dollar.type + _t1110 = _t1109(msg) + fields351 = _t1110 + assert fields351 is not None + unwrapped_fields352 = fields351 + self.write('(') + self.write('min') + self.indent() + self.newline() + _t1111 = self.pretty_type(unwrapped_fields352) + self.dedent() + self.write(')') + return None + + def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: + def _t1112(_dollar_dollar): + return _dollar_dollar.type + _t1113 = _t1112(msg) + fields353 = _t1113 + assert fields353 is not None + unwrapped_fields354 = fields353 + self.write('(') + self.write('max') + self.indent() + self.newline() + _t1114 = self.pretty_type(unwrapped_fields354) + self.dedent() + self.write(')') + return None + + def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: + def _t1115(_dollar_dollar): + return _dollar_dollar.type + _t1116 = _t1115(msg) + fields355 = _t1116 + assert fields355 is not None + unwrapped_fields356 = fields355 + self.write('(') + self.write('sum') + self.indent() + self.newline() + _t1117 = self.pretty_type(unwrapped_fields356) + self.dedent() + self.write(')') + return None + + def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: + def _t1118(_dollar_dollar): + + if not len(_dollar_dollar.attrs) == 0: + _t1119 = _dollar_dollar.attrs + else: + _t1119 = None + return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1119,) + _t1120 = _t1118(msg) + fields357 = _t1120 + assert fields357 is not None + unwrapped_fields358 = fields357 + self.write('(') + self.write('monus') + self.indent() + self.newline() + field359 = unwrapped_fields358[0] + _t1121 = self.pretty_monoid(field359) + self.newline() + field360 = unwrapped_fields358[1] + _t1122 = self.pretty_relation_id(field360) + self.newline() + field361 = unwrapped_fields358[2] + _t1123 = self.pretty_abstraction_with_arity(field361) + field362 = unwrapped_fields358[3] + + if field362 is not None: + self.newline() + assert field362 is not None + opt_val363 = field362 + _t1125 = self.pretty_attrs(opt_val363) + _t1124 = _t1125 + else: + _t1124 = None + self.dedent() + self.write(')') + return None + + def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: + def _t1126(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) + _t1127 = _t1126(msg) + fields364 = _t1127 + assert fields364 is not None + unwrapped_fields365 = fields364 + self.write('(') + self.write('functional_dependency') + self.indent() + self.newline() + field366 = unwrapped_fields365[0] + _t1128 = self.pretty_relation_id(field366) + self.newline() + field367 = unwrapped_fields365[1] + _t1129 = self.pretty_abstraction(field367) + self.newline() + field368 = unwrapped_fields365[2] + _t1130 = self.pretty_functional_dependency_keys(field368) + self.newline() + field369 = unwrapped_fields365[3] + _t1131 = self.pretty_functional_dependency_values(field369) + self.dedent() + self.write(')') + return None + + def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def _t1132(_dollar_dollar): + return _dollar_dollar + _t1133 = _t1132(msg) + fields370 = _t1133 + assert fields370 is not None + unwrapped_fields371 = fields370 + self.write('(') + self.write('keys') + self.indent() + if not len(unwrapped_fields371) == 0: + self.newline() + for i373, elem372 in enumerate(unwrapped_fields371): + + if (i373 > 0): + self.newline() + _t1134 = None + else: + _t1134 = None + _t1135 = self.pretty_var(elem372) + self.dedent() + self.write(')') + return None + + def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def _t1136(_dollar_dollar): + return _dollar_dollar + _t1137 = _t1136(msg) + fields374 = _t1137 + assert fields374 is not None + unwrapped_fields375 = fields374 + self.write('(') + self.write('values') + self.indent() + if not len(unwrapped_fields375) == 0: + self.newline() + for i377, elem376 in enumerate(unwrapped_fields375): + + if (i377 > 0): + self.newline() + _t1138 = None + else: + _t1138 = None + _t1139 = self.pretty_var(elem376) + self.dedent() + self.write(')') + return None + + def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: + def _t1140(_dollar_dollar): + + if _dollar_dollar.HasField('rel_edb'): + _t1141 = _dollar_dollar.rel_edb + else: + _t1141 = None + return _t1141 + _t1142 = _t1140(msg) + deconstruct_result380 = _t1142 + + if deconstruct_result380 is not None: + _t1144 = self.pretty_rel_edb(deconstruct_result380) + _t1143 = _t1144 + else: + def _t1145(_dollar_dollar): + + if _dollar_dollar.HasField('betree_relation'): + _t1146 = _dollar_dollar.betree_relation + else: + _t1146 = None + return _t1146 + _t1147 = _t1145(msg) + deconstruct_result379 = _t1147 + + if deconstruct_result379 is not None: + _t1149 = self.pretty_betree_relation(deconstruct_result379) + _t1148 = _t1149 + else: + def _t1150(_dollar_dollar): + + if _dollar_dollar.HasField('csv_data'): + _t1151 = _dollar_dollar.csv_data + else: + _t1151 = None + return _t1151 + _t1152 = _t1150(msg) + deconstruct_result378 = _t1152 + + if deconstruct_result378 is not None: + _t1154 = self.pretty_csv_data(deconstruct_result378) + _t1153 = _t1154 + else: + raise ParseError('No matching rule for data') + _t1148 = _t1153 + _t1143 = _t1148 + return _t1143 + + def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: + def _t1155(_dollar_dollar): + return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) + _t1156 = _t1155(msg) + fields381 = _t1156 + assert fields381 is not None + unwrapped_fields382 = fields381 + self.write('(') + self.write('rel_edb') + self.indent() + self.newline() + field383 = unwrapped_fields382[0] + _t1157 = self.pretty_relation_id(field383) + self.newline() + field384 = unwrapped_fields382[1] + _t1158 = self.pretty_rel_edb_path(field384) + self.newline() + field385 = unwrapped_fields382[2] + _t1159 = self.pretty_rel_edb_types(field385) + self.dedent() + self.write(')') + return None + + def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: + def _t1160(_dollar_dollar): + return _dollar_dollar + _t1161 = _t1160(msg) + fields386 = _t1161 + assert fields386 is not None + unwrapped_fields387 = fields386 + self.write('[') + for i389, elem388 in enumerate(unwrapped_fields387): + + if (i389 > 0): + self.newline() + _t1162 = None + else: + _t1162 = None + self.write(self.format_string_value(elem388)) + self.write(']') + return None + + def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1163(_dollar_dollar): + return _dollar_dollar + _t1164 = _t1163(msg) + fields390 = _t1164 + assert fields390 is not None + unwrapped_fields391 = fields390 + self.write('[') + for i393, elem392 in enumerate(unwrapped_fields391): + + if (i393 > 0): + self.newline() + _t1165 = None + else: + _t1165 = None + _t1166 = self.pretty_type(elem392) + self.write(']') + return None + + def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: + def _t1167(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.relation_info,) + _t1168 = _t1167(msg) + fields394 = _t1168 + assert fields394 is not None + unwrapped_fields395 = fields394 + self.write('(') + self.write('betree_relation') + self.indent() + self.newline() + field396 = unwrapped_fields395[0] + _t1169 = self.pretty_relation_id(field396) + self.newline() + field397 = unwrapped_fields395[1] + _t1170 = self.pretty_betree_info(field397) + self.dedent() + self.write(')') + return None + + def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: + def _t1171(_dollar_dollar): + _t1172 = self.deconstruct_betree_info_config(_dollar_dollar) + return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1172,) + _t1173 = _t1171(msg) + fields398 = _t1173 + assert fields398 is not None + unwrapped_fields399 = fields398 + self.write('(') + self.write('betree_info') + self.indent() + self.newline() + field400 = unwrapped_fields399[0] + _t1174 = self.pretty_betree_info_key_types(field400) + self.newline() + field401 = unwrapped_fields399[1] + _t1175 = self.pretty_betree_info_value_types(field401) + self.newline() + field402 = unwrapped_fields399[2] + _t1176 = self.pretty_config_dict(field402) + self.dedent() + self.write(')') + return None + + def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1177(_dollar_dollar): + return _dollar_dollar + _t1178 = _t1177(msg) + fields403 = _t1178 + assert fields403 is not None + unwrapped_fields404 = fields403 + self.write('(') + self.write('key_types') + self.indent() + if not len(unwrapped_fields404) == 0: + self.newline() + for i406, elem405 in enumerate(unwrapped_fields404): + + if (i406 > 0): + self.newline() + _t1179 = None + else: + _t1179 = None + _t1180 = self.pretty_type(elem405) + self.dedent() + self.write(')') + return None + + def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def _t1181(_dollar_dollar): + return _dollar_dollar + _t1182 = _t1181(msg) + fields407 = _t1182 + assert fields407 is not None + unwrapped_fields408 = fields407 + self.write('(') + self.write('value_types') + self.indent() + if not len(unwrapped_fields408) == 0: + self.newline() + for i410, elem409 in enumerate(unwrapped_fields408): + + if (i410 > 0): + self.newline() + _t1183 = None + else: + _t1183 = None + _t1184 = self.pretty_type(elem409) + self.dedent() + self.write(')') + return None + + def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: + def _t1185(_dollar_dollar): + return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) + _t1186 = _t1185(msg) + fields411 = _t1186 + assert fields411 is not None + unwrapped_fields412 = fields411 + self.write('(') + self.write('csv_data') + self.indent() + self.newline() + field413 = unwrapped_fields412[0] + _t1187 = self.pretty_csvlocator(field413) + self.newline() + field414 = unwrapped_fields412[1] + _t1188 = self.pretty_csv_config(field414) + self.newline() + field415 = unwrapped_fields412[2] + _t1189 = self.pretty_csv_columns(field415) + self.newline() + field416 = unwrapped_fields412[3] + _t1190 = self.pretty_csv_asof(field416) + self.dedent() + self.write(')') + return None + + def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: + def _t1191(_dollar_dollar): + + if not len(_dollar_dollar.paths) == 0: + _t1192 = _dollar_dollar.paths + else: + _t1192 = None + + if _dollar_dollar.inline_data.decode('utf-8') != '': + _t1193 = _dollar_dollar.inline_data.decode('utf-8') + else: + _t1193 = None + return (_t1192, _t1193,) + _t1194 = _t1191(msg) + fields417 = _t1194 + assert fields417 is not None + unwrapped_fields418 = fields417 + self.write('(') + self.write('csv_locator') + self.indent() + field419 = unwrapped_fields418[0] + + if field419 is not None: + self.newline() + assert field419 is not None + opt_val420 = field419 + _t1196 = self.pretty_csv_locator_paths(opt_val420) + _t1195 = _t1196 + else: + _t1195 = None + field421 = unwrapped_fields418[1] + + if field421 is not None: + self.newline() + assert field421 is not None + opt_val422 = field421 + _t1198 = self.pretty_csv_locator_inline_data(opt_val422) + _t1197 = _t1198 + else: + _t1197 = None + self.dedent() + self.write(')') + return None + + def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: + def _t1199(_dollar_dollar): + return _dollar_dollar + _t1200 = _t1199(msg) + fields423 = _t1200 + assert fields423 is not None + unwrapped_fields424 = fields423 + self.write('(') + self.write('paths') + self.indent() + if not len(unwrapped_fields424) == 0: + self.newline() + for i426, elem425 in enumerate(unwrapped_fields424): + + if (i426 > 0): + self.newline() + _t1201 = None + else: + _t1201 = None + self.write(self.format_string_value(elem425)) + self.dedent() + self.write(')') + return None + + def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: + def _t1202(_dollar_dollar): + return _dollar_dollar + _t1203 = _t1202(msg) + fields427 = _t1203 + assert fields427 is not None + unwrapped_fields428 = fields427 + self.write('(') + self.write('inline_data') + self.indent() + self.newline() + self.write(self.format_string_value(unwrapped_fields428)) + self.dedent() + self.write(')') + return None + + def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: + def _t1204(_dollar_dollar): + _t1205 = self.deconstruct_csv_config(_dollar_dollar) + return _t1205 + _t1206 = _t1204(msg) + fields429 = _t1206 + assert fields429 is not None + unwrapped_fields430 = fields429 + self.write('(') + self.write('csv_config') + self.indent() + self.newline() + _t1207 = self.pretty_config_dict(unwrapped_fields430) + self.dedent() + self.write(')') + return None + + def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: + def _t1208(_dollar_dollar): + return _dollar_dollar + _t1209 = _t1208(msg) + fields431 = _t1209 + assert fields431 is not None + unwrapped_fields432 = fields431 + self.write('(') + self.write('columns') + self.indent() + if not len(unwrapped_fields432) == 0: + self.newline() + for i434, elem433 in enumerate(unwrapped_fields432): + + if (i434 > 0): + self.newline() + _t1210 = None + else: + _t1210 = None + _t1211 = self.pretty_csv_column(elem433) + self.dedent() + self.write(')') + return None + + def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: + def _t1212(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) + _t1213 = _t1212(msg) + fields435 = _t1213 + assert fields435 is not None + unwrapped_fields436 = fields435 + self.write('(') + self.write('column') + self.indent() + self.newline() + field437 = unwrapped_fields436[0] + self.write(self.format_string_value(field437)) + self.newline() + field438 = unwrapped_fields436[1] + _t1214 = self.pretty_relation_id(field438) + self.write('[') + field439 = unwrapped_fields436[2] + if not len(field439) == 0: + self.newline() + for i441, elem440 in enumerate(field439): + + if (i441 > 0): + self.newline() + _t1215 = None + else: + _t1215 = None + _t1216 = self.pretty_type(elem440) + self.write(']') + self.dedent() + self.write(')') + return None + + def pretty_csv_asof(self, msg: str) -> Optional[Never]: + def _t1217(_dollar_dollar): + return _dollar_dollar + _t1218 = _t1217(msg) + fields442 = _t1218 + assert fields442 is not None + unwrapped_fields443 = fields442 + self.write('(') + self.write('asof') + self.indent() + self.newline() + self.write(self.format_string_value(unwrapped_fields443)) + self.dedent() + self.write(')') + return None + + def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: + def _t1219(_dollar_dollar): + return _dollar_dollar.fragment_id + _t1220 = _t1219(msg) + fields444 = _t1220 + assert fields444 is not None + unwrapped_fields445 = fields444 + self.write('(') + self.write('undefine') + self.indent() + self.newline() + _t1221 = self.pretty_fragment_id(unwrapped_fields445) + self.dedent() + self.write(')') + return None + + def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: + def _t1222(_dollar_dollar): + return _dollar_dollar.relations + _t1223 = _t1222(msg) + fields446 = _t1223 + assert fields446 is not None + unwrapped_fields447 = fields446 + self.write('(') + self.write('context') + self.indent() + if not len(unwrapped_fields447) == 0: + self.newline() + for i449, elem448 in enumerate(unwrapped_fields447): + + if (i449 > 0): + self.newline() + _t1224 = None + else: + _t1224 = None + _t1225 = self.pretty_relation_id(elem448) + self.dedent() + self.write(')') + return None + + def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: + def _t1226(_dollar_dollar): + return _dollar_dollar + _t1227 = _t1226(msg) + fields450 = _t1227 + assert fields450 is not None + unwrapped_fields451 = fields450 + self.write('(') + self.write('reads') + self.indent() + if not len(unwrapped_fields451) == 0: + self.newline() + for i453, elem452 in enumerate(unwrapped_fields451): + + if (i453 > 0): + self.newline() + _t1228 = None + else: + _t1228 = None + _t1229 = self.pretty_read(elem452) + self.dedent() + self.write(')') + return None + + def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: + def _t1230(_dollar_dollar): + + if _dollar_dollar.HasField('demand'): + _t1231 = _dollar_dollar.demand + else: + _t1231 = None + return _t1231 + _t1232 = _t1230(msg) + deconstruct_result458 = _t1232 + + if deconstruct_result458 is not None: + _t1234 = self.pretty_demand(deconstruct_result458) + _t1233 = _t1234 + else: + def _t1235(_dollar_dollar): + + if _dollar_dollar.HasField('output'): + _t1236 = _dollar_dollar.output + else: + _t1236 = None + return _t1236 + _t1237 = _t1235(msg) + deconstruct_result457 = _t1237 + + if deconstruct_result457 is not None: + _t1239 = self.pretty_output(deconstruct_result457) + _t1238 = _t1239 + else: + def _t1240(_dollar_dollar): + + if _dollar_dollar.HasField('what_if'): + _t1241 = _dollar_dollar.what_if + else: + _t1241 = None + return _t1241 + _t1242 = _t1240(msg) + deconstruct_result456 = _t1242 + + if deconstruct_result456 is not None: + _t1244 = self.pretty_what_if(deconstruct_result456) + _t1243 = _t1244 + else: + def _t1245(_dollar_dollar): + + if _dollar_dollar.HasField('abort'): + _t1246 = _dollar_dollar.abort + else: + _t1246 = None + return _t1246 + _t1247 = _t1245(msg) + deconstruct_result455 = _t1247 + + if deconstruct_result455 is not None: + _t1249 = self.pretty_abort(deconstruct_result455) + _t1248 = _t1249 + else: + def _t1250(_dollar_dollar): + + if _dollar_dollar.HasField('export'): + _t1251 = _dollar_dollar.export + else: + _t1251 = None + return _t1251 + _t1252 = _t1250(msg) + deconstruct_result454 = _t1252 + + if deconstruct_result454 is not None: + _t1254 = self.pretty_export(deconstruct_result454) + _t1253 = _t1254 + else: + raise ParseError('No matching rule for read') + _t1248 = _t1253 + _t1243 = _t1248 + _t1238 = _t1243 + _t1233 = _t1238 + return _t1233 + + def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: + def _t1255(_dollar_dollar): + return _dollar_dollar.relation_id + _t1256 = _t1255(msg) + fields459 = _t1256 + assert fields459 is not None + unwrapped_fields460 = fields459 + self.write('(') + self.write('demand') + self.indent() + self.newline() + _t1257 = self.pretty_relation_id(unwrapped_fields460) + self.dedent() + self.write(')') + return None + + def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: + def _t1258(_dollar_dollar): + return (_dollar_dollar.name, _dollar_dollar.relation_id,) + _t1259 = _t1258(msg) + fields461 = _t1259 + assert fields461 is not None + unwrapped_fields462 = fields461 + self.write('(') + self.write('output') + self.indent() + self.newline() + field463 = unwrapped_fields462[0] + _t1260 = self.pretty_name(field463) + self.newline() + field464 = unwrapped_fields462[1] + _t1261 = self.pretty_relation_id(field464) + self.dedent() + self.write(')') + return None + + def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: + def _t1262(_dollar_dollar): + return (_dollar_dollar.branch, _dollar_dollar.epoch,) + _t1263 = _t1262(msg) + fields465 = _t1263 + assert fields465 is not None + unwrapped_fields466 = fields465 + self.write('(') + self.write('what_if') + self.indent() + self.newline() + field467 = unwrapped_fields466[0] + _t1264 = self.pretty_name(field467) + self.newline() + field468 = unwrapped_fields466[1] + _t1265 = self.pretty_epoch(field468) + self.dedent() + self.write(')') + return None + + def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: + def _t1266(_dollar_dollar): + + if _dollar_dollar.name != 'abort': + _t1267 = _dollar_dollar.name + else: + _t1267 = None + return (_t1267, _dollar_dollar.relation_id,) + _t1268 = _t1266(msg) + fields469 = _t1268 + assert fields469 is not None + unwrapped_fields470 = fields469 + self.write('(') + self.write('abort') + self.indent() + field471 = unwrapped_fields470[0] + + if field471 is not None: + self.newline() + assert field471 is not None + opt_val472 = field471 + _t1270 = self.pretty_name(opt_val472) + _t1269 = _t1270 + else: + _t1269 = None + self.newline() + field473 = unwrapped_fields470[1] + _t1271 = self.pretty_relation_id(field473) + self.dedent() + self.write(')') + return None + + def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: + def _t1272(_dollar_dollar): + return _dollar_dollar.csv_config + _t1273 = _t1272(msg) + fields474 = _t1273 + assert fields474 is not None + unwrapped_fields475 = fields474 + self.write('(') + self.write('export') + self.indent() + self.newline() + _t1274 = self.pretty_export_csv_config(unwrapped_fields475) + self.dedent() + self.write(')') + return None + + def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: + def _t1275(_dollar_dollar): + _t1276 = self.deconstruct_export_csv_config(_dollar_dollar) + return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1276,) + _t1277 = _t1275(msg) + fields476 = _t1277 + assert fields476 is not None + unwrapped_fields477 = fields476 + self.write('(') + self.write('export_csv_config') + self.indent() + self.newline() + field478 = unwrapped_fields477[0] + _t1278 = self.pretty_export_csv_path(field478) + self.newline() + field479 = unwrapped_fields477[1] + _t1279 = self.pretty_export_csv_columns(field479) + self.newline() + field480 = unwrapped_fields477[2] + _t1280 = self.pretty_config_dict(field480) + self.dedent() + self.write(')') + return None + + def pretty_export_csv_path(self, msg: str) -> Optional[Never]: + def _t1281(_dollar_dollar): + return _dollar_dollar + _t1282 = _t1281(msg) + fields481 = _t1282 + assert fields481 is not None + unwrapped_fields482 = fields481 + self.write('(') + self.write('path') + self.indent() + self.newline() + self.write(self.format_string_value(unwrapped_fields482)) + self.dedent() + self.write(')') + return None + + def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: + def _t1283(_dollar_dollar): + return _dollar_dollar + _t1284 = _t1283(msg) + fields483 = _t1284 + assert fields483 is not None + unwrapped_fields484 = fields483 + self.write('(') + self.write('columns') + self.indent() + if not len(unwrapped_fields484) == 0: + self.newline() + for i486, elem485 in enumerate(unwrapped_fields484): + + if (i486 > 0): + self.newline() + _t1285 = None + else: + _t1285 = None + _t1286 = self.pretty_export_csv_column(elem485) + self.dedent() + self.write(')') + return None + + def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: + def _t1287(_dollar_dollar): + return (_dollar_dollar.column_name, _dollar_dollar.column_data,) + _t1288 = _t1287(msg) + fields487 = _t1288 + assert fields487 is not None + unwrapped_fields488 = fields487 + self.write('(') + self.write('column') + self.indent() + self.newline() + field489 = unwrapped_fields488[0] + self.write(self.format_string_value(field489)) + self.newline() + field490 = unwrapped_fields488[1] + _t1289 = self.pretty_relation_id(field490) + self.dedent() + self.write(')') + return None + + +def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: + """Pretty print a protobuf message and return the string representation.""" + printer = PrettyPrinter(io) + printer.pretty_transaction(msg) + printer.newline() + return printer.get_output() From 9c1dca72b8d6f49b48340d412581662a738c7d6e Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 18:06:36 +0100 Subject: [PATCH 12/25] update --- julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl | 2 +- julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl | 2 +- julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl index dbb42a51..de988d72 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:36.128 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.617 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl index f663fba4..610db0e5 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:35.595 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.102 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl index d7ac00a7..70e7c3c1 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T17:58:36.128 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.617 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) import ProtoBuf as PB From f996a16cf90eb082c056400c5da3d3427ef02666 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 18:32:33 +0100 Subject: [PATCH 13/25] more normalization before comparison --- .../tests/test_generated_pretty_printer.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index ce264351..d35926cb 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -41,6 +41,29 @@ def _parse_and_pretty(input_file: str) -> str: return pretty(proto) +def _normalize_primitives(s: str) -> str: + """Normalize shorthand primitive syntax to verbose form.""" + # Binary primitives: (= a b) → (primitive :rel_primitive_eq a b) + s = re.sub(r'\(\s*=\s+', '(primitive :rel_primitive_eq ', s) + s = re.sub(r'\(\s*<=\s+', '(primitive :rel_primitive_lt_eq_monotype ', s) + s = re.sub(r'\(\s*>=\s+', '(primitive :rel_primitive_gt_eq_monotype ', s) + s = re.sub(r'\(\s*<\s+', '(primitive :rel_primitive_lt_monotype ', s) + s = re.sub(r'\(\s*>\s+', '(primitive :rel_primitive_gt_monotype ', s) + # Ternary primitives: (+ a b c) → (primitive :rel_primitive_add_monotype a b c) + s = re.sub(r'\(\s*\+\s+', '(primitive :rel_primitive_add_monotype ', s) + s = re.sub(r'\(\s*-\s+', '(primitive :rel_primitive_subtract_monotype ', s) + s = re.sub(r'\(\s*\*\s+', '(primitive :rel_primitive_multiply_monotype ', s) + s = re.sub(r'\(\s*/\s+', '(primitive :rel_primitive_divide_monotype ', s) + return s + + +def _normalize_formulas(s: str) -> str: + """Normalize (true) to (and) and (false) to (or).""" + s = re.sub(r'\(\s*true\s*\)', '(and)', s) + s = re.sub(r'\(\s*false\s*\)', '(or)', s) + return s + + def _normalize_ws(s: str) -> str: """Collapse all whitespace sequences to a single space.""" return re.sub(r'\s+', ' ', s).strip() @@ -92,6 +115,11 @@ def test_matches_old_pretty_printer(input_file): options[str(lqp_print.PrettyOptions.PRINT_DEBUG)] = False old_output = lqp_print.to_string(ir_node, options) + generated_output = _normalize_primitives(generated_output) + generated_output = _normalize_formulas(generated_output) + old_output = _normalize_primitives(old_output) + old_output = _normalize_formulas(old_output) + assert _normalize_ws(generated_output) == _normalize_ws(old_output), ( f"Outputs differ for {stem}.\n" f"=== Generated ===\n{generated_output}\n" From 54ee88770f47595a1905ed44a13e9bc602b0c483 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 19:27:53 +0100 Subject: [PATCH 14/25] more fixes --- Makefile | 49 +- .../src/relationalai/lqp/v1/fragments_pb.jl | 2 +- .../src/relationalai/lqp/v1/logic_pb.jl | 2 +- .../relationalai/lqp/v1/transactions_pb.jl | 2 +- python-tools/src/lqp/gen/parser.py | 301 +-- python-tools/src/lqp/gen/pretty.py | 2319 ++++++++--------- python-tools/src/meta/codegen_templates.py | 3 + python-tools/src/meta/grammar.y | 73 +- python-tools/src/meta/pretty_gen.py | 6 +- python-tools/src/meta/target_builtins.py | 1 + python-tools/src/meta/yacc_action_parser.py | 33 +- python-tools/src/meta/yacc_parser.py | 23 + .../tests/test_generated_pretty_printer.py | 6 +- 13 files changed, 1402 insertions(+), 1418 deletions(-) diff --git a/Makefile b/Makefile index d5514eed..079a15b4 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,15 @@ PROTO_FILES := \ GRAMMAR := python-tools/src/meta/grammar.y -# Generated protobuf outputs +# Generated protobuf output directories PY_PROTO_DIR := python-tools/src/lqp/proto/v1 JL_PROTO_DIR := julia/LQPParser/src/relationalai/lqp/v1 GO_PROTO_DIR := go/src/lqp/v1 +# Representative generated protobuf files (used as make targets) +PY_GO_PROTO_GEN := $(PY_PROTO_DIR)/logic_pb2.py +JL_PROTO_GEN := $(JL_PROTO_DIR)/logic_pb.jl + # Generated parser outputs PY_PARSER := python-tools/src/lqp/gen/parser.py JL_PARSER := julia/LQPParser/src/parser.jl @@ -51,10 +55,11 @@ META_PROTO_ARGS := \ --grammar src/meta/grammar.y -.PHONY: all build protobuf-lint protobuf protobuf-py protobuf-julia protobuf-go \ +.PHONY: all build protobuf protobuf-lint protobuf-py-go protobuf-julia \ parsers parser-python parser-julia parser-go \ force-parsers force-parser-python force-parser-julia force-parser-go \ printers printer-python printer-julia printer-go \ + force-printers force-printer-python force-printer-julia force-printer-go \ test test-python test-julia test-go check-python \ clean @@ -66,9 +71,15 @@ protobuf-lint: $(PROTO_FILES) buf lint buf breaking --against ".git#branch=main,subdir=proto" -protobuf: protobuf-py-go protobuf-julia +# Convenience phony targets +protobuf: $(PY_GO_PROTO_GEN) $(JL_PROTO_GEN) +protobuf-py-go: $(PY_GO_PROTO_GEN) +protobuf-julia: $(JL_PROTO_GEN) -protobuf-py-go: protobuf-lint $(PROTO_FILES) +# Only regenerate when .proto files are newer than the generated output +$(PY_GO_PROTO_GEN): $(PROTO_FILES) + buf lint + buf breaking --against ".git#branch=main,subdir=proto" buf generate mkdir -p $(PY_PROTO_DIR) cp gen/python/relationalai/lqp/v1/*_pb2.py* $(PY_PROTO_DIR)/ @@ -82,7 +93,9 @@ protobuf-py-go: protobuf-lint $(PROTO_FILES) cp gen/go/relationalai/lqp/v1/*.pb.go $(GO_PROTO_DIR)/ rm -rf gen/python gen/go -protobuf-julia: protobuf-lint $(PROTO_FILES) +$(JL_PROTO_GEN): $(PROTO_FILES) + buf lint + buf breaking --against ".git#branch=main,subdir=proto" cd julia && julia --project=LQPParser generate_proto.jl # ---------- parser generation ---------- @@ -90,51 +103,51 @@ protobuf-julia: protobuf-lint $(PROTO_FILES) parsers: parser-python parser-julia parser-go parser-python: $(PY_PARSER) -$(PY_PARSER): protobuf $(PROTO_FILES) $(GRAMMAR) $(PY_TEMPLATE) +$(PY_PARSER): $(PY_GO_PROTO_GEN) $(GRAMMAR) $(PY_TEMPLATE) $(META_CLI) $(META_PROTO_ARGS) --parser python -o src/lqp/gen/parser.py parser-julia: $(JL_PARSER) -$(JL_PARSER): protobuf $(PROTO_FILES) $(GRAMMAR) $(JL_TEMPLATE) +$(JL_PARSER): $(JL_PROTO_GEN) $(GRAMMAR) $(JL_TEMPLATE) $(META_CLI) $(META_PROTO_ARGS) --parser julia -o ../julia/LQPParser/src/parser.jl parser-go: $(GO_PARSER) -$(GO_PARSER): protobuf $(PROTO_FILES) $(GRAMMAR) $(GO_TEMPLATE) +$(GO_PARSER): $(PY_GO_PROTO_GEN) $(GRAMMAR) $(GO_TEMPLATE) $(META_CLI) $(META_PROTO_ARGS) --parser go -o ../go/src/parser.go force-parsers: force-parser-python force-parser-julia force-parser-go -force-parser-python: protobuf +force-parser-python: $(PY_GO_PROTO_GEN) $(META_CLI) $(META_PROTO_ARGS) --parser python -o src/lqp/gen/parser.py -force-parser-julia: protobuf +force-parser-julia: $(JL_PROTO_GEN) $(META_CLI) $(META_PROTO_ARGS) --parser julia -o ../julia/LQPParser/src/parser.jl -force-parser-go: protobuf +force-parser-go: $(PY_GO_PROTO_GEN) $(META_CLI) $(META_PROTO_ARGS) --parser go -o ../go/src/parser.go # ---------- pretty printer generation ---------- printers: printer-python printer-julia printer-go -printer-python: protobuf $(PY_PRINTER) -$(PY_PRINTER): $(PROTO_FILES) $(GRAMMAR) +printer-python: $(PY_PRINTER) +$(PY_PRINTER): $(PY_GO_PROTO_GEN) $(GRAMMAR) $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/gen/pretty.py -printer-julia: protobuf +printer-julia: $(JL_PROTO_GEN) @echo "Pretty printer generation for Julia is not yet implemented." -printer-go: protobuf +printer-go: $(PY_GO_PROTO_GEN) @echo "Pretty printer generation for Go is not yet implemented." force-printers: force-printer-python force-printer-julia force-printer-go -force-printer-python: protobuf +force-printer-python: $(PY_GO_PROTO_GEN) $(META_CLI) $(META_PROTO_ARGS) --printer python -o src/lqp/gen/pretty.py -force-printer-julia: protobuf +force-printer-julia: $(JL_PROTO_GEN) @echo "Pretty printer generation for Julia is not yet implemented." -force-printer-go: protobuf +force-printer-go: $(PY_GO_PROTO_GEN) @echo "Pretty printer generation for Go is not yet implemented." # ---------- testing ---------- diff --git a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl index de988d72..eb7a0ce6 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/fragments_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.617 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:09:35.175 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/fragments.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl index 610db0e5..bde9a7e9 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/logic_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.102 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:09:34.645 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/logic.proto (proto3 syntax) import ProtoBuf as PB diff --git a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl index 70e7c3c1..b2aa6da3 100644 --- a/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl +++ b/julia/LQPParser/src/relationalai/lqp/v1/transactions_pb.jl @@ -1,4 +1,4 @@ -# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:05:33.617 +# Autogenerated using ProtoBuf.jl v1.2.0 on 2026-02-11T18:09:35.175 # original file: /Users/nystrom/rai/nn-meta-13-pretty/proto/relationalai/lqp/v1/transactions.proto (proto3 syntax) import ProtoBuf as PB diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 333b80ff..1372cfed 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -277,6 +277,13 @@ def relation_id_to_uint128(self, msg): # --- Helper functions --- + def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) -> int: + assert value is not None + if (value is not None and value.HasField('int_value')): + assert value is not None + return int(value.int_value) + return default + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: assert value is not None if (value is not None and value.HasField('int_value')): @@ -370,7 +377,7 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t945 = self._extract_value_int64(config.get('csv_header_row'), 1) + _t945 = self._extract_value_int32(config.get('csv_header_row'), 1) header_row = _t945 _t946 = self._extract_value_int64(config.get('csv_skip'), 0) skip = _t946 @@ -392,7 +399,7 @@ def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) - encoding = _t954 _t955 = self._extract_value_string(config.get('csv_compression'), 'auto') compression = _t955 - _t956 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + _t956 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t956 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: @@ -467,26 +474,30 @@ def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVC _t980 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) return _t980 - def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t981 = logic_pb2.Value(int_value=v) + def _make_value_int32(self, v: int) -> logic_pb2.Value: + _t981 = logic_pb2.Value(int_value=int(v)) return _t981 - def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t982 = logic_pb2.Value(float_value=v) + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t982 = logic_pb2.Value(int_value=v) return _t982 - def _make_value_string(self, v: str) -> logic_pb2.Value: - _t983 = logic_pb2.Value(string_value=v) + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t983 = logic_pb2.Value(float_value=v) return _t983 - def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t984 = logic_pb2.Value(boolean_value=v) + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t984 = logic_pb2.Value(string_value=v) return _t984 - def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t985 = logic_pb2.Value(uint128_value=v) + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t985 = logic_pb2.Value(boolean_value=v) return _t985 + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t986 = logic_pb2.Value(uint128_value=v) + return _t986 + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: return False @@ -498,241 +509,181 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t987 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t987,)) - _t986 = None + _t988 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t988,)) + _t987 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t989 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t989,)) - _t988 = None + _t990 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t990,)) + _t989 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t991 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t991,)) - _t990 = None + _t992 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t992,)) + _t991 = None else: - _t990 = None - _t988 = _t990 - _t986 = _t988 - _t992 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t992,)) - return result + _t991 = None + _t989 = _t991 + _t987 = _t989 + _t993 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t993,)) + return sorted(result) def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - - if msg.header_row != 1: - _t994 = self._make_value_int64(int(msg.header_row)) - result.append(('csv_header_row', _t994,)) - _t993 = None - else: - _t993 = None - - if msg.skip != 0: - _t996 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t996,)) - _t995 = None - else: - _t995 = None - - if msg.new_line != '': - _t998 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t998,)) - _t997 = None - else: - _t997 = None - - if msg.delimiter != ',': - _t1000 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1000,)) - _t999 = None - else: - _t999 = None - - if msg.quotechar != '"': - _t1002 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1002,)) - _t1001 = None - else: - _t1001 = None - - if msg.escapechar != '"': - _t1004 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1004,)) - _t1003 = None - else: - _t1003 = None - - if msg.comment != '': - _t1006 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1006,)) - _t1005 = None - else: - _t1005 = None - - if not len(msg.missing_strings) == 0: - _t1008 = self._make_value_string(msg.missing_strings[0]) - result.append(('csv_missing_strings', _t1008,)) - _t1007 = None - else: - _t1007 = None - - if msg.decimal_separator != '.': - _t1010 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1010,)) - _t1009 = None - else: - _t1009 = None - - if msg.encoding != 'utf-8': - _t1012 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1012,)) - _t1011 = None - else: - _t1011 = None - - if msg.compression != 'auto': - _t1014 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1014,)) - _t1013 = None - else: - _t1013 = None - return result + _t994 = self._make_value_int32(msg.header_row) + result.append(('csv_header_row', _t994,)) + _t995 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t995,)) + _t996 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t996,)) + _t997 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t997,)) + _t998 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t998,)) + _t999 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t999,)) + _t1000 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1000,)) + for missing_string in msg.missing_strings: + _t1001 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1001,)) + _t1002 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1002,)) + _t1003 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1003,)) + _t1004 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1004,)) + return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1016 = self._make_value_float64(val) - result.append((key, _t1016,)) - _t1015 = None + _t1006 = self._make_value_float64(val) + result.append((key, _t1006,)) + _t1005 = None else: - _t1015 = None + _t1005 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1018 = self._make_value_int64(val) - result.append((key, _t1018,)) - _t1017 = None + _t1008 = self._make_value_int64(val) + result.append((key, _t1008,)) + _t1007 = None else: - _t1017 = None + _t1007 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1020 = self._make_value_uint128(val) - result.append((key, _t1020,)) - _t1019 = None + _t1010 = self._make_value_uint128(val) + result.append((key, _t1010,)) + _t1009 = None else: - _t1019 = None + _t1009 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: assert val is not None - _t1022 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1022,)) - _t1021 = None + _t1012 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1012,)) + _t1011 = None else: - _t1021 = None + _t1011 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1023 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1024 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1025 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1026 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1013 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1014 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1015 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1016 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1028 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1027 = _t1028 + _t1018 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1017 = _t1018 else: - _t1027 = None + _t1017 = None if msg.relation_locator.HasField('inline_data'): - _t1030 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1029 = _t1030 + _t1020 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1019 = _t1020 else: - _t1029 = None - _t1031 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1032 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) - return result + _t1019 = None + _t1021 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1022 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - assert msg.partition_size is not None - if (msg.partition_size is not None and msg.partition_size != 0): + if msg.partition_size is not None: assert msg.partition_size is not None - _t1034 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1034,)) - _t1033 = None + _t1024 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1024,)) + _t1023 = None else: - _t1033 = None - assert msg.compression is not None + _t1023 = None - if (msg.compression is not None and msg.compression != ''): + if msg.compression is not None: assert msg.compression is not None - _t1036 = self._make_value_string(msg.compression) - result.append(('compression', _t1036,)) - _t1035 = None + _t1026 = self._make_value_string(msg.compression) + result.append(('compression', _t1026,)) + _t1025 = None else: - _t1035 = None + _t1025 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1038 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1038,)) - _t1037 = None + _t1028 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1028,)) + _t1027 = None else: - _t1037 = None - assert msg.syntax_missing_string is not None + _t1027 = None - if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1040 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1040,)) - _t1039 = None + _t1030 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1030,)) + _t1029 = None else: - _t1039 = None - assert msg.syntax_delim is not None + _t1029 = None - if (msg.syntax_delim is not None and msg.syntax_delim != ','): + if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1042 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1042,)) - _t1041 = None + _t1032 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1032,)) + _t1031 = None else: - _t1041 = None - assert msg.syntax_quotechar is not None + _t1031 = None - if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1044 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1044,)) - _t1043 = None + _t1034 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1034,)) + _t1033 = None else: - _t1043 = None - assert msg.syntax_escapechar is not None + _t1033 = None - if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1046 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1046,)) - _t1045 = None + _t1036 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1036,)) + _t1035 = None else: - _t1045 = None - return result + _t1035 = None + return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: name = self.relation_id_to_string(msg) diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py index ea98ebf7..ca29e634 100644 --- a/python-tools/src/lqp/gen/pretty.py +++ b/python-tools/src/lqp/gen/pretty.py @@ -117,6 +117,13 @@ def format_string_value(self, s: str) -> str: # --- Helper functions --- + def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) -> int: + assert value is not None + if (value is not None and value.HasField('int_value')): + assert value is not None + return int(value.int_value) + return default + def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: assert value is not None if (value is not None and value.HasField('int_value')): @@ -210,7 +217,7 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t1290 = self._extract_value_int64(config.get('csv_header_row'), 1) + _t1290 = self._extract_value_int32(config.get('csv_header_row'), 1) header_row = _t1290 _t1291 = self._extract_value_int64(config.get('csv_skip'), 0) skip = _t1291 @@ -232,7 +239,7 @@ def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) - encoding = _t1299 _t1300 = self._extract_value_string(config.get('csv_compression'), 'auto') compression = _t1300 - _t1301 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + _t1301 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t1301 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: @@ -307,26 +314,30 @@ def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVC _t1325 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) return _t1325 - def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t1326 = logic_pb2.Value(int_value=v) + def _make_value_int32(self, v: int) -> logic_pb2.Value: + _t1326 = logic_pb2.Value(int_value=int(v)) return _t1326 - def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t1327 = logic_pb2.Value(float_value=v) + def _make_value_int64(self, v: int) -> logic_pb2.Value: + _t1327 = logic_pb2.Value(int_value=v) return _t1327 - def _make_value_string(self, v: str) -> logic_pb2.Value: - _t1328 = logic_pb2.Value(string_value=v) + def _make_value_float64(self, v: float) -> logic_pb2.Value: + _t1328 = logic_pb2.Value(float_value=v) return _t1328 - def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t1329 = logic_pb2.Value(boolean_value=v) + def _make_value_string(self, v: str) -> logic_pb2.Value: + _t1329 = logic_pb2.Value(string_value=v) return _t1329 - def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1330 = logic_pb2.Value(uint128_value=v) + def _make_value_boolean(self, v: bool) -> logic_pb2.Value: + _t1330 = logic_pb2.Value(boolean_value=v) return _t1330 + def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: + _t1331 = logic_pb2.Value(uint128_value=v) + return _t1331 + def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: return False @@ -338,241 +349,181 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1332 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1332,)) - _t1331 = None + _t1333 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1333,)) + _t1332 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1334 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1334,)) - _t1333 = None + _t1335 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1335,)) + _t1334 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1336 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1336,)) - _t1335 = None + _t1337 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1337,)) + _t1336 = None else: - _t1335 = None - _t1333 = _t1335 - _t1331 = _t1333 - _t1337 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1337,)) - return result + _t1336 = None + _t1334 = _t1336 + _t1332 = _t1334 + _t1338 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1338,)) + return sorted(result) def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - - if msg.header_row != 1: - _t1339 = self._make_value_int64(int(msg.header_row)) - result.append(('csv_header_row', _t1339,)) - _t1338 = None - else: - _t1338 = None - - if msg.skip != 0: - _t1341 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1341,)) - _t1340 = None - else: - _t1340 = None - - if msg.new_line != '': - _t1343 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1343,)) - _t1342 = None - else: - _t1342 = None - - if msg.delimiter != ',': - _t1345 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1345,)) - _t1344 = None - else: - _t1344 = None - - if msg.quotechar != '"': - _t1347 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1347,)) - _t1346 = None - else: - _t1346 = None - - if msg.escapechar != '"': - _t1349 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1349,)) - _t1348 = None - else: - _t1348 = None - - if msg.comment != '': - _t1351 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1351,)) - _t1350 = None - else: - _t1350 = None - - if not len(msg.missing_strings) == 0: - _t1353 = self._make_value_string(msg.missing_strings[0]) - result.append(('csv_missing_strings', _t1353,)) - _t1352 = None - else: - _t1352 = None - - if msg.decimal_separator != '.': - _t1355 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1355,)) - _t1354 = None - else: - _t1354 = None - - if msg.encoding != 'utf-8': - _t1357 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1357,)) - _t1356 = None - else: - _t1356 = None - - if msg.compression != 'auto': - _t1359 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1359,)) - _t1358 = None - else: - _t1358 = None - return result + _t1339 = self._make_value_int32(msg.header_row) + result.append(('csv_header_row', _t1339,)) + _t1340 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1340,)) + _t1341 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1341,)) + _t1342 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1342,)) + _t1343 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1343,)) + _t1344 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1344,)) + _t1345 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1345,)) + for missing_string in msg.missing_strings: + _t1346 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1346,)) + _t1347 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1347,)) + _t1348 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1348,)) + _t1349 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1349,)) + return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1361 = self._make_value_float64(val) - result.append((key, _t1361,)) - _t1360 = None + _t1351 = self._make_value_float64(val) + result.append((key, _t1351,)) + _t1350 = None else: - _t1360 = None + _t1350 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1363 = self._make_value_int64(val) - result.append((key, _t1363,)) - _t1362 = None + _t1353 = self._make_value_int64(val) + result.append((key, _t1353,)) + _t1352 = None else: - _t1362 = None + _t1352 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1365 = self._make_value_uint128(val) - result.append((key, _t1365,)) - _t1364 = None + _t1355 = self._make_value_uint128(val) + result.append((key, _t1355,)) + _t1354 = None else: - _t1364 = None + _t1354 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: assert val is not None - _t1367 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1367,)) - _t1366 = None + _t1357 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1357,)) + _t1356 = None else: - _t1366 = None + _t1356 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1358 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1359 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1360 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1361 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1373 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1372 = _t1373 + _t1363 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1362 = _t1363 else: - _t1372 = None + _t1362 = None if msg.relation_locator.HasField('inline_data'): - _t1375 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1374 = _t1375 + _t1365 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1364 = _t1365 else: - _t1374 = None - _t1376 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1377 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) - return result + _t1364 = None + _t1366 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1367 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - assert msg.partition_size is not None - if (msg.partition_size is not None and msg.partition_size != 0): + if msg.partition_size is not None: assert msg.partition_size is not None - _t1379 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1379,)) - _t1378 = None + _t1369 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1369,)) + _t1368 = None else: - _t1378 = None - assert msg.compression is not None + _t1368 = None - if (msg.compression is not None and msg.compression != ''): + if msg.compression is not None: assert msg.compression is not None - _t1381 = self._make_value_string(msg.compression) - result.append(('compression', _t1381,)) - _t1380 = None + _t1371 = self._make_value_string(msg.compression) + result.append(('compression', _t1371,)) + _t1370 = None else: - _t1380 = None + _t1370 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1383 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1383,)) - _t1382 = None + _t1373 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1373,)) + _t1372 = None else: - _t1382 = None - assert msg.syntax_missing_string is not None + _t1372 = None - if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): + if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1385 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1385,)) - _t1384 = None + _t1375 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1375,)) + _t1374 = None else: - _t1384 = None - assert msg.syntax_delim is not None + _t1374 = None - if (msg.syntax_delim is not None and msg.syntax_delim != ','): + if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1387 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1387,)) - _t1386 = None + _t1377 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1377,)) + _t1376 = None else: - _t1386 = None - assert msg.syntax_quotechar is not None + _t1376 = None - if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): + if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1389 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1389,)) - _t1388 = None + _t1379 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1379,)) + _t1378 = None else: - _t1388 = None - assert msg.syntax_escapechar is not None + _t1378 = None - if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): + if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1391 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1391,)) - _t1390 = None + _t1381 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1381,)) + _t1380 = None else: - _t1390 = None - return result + _t1380 = None + return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: name = self.relation_id_to_string(msg) @@ -598,20 +549,20 @@ def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arit # --- Pretty-print methods --- def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: - def _t491(_dollar_dollar): + def _t490(_dollar_dollar): if _dollar_dollar.HasField('configure'): - _t492 = _dollar_dollar.configure + _t491 = _dollar_dollar.configure else: - _t492 = None + _t491 = None if _dollar_dollar.HasField('sync'): - _t493 = _dollar_dollar.sync + _t492 = _dollar_dollar.sync else: - _t493 = None - return (_t492, _t493, _dollar_dollar.epochs,) - _t494 = _t491(msg) - fields0 = _t494 + _t492 = None + return (_t491, _t492, _dollar_dollar.epochs,) + _t493 = _t490(msg) + fields0 = _t493 assert fields0 is not None unwrapped_fields1 = fields0 self.write('(') @@ -623,20 +574,20 @@ def _t491(_dollar_dollar): self.newline() assert field2 is not None opt_val3 = field2 - _t496 = self.pretty_configure(opt_val3) - _t495 = _t496 + _t495 = self.pretty_configure(opt_val3) + _t494 = _t495 else: - _t495 = None + _t494 = None field4 = unwrapped_fields1[1] if field4 is not None: self.newline() assert field4 is not None opt_val5 = field4 - _t498 = self.pretty_sync(opt_val5) - _t497 = _t498 + _t497 = self.pretty_sync(opt_val5) + _t496 = _t497 else: - _t497 = None + _t496 = None field6 = unwrapped_fields1[2] if not len(field6) == 0: self.newline() @@ -644,36 +595,36 @@ def _t491(_dollar_dollar): if (i8 > 0): self.newline() - _t499 = None + _t498 = None else: - _t499 = None - _t500 = self.pretty_epoch(elem7) + _t498 = None + _t499 = self.pretty_epoch(elem7) self.dedent() self.write(')') return None def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: - def _t501(_dollar_dollar): - _t502 = self.deconstruct_configure(_dollar_dollar) - return _t502 - _t503 = _t501(msg) - fields9 = _t503 + def _t500(_dollar_dollar): + _t501 = self.deconstruct_configure(_dollar_dollar) + return _t501 + _t502 = _t500(msg) + fields9 = _t502 assert fields9 is not None unwrapped_fields10 = fields9 self.write('(') self.write('configure') self.indent() self.newline() - _t504 = self.pretty_config_dict(unwrapped_fields10) + _t503 = self.pretty_config_dict(unwrapped_fields10) self.dedent() self.write(')') return None def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: - def _t505(_dollar_dollar): + def _t504(_dollar_dollar): return _dollar_dollar - _t506 = _t505(msg) - fields11 = _t506 + _t505 = _t504(msg) + fields11 = _t505 assert fields11 is not None unwrapped_fields12 = fields11 self.write('{') @@ -683,18 +634,18 @@ def _t505(_dollar_dollar): if (i14 > 0): self.newline() - _t507 = None + _t506 = None else: - _t507 = None - _t508 = self.pretty_config_key_value(elem13) + _t506 = None + _t507 = self.pretty_config_key_value(elem13) self.write('}') return None def pretty_config_key_value(self, msg: tuple[str, logic_pb2.Value]) -> Optional[Never]: - def _t509(_dollar_dollar): + def _t508(_dollar_dollar): return (_dollar_dollar[0], _dollar_dollar[1],) - _t510 = _t509(msg) - fields15 = _t510 + _t509 = _t508(msg) + fields15 = _t509 assert fields15 is not None unwrapped_fields16 = fields15 self.write(':') @@ -702,159 +653,159 @@ def _t509(_dollar_dollar): self.write(field17) self.write(' ') field18 = unwrapped_fields16[1] - _t511 = self.pretty_value(field18) - return _t511 + _t510 = self.pretty_value(field18) + return _t510 def pretty_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t512(_dollar_dollar): + def _t511(_dollar_dollar): if _dollar_dollar.HasField('date_value'): - _t513 = _dollar_dollar.date_value + _t512 = _dollar_dollar.date_value else: - _t513 = None - return _t513 - _t514 = _t512(msg) - deconstruct_result29 = _t514 + _t512 = None + return _t512 + _t513 = _t511(msg) + deconstruct_result29 = _t513 if deconstruct_result29 is not None: - _t516 = self.pretty_date(deconstruct_result29) - _t515 = _t516 + _t515 = self.pretty_date(deconstruct_result29) + _t514 = _t515 else: - def _t517(_dollar_dollar): + def _t516(_dollar_dollar): if _dollar_dollar.HasField('datetime_value'): - _t518 = _dollar_dollar.datetime_value + _t517 = _dollar_dollar.datetime_value else: - _t518 = None - return _t518 - _t519 = _t517(msg) - deconstruct_result28 = _t519 + _t517 = None + return _t517 + _t518 = _t516(msg) + deconstruct_result28 = _t518 if deconstruct_result28 is not None: - _t521 = self.pretty_datetime(deconstruct_result28) - _t520 = _t521 + _t520 = self.pretty_datetime(deconstruct_result28) + _t519 = _t520 else: - def _t522(_dollar_dollar): + def _t521(_dollar_dollar): if _dollar_dollar.HasField('string_value'): - _t523 = _dollar_dollar.string_value + _t522 = _dollar_dollar.string_value else: - _t523 = None - return _t523 - _t524 = _t522(msg) - deconstruct_result27 = _t524 + _t522 = None + return _t522 + _t523 = _t521(msg) + deconstruct_result27 = _t523 if deconstruct_result27 is not None: self.write(self.format_string_value(deconstruct_result27)) - _t525 = None + _t524 = None else: - def _t526(_dollar_dollar): + def _t525(_dollar_dollar): if _dollar_dollar.HasField('int_value'): - _t527 = _dollar_dollar.int_value + _t526 = _dollar_dollar.int_value else: - _t527 = None - return _t527 - _t528 = _t526(msg) - deconstruct_result26 = _t528 + _t526 = None + return _t526 + _t527 = _t525(msg) + deconstruct_result26 = _t527 if deconstruct_result26 is not None: self.write(str(deconstruct_result26)) - _t529 = None + _t528 = None else: - def _t530(_dollar_dollar): + def _t529(_dollar_dollar): if _dollar_dollar.HasField('float_value'): - _t531 = _dollar_dollar.float_value + _t530 = _dollar_dollar.float_value else: - _t531 = None - return _t531 - _t532 = _t530(msg) - deconstruct_result25 = _t532 + _t530 = None + return _t530 + _t531 = _t529(msg) + deconstruct_result25 = _t531 if deconstruct_result25 is not None: self.write(str(deconstruct_result25)) - _t533 = None + _t532 = None else: - def _t534(_dollar_dollar): + def _t533(_dollar_dollar): if _dollar_dollar.HasField('uint128_value'): - _t535 = _dollar_dollar.uint128_value + _t534 = _dollar_dollar.uint128_value else: - _t535 = None - return _t535 - _t536 = _t534(msg) - deconstruct_result24 = _t536 + _t534 = None + return _t534 + _t535 = _t533(msg) + deconstruct_result24 = _t535 if deconstruct_result24 is not None: self.write(self.format_uint128(deconstruct_result24)) - _t537 = None + _t536 = None else: - def _t538(_dollar_dollar): + def _t537(_dollar_dollar): if _dollar_dollar.HasField('int128_value'): - _t539 = _dollar_dollar.int128_value + _t538 = _dollar_dollar.int128_value else: - _t539 = None - return _t539 - _t540 = _t538(msg) - deconstruct_result23 = _t540 + _t538 = None + return _t538 + _t539 = _t537(msg) + deconstruct_result23 = _t539 if deconstruct_result23 is not None: self.write(self.format_int128(deconstruct_result23)) - _t541 = None + _t540 = None else: - def _t542(_dollar_dollar): + def _t541(_dollar_dollar): if _dollar_dollar.HasField('decimal_value'): - _t543 = _dollar_dollar.decimal_value + _t542 = _dollar_dollar.decimal_value else: - _t543 = None - return _t543 - _t544 = _t542(msg) - deconstruct_result22 = _t544 + _t542 = None + return _t542 + _t543 = _t541(msg) + deconstruct_result22 = _t543 if deconstruct_result22 is not None: self.write(self.format_decimal(deconstruct_result22)) - _t545 = None + _t544 = None else: - def _t546(_dollar_dollar): + def _t545(_dollar_dollar): if _dollar_dollar.HasField('boolean_value'): - _t547 = _dollar_dollar.boolean_value + _t546 = _dollar_dollar.boolean_value else: - _t547 = None - return _t547 - _t548 = _t546(msg) - deconstruct_result21 = _t548 + _t546 = None + return _t546 + _t547 = _t545(msg) + deconstruct_result21 = _t547 if deconstruct_result21 is not None: - _t550 = self.pretty_boolean_value(deconstruct_result21) - _t549 = _t550 + _t549 = self.pretty_boolean_value(deconstruct_result21) + _t548 = _t549 else: - def _t551(_dollar_dollar): + def _t550(_dollar_dollar): return _dollar_dollar - _t552 = _t551(msg) - fields19 = _t552 + _t551 = _t550(msg) + fields19 = _t551 assert fields19 is not None unwrapped_fields20 = fields19 self.write('missing') - _t549 = None - _t545 = _t549 - _t541 = _t545 - _t537 = _t541 - _t533 = _t537 - _t529 = _t533 - _t525 = _t529 - _t520 = _t525 - _t515 = _t520 - return _t515 + _t548 = None + _t544 = _t548 + _t540 = _t544 + _t536 = _t540 + _t532 = _t536 + _t528 = _t532 + _t524 = _t528 + _t519 = _t524 + _t514 = _t519 + return _t514 def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: - def _t553(_dollar_dollar): + def _t552(_dollar_dollar): return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) - _t554 = _t553(msg) - fields30 = _t554 + _t553 = _t552(msg) + fields30 = _t553 assert fields30 is not None unwrapped_fields31 = fields30 self.write('(') @@ -874,15 +825,10 @@ def _t553(_dollar_dollar): return None def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: - def _t555(_dollar_dollar): - - if _dollar_dollar.microsecond != 0: - _t556 = int(_dollar_dollar.microsecond) - else: - _t556 = None - return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), _t556,) - _t557 = _t555(msg) - fields35 = _t557 + def _t554(_dollar_dollar): + return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), int(_dollar_dollar.microsecond),) + _t555 = _t554(msg) + fields35 = _t555 assert fields35 is not None unwrapped_fields36 = fields35 self.write('(') @@ -913,58 +859,66 @@ def _t555(_dollar_dollar): assert field43 is not None opt_val44 = field43 self.write(str(opt_val44)) - _t558 = None + _t556 = None else: - _t558 = None + _t556 = None self.dedent() self.write(')') return None def pretty_boolean_value(self, msg: bool) -> Optional[Never]: - def _t559(_dollar_dollar): + def _t557(_dollar_dollar): if _dollar_dollar: - _t560 = () + _t558 = () else: - _t560 = None - return _t560 - _t561 = _t559(msg) - deconstruct_result47 = _t561 + _t558 = None + return _t558 + _t559 = _t557(msg) + deconstruct_result46 = _t559 - if deconstruct_result47 is not None: + if deconstruct_result46 is not None: self.write('true') - _t562 = None + _t560 = None else: - def _t563(_dollar_dollar): - return _dollar_dollar - _t564 = _t563(msg) - fields45 = _t564 - assert fields45 is not None - unwrapped_fields46 = fields45 - self.write('false') - _t562 = None - return _t562 + def _t561(_dollar_dollar): + + if not _dollar_dollar: + _t562 = () + else: + _t562 = None + return _t562 + _t563 = _t561(msg) + deconstruct_result45 = _t563 + + if deconstruct_result45 is not None: + self.write('false') + _t564 = None + else: + raise ParseError('No matching rule for boolean_value') + _t560 = _t564 + return _t560 def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: def _t565(_dollar_dollar): return _dollar_dollar.fragments _t566 = _t565(msg) - fields48 = _t566 - assert fields48 is not None - unwrapped_fields49 = fields48 + fields47 = _t566 + assert fields47 is not None + unwrapped_fields48 = fields47 self.write('(') self.write('sync') self.indent() - if not len(unwrapped_fields49) == 0: + if not len(unwrapped_fields48) == 0: self.newline() - for i51, elem50 in enumerate(unwrapped_fields49): + for i50, elem49 in enumerate(unwrapped_fields48): - if (i51 > 0): + if (i50 > 0): self.newline() _t567 = None else: _t567 = None - _t568 = self.pretty_fragment_id(elem50) + _t568 = self.pretty_fragment_id(elem49) self.dedent() self.write(')') return None @@ -973,11 +927,11 @@ def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: def _t569(_dollar_dollar): return self.fragment_id_to_string(_dollar_dollar) _t570 = _t569(msg) - fields52 = _t570 - assert fields52 is not None - unwrapped_fields53 = fields52 + fields51 = _t570 + assert fields51 is not None + unwrapped_fields52 = fields51 self.write(':') - self.write(unwrapped_fields53) + self.write(unwrapped_fields52) return None def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: @@ -994,29 +948,29 @@ def _t571(_dollar_dollar): _t573 = None return (_t572, _t573,) _t574 = _t571(msg) - fields54 = _t574 - assert fields54 is not None - unwrapped_fields55 = fields54 + fields53 = _t574 + assert fields53 is not None + unwrapped_fields54 = fields53 self.write('(') self.write('epoch') self.indent() - field56 = unwrapped_fields55[0] + field55 = unwrapped_fields54[0] - if field56 is not None: + if field55 is not None: self.newline() - assert field56 is not None - opt_val57 = field56 - _t576 = self.pretty_epoch_writes(opt_val57) + assert field55 is not None + opt_val56 = field55 + _t576 = self.pretty_epoch_writes(opt_val56) _t575 = _t576 else: _t575 = None - field58 = unwrapped_fields55[1] + field57 = unwrapped_fields54[1] - if field58 is not None: + if field57 is not None: self.newline() - assert field58 is not None - opt_val59 = field58 - _t578 = self.pretty_epoch_reads(opt_val59) + assert field57 is not None + opt_val58 = field57 + _t578 = self.pretty_epoch_reads(opt_val58) _t577 = _t578 else: _t577 = None @@ -1028,22 +982,22 @@ def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Nev def _t579(_dollar_dollar): return _dollar_dollar _t580 = _t579(msg) - fields60 = _t580 - assert fields60 is not None - unwrapped_fields61 = fields60 + fields59 = _t580 + assert fields59 is not None + unwrapped_fields60 = fields59 self.write('(') self.write('writes') self.indent() - if not len(unwrapped_fields61) == 0: + if not len(unwrapped_fields60) == 0: self.newline() - for i63, elem62 in enumerate(unwrapped_fields61): + for i62, elem61 in enumerate(unwrapped_fields60): - if (i63 > 0): + if (i62 > 0): self.newline() _t581 = None else: _t581 = None - _t582 = self.pretty_write(elem62) + _t582 = self.pretty_write(elem61) self.dedent() self.write(')') return None @@ -1057,10 +1011,10 @@ def _t583(_dollar_dollar): _t584 = None return _t584 _t585 = _t583(msg) - deconstruct_result66 = _t585 + deconstruct_result65 = _t585 - if deconstruct_result66 is not None: - _t587 = self.pretty_define(deconstruct_result66) + if deconstruct_result65 is not None: + _t587 = self.pretty_define(deconstruct_result65) _t586 = _t587 else: def _t588(_dollar_dollar): @@ -1071,10 +1025,10 @@ def _t588(_dollar_dollar): _t589 = None return _t589 _t590 = _t588(msg) - deconstruct_result65 = _t590 + deconstruct_result64 = _t590 - if deconstruct_result65 is not None: - _t592 = self.pretty_undefine(deconstruct_result65) + if deconstruct_result64 is not None: + _t592 = self.pretty_undefine(deconstruct_result64) _t591 = _t592 else: def _t593(_dollar_dollar): @@ -1085,10 +1039,10 @@ def _t593(_dollar_dollar): _t594 = None return _t594 _t595 = _t593(msg) - deconstruct_result64 = _t595 + deconstruct_result63 = _t595 - if deconstruct_result64 is not None: - _t597 = self.pretty_context(deconstruct_result64) + if deconstruct_result63 is not None: + _t597 = self.pretty_context(deconstruct_result63) _t596 = _t597 else: raise ParseError('No matching rule for write') @@ -1100,14 +1054,14 @@ def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: def _t598(_dollar_dollar): return _dollar_dollar.fragment _t599 = _t598(msg) - fields67 = _t599 - assert fields67 is not None - unwrapped_fields68 = fields67 + fields66 = _t599 + assert fields66 is not None + unwrapped_fields67 = fields66 self.write('(') self.write('define') self.indent() self.newline() - _t600 = self.pretty_fragment(unwrapped_fields68) + _t600 = self.pretty_fragment(unwrapped_fields67) self.dedent() self.write(')') return None @@ -1117,26 +1071,26 @@ def _t601(_dollar_dollar): _t602 = self.start_pretty_fragment(_dollar_dollar) return (_dollar_dollar.id, _dollar_dollar.declarations,) _t603 = _t601(msg) - fields69 = _t603 - assert fields69 is not None - unwrapped_fields70 = fields69 + fields68 = _t603 + assert fields68 is not None + unwrapped_fields69 = fields68 self.write('(') self.write('fragment') self.indent() self.newline() - field71 = unwrapped_fields70[0] - _t604 = self.pretty_new_fragment_id(field71) - field72 = unwrapped_fields70[1] - if not len(field72) == 0: + field70 = unwrapped_fields69[0] + _t604 = self.pretty_new_fragment_id(field70) + field71 = unwrapped_fields69[1] + if not len(field71) == 0: self.newline() - for i74, elem73 in enumerate(field72): + for i73, elem72 in enumerate(field71): - if (i74 > 0): + if (i73 > 0): self.newline() _t605 = None else: _t605 = None - _t606 = self.pretty_declaration(elem73) + _t606 = self.pretty_declaration(elem72) self.dedent() self.write(')') return None @@ -1145,10 +1099,10 @@ def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Neve def _t607(_dollar_dollar): return _dollar_dollar _t608 = _t607(msg) - fields75 = _t608 - assert fields75 is not None - unwrapped_fields76 = fields75 - _t609 = self.pretty_fragment_id(unwrapped_fields76) + fields74 = _t608 + assert fields74 is not None + unwrapped_fields75 = fields74 + _t609 = self.pretty_fragment_id(unwrapped_fields75) return _t609 def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: @@ -1160,10 +1114,10 @@ def _t610(_dollar_dollar): _t611 = None return _t611 _t612 = _t610(msg) - deconstruct_result80 = _t612 + deconstruct_result79 = _t612 - if deconstruct_result80 is not None: - _t614 = self.pretty_def(deconstruct_result80) + if deconstruct_result79 is not None: + _t614 = self.pretty_def(deconstruct_result79) _t613 = _t614 else: def _t615(_dollar_dollar): @@ -1174,10 +1128,10 @@ def _t615(_dollar_dollar): _t616 = None return _t616 _t617 = _t615(msg) - deconstruct_result79 = _t617 + deconstruct_result78 = _t617 - if deconstruct_result79 is not None: - _t619 = self.pretty_algorithm(deconstruct_result79) + if deconstruct_result78 is not None: + _t619 = self.pretty_algorithm(deconstruct_result78) _t618 = _t619 else: def _t620(_dollar_dollar): @@ -1188,10 +1142,10 @@ def _t620(_dollar_dollar): _t621 = None return _t621 _t622 = _t620(msg) - deconstruct_result78 = _t622 + deconstruct_result77 = _t622 - if deconstruct_result78 is not None: - _t624 = self.pretty_constraint(deconstruct_result78) + if deconstruct_result77 is not None: + _t624 = self.pretty_constraint(deconstruct_result77) _t623 = _t624 else: def _t625(_dollar_dollar): @@ -1202,10 +1156,10 @@ def _t625(_dollar_dollar): _t626 = None return _t626 _t627 = _t625(msg) - deconstruct_result77 = _t627 + deconstruct_result76 = _t627 - if deconstruct_result77 is not None: - _t629 = self.pretty_data(deconstruct_result77) + if deconstruct_result76 is not None: + _t629 = self.pretty_data(deconstruct_result76) _t628 = _t629 else: raise ParseError('No matching rule for declaration') @@ -1223,25 +1177,25 @@ def _t630(_dollar_dollar): _t631 = None return (_dollar_dollar.name, _dollar_dollar.body, _t631,) _t632 = _t630(msg) - fields81 = _t632 - assert fields81 is not None - unwrapped_fields82 = fields81 + fields80 = _t632 + assert fields80 is not None + unwrapped_fields81 = fields80 self.write('(') self.write('def') self.indent() self.newline() - field83 = unwrapped_fields82[0] - _t633 = self.pretty_relation_id(field83) + field82 = unwrapped_fields81[0] + _t633 = self.pretty_relation_id(field82) self.newline() - field84 = unwrapped_fields82[1] - _t634 = self.pretty_abstraction(field84) - field85 = unwrapped_fields82[2] + field83 = unwrapped_fields81[1] + _t634 = self.pretty_abstraction(field83) + field84 = unwrapped_fields81[2] - if field85 is not None: + if field84 is not None: self.newline() - assert field85 is not None - opt_val86 = field85 - _t636 = self.pretty_attrs(opt_val86) + assert field84 is not None + opt_val85 = field84 + _t636 = self.pretty_attrs(opt_val85) _t635 = _t636 else: _t635 = None @@ -1254,21 +1208,21 @@ def _t637(_dollar_dollar): _t638 = self.deconstruct_relation_id_string(_dollar_dollar) return _t638 _t639 = _t637(msg) - deconstruct_result88 = _t639 + deconstruct_result87 = _t639 - if deconstruct_result88 is not None: + if deconstruct_result87 is not None: self.write(':') - self.write(deconstruct_result88) + self.write(deconstruct_result87) _t640 = None else: def _t641(_dollar_dollar): _t642 = self.deconstruct_relation_id_uint128(_dollar_dollar) return _t642 _t643 = _t641(msg) - deconstruct_result87 = _t643 + deconstruct_result86 = _t643 - if deconstruct_result87 is not None: - self.write(self.format_uint128(deconstruct_result87)) + if deconstruct_result86 is not None: + self.write(self.format_uint128(deconstruct_result86)) _t644 = None else: raise ParseError('No matching rule for relation_id') @@ -1280,15 +1234,15 @@ def _t645(_dollar_dollar): _t646 = self.deconstruct_bindings(_dollar_dollar) return (_t646, _dollar_dollar.value,) _t647 = _t645(msg) - fields89 = _t647 - assert fields89 is not None - unwrapped_fields90 = fields89 + fields88 = _t647 + assert fields88 is not None + unwrapped_fields89 = fields88 self.write('(') - field91 = unwrapped_fields90[0] - _t648 = self.pretty_bindings(field91) + field90 = unwrapped_fields89[0] + _t648 = self.pretty_bindings(field90) self.write(' ') - field92 = unwrapped_fields90[1] - _t649 = self.pretty_formula(field92) + field91 = unwrapped_fields89[1] + _t649 = self.pretty_formula(field91) self.write(')') return None @@ -1301,26 +1255,26 @@ def _t650(_dollar_dollar): _t651 = None return (_dollar_dollar[0], _t651,) _t652 = _t650(msg) - fields93 = _t652 - assert fields93 is not None - unwrapped_fields94 = fields93 + fields92 = _t652 + assert fields92 is not None + unwrapped_fields93 = fields92 self.write('[') - field95 = unwrapped_fields94[0] - for i97, elem96 in enumerate(field95): + field94 = unwrapped_fields93[0] + for i96, elem95 in enumerate(field94): - if (i97 > 0): + if (i96 > 0): self.newline() _t653 = None else: _t653 = None - _t654 = self.pretty_binding(elem96) - field98 = unwrapped_fields94[1] + _t654 = self.pretty_binding(elem95) + field97 = unwrapped_fields93[1] - if field98 is not None: + if field97 is not None: self.write(' ') - assert field98 is not None - opt_val99 = field98 - _t656 = self.pretty_value_bindings(opt_val99) + assert field97 is not None + opt_val98 = field97 + _t656 = self.pretty_value_bindings(opt_val98) _t655 = _t656 else: _t655 = None @@ -1331,14 +1285,14 @@ def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: def _t657(_dollar_dollar): return (_dollar_dollar.var.name, _dollar_dollar.type,) _t658 = _t657(msg) - fields100 = _t658 - assert fields100 is not None - unwrapped_fields101 = fields100 - field102 = unwrapped_fields101[0] - self.write(field102) + fields99 = _t658 + assert fields99 is not None + unwrapped_fields100 = fields99 + field101 = unwrapped_fields100[0] + self.write(field101) self.write('::') - field103 = unwrapped_fields101[1] - _t659 = self.pretty_type(field103) + field102 = unwrapped_fields100[1] + _t659 = self.pretty_type(field102) return _t659 def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: @@ -1350,10 +1304,10 @@ def _t660(_dollar_dollar): _t661 = None return _t661 _t662 = _t660(msg) - deconstruct_result114 = _t662 + deconstruct_result113 = _t662 - if deconstruct_result114 is not None: - _t664 = self.pretty_unspecified_type(deconstruct_result114) + if deconstruct_result113 is not None: + _t664 = self.pretty_unspecified_type(deconstruct_result113) _t663 = _t664 else: def _t665(_dollar_dollar): @@ -1364,10 +1318,10 @@ def _t665(_dollar_dollar): _t666 = None return _t666 _t667 = _t665(msg) - deconstruct_result113 = _t667 + deconstruct_result112 = _t667 - if deconstruct_result113 is not None: - _t669 = self.pretty_string_type(deconstruct_result113) + if deconstruct_result112 is not None: + _t669 = self.pretty_string_type(deconstruct_result112) _t668 = _t669 else: def _t670(_dollar_dollar): @@ -1378,10 +1332,10 @@ def _t670(_dollar_dollar): _t671 = None return _t671 _t672 = _t670(msg) - deconstruct_result112 = _t672 + deconstruct_result111 = _t672 - if deconstruct_result112 is not None: - _t674 = self.pretty_int_type(deconstruct_result112) + if deconstruct_result111 is not None: + _t674 = self.pretty_int_type(deconstruct_result111) _t673 = _t674 else: def _t675(_dollar_dollar): @@ -1392,10 +1346,10 @@ def _t675(_dollar_dollar): _t676 = None return _t676 _t677 = _t675(msg) - deconstruct_result111 = _t677 + deconstruct_result110 = _t677 - if deconstruct_result111 is not None: - _t679 = self.pretty_float_type(deconstruct_result111) + if deconstruct_result110 is not None: + _t679 = self.pretty_float_type(deconstruct_result110) _t678 = _t679 else: def _t680(_dollar_dollar): @@ -1406,10 +1360,10 @@ def _t680(_dollar_dollar): _t681 = None return _t681 _t682 = _t680(msg) - deconstruct_result110 = _t682 + deconstruct_result109 = _t682 - if deconstruct_result110 is not None: - _t684 = self.pretty_uint128_type(deconstruct_result110) + if deconstruct_result109 is not None: + _t684 = self.pretty_uint128_type(deconstruct_result109) _t683 = _t684 else: def _t685(_dollar_dollar): @@ -1420,10 +1374,10 @@ def _t685(_dollar_dollar): _t686 = None return _t686 _t687 = _t685(msg) - deconstruct_result109 = _t687 + deconstruct_result108 = _t687 - if deconstruct_result109 is not None: - _t689 = self.pretty_int128_type(deconstruct_result109) + if deconstruct_result108 is not None: + _t689 = self.pretty_int128_type(deconstruct_result108) _t688 = _t689 else: def _t690(_dollar_dollar): @@ -1434,10 +1388,10 @@ def _t690(_dollar_dollar): _t691 = None return _t691 _t692 = _t690(msg) - deconstruct_result108 = _t692 + deconstruct_result107 = _t692 - if deconstruct_result108 is not None: - _t694 = self.pretty_date_type(deconstruct_result108) + if deconstruct_result107 is not None: + _t694 = self.pretty_date_type(deconstruct_result107) _t693 = _t694 else: def _t695(_dollar_dollar): @@ -1448,10 +1402,10 @@ def _t695(_dollar_dollar): _t696 = None return _t696 _t697 = _t695(msg) - deconstruct_result107 = _t697 + deconstruct_result106 = _t697 - if deconstruct_result107 is not None: - _t699 = self.pretty_datetime_type(deconstruct_result107) + if deconstruct_result106 is not None: + _t699 = self.pretty_datetime_type(deconstruct_result106) _t698 = _t699 else: def _t700(_dollar_dollar): @@ -1462,10 +1416,10 @@ def _t700(_dollar_dollar): _t701 = None return _t701 _t702 = _t700(msg) - deconstruct_result106 = _t702 + deconstruct_result105 = _t702 - if deconstruct_result106 is not None: - _t704 = self.pretty_missing_type(deconstruct_result106) + if deconstruct_result105 is not None: + _t704 = self.pretty_missing_type(deconstruct_result105) _t703 = _t704 else: def _t705(_dollar_dollar): @@ -1476,10 +1430,10 @@ def _t705(_dollar_dollar): _t706 = None return _t706 _t707 = _t705(msg) - deconstruct_result105 = _t707 + deconstruct_result104 = _t707 - if deconstruct_result105 is not None: - _t709 = self.pretty_decimal_type(deconstruct_result105) + if deconstruct_result104 is not None: + _t709 = self.pretty_decimal_type(deconstruct_result104) _t708 = _t709 else: def _t710(_dollar_dollar): @@ -1490,10 +1444,10 @@ def _t710(_dollar_dollar): _t711 = None return _t711 _t712 = _t710(msg) - deconstruct_result104 = _t712 + deconstruct_result103 = _t712 - if deconstruct_result104 is not None: - _t714 = self.pretty_boolean_type(deconstruct_result104) + if deconstruct_result103 is not None: + _t714 = self.pretty_boolean_type(deconstruct_result103) _t713 = _t714 else: raise ParseError('No matching rule for type') @@ -1513,9 +1467,9 @@ def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Ne def _t715(_dollar_dollar): return _dollar_dollar _t716 = _t715(msg) - fields115 = _t716 - assert fields115 is not None - unwrapped_fields116 = fields115 + fields114 = _t716 + assert fields114 is not None + unwrapped_fields115 = fields114 self.write('UNKNOWN') return None @@ -1523,9 +1477,9 @@ def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: def _t717(_dollar_dollar): return _dollar_dollar _t718 = _t717(msg) - fields117 = _t718 - assert fields117 is not None - unwrapped_fields118 = fields117 + fields116 = _t718 + assert fields116 is not None + unwrapped_fields117 = fields116 self.write('STRING') return None @@ -1533,9 +1487,9 @@ def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: def _t719(_dollar_dollar): return _dollar_dollar _t720 = _t719(msg) - fields119 = _t720 - assert fields119 is not None - unwrapped_fields120 = fields119 + fields118 = _t720 + assert fields118 is not None + unwrapped_fields119 = fields118 self.write('INT') return None @@ -1543,9 +1497,9 @@ def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: def _t721(_dollar_dollar): return _dollar_dollar _t722 = _t721(msg) - fields121 = _t722 - assert fields121 is not None - unwrapped_fields122 = fields121 + fields120 = _t722 + assert fields120 is not None + unwrapped_fields121 = fields120 self.write('FLOAT') return None @@ -1553,9 +1507,9 @@ def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: def _t723(_dollar_dollar): return _dollar_dollar _t724 = _t723(msg) - fields123 = _t724 - assert fields123 is not None - unwrapped_fields124 = fields123 + fields122 = _t724 + assert fields122 is not None + unwrapped_fields123 = fields122 self.write('UINT128') return None @@ -1563,9 +1517,9 @@ def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: def _t725(_dollar_dollar): return _dollar_dollar _t726 = _t725(msg) - fields125 = _t726 - assert fields125 is not None - unwrapped_fields126 = fields125 + fields124 = _t726 + assert fields124 is not None + unwrapped_fields125 = fields124 self.write('INT128') return None @@ -1573,9 +1527,9 @@ def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: def _t727(_dollar_dollar): return _dollar_dollar _t728 = _t727(msg) - fields127 = _t728 - assert fields127 is not None - unwrapped_fields128 = fields127 + fields126 = _t728 + assert fields126 is not None + unwrapped_fields127 = fields126 self.write('DATE') return None @@ -1583,9 +1537,9 @@ def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: def _t729(_dollar_dollar): return _dollar_dollar _t730 = _t729(msg) - fields129 = _t730 - assert fields129 is not None - unwrapped_fields130 = fields129 + fields128 = _t730 + assert fields128 is not None + unwrapped_fields129 = fields128 self.write('DATETIME') return None @@ -1593,9 +1547,9 @@ def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: def _t731(_dollar_dollar): return _dollar_dollar _t732 = _t731(msg) - fields131 = _t732 - assert fields131 is not None - unwrapped_fields132 = fields131 + fields130 = _t732 + assert fields130 is not None + unwrapped_fields131 = fields130 self.write('MISSING') return None @@ -1603,18 +1557,18 @@ def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: def _t733(_dollar_dollar): return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) _t734 = _t733(msg) - fields133 = _t734 - assert fields133 is not None - unwrapped_fields134 = fields133 + fields132 = _t734 + assert fields132 is not None + unwrapped_fields133 = fields132 self.write('(') self.write('DECIMAL') self.indent() self.newline() - field135 = unwrapped_fields134[0] - self.write(str(field135)) + field134 = unwrapped_fields133[0] + self.write(str(field134)) self.newline() - field136 = unwrapped_fields134[1] - self.write(str(field136)) + field135 = unwrapped_fields133[1] + self.write(str(field135)) self.dedent() self.write(')') return None @@ -1623,9 +1577,9 @@ def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: def _t735(_dollar_dollar): return _dollar_dollar _t736 = _t735(msg) - fields137 = _t736 - assert fields137 is not None - unwrapped_fields138 = fields137 + fields136 = _t736 + assert fields136 is not None + unwrapped_fields137 = fields136 self.write('BOOLEAN') return None @@ -1633,20 +1587,20 @@ def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never] def _t737(_dollar_dollar): return _dollar_dollar _t738 = _t737(msg) - fields139 = _t738 - assert fields139 is not None - unwrapped_fields140 = fields139 + fields138 = _t738 + assert fields138 is not None + unwrapped_fields139 = fields138 self.write('|') - if not len(unwrapped_fields140) == 0: + if not len(unwrapped_fields139) == 0: self.write(' ') - for i142, elem141 in enumerate(unwrapped_fields140): + for i141, elem140 in enumerate(unwrapped_fields139): - if (i142 > 0): + if (i141 > 0): self.newline() _t739 = None else: _t739 = None - _t740 = self.pretty_binding(elem141) + _t740 = self.pretty_binding(elem140) return None def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: @@ -1658,10 +1612,10 @@ def _t741(_dollar_dollar): _t742 = None return _t742 _t743 = _t741(msg) - deconstruct_result155 = _t743 + deconstruct_result154 = _t743 - if deconstruct_result155 is not None: - _t745 = self.pretty_true(deconstruct_result155) + if deconstruct_result154 is not None: + _t745 = self.pretty_true(deconstruct_result154) _t744 = _t745 else: def _t746(_dollar_dollar): @@ -1672,10 +1626,10 @@ def _t746(_dollar_dollar): _t747 = None return _t747 _t748 = _t746(msg) - deconstruct_result154 = _t748 + deconstruct_result153 = _t748 - if deconstruct_result154 is not None: - _t750 = self.pretty_false(deconstruct_result154) + if deconstruct_result153 is not None: + _t750 = self.pretty_false(deconstruct_result153) _t749 = _t750 else: def _t751(_dollar_dollar): @@ -1686,10 +1640,10 @@ def _t751(_dollar_dollar): _t752 = None return _t752 _t753 = _t751(msg) - deconstruct_result153 = _t753 + deconstruct_result152 = _t753 - if deconstruct_result153 is not None: - _t755 = self.pretty_exists(deconstruct_result153) + if deconstruct_result152 is not None: + _t755 = self.pretty_exists(deconstruct_result152) _t754 = _t755 else: def _t756(_dollar_dollar): @@ -1700,10 +1654,10 @@ def _t756(_dollar_dollar): _t757 = None return _t757 _t758 = _t756(msg) - deconstruct_result152 = _t758 + deconstruct_result151 = _t758 - if deconstruct_result152 is not None: - _t760 = self.pretty_reduce(deconstruct_result152) + if deconstruct_result151 is not None: + _t760 = self.pretty_reduce(deconstruct_result151) _t759 = _t760 else: def _t761(_dollar_dollar): @@ -1714,10 +1668,10 @@ def _t761(_dollar_dollar): _t762 = None return _t762 _t763 = _t761(msg) - deconstruct_result151 = _t763 + deconstruct_result150 = _t763 - if deconstruct_result151 is not None: - _t765 = self.pretty_conjunction(deconstruct_result151) + if deconstruct_result150 is not None: + _t765 = self.pretty_conjunction(deconstruct_result150) _t764 = _t765 else: def _t766(_dollar_dollar): @@ -1728,10 +1682,10 @@ def _t766(_dollar_dollar): _t767 = None return _t767 _t768 = _t766(msg) - deconstruct_result150 = _t768 + deconstruct_result149 = _t768 - if deconstruct_result150 is not None: - _t770 = self.pretty_disjunction(deconstruct_result150) + if deconstruct_result149 is not None: + _t770 = self.pretty_disjunction(deconstruct_result149) _t769 = _t770 else: def _t771(_dollar_dollar): @@ -1742,10 +1696,10 @@ def _t771(_dollar_dollar): _t772 = None return _t772 _t773 = _t771(msg) - deconstruct_result149 = _t773 + deconstruct_result148 = _t773 - if deconstruct_result149 is not None: - _t775 = self.pretty_not(deconstruct_result149) + if deconstruct_result148 is not None: + _t775 = self.pretty_not(deconstruct_result148) _t774 = _t775 else: def _t776(_dollar_dollar): @@ -1756,10 +1710,10 @@ def _t776(_dollar_dollar): _t777 = None return _t777 _t778 = _t776(msg) - deconstruct_result148 = _t778 + deconstruct_result147 = _t778 - if deconstruct_result148 is not None: - _t780 = self.pretty_ffi(deconstruct_result148) + if deconstruct_result147 is not None: + _t780 = self.pretty_ffi(deconstruct_result147) _t779 = _t780 else: def _t781(_dollar_dollar): @@ -1770,10 +1724,10 @@ def _t781(_dollar_dollar): _t782 = None return _t782 _t783 = _t781(msg) - deconstruct_result147 = _t783 + deconstruct_result146 = _t783 - if deconstruct_result147 is not None: - _t785 = self.pretty_atom(deconstruct_result147) + if deconstruct_result146 is not None: + _t785 = self.pretty_atom(deconstruct_result146) _t784 = _t785 else: def _t786(_dollar_dollar): @@ -1784,10 +1738,10 @@ def _t786(_dollar_dollar): _t787 = None return _t787 _t788 = _t786(msg) - deconstruct_result146 = _t788 + deconstruct_result145 = _t788 - if deconstruct_result146 is not None: - _t790 = self.pretty_pragma(deconstruct_result146) + if deconstruct_result145 is not None: + _t790 = self.pretty_pragma(deconstruct_result145) _t789 = _t790 else: def _t791(_dollar_dollar): @@ -1798,10 +1752,10 @@ def _t791(_dollar_dollar): _t792 = None return _t792 _t793 = _t791(msg) - deconstruct_result145 = _t793 + deconstruct_result144 = _t793 - if deconstruct_result145 is not None: - _t795 = self.pretty_primitive(deconstruct_result145) + if deconstruct_result144 is not None: + _t795 = self.pretty_primitive(deconstruct_result144) _t794 = _t795 else: def _t796(_dollar_dollar): @@ -1812,10 +1766,10 @@ def _t796(_dollar_dollar): _t797 = None return _t797 _t798 = _t796(msg) - deconstruct_result144 = _t798 + deconstruct_result143 = _t798 - if deconstruct_result144 is not None: - _t800 = self.pretty_rel_atom(deconstruct_result144) + if deconstruct_result143 is not None: + _t800 = self.pretty_rel_atom(deconstruct_result143) _t799 = _t800 else: def _t801(_dollar_dollar): @@ -1826,10 +1780,10 @@ def _t801(_dollar_dollar): _t802 = None return _t802 _t803 = _t801(msg) - deconstruct_result143 = _t803 + deconstruct_result142 = _t803 - if deconstruct_result143 is not None: - _t805 = self.pretty_cast(deconstruct_result143) + if deconstruct_result142 is not None: + _t805 = self.pretty_cast(deconstruct_result142) _t804 = _t805 else: raise ParseError('No matching rule for formula') @@ -1851,9 +1805,9 @@ def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: def _t806(_dollar_dollar): return _dollar_dollar _t807 = _t806(msg) - fields156 = _t807 - assert fields156 is not None - unwrapped_fields157 = fields156 + fields155 = _t807 + assert fields155 is not None + unwrapped_fields156 = fields155 self.write('(') self.write('true') self.write(')') @@ -1863,9 +1817,9 @@ def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: def _t808(_dollar_dollar): return _dollar_dollar _t809 = _t808(msg) - fields158 = _t809 - assert fields158 is not None - unwrapped_fields159 = fields158 + fields157 = _t809 + assert fields157 is not None + unwrapped_fields158 = fields157 self.write('(') self.write('false') self.write(')') @@ -1876,18 +1830,18 @@ def _t810(_dollar_dollar): _t811 = self.deconstruct_bindings(_dollar_dollar.body) return (_t811, _dollar_dollar.body.value,) _t812 = _t810(msg) - fields160 = _t812 - assert fields160 is not None - unwrapped_fields161 = fields160 + fields159 = _t812 + assert fields159 is not None + unwrapped_fields160 = fields159 self.write('(') self.write('exists') self.indent() self.newline() - field162 = unwrapped_fields161[0] - _t813 = self.pretty_bindings(field162) + field161 = unwrapped_fields160[0] + _t813 = self.pretty_bindings(field161) self.newline() - field163 = unwrapped_fields161[1] - _t814 = self.pretty_formula(field163) + field162 = unwrapped_fields160[1] + _t814 = self.pretty_formula(field162) self.dedent() self.write(')') return None @@ -1896,21 +1850,21 @@ def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: def _t815(_dollar_dollar): return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) _t816 = _t815(msg) - fields164 = _t816 - assert fields164 is not None - unwrapped_fields165 = fields164 + fields163 = _t816 + assert fields163 is not None + unwrapped_fields164 = fields163 self.write('(') self.write('reduce') self.indent() self.newline() - field166 = unwrapped_fields165[0] - _t817 = self.pretty_abstraction(field166) + field165 = unwrapped_fields164[0] + _t817 = self.pretty_abstraction(field165) self.newline() - field167 = unwrapped_fields165[1] - _t818 = self.pretty_abstraction(field167) + field166 = unwrapped_fields164[1] + _t818 = self.pretty_abstraction(field166) self.newline() - field168 = unwrapped_fields165[2] - _t819 = self.pretty_terms(field168) + field167 = unwrapped_fields164[2] + _t819 = self.pretty_terms(field167) self.dedent() self.write(')') return None @@ -1919,22 +1873,22 @@ def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: def _t820(_dollar_dollar): return _dollar_dollar _t821 = _t820(msg) - fields169 = _t821 - assert fields169 is not None - unwrapped_fields170 = fields169 + fields168 = _t821 + assert fields168 is not None + unwrapped_fields169 = fields168 self.write('(') self.write('terms') self.indent() - if not len(unwrapped_fields170) == 0: + if not len(unwrapped_fields169) == 0: self.newline() - for i172, elem171 in enumerate(unwrapped_fields170): + for i171, elem170 in enumerate(unwrapped_fields169): - if (i172 > 0): + if (i171 > 0): self.newline() _t822 = None else: _t822 = None - _t823 = self.pretty_term(elem171) + _t823 = self.pretty_term(elem170) self.dedent() self.write(')') return None @@ -1948,10 +1902,10 @@ def _t824(_dollar_dollar): _t825 = None return _t825 _t826 = _t824(msg) - deconstruct_result174 = _t826 + deconstruct_result173 = _t826 - if deconstruct_result174 is not None: - _t828 = self.pretty_var(deconstruct_result174) + if deconstruct_result173 is not None: + _t828 = self.pretty_var(deconstruct_result173) _t827 = _t828 else: def _t829(_dollar_dollar): @@ -1962,10 +1916,10 @@ def _t829(_dollar_dollar): _t830 = None return _t830 _t831 = _t829(msg) - deconstruct_result173 = _t831 + deconstruct_result172 = _t831 - if deconstruct_result173 is not None: - _t833 = self.pretty_constant(deconstruct_result173) + if deconstruct_result172 is not None: + _t833 = self.pretty_constant(deconstruct_result172) _t832 = _t833 else: raise ParseError('No matching rule for term') @@ -1976,42 +1930,42 @@ def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: def _t834(_dollar_dollar): return _dollar_dollar.name _t835 = _t834(msg) - fields175 = _t835 - assert fields175 is not None - unwrapped_fields176 = fields175 - self.write(unwrapped_fields176) + fields174 = _t835 + assert fields174 is not None + unwrapped_fields175 = fields174 + self.write(unwrapped_fields175) return None def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: def _t836(_dollar_dollar): return _dollar_dollar _t837 = _t836(msg) - fields177 = _t837 - assert fields177 is not None - unwrapped_fields178 = fields177 - _t838 = self.pretty_value(unwrapped_fields178) + fields176 = _t837 + assert fields176 is not None + unwrapped_fields177 = fields176 + _t838 = self.pretty_value(unwrapped_fields177) return _t838 def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: def _t839(_dollar_dollar): return _dollar_dollar.args _t840 = _t839(msg) - fields179 = _t840 - assert fields179 is not None - unwrapped_fields180 = fields179 + fields178 = _t840 + assert fields178 is not None + unwrapped_fields179 = fields178 self.write('(') self.write('and') self.indent() - if not len(unwrapped_fields180) == 0: + if not len(unwrapped_fields179) == 0: self.newline() - for i182, elem181 in enumerate(unwrapped_fields180): + for i181, elem180 in enumerate(unwrapped_fields179): - if (i182 > 0): + if (i181 > 0): self.newline() _t841 = None else: _t841 = None - _t842 = self.pretty_formula(elem181) + _t842 = self.pretty_formula(elem180) self.dedent() self.write(')') return None @@ -2020,22 +1974,22 @@ def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: def _t843(_dollar_dollar): return _dollar_dollar.args _t844 = _t843(msg) - fields183 = _t844 - assert fields183 is not None - unwrapped_fields184 = fields183 + fields182 = _t844 + assert fields182 is not None + unwrapped_fields183 = fields182 self.write('(') self.write('or') self.indent() - if not len(unwrapped_fields184) == 0: + if not len(unwrapped_fields183) == 0: self.newline() - for i186, elem185 in enumerate(unwrapped_fields184): + for i185, elem184 in enumerate(unwrapped_fields183): - if (i186 > 0): + if (i185 > 0): self.newline() _t845 = None else: _t845 = None - _t846 = self.pretty_formula(elem185) + _t846 = self.pretty_formula(elem184) self.dedent() self.write(')') return None @@ -2044,14 +1998,14 @@ def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: def _t847(_dollar_dollar): return _dollar_dollar.arg _t848 = _t847(msg) - fields187 = _t848 - assert fields187 is not None - unwrapped_fields188 = fields187 + fields186 = _t848 + assert fields186 is not None + unwrapped_fields187 = fields186 self.write('(') self.write('not') self.indent() self.newline() - _t849 = self.pretty_formula(unwrapped_fields188) + _t849 = self.pretty_formula(unwrapped_fields187) self.dedent() self.write(')') return None @@ -2060,21 +2014,21 @@ def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: def _t850(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) _t851 = _t850(msg) - fields189 = _t851 - assert fields189 is not None - unwrapped_fields190 = fields189 + fields188 = _t851 + assert fields188 is not None + unwrapped_fields189 = fields188 self.write('(') self.write('ffi') self.indent() self.newline() - field191 = unwrapped_fields190[0] - _t852 = self.pretty_name(field191) + field190 = unwrapped_fields189[0] + _t852 = self.pretty_name(field190) self.newline() - field192 = unwrapped_fields190[1] - _t853 = self.pretty_ffi_args(field192) + field191 = unwrapped_fields189[1] + _t853 = self.pretty_ffi_args(field191) self.newline() - field193 = unwrapped_fields190[2] - _t854 = self.pretty_terms(field193) + field192 = unwrapped_fields189[2] + _t854 = self.pretty_terms(field192) self.dedent() self.write(')') return None @@ -2083,33 +2037,33 @@ def pretty_name(self, msg: str) -> Optional[Never]: def _t855(_dollar_dollar): return _dollar_dollar _t856 = _t855(msg) - fields194 = _t856 - assert fields194 is not None - unwrapped_fields195 = fields194 + fields193 = _t856 + assert fields193 is not None + unwrapped_fields194 = fields193 self.write(':') - self.write(unwrapped_fields195) + self.write(unwrapped_fields194) return None def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: def _t857(_dollar_dollar): return _dollar_dollar _t858 = _t857(msg) - fields196 = _t858 - assert fields196 is not None - unwrapped_fields197 = fields196 + fields195 = _t858 + assert fields195 is not None + unwrapped_fields196 = fields195 self.write('(') self.write('args') self.indent() - if not len(unwrapped_fields197) == 0: + if not len(unwrapped_fields196) == 0: self.newline() - for i199, elem198 in enumerate(unwrapped_fields197): + for i198, elem197 in enumerate(unwrapped_fields196): - if (i199 > 0): + if (i198 > 0): self.newline() _t859 = None else: _t859 = None - _t860 = self.pretty_abstraction(elem198) + _t860 = self.pretty_abstraction(elem197) self.dedent() self.write(')') return None @@ -2118,26 +2072,26 @@ def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: def _t861(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t862 = _t861(msg) - fields200 = _t862 - assert fields200 is not None - unwrapped_fields201 = fields200 + fields199 = _t862 + assert fields199 is not None + unwrapped_fields200 = fields199 self.write('(') self.write('atom') self.indent() self.newline() - field202 = unwrapped_fields201[0] - _t863 = self.pretty_relation_id(field202) - field203 = unwrapped_fields201[1] - if not len(field203) == 0: + field201 = unwrapped_fields200[0] + _t863 = self.pretty_relation_id(field201) + field202 = unwrapped_fields200[1] + if not len(field202) == 0: self.newline() - for i205, elem204 in enumerate(field203): + for i204, elem203 in enumerate(field202): - if (i205 > 0): + if (i204 > 0): self.newline() _t864 = None else: _t864 = None - _t865 = self.pretty_term(elem204) + _t865 = self.pretty_term(elem203) self.dedent() self.write(')') return None @@ -2146,26 +2100,26 @@ def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: def _t866(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t867 = _t866(msg) - fields206 = _t867 - assert fields206 is not None - unwrapped_fields207 = fields206 + fields205 = _t867 + assert fields205 is not None + unwrapped_fields206 = fields205 self.write('(') self.write('pragma') self.indent() self.newline() - field208 = unwrapped_fields207[0] - _t868 = self.pretty_name(field208) - field209 = unwrapped_fields207[1] - if not len(field209) == 0: + field207 = unwrapped_fields206[0] + _t868 = self.pretty_name(field207) + field208 = unwrapped_fields206[1] + if not len(field208) == 0: self.newline() - for i211, elem210 in enumerate(field209): + for i210, elem209 in enumerate(field208): - if (i211 > 0): + if (i210 > 0): self.newline() _t869 = None else: _t869 = None - _t870 = self.pretty_term(elem210) + _t870 = self.pretty_term(elem209) self.dedent() self.write(')') return None @@ -2179,9 +2133,9 @@ def _t871(_dollar_dollar): _t872 = None return _t872 _t873 = _t871(msg) - guard_result226 = _t873 + guard_result225 = _t873 - if guard_result226 is not None: + if guard_result225 is not None: _t875 = self.pretty_eq(msg) _t874 = _t875 else: @@ -2193,9 +2147,9 @@ def _t876(_dollar_dollar): _t877 = None return _t877 _t878 = _t876(msg) - guard_result225 = _t878 + guard_result224 = _t878 - if guard_result225 is not None: + if guard_result224 is not None: _t880 = self.pretty_lt(msg) _t879 = _t880 else: @@ -2207,9 +2161,9 @@ def _t881(_dollar_dollar): _t882 = None return _t882 _t883 = _t881(msg) - guard_result224 = _t883 + guard_result223 = _t883 - if guard_result224 is not None: + if guard_result223 is not None: _t885 = self.pretty_lt_eq(msg) _t884 = _t885 else: @@ -2221,9 +2175,9 @@ def _t886(_dollar_dollar): _t887 = None return _t887 _t888 = _t886(msg) - guard_result223 = _t888 + guard_result222 = _t888 - if guard_result223 is not None: + if guard_result222 is not None: _t890 = self.pretty_gt(msg) _t889 = _t890 else: @@ -2235,9 +2189,9 @@ def _t891(_dollar_dollar): _t892 = None return _t892 _t893 = _t891(msg) - guard_result222 = _t893 + guard_result221 = _t893 - if guard_result222 is not None: + if guard_result221 is not None: _t895 = self.pretty_gt_eq(msg) _t894 = _t895 else: @@ -2249,9 +2203,9 @@ def _t896(_dollar_dollar): _t897 = None return _t897 _t898 = _t896(msg) - guard_result221 = _t898 + guard_result220 = _t898 - if guard_result221 is not None: + if guard_result220 is not None: _t900 = self.pretty_add(msg) _t899 = _t900 else: @@ -2263,9 +2217,9 @@ def _t901(_dollar_dollar): _t902 = None return _t902 _t903 = _t901(msg) - guard_result220 = _t903 + guard_result219 = _t903 - if guard_result220 is not None: + if guard_result219 is not None: _t905 = self.pretty_minus(msg) _t904 = _t905 else: @@ -2277,9 +2231,9 @@ def _t906(_dollar_dollar): _t907 = None return _t907 _t908 = _t906(msg) - guard_result219 = _t908 + guard_result218 = _t908 - if guard_result219 is not None: + if guard_result218 is not None: _t910 = self.pretty_multiply(msg) _t909 = _t910 else: @@ -2291,35 +2245,35 @@ def _t911(_dollar_dollar): _t912 = None return _t912 _t913 = _t911(msg) - guard_result218 = _t913 + guard_result217 = _t913 - if guard_result218 is not None: + if guard_result217 is not None: _t915 = self.pretty_divide(msg) _t914 = _t915 else: def _t916(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t917 = _t916(msg) - fields212 = _t917 - assert fields212 is not None - unwrapped_fields213 = fields212 + fields211 = _t917 + assert fields211 is not None + unwrapped_fields212 = fields211 self.write('(') self.write('primitive') self.indent() self.newline() - field214 = unwrapped_fields213[0] - _t918 = self.pretty_name(field214) - field215 = unwrapped_fields213[1] - if not len(field215) == 0: + field213 = unwrapped_fields212[0] + _t918 = self.pretty_name(field213) + field214 = unwrapped_fields212[1] + if not len(field214) == 0: self.newline() - for i217, elem216 in enumerate(field215): + for i216, elem215 in enumerate(field214): - if (i217 > 0): + if (i216 > 0): self.newline() _t919 = None else: _t919 = None - _t920 = self.pretty_rel_term(elem216) + _t920 = self.pretty_rel_term(elem215) self.dedent() self.write(')') _t914 = None @@ -2342,18 +2296,18 @@ def _t921(_dollar_dollar): _t922 = None return _t922 _t923 = _t921(msg) - fields227 = _t923 - assert fields227 is not None - unwrapped_fields228 = fields227 + fields226 = _t923 + assert fields226 is not None + unwrapped_fields227 = fields226 self.write('(') self.write('=') self.indent() self.newline() - field229 = unwrapped_fields228[0] - _t924 = self.pretty_term(field229) + field228 = unwrapped_fields227[0] + _t924 = self.pretty_term(field228) self.newline() - field230 = unwrapped_fields228[1] - _t925 = self.pretty_term(field230) + field229 = unwrapped_fields227[1] + _t925 = self.pretty_term(field229) self.dedent() self.write(')') return None @@ -2367,18 +2321,18 @@ def _t926(_dollar_dollar): _t927 = None return _t927 _t928 = _t926(msg) - fields231 = _t928 - assert fields231 is not None - unwrapped_fields232 = fields231 + fields230 = _t928 + assert fields230 is not None + unwrapped_fields231 = fields230 self.write('(') self.write('<') self.indent() self.newline() - field233 = unwrapped_fields232[0] - _t929 = self.pretty_term(field233) + field232 = unwrapped_fields231[0] + _t929 = self.pretty_term(field232) self.newline() - field234 = unwrapped_fields232[1] - _t930 = self.pretty_term(field234) + field233 = unwrapped_fields231[1] + _t930 = self.pretty_term(field233) self.dedent() self.write(')') return None @@ -2392,18 +2346,18 @@ def _t931(_dollar_dollar): _t932 = None return _t932 _t933 = _t931(msg) - fields235 = _t933 - assert fields235 is not None - unwrapped_fields236 = fields235 + fields234 = _t933 + assert fields234 is not None + unwrapped_fields235 = fields234 self.write('(') self.write('<=') self.indent() self.newline() - field237 = unwrapped_fields236[0] - _t934 = self.pretty_term(field237) + field236 = unwrapped_fields235[0] + _t934 = self.pretty_term(field236) self.newline() - field238 = unwrapped_fields236[1] - _t935 = self.pretty_term(field238) + field237 = unwrapped_fields235[1] + _t935 = self.pretty_term(field237) self.dedent() self.write(')') return None @@ -2417,18 +2371,18 @@ def _t936(_dollar_dollar): _t937 = None return _t937 _t938 = _t936(msg) - fields239 = _t938 - assert fields239 is not None - unwrapped_fields240 = fields239 + fields238 = _t938 + assert fields238 is not None + unwrapped_fields239 = fields238 self.write('(') self.write('>') self.indent() self.newline() - field241 = unwrapped_fields240[0] - _t939 = self.pretty_term(field241) + field240 = unwrapped_fields239[0] + _t939 = self.pretty_term(field240) self.newline() - field242 = unwrapped_fields240[1] - _t940 = self.pretty_term(field242) + field241 = unwrapped_fields239[1] + _t940 = self.pretty_term(field241) self.dedent() self.write(')') return None @@ -2442,18 +2396,18 @@ def _t941(_dollar_dollar): _t942 = None return _t942 _t943 = _t941(msg) - fields243 = _t943 - assert fields243 is not None - unwrapped_fields244 = fields243 + fields242 = _t943 + assert fields242 is not None + unwrapped_fields243 = fields242 self.write('(') self.write('>=') self.indent() self.newline() - field245 = unwrapped_fields244[0] - _t944 = self.pretty_term(field245) + field244 = unwrapped_fields243[0] + _t944 = self.pretty_term(field244) self.newline() - field246 = unwrapped_fields244[1] - _t945 = self.pretty_term(field246) + field245 = unwrapped_fields243[1] + _t945 = self.pretty_term(field245) self.dedent() self.write(')') return None @@ -2467,21 +2421,21 @@ def _t946(_dollar_dollar): _t947 = None return _t947 _t948 = _t946(msg) - fields247 = _t948 - assert fields247 is not None - unwrapped_fields248 = fields247 + fields246 = _t948 + assert fields246 is not None + unwrapped_fields247 = fields246 self.write('(') self.write('+') self.indent() self.newline() - field249 = unwrapped_fields248[0] - _t949 = self.pretty_term(field249) + field248 = unwrapped_fields247[0] + _t949 = self.pretty_term(field248) self.newline() - field250 = unwrapped_fields248[1] - _t950 = self.pretty_term(field250) + field249 = unwrapped_fields247[1] + _t950 = self.pretty_term(field249) self.newline() - field251 = unwrapped_fields248[2] - _t951 = self.pretty_term(field251) + field250 = unwrapped_fields247[2] + _t951 = self.pretty_term(field250) self.dedent() self.write(')') return None @@ -2495,21 +2449,21 @@ def _t952(_dollar_dollar): _t953 = None return _t953 _t954 = _t952(msg) - fields252 = _t954 - assert fields252 is not None - unwrapped_fields253 = fields252 + fields251 = _t954 + assert fields251 is not None + unwrapped_fields252 = fields251 self.write('(') self.write('-') self.indent() self.newline() - field254 = unwrapped_fields253[0] - _t955 = self.pretty_term(field254) + field253 = unwrapped_fields252[0] + _t955 = self.pretty_term(field253) self.newline() - field255 = unwrapped_fields253[1] - _t956 = self.pretty_term(field255) + field254 = unwrapped_fields252[1] + _t956 = self.pretty_term(field254) self.newline() - field256 = unwrapped_fields253[2] - _t957 = self.pretty_term(field256) + field255 = unwrapped_fields252[2] + _t957 = self.pretty_term(field255) self.dedent() self.write(')') return None @@ -2523,21 +2477,21 @@ def _t958(_dollar_dollar): _t959 = None return _t959 _t960 = _t958(msg) - fields257 = _t960 - assert fields257 is not None - unwrapped_fields258 = fields257 + fields256 = _t960 + assert fields256 is not None + unwrapped_fields257 = fields256 self.write('(') self.write('*') self.indent() self.newline() - field259 = unwrapped_fields258[0] - _t961 = self.pretty_term(field259) + field258 = unwrapped_fields257[0] + _t961 = self.pretty_term(field258) self.newline() - field260 = unwrapped_fields258[1] - _t962 = self.pretty_term(field260) + field259 = unwrapped_fields257[1] + _t962 = self.pretty_term(field259) self.newline() - field261 = unwrapped_fields258[2] - _t963 = self.pretty_term(field261) + field260 = unwrapped_fields257[2] + _t963 = self.pretty_term(field260) self.dedent() self.write(')') return None @@ -2551,21 +2505,21 @@ def _t964(_dollar_dollar): _t965 = None return _t965 _t966 = _t964(msg) - fields262 = _t966 - assert fields262 is not None - unwrapped_fields263 = fields262 + fields261 = _t966 + assert fields261 is not None + unwrapped_fields262 = fields261 self.write('(') self.write('/') self.indent() self.newline() - field264 = unwrapped_fields263[0] - _t967 = self.pretty_term(field264) + field263 = unwrapped_fields262[0] + _t967 = self.pretty_term(field263) self.newline() - field265 = unwrapped_fields263[1] - _t968 = self.pretty_term(field265) + field264 = unwrapped_fields262[1] + _t968 = self.pretty_term(field264) self.newline() - field266 = unwrapped_fields263[2] - _t969 = self.pretty_term(field266) + field265 = unwrapped_fields262[2] + _t969 = self.pretty_term(field265) self.dedent() self.write(')') return None @@ -2579,10 +2533,10 @@ def _t970(_dollar_dollar): _t971 = None return _t971 _t972 = _t970(msg) - deconstruct_result268 = _t972 + deconstruct_result267 = _t972 - if deconstruct_result268 is not None: - _t974 = self.pretty_specialized_value(deconstruct_result268) + if deconstruct_result267 is not None: + _t974 = self.pretty_specialized_value(deconstruct_result267) _t973 = _t974 else: def _t975(_dollar_dollar): @@ -2593,10 +2547,10 @@ def _t975(_dollar_dollar): _t976 = None return _t976 _t977 = _t975(msg) - deconstruct_result267 = _t977 + deconstruct_result266 = _t977 - if deconstruct_result267 is not None: - _t979 = self.pretty_term(deconstruct_result267) + if deconstruct_result266 is not None: + _t979 = self.pretty_term(deconstruct_result266) _t978 = _t979 else: raise ParseError('No matching rule for rel_term') @@ -2607,37 +2561,37 @@ def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: def _t980(_dollar_dollar): return _dollar_dollar _t981 = _t980(msg) - fields269 = _t981 - assert fields269 is not None - unwrapped_fields270 = fields269 + fields268 = _t981 + assert fields268 is not None + unwrapped_fields269 = fields268 self.write('#') - _t982 = self.pretty_value(unwrapped_fields270) + _t982 = self.pretty_value(unwrapped_fields269) return _t982 def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: def _t983(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.terms,) _t984 = _t983(msg) - fields271 = _t984 - assert fields271 is not None - unwrapped_fields272 = fields271 + fields270 = _t984 + assert fields270 is not None + unwrapped_fields271 = fields270 self.write('(') self.write('relatom') self.indent() self.newline() - field273 = unwrapped_fields272[0] - _t985 = self.pretty_name(field273) - field274 = unwrapped_fields272[1] - if not len(field274) == 0: + field272 = unwrapped_fields271[0] + _t985 = self.pretty_name(field272) + field273 = unwrapped_fields271[1] + if not len(field273) == 0: self.newline() - for i276, elem275 in enumerate(field274): + for i275, elem274 in enumerate(field273): - if (i276 > 0): + if (i275 > 0): self.newline() _t986 = None else: _t986 = None - _t987 = self.pretty_rel_term(elem275) + _t987 = self.pretty_rel_term(elem274) self.dedent() self.write(')') return None @@ -2646,18 +2600,18 @@ def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: def _t988(_dollar_dollar): return (_dollar_dollar.input, _dollar_dollar.result,) _t989 = _t988(msg) - fields277 = _t989 - assert fields277 is not None - unwrapped_fields278 = fields277 + fields276 = _t989 + assert fields276 is not None + unwrapped_fields277 = fields276 self.write('(') self.write('cast') self.indent() self.newline() - field279 = unwrapped_fields278[0] - _t990 = self.pretty_term(field279) + field278 = unwrapped_fields277[0] + _t990 = self.pretty_term(field278) self.newline() - field280 = unwrapped_fields278[1] - _t991 = self.pretty_term(field280) + field279 = unwrapped_fields277[1] + _t991 = self.pretty_term(field279) self.dedent() self.write(')') return None @@ -2666,22 +2620,22 @@ def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: def _t992(_dollar_dollar): return _dollar_dollar _t993 = _t992(msg) - fields281 = _t993 - assert fields281 is not None - unwrapped_fields282 = fields281 + fields280 = _t993 + assert fields280 is not None + unwrapped_fields281 = fields280 self.write('(') self.write('attrs') self.indent() - if not len(unwrapped_fields282) == 0: + if not len(unwrapped_fields281) == 0: self.newline() - for i284, elem283 in enumerate(unwrapped_fields282): + for i283, elem282 in enumerate(unwrapped_fields281): - if (i284 > 0): + if (i283 > 0): self.newline() _t994 = None else: _t994 = None - _t995 = self.pretty_attribute(elem283) + _t995 = self.pretty_attribute(elem282) self.dedent() self.write(')') return None @@ -2690,26 +2644,26 @@ def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: def _t996(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.args,) _t997 = _t996(msg) - fields285 = _t997 - assert fields285 is not None - unwrapped_fields286 = fields285 + fields284 = _t997 + assert fields284 is not None + unwrapped_fields285 = fields284 self.write('(') self.write('attribute') self.indent() self.newline() - field287 = unwrapped_fields286[0] - _t998 = self.pretty_name(field287) - field288 = unwrapped_fields286[1] - if not len(field288) == 0: + field286 = unwrapped_fields285[0] + _t998 = self.pretty_name(field286) + field287 = unwrapped_fields285[1] + if not len(field287) == 0: self.newline() - for i290, elem289 in enumerate(field288): + for i289, elem288 in enumerate(field287): - if (i290 > 0): + if (i289 > 0): self.newline() _t999 = None else: _t999 = None - _t1000 = self.pretty_value(elem289) + _t1000 = self.pretty_value(elem288) self.dedent() self.write(')') return None @@ -2718,26 +2672,26 @@ def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: def _t1001(_dollar_dollar): return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) _t1002 = _t1001(msg) - fields291 = _t1002 - assert fields291 is not None - unwrapped_fields292 = fields291 + fields290 = _t1002 + assert fields290 is not None + unwrapped_fields291 = fields290 self.write('(') self.write('algorithm') self.indent() - field293 = unwrapped_fields292[0] - if not len(field293) == 0: + field292 = unwrapped_fields291[0] + if not len(field292) == 0: self.newline() - for i295, elem294 in enumerate(field293): + for i294, elem293 in enumerate(field292): - if (i295 > 0): + if (i294 > 0): self.newline() _t1003 = None else: _t1003 = None - _t1004 = self.pretty_relation_id(elem294) + _t1004 = self.pretty_relation_id(elem293) self.newline() - field296 = unwrapped_fields292[1] - _t1005 = self.pretty_script(field296) + field295 = unwrapped_fields291[1] + _t1005 = self.pretty_script(field295) self.dedent() self.write(')') return None @@ -2746,22 +2700,22 @@ def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: def _t1006(_dollar_dollar): return _dollar_dollar.constructs _t1007 = _t1006(msg) - fields297 = _t1007 - assert fields297 is not None - unwrapped_fields298 = fields297 + fields296 = _t1007 + assert fields296 is not None + unwrapped_fields297 = fields296 self.write('(') self.write('script') self.indent() - if not len(unwrapped_fields298) == 0: + if not len(unwrapped_fields297) == 0: self.newline() - for i300, elem299 in enumerate(unwrapped_fields298): + for i299, elem298 in enumerate(unwrapped_fields297): - if (i300 > 0): + if (i299 > 0): self.newline() _t1008 = None else: _t1008 = None - _t1009 = self.pretty_construct(elem299) + _t1009 = self.pretty_construct(elem298) self.dedent() self.write(')') return None @@ -2775,10 +2729,10 @@ def _t1010(_dollar_dollar): _t1011 = None return _t1011 _t1012 = _t1010(msg) - deconstruct_result302 = _t1012 + deconstruct_result301 = _t1012 - if deconstruct_result302 is not None: - _t1014 = self.pretty_loop(deconstruct_result302) + if deconstruct_result301 is not None: + _t1014 = self.pretty_loop(deconstruct_result301) _t1013 = _t1014 else: def _t1015(_dollar_dollar): @@ -2789,10 +2743,10 @@ def _t1015(_dollar_dollar): _t1016 = None return _t1016 _t1017 = _t1015(msg) - deconstruct_result301 = _t1017 + deconstruct_result300 = _t1017 - if deconstruct_result301 is not None: - _t1019 = self.pretty_instruction(deconstruct_result301) + if deconstruct_result300 is not None: + _t1019 = self.pretty_instruction(deconstruct_result300) _t1018 = _t1019 else: raise ParseError('No matching rule for construct') @@ -2803,18 +2757,18 @@ def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: def _t1020(_dollar_dollar): return (_dollar_dollar.init, _dollar_dollar.body,) _t1021 = _t1020(msg) - fields303 = _t1021 - assert fields303 is not None - unwrapped_fields304 = fields303 + fields302 = _t1021 + assert fields302 is not None + unwrapped_fields303 = fields302 self.write('(') self.write('loop') self.indent() self.newline() - field305 = unwrapped_fields304[0] - _t1022 = self.pretty_init(field305) + field304 = unwrapped_fields303[0] + _t1022 = self.pretty_init(field304) self.newline() - field306 = unwrapped_fields304[1] - _t1023 = self.pretty_script(field306) + field305 = unwrapped_fields303[1] + _t1023 = self.pretty_script(field305) self.dedent() self.write(')') return None @@ -2823,22 +2777,22 @@ def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: def _t1024(_dollar_dollar): return _dollar_dollar _t1025 = _t1024(msg) - fields307 = _t1025 - assert fields307 is not None - unwrapped_fields308 = fields307 + fields306 = _t1025 + assert fields306 is not None + unwrapped_fields307 = fields306 self.write('(') self.write('init') self.indent() - if not len(unwrapped_fields308) == 0: + if not len(unwrapped_fields307) == 0: self.newline() - for i310, elem309 in enumerate(unwrapped_fields308): + for i309, elem308 in enumerate(unwrapped_fields307): - if (i310 > 0): + if (i309 > 0): self.newline() _t1026 = None else: _t1026 = None - _t1027 = self.pretty_instruction(elem309) + _t1027 = self.pretty_instruction(elem308) self.dedent() self.write(')') return None @@ -2852,10 +2806,10 @@ def _t1028(_dollar_dollar): _t1029 = None return _t1029 _t1030 = _t1028(msg) - deconstruct_result315 = _t1030 + deconstruct_result314 = _t1030 - if deconstruct_result315 is not None: - _t1032 = self.pretty_assign(deconstruct_result315) + if deconstruct_result314 is not None: + _t1032 = self.pretty_assign(deconstruct_result314) _t1031 = _t1032 else: def _t1033(_dollar_dollar): @@ -2866,10 +2820,10 @@ def _t1033(_dollar_dollar): _t1034 = None return _t1034 _t1035 = _t1033(msg) - deconstruct_result314 = _t1035 + deconstruct_result313 = _t1035 - if deconstruct_result314 is not None: - _t1037 = self.pretty_upsert(deconstruct_result314) + if deconstruct_result313 is not None: + _t1037 = self.pretty_upsert(deconstruct_result313) _t1036 = _t1037 else: def _t1038(_dollar_dollar): @@ -2880,10 +2834,10 @@ def _t1038(_dollar_dollar): _t1039 = None return _t1039 _t1040 = _t1038(msg) - deconstruct_result313 = _t1040 + deconstruct_result312 = _t1040 - if deconstruct_result313 is not None: - _t1042 = self.pretty_break(deconstruct_result313) + if deconstruct_result312 is not None: + _t1042 = self.pretty_break(deconstruct_result312) _t1041 = _t1042 else: def _t1043(_dollar_dollar): @@ -2894,10 +2848,10 @@ def _t1043(_dollar_dollar): _t1044 = None return _t1044 _t1045 = _t1043(msg) - deconstruct_result312 = _t1045 + deconstruct_result311 = _t1045 - if deconstruct_result312 is not None: - _t1047 = self.pretty_monoid_def(deconstruct_result312) + if deconstruct_result311 is not None: + _t1047 = self.pretty_monoid_def(deconstruct_result311) _t1046 = _t1047 else: def _t1048(_dollar_dollar): @@ -2908,10 +2862,10 @@ def _t1048(_dollar_dollar): _t1049 = None return _t1049 _t1050 = _t1048(msg) - deconstruct_result311 = _t1050 + deconstruct_result310 = _t1050 - if deconstruct_result311 is not None: - _t1052 = self.pretty_monus_def(deconstruct_result311) + if deconstruct_result310 is not None: + _t1052 = self.pretty_monus_def(deconstruct_result310) _t1051 = _t1052 else: raise ParseError('No matching rule for instruction') @@ -2930,25 +2884,25 @@ def _t1053(_dollar_dollar): _t1054 = None return (_dollar_dollar.name, _dollar_dollar.body, _t1054,) _t1055 = _t1053(msg) - fields316 = _t1055 - assert fields316 is not None - unwrapped_fields317 = fields316 + fields315 = _t1055 + assert fields315 is not None + unwrapped_fields316 = fields315 self.write('(') self.write('assign') self.indent() self.newline() - field318 = unwrapped_fields317[0] - _t1056 = self.pretty_relation_id(field318) + field317 = unwrapped_fields316[0] + _t1056 = self.pretty_relation_id(field317) self.newline() - field319 = unwrapped_fields317[1] - _t1057 = self.pretty_abstraction(field319) - field320 = unwrapped_fields317[2] + field318 = unwrapped_fields316[1] + _t1057 = self.pretty_abstraction(field318) + field319 = unwrapped_fields316[2] - if field320 is not None: + if field319 is not None: self.newline() - assert field320 is not None - opt_val321 = field320 - _t1059 = self.pretty_attrs(opt_val321) + assert field319 is not None + opt_val320 = field319 + _t1059 = self.pretty_attrs(opt_val320) _t1058 = _t1059 else: _t1058 = None @@ -2965,25 +2919,25 @@ def _t1060(_dollar_dollar): _t1061 = None return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1061,) _t1062 = _t1060(msg) - fields322 = _t1062 - assert fields322 is not None - unwrapped_fields323 = fields322 + fields321 = _t1062 + assert fields321 is not None + unwrapped_fields322 = fields321 self.write('(') self.write('upsert') self.indent() self.newline() - field324 = unwrapped_fields323[0] - _t1063 = self.pretty_relation_id(field324) + field323 = unwrapped_fields322[0] + _t1063 = self.pretty_relation_id(field323) self.newline() - field325 = unwrapped_fields323[1] - _t1064 = self.pretty_abstraction_with_arity(field325) - field326 = unwrapped_fields323[2] + field324 = unwrapped_fields322[1] + _t1064 = self.pretty_abstraction_with_arity(field324) + field325 = unwrapped_fields322[2] - if field326 is not None: + if field325 is not None: self.newline() - assert field326 is not None - opt_val327 = field326 - _t1066 = self.pretty_attrs(opt_val327) + assert field325 is not None + opt_val326 = field325 + _t1066 = self.pretty_attrs(opt_val326) _t1065 = _t1066 else: _t1065 = None @@ -2996,15 +2950,15 @@ def _t1067(_dollar_dollar): _t1068 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) return (_t1068, _dollar_dollar[0].value,) _t1069 = _t1067(msg) - fields328 = _t1069 - assert fields328 is not None - unwrapped_fields329 = fields328 + fields327 = _t1069 + assert fields327 is not None + unwrapped_fields328 = fields327 self.write('(') - field330 = unwrapped_fields329[0] - _t1070 = self.pretty_bindings(field330) + field329 = unwrapped_fields328[0] + _t1070 = self.pretty_bindings(field329) self.write(' ') - field331 = unwrapped_fields329[1] - _t1071 = self.pretty_formula(field331) + field330 = unwrapped_fields328[1] + _t1071 = self.pretty_formula(field330) self.write(')') return None @@ -3017,25 +2971,25 @@ def _t1072(_dollar_dollar): _t1073 = None return (_dollar_dollar.name, _dollar_dollar.body, _t1073,) _t1074 = _t1072(msg) - fields332 = _t1074 - assert fields332 is not None - unwrapped_fields333 = fields332 + fields331 = _t1074 + assert fields331 is not None + unwrapped_fields332 = fields331 self.write('(') self.write('break') self.indent() self.newline() - field334 = unwrapped_fields333[0] - _t1075 = self.pretty_relation_id(field334) + field333 = unwrapped_fields332[0] + _t1075 = self.pretty_relation_id(field333) self.newline() - field335 = unwrapped_fields333[1] - _t1076 = self.pretty_abstraction(field335) - field336 = unwrapped_fields333[2] + field334 = unwrapped_fields332[1] + _t1076 = self.pretty_abstraction(field334) + field335 = unwrapped_fields332[2] - if field336 is not None: + if field335 is not None: self.newline() - assert field336 is not None - opt_val337 = field336 - _t1078 = self.pretty_attrs(opt_val337) + assert field335 is not None + opt_val336 = field335 + _t1078 = self.pretty_attrs(opt_val336) _t1077 = _t1078 else: _t1077 = None @@ -3052,28 +3006,28 @@ def _t1079(_dollar_dollar): _t1080 = None return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1080,) _t1081 = _t1079(msg) - fields338 = _t1081 - assert fields338 is not None - unwrapped_fields339 = fields338 + fields337 = _t1081 + assert fields337 is not None + unwrapped_fields338 = fields337 self.write('(') self.write('monoid') self.indent() self.newline() - field340 = unwrapped_fields339[0] - _t1082 = self.pretty_monoid(field340) + field339 = unwrapped_fields338[0] + _t1082 = self.pretty_monoid(field339) self.newline() - field341 = unwrapped_fields339[1] - _t1083 = self.pretty_relation_id(field341) + field340 = unwrapped_fields338[1] + _t1083 = self.pretty_relation_id(field340) self.newline() - field342 = unwrapped_fields339[2] - _t1084 = self.pretty_abstraction_with_arity(field342) - field343 = unwrapped_fields339[3] + field341 = unwrapped_fields338[2] + _t1084 = self.pretty_abstraction_with_arity(field341) + field342 = unwrapped_fields338[3] - if field343 is not None: + if field342 is not None: self.newline() - assert field343 is not None - opt_val344 = field343 - _t1086 = self.pretty_attrs(opt_val344) + assert field342 is not None + opt_val343 = field342 + _t1086 = self.pretty_attrs(opt_val343) _t1085 = _t1086 else: _t1085 = None @@ -3090,10 +3044,10 @@ def _t1087(_dollar_dollar): _t1088 = None return _t1088 _t1089 = _t1087(msg) - deconstruct_result348 = _t1089 + deconstruct_result347 = _t1089 - if deconstruct_result348 is not None: - _t1091 = self.pretty_or_monoid(deconstruct_result348) + if deconstruct_result347 is not None: + _t1091 = self.pretty_or_monoid(deconstruct_result347) _t1090 = _t1091 else: def _t1092(_dollar_dollar): @@ -3104,10 +3058,10 @@ def _t1092(_dollar_dollar): _t1093 = None return _t1093 _t1094 = _t1092(msg) - deconstruct_result347 = _t1094 + deconstruct_result346 = _t1094 - if deconstruct_result347 is not None: - _t1096 = self.pretty_min_monoid(deconstruct_result347) + if deconstruct_result346 is not None: + _t1096 = self.pretty_min_monoid(deconstruct_result346) _t1095 = _t1096 else: def _t1097(_dollar_dollar): @@ -3118,10 +3072,10 @@ def _t1097(_dollar_dollar): _t1098 = None return _t1098 _t1099 = _t1097(msg) - deconstruct_result346 = _t1099 + deconstruct_result345 = _t1099 - if deconstruct_result346 is not None: - _t1101 = self.pretty_max_monoid(deconstruct_result346) + if deconstruct_result345 is not None: + _t1101 = self.pretty_max_monoid(deconstruct_result345) _t1100 = _t1101 else: def _t1102(_dollar_dollar): @@ -3132,10 +3086,10 @@ def _t1102(_dollar_dollar): _t1103 = None return _t1103 _t1104 = _t1102(msg) - deconstruct_result345 = _t1104 + deconstruct_result344 = _t1104 - if deconstruct_result345 is not None: - _t1106 = self.pretty_sum_monoid(deconstruct_result345) + if deconstruct_result344 is not None: + _t1106 = self.pretty_sum_monoid(deconstruct_result344) _t1105 = _t1106 else: raise ParseError('No matching rule for monoid') @@ -3148,9 +3102,9 @@ def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: def _t1107(_dollar_dollar): return _dollar_dollar _t1108 = _t1107(msg) - fields349 = _t1108 - assert fields349 is not None - unwrapped_fields350 = fields349 + fields348 = _t1108 + assert fields348 is not None + unwrapped_fields349 = fields348 self.write('(') self.write('or') self.write(')') @@ -3160,14 +3114,14 @@ def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: def _t1109(_dollar_dollar): return _dollar_dollar.type _t1110 = _t1109(msg) - fields351 = _t1110 - assert fields351 is not None - unwrapped_fields352 = fields351 + fields350 = _t1110 + assert fields350 is not None + unwrapped_fields351 = fields350 self.write('(') self.write('min') self.indent() self.newline() - _t1111 = self.pretty_type(unwrapped_fields352) + _t1111 = self.pretty_type(unwrapped_fields351) self.dedent() self.write(')') return None @@ -3176,14 +3130,14 @@ def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: def _t1112(_dollar_dollar): return _dollar_dollar.type _t1113 = _t1112(msg) - fields353 = _t1113 - assert fields353 is not None - unwrapped_fields354 = fields353 + fields352 = _t1113 + assert fields352 is not None + unwrapped_fields353 = fields352 self.write('(') self.write('max') self.indent() self.newline() - _t1114 = self.pretty_type(unwrapped_fields354) + _t1114 = self.pretty_type(unwrapped_fields353) self.dedent() self.write(')') return None @@ -3192,14 +3146,14 @@ def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: def _t1115(_dollar_dollar): return _dollar_dollar.type _t1116 = _t1115(msg) - fields355 = _t1116 - assert fields355 is not None - unwrapped_fields356 = fields355 + fields354 = _t1116 + assert fields354 is not None + unwrapped_fields355 = fields354 self.write('(') self.write('sum') self.indent() self.newline() - _t1117 = self.pretty_type(unwrapped_fields356) + _t1117 = self.pretty_type(unwrapped_fields355) self.dedent() self.write(')') return None @@ -3213,28 +3167,28 @@ def _t1118(_dollar_dollar): _t1119 = None return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1119,) _t1120 = _t1118(msg) - fields357 = _t1120 - assert fields357 is not None - unwrapped_fields358 = fields357 + fields356 = _t1120 + assert fields356 is not None + unwrapped_fields357 = fields356 self.write('(') self.write('monus') self.indent() self.newline() - field359 = unwrapped_fields358[0] - _t1121 = self.pretty_monoid(field359) + field358 = unwrapped_fields357[0] + _t1121 = self.pretty_monoid(field358) self.newline() - field360 = unwrapped_fields358[1] - _t1122 = self.pretty_relation_id(field360) + field359 = unwrapped_fields357[1] + _t1122 = self.pretty_relation_id(field359) self.newline() - field361 = unwrapped_fields358[2] - _t1123 = self.pretty_abstraction_with_arity(field361) - field362 = unwrapped_fields358[3] + field360 = unwrapped_fields357[2] + _t1123 = self.pretty_abstraction_with_arity(field360) + field361 = unwrapped_fields357[3] - if field362 is not None: + if field361 is not None: self.newline() - assert field362 is not None - opt_val363 = field362 - _t1125 = self.pretty_attrs(opt_val363) + assert field361 is not None + opt_val362 = field361 + _t1125 = self.pretty_attrs(opt_val362) _t1124 = _t1125 else: _t1124 = None @@ -3246,24 +3200,24 @@ def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: def _t1126(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) _t1127 = _t1126(msg) - fields364 = _t1127 - assert fields364 is not None - unwrapped_fields365 = fields364 + fields363 = _t1127 + assert fields363 is not None + unwrapped_fields364 = fields363 self.write('(') self.write('functional_dependency') self.indent() self.newline() - field366 = unwrapped_fields365[0] - _t1128 = self.pretty_relation_id(field366) + field365 = unwrapped_fields364[0] + _t1128 = self.pretty_relation_id(field365) self.newline() - field367 = unwrapped_fields365[1] - _t1129 = self.pretty_abstraction(field367) + field366 = unwrapped_fields364[1] + _t1129 = self.pretty_abstraction(field366) self.newline() - field368 = unwrapped_fields365[2] - _t1130 = self.pretty_functional_dependency_keys(field368) + field367 = unwrapped_fields364[2] + _t1130 = self.pretty_functional_dependency_keys(field367) self.newline() - field369 = unwrapped_fields365[3] - _t1131 = self.pretty_functional_dependency_values(field369) + field368 = unwrapped_fields364[3] + _t1131 = self.pretty_functional_dependency_values(field368) self.dedent() self.write(')') return None @@ -3272,22 +3226,22 @@ def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optiona def _t1132(_dollar_dollar): return _dollar_dollar _t1133 = _t1132(msg) - fields370 = _t1133 - assert fields370 is not None - unwrapped_fields371 = fields370 + fields369 = _t1133 + assert fields369 is not None + unwrapped_fields370 = fields369 self.write('(') self.write('keys') self.indent() - if not len(unwrapped_fields371) == 0: + if not len(unwrapped_fields370) == 0: self.newline() - for i373, elem372 in enumerate(unwrapped_fields371): + for i372, elem371 in enumerate(unwrapped_fields370): - if (i373 > 0): + if (i372 > 0): self.newline() _t1134 = None else: _t1134 = None - _t1135 = self.pretty_var(elem372) + _t1135 = self.pretty_var(elem371) self.dedent() self.write(')') return None @@ -3296,22 +3250,22 @@ def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optio def _t1136(_dollar_dollar): return _dollar_dollar _t1137 = _t1136(msg) - fields374 = _t1137 - assert fields374 is not None - unwrapped_fields375 = fields374 + fields373 = _t1137 + assert fields373 is not None + unwrapped_fields374 = fields373 self.write('(') self.write('values') self.indent() - if not len(unwrapped_fields375) == 0: + if not len(unwrapped_fields374) == 0: self.newline() - for i377, elem376 in enumerate(unwrapped_fields375): + for i376, elem375 in enumerate(unwrapped_fields374): - if (i377 > 0): + if (i376 > 0): self.newline() _t1138 = None else: _t1138 = None - _t1139 = self.pretty_var(elem376) + _t1139 = self.pretty_var(elem375) self.dedent() self.write(')') return None @@ -3325,10 +3279,10 @@ def _t1140(_dollar_dollar): _t1141 = None return _t1141 _t1142 = _t1140(msg) - deconstruct_result380 = _t1142 + deconstruct_result379 = _t1142 - if deconstruct_result380 is not None: - _t1144 = self.pretty_rel_edb(deconstruct_result380) + if deconstruct_result379 is not None: + _t1144 = self.pretty_rel_edb(deconstruct_result379) _t1143 = _t1144 else: def _t1145(_dollar_dollar): @@ -3339,10 +3293,10 @@ def _t1145(_dollar_dollar): _t1146 = None return _t1146 _t1147 = _t1145(msg) - deconstruct_result379 = _t1147 + deconstruct_result378 = _t1147 - if deconstruct_result379 is not None: - _t1149 = self.pretty_betree_relation(deconstruct_result379) + if deconstruct_result378 is not None: + _t1149 = self.pretty_betree_relation(deconstruct_result378) _t1148 = _t1149 else: def _t1150(_dollar_dollar): @@ -3353,10 +3307,10 @@ def _t1150(_dollar_dollar): _t1151 = None return _t1151 _t1152 = _t1150(msg) - deconstruct_result378 = _t1152 + deconstruct_result377 = _t1152 - if deconstruct_result378 is not None: - _t1154 = self.pretty_csv_data(deconstruct_result378) + if deconstruct_result377 is not None: + _t1154 = self.pretty_csv_data(deconstruct_result377) _t1153 = _t1154 else: raise ParseError('No matching rule for data') @@ -3368,21 +3322,21 @@ def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: def _t1155(_dollar_dollar): return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) _t1156 = _t1155(msg) - fields381 = _t1156 - assert fields381 is not None - unwrapped_fields382 = fields381 + fields380 = _t1156 + assert fields380 is not None + unwrapped_fields381 = fields380 self.write('(') self.write('rel_edb') self.indent() self.newline() - field383 = unwrapped_fields382[0] - _t1157 = self.pretty_relation_id(field383) + field382 = unwrapped_fields381[0] + _t1157 = self.pretty_relation_id(field382) self.newline() - field384 = unwrapped_fields382[1] - _t1158 = self.pretty_rel_edb_path(field384) + field383 = unwrapped_fields381[1] + _t1158 = self.pretty_rel_edb_path(field383) self.newline() - field385 = unwrapped_fields382[2] - _t1159 = self.pretty_rel_edb_types(field385) + field384 = unwrapped_fields381[2] + _t1159 = self.pretty_rel_edb_types(field384) self.dedent() self.write(')') return None @@ -3391,18 +3345,18 @@ def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: def _t1160(_dollar_dollar): return _dollar_dollar _t1161 = _t1160(msg) - fields386 = _t1161 - assert fields386 is not None - unwrapped_fields387 = fields386 + fields385 = _t1161 + assert fields385 is not None + unwrapped_fields386 = fields385 self.write('[') - for i389, elem388 in enumerate(unwrapped_fields387): + for i388, elem387 in enumerate(unwrapped_fields386): - if (i389 > 0): + if (i388 > 0): self.newline() _t1162 = None else: _t1162 = None - self.write(self.format_string_value(elem388)) + self.write(self.format_string_value(elem387)) self.write(']') return None @@ -3410,18 +3364,18 @@ def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: def _t1163(_dollar_dollar): return _dollar_dollar _t1164 = _t1163(msg) - fields390 = _t1164 - assert fields390 is not None - unwrapped_fields391 = fields390 + fields389 = _t1164 + assert fields389 is not None + unwrapped_fields390 = fields389 self.write('[') - for i393, elem392 in enumerate(unwrapped_fields391): + for i392, elem391 in enumerate(unwrapped_fields390): - if (i393 > 0): + if (i392 > 0): self.newline() _t1165 = None else: _t1165 = None - _t1166 = self.pretty_type(elem392) + _t1166 = self.pretty_type(elem391) self.write(']') return None @@ -3429,18 +3383,18 @@ def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Neve def _t1167(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_info,) _t1168 = _t1167(msg) - fields394 = _t1168 - assert fields394 is not None - unwrapped_fields395 = fields394 + fields393 = _t1168 + assert fields393 is not None + unwrapped_fields394 = fields393 self.write('(') self.write('betree_relation') self.indent() self.newline() - field396 = unwrapped_fields395[0] - _t1169 = self.pretty_relation_id(field396) + field395 = unwrapped_fields394[0] + _t1169 = self.pretty_relation_id(field395) self.newline() - field397 = unwrapped_fields395[1] - _t1170 = self.pretty_betree_info(field397) + field396 = unwrapped_fields394[1] + _t1170 = self.pretty_betree_info(field396) self.dedent() self.write(')') return None @@ -3450,21 +3404,21 @@ def _t1171(_dollar_dollar): _t1172 = self.deconstruct_betree_info_config(_dollar_dollar) return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1172,) _t1173 = _t1171(msg) - fields398 = _t1173 - assert fields398 is not None - unwrapped_fields399 = fields398 + fields397 = _t1173 + assert fields397 is not None + unwrapped_fields398 = fields397 self.write('(') self.write('betree_info') self.indent() self.newline() - field400 = unwrapped_fields399[0] - _t1174 = self.pretty_betree_info_key_types(field400) + field399 = unwrapped_fields398[0] + _t1174 = self.pretty_betree_info_key_types(field399) self.newline() - field401 = unwrapped_fields399[1] - _t1175 = self.pretty_betree_info_value_types(field401) + field400 = unwrapped_fields398[1] + _t1175 = self.pretty_betree_info_value_types(field400) self.newline() - field402 = unwrapped_fields399[2] - _t1176 = self.pretty_config_dict(field402) + field401 = unwrapped_fields398[2] + _t1176 = self.pretty_config_dict(field401) self.dedent() self.write(')') return None @@ -3473,22 +3427,22 @@ def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Ne def _t1177(_dollar_dollar): return _dollar_dollar _t1178 = _t1177(msg) - fields403 = _t1178 - assert fields403 is not None - unwrapped_fields404 = fields403 + fields402 = _t1178 + assert fields402 is not None + unwrapped_fields403 = fields402 self.write('(') self.write('key_types') self.indent() - if not len(unwrapped_fields404) == 0: + if not len(unwrapped_fields403) == 0: self.newline() - for i406, elem405 in enumerate(unwrapped_fields404): + for i405, elem404 in enumerate(unwrapped_fields403): - if (i406 > 0): + if (i405 > 0): self.newline() _t1179 = None else: _t1179 = None - _t1180 = self.pretty_type(elem405) + _t1180 = self.pretty_type(elem404) self.dedent() self.write(')') return None @@ -3497,22 +3451,22 @@ def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[ def _t1181(_dollar_dollar): return _dollar_dollar _t1182 = _t1181(msg) - fields407 = _t1182 - assert fields407 is not None - unwrapped_fields408 = fields407 + fields406 = _t1182 + assert fields406 is not None + unwrapped_fields407 = fields406 self.write('(') self.write('value_types') self.indent() - if not len(unwrapped_fields408) == 0: + if not len(unwrapped_fields407) == 0: self.newline() - for i410, elem409 in enumerate(unwrapped_fields408): + for i409, elem408 in enumerate(unwrapped_fields407): - if (i410 > 0): + if (i409 > 0): self.newline() _t1183 = None else: _t1183 = None - _t1184 = self.pretty_type(elem409) + _t1184 = self.pretty_type(elem408) self.dedent() self.write(')') return None @@ -3521,24 +3475,24 @@ def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: def _t1185(_dollar_dollar): return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) _t1186 = _t1185(msg) - fields411 = _t1186 - assert fields411 is not None - unwrapped_fields412 = fields411 + fields410 = _t1186 + assert fields410 is not None + unwrapped_fields411 = fields410 self.write('(') self.write('csv_data') self.indent() self.newline() - field413 = unwrapped_fields412[0] - _t1187 = self.pretty_csvlocator(field413) + field412 = unwrapped_fields411[0] + _t1187 = self.pretty_csvlocator(field412) self.newline() - field414 = unwrapped_fields412[1] - _t1188 = self.pretty_csv_config(field414) + field413 = unwrapped_fields411[1] + _t1188 = self.pretty_csv_config(field413) self.newline() - field415 = unwrapped_fields412[2] - _t1189 = self.pretty_csv_columns(field415) + field414 = unwrapped_fields411[2] + _t1189 = self.pretty_csv_columns(field414) self.newline() - field416 = unwrapped_fields412[3] - _t1190 = self.pretty_csv_asof(field416) + field415 = unwrapped_fields411[3] + _t1190 = self.pretty_csv_asof(field415) self.dedent() self.write(')') return None @@ -3557,29 +3511,29 @@ def _t1191(_dollar_dollar): _t1193 = None return (_t1192, _t1193,) _t1194 = _t1191(msg) - fields417 = _t1194 - assert fields417 is not None - unwrapped_fields418 = fields417 + fields416 = _t1194 + assert fields416 is not None + unwrapped_fields417 = fields416 self.write('(') self.write('csv_locator') self.indent() - field419 = unwrapped_fields418[0] + field418 = unwrapped_fields417[0] - if field419 is not None: + if field418 is not None: self.newline() - assert field419 is not None - opt_val420 = field419 - _t1196 = self.pretty_csv_locator_paths(opt_val420) + assert field418 is not None + opt_val419 = field418 + _t1196 = self.pretty_csv_locator_paths(opt_val419) _t1195 = _t1196 else: _t1195 = None - field421 = unwrapped_fields418[1] + field420 = unwrapped_fields417[1] - if field421 is not None: + if field420 is not None: self.newline() - assert field421 is not None - opt_val422 = field421 - _t1198 = self.pretty_csv_locator_inline_data(opt_val422) + assert field420 is not None + opt_val421 = field420 + _t1198 = self.pretty_csv_locator_inline_data(opt_val421) _t1197 = _t1198 else: _t1197 = None @@ -3591,22 +3545,22 @@ def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: def _t1199(_dollar_dollar): return _dollar_dollar _t1200 = _t1199(msg) - fields423 = _t1200 - assert fields423 is not None - unwrapped_fields424 = fields423 + fields422 = _t1200 + assert fields422 is not None + unwrapped_fields423 = fields422 self.write('(') self.write('paths') self.indent() - if not len(unwrapped_fields424) == 0: + if not len(unwrapped_fields423) == 0: self.newline() - for i426, elem425 in enumerate(unwrapped_fields424): + for i425, elem424 in enumerate(unwrapped_fields423): - if (i426 > 0): + if (i425 > 0): self.newline() _t1201 = None else: _t1201 = None - self.write(self.format_string_value(elem425)) + self.write(self.format_string_value(elem424)) self.dedent() self.write(')') return None @@ -3615,14 +3569,14 @@ def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: def _t1202(_dollar_dollar): return _dollar_dollar _t1203 = _t1202(msg) - fields427 = _t1203 - assert fields427 is not None - unwrapped_fields428 = fields427 + fields426 = _t1203 + assert fields426 is not None + unwrapped_fields427 = fields426 self.write('(') self.write('inline_data') self.indent() self.newline() - self.write(self.format_string_value(unwrapped_fields428)) + self.write(self.format_string_value(unwrapped_fields427)) self.dedent() self.write(')') return None @@ -3632,14 +3586,14 @@ def _t1204(_dollar_dollar): _t1205 = self.deconstruct_csv_config(_dollar_dollar) return _t1205 _t1206 = _t1204(msg) - fields429 = _t1206 - assert fields429 is not None - unwrapped_fields430 = fields429 + fields428 = _t1206 + assert fields428 is not None + unwrapped_fields429 = fields428 self.write('(') self.write('csv_config') self.indent() self.newline() - _t1207 = self.pretty_config_dict(unwrapped_fields430) + _t1207 = self.pretty_config_dict(unwrapped_fields429) self.dedent() self.write(')') return None @@ -3648,22 +3602,22 @@ def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: def _t1208(_dollar_dollar): return _dollar_dollar _t1209 = _t1208(msg) - fields431 = _t1209 - assert fields431 is not None - unwrapped_fields432 = fields431 + fields430 = _t1209 + assert fields430 is not None + unwrapped_fields431 = fields430 self.write('(') self.write('columns') self.indent() - if not len(unwrapped_fields432) == 0: + if not len(unwrapped_fields431) == 0: self.newline() - for i434, elem433 in enumerate(unwrapped_fields432): + for i433, elem432 in enumerate(unwrapped_fields431): - if (i434 > 0): + if (i433 > 0): self.newline() _t1210 = None else: _t1210 = None - _t1211 = self.pretty_csv_column(elem433) + _t1211 = self.pretty_csv_column(elem432) self.dedent() self.write(')') return None @@ -3672,30 +3626,31 @@ def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: def _t1212(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) _t1213 = _t1212(msg) - fields435 = _t1213 - assert fields435 is not None - unwrapped_fields436 = fields435 + fields434 = _t1213 + assert fields434 is not None + unwrapped_fields435 = fields434 self.write('(') self.write('column') self.indent() self.newline() - field437 = unwrapped_fields436[0] - self.write(self.format_string_value(field437)) + field436 = unwrapped_fields435[0] + self.write(self.format_string_value(field436)) + self.newline() + field437 = unwrapped_fields435[1] + _t1214 = self.pretty_relation_id(field437) self.newline() - field438 = unwrapped_fields436[1] - _t1214 = self.pretty_relation_id(field438) self.write('[') - field439 = unwrapped_fields436[2] - if not len(field439) == 0: + field438 = unwrapped_fields435[2] + if not len(field438) == 0: self.newline() - for i441, elem440 in enumerate(field439): + for i440, elem439 in enumerate(field438): - if (i441 > 0): + if (i440 > 0): self.newline() _t1215 = None else: _t1215 = None - _t1216 = self.pretty_type(elem440) + _t1216 = self.pretty_type(elem439) self.write(']') self.dedent() self.write(')') @@ -3705,14 +3660,14 @@ def pretty_csv_asof(self, msg: str) -> Optional[Never]: def _t1217(_dollar_dollar): return _dollar_dollar _t1218 = _t1217(msg) - fields442 = _t1218 - assert fields442 is not None - unwrapped_fields443 = fields442 + fields441 = _t1218 + assert fields441 is not None + unwrapped_fields442 = fields441 self.write('(') self.write('asof') self.indent() self.newline() - self.write(self.format_string_value(unwrapped_fields443)) + self.write(self.format_string_value(unwrapped_fields442)) self.dedent() self.write(')') return None @@ -3721,14 +3676,14 @@ def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: def _t1219(_dollar_dollar): return _dollar_dollar.fragment_id _t1220 = _t1219(msg) - fields444 = _t1220 - assert fields444 is not None - unwrapped_fields445 = fields444 + fields443 = _t1220 + assert fields443 is not None + unwrapped_fields444 = fields443 self.write('(') self.write('undefine') self.indent() self.newline() - _t1221 = self.pretty_fragment_id(unwrapped_fields445) + _t1221 = self.pretty_fragment_id(unwrapped_fields444) self.dedent() self.write(')') return None @@ -3737,22 +3692,22 @@ def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: def _t1222(_dollar_dollar): return _dollar_dollar.relations _t1223 = _t1222(msg) - fields446 = _t1223 - assert fields446 is not None - unwrapped_fields447 = fields446 + fields445 = _t1223 + assert fields445 is not None + unwrapped_fields446 = fields445 self.write('(') self.write('context') self.indent() - if not len(unwrapped_fields447) == 0: + if not len(unwrapped_fields446) == 0: self.newline() - for i449, elem448 in enumerate(unwrapped_fields447): + for i448, elem447 in enumerate(unwrapped_fields446): - if (i449 > 0): + if (i448 > 0): self.newline() _t1224 = None else: _t1224 = None - _t1225 = self.pretty_relation_id(elem448) + _t1225 = self.pretty_relation_id(elem447) self.dedent() self.write(')') return None @@ -3761,22 +3716,22 @@ def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never def _t1226(_dollar_dollar): return _dollar_dollar _t1227 = _t1226(msg) - fields450 = _t1227 - assert fields450 is not None - unwrapped_fields451 = fields450 + fields449 = _t1227 + assert fields449 is not None + unwrapped_fields450 = fields449 self.write('(') self.write('reads') self.indent() - if not len(unwrapped_fields451) == 0: + if not len(unwrapped_fields450) == 0: self.newline() - for i453, elem452 in enumerate(unwrapped_fields451): + for i452, elem451 in enumerate(unwrapped_fields450): - if (i453 > 0): + if (i452 > 0): self.newline() _t1228 = None else: _t1228 = None - _t1229 = self.pretty_read(elem452) + _t1229 = self.pretty_read(elem451) self.dedent() self.write(')') return None @@ -3790,10 +3745,10 @@ def _t1230(_dollar_dollar): _t1231 = None return _t1231 _t1232 = _t1230(msg) - deconstruct_result458 = _t1232 + deconstruct_result457 = _t1232 - if deconstruct_result458 is not None: - _t1234 = self.pretty_demand(deconstruct_result458) + if deconstruct_result457 is not None: + _t1234 = self.pretty_demand(deconstruct_result457) _t1233 = _t1234 else: def _t1235(_dollar_dollar): @@ -3804,10 +3759,10 @@ def _t1235(_dollar_dollar): _t1236 = None return _t1236 _t1237 = _t1235(msg) - deconstruct_result457 = _t1237 + deconstruct_result456 = _t1237 - if deconstruct_result457 is not None: - _t1239 = self.pretty_output(deconstruct_result457) + if deconstruct_result456 is not None: + _t1239 = self.pretty_output(deconstruct_result456) _t1238 = _t1239 else: def _t1240(_dollar_dollar): @@ -3818,10 +3773,10 @@ def _t1240(_dollar_dollar): _t1241 = None return _t1241 _t1242 = _t1240(msg) - deconstruct_result456 = _t1242 + deconstruct_result455 = _t1242 - if deconstruct_result456 is not None: - _t1244 = self.pretty_what_if(deconstruct_result456) + if deconstruct_result455 is not None: + _t1244 = self.pretty_what_if(deconstruct_result455) _t1243 = _t1244 else: def _t1245(_dollar_dollar): @@ -3832,10 +3787,10 @@ def _t1245(_dollar_dollar): _t1246 = None return _t1246 _t1247 = _t1245(msg) - deconstruct_result455 = _t1247 + deconstruct_result454 = _t1247 - if deconstruct_result455 is not None: - _t1249 = self.pretty_abort(deconstruct_result455) + if deconstruct_result454 is not None: + _t1249 = self.pretty_abort(deconstruct_result454) _t1248 = _t1249 else: def _t1250(_dollar_dollar): @@ -3846,10 +3801,10 @@ def _t1250(_dollar_dollar): _t1251 = None return _t1251 _t1252 = _t1250(msg) - deconstruct_result454 = _t1252 + deconstruct_result453 = _t1252 - if deconstruct_result454 is not None: - _t1254 = self.pretty_export(deconstruct_result454) + if deconstruct_result453 is not None: + _t1254 = self.pretty_export(deconstruct_result453) _t1253 = _t1254 else: raise ParseError('No matching rule for read') @@ -3863,14 +3818,14 @@ def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: def _t1255(_dollar_dollar): return _dollar_dollar.relation_id _t1256 = _t1255(msg) - fields459 = _t1256 - assert fields459 is not None - unwrapped_fields460 = fields459 + fields458 = _t1256 + assert fields458 is not None + unwrapped_fields459 = fields458 self.write('(') self.write('demand') self.indent() self.newline() - _t1257 = self.pretty_relation_id(unwrapped_fields460) + _t1257 = self.pretty_relation_id(unwrapped_fields459) self.dedent() self.write(')') return None @@ -3879,18 +3834,18 @@ def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: def _t1258(_dollar_dollar): return (_dollar_dollar.name, _dollar_dollar.relation_id,) _t1259 = _t1258(msg) - fields461 = _t1259 - assert fields461 is not None - unwrapped_fields462 = fields461 + fields460 = _t1259 + assert fields460 is not None + unwrapped_fields461 = fields460 self.write('(') self.write('output') self.indent() self.newline() - field463 = unwrapped_fields462[0] - _t1260 = self.pretty_name(field463) + field462 = unwrapped_fields461[0] + _t1260 = self.pretty_name(field462) self.newline() - field464 = unwrapped_fields462[1] - _t1261 = self.pretty_relation_id(field464) + field463 = unwrapped_fields461[1] + _t1261 = self.pretty_relation_id(field463) self.dedent() self.write(')') return None @@ -3899,18 +3854,18 @@ def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: def _t1262(_dollar_dollar): return (_dollar_dollar.branch, _dollar_dollar.epoch,) _t1263 = _t1262(msg) - fields465 = _t1263 - assert fields465 is not None - unwrapped_fields466 = fields465 + fields464 = _t1263 + assert fields464 is not None + unwrapped_fields465 = fields464 self.write('(') self.write('what_if') self.indent() self.newline() - field467 = unwrapped_fields466[0] - _t1264 = self.pretty_name(field467) + field466 = unwrapped_fields465[0] + _t1264 = self.pretty_name(field466) self.newline() - field468 = unwrapped_fields466[1] - _t1265 = self.pretty_epoch(field468) + field467 = unwrapped_fields465[1] + _t1265 = self.pretty_epoch(field467) self.dedent() self.write(')') return None @@ -3924,25 +3879,25 @@ def _t1266(_dollar_dollar): _t1267 = None return (_t1267, _dollar_dollar.relation_id,) _t1268 = _t1266(msg) - fields469 = _t1268 - assert fields469 is not None - unwrapped_fields470 = fields469 + fields468 = _t1268 + assert fields468 is not None + unwrapped_fields469 = fields468 self.write('(') self.write('abort') self.indent() - field471 = unwrapped_fields470[0] + field470 = unwrapped_fields469[0] - if field471 is not None: + if field470 is not None: self.newline() - assert field471 is not None - opt_val472 = field471 - _t1270 = self.pretty_name(opt_val472) + assert field470 is not None + opt_val471 = field470 + _t1270 = self.pretty_name(opt_val471) _t1269 = _t1270 else: _t1269 = None self.newline() - field473 = unwrapped_fields470[1] - _t1271 = self.pretty_relation_id(field473) + field472 = unwrapped_fields469[1] + _t1271 = self.pretty_relation_id(field472) self.dedent() self.write(')') return None @@ -3951,14 +3906,14 @@ def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: def _t1272(_dollar_dollar): return _dollar_dollar.csv_config _t1273 = _t1272(msg) - fields474 = _t1273 - assert fields474 is not None - unwrapped_fields475 = fields474 + fields473 = _t1273 + assert fields473 is not None + unwrapped_fields474 = fields473 self.write('(') self.write('export') self.indent() self.newline() - _t1274 = self.pretty_export_csv_config(unwrapped_fields475) + _t1274 = self.pretty_export_csv_config(unwrapped_fields474) self.dedent() self.write(')') return None @@ -3968,21 +3923,21 @@ def _t1275(_dollar_dollar): _t1276 = self.deconstruct_export_csv_config(_dollar_dollar) return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1276,) _t1277 = _t1275(msg) - fields476 = _t1277 - assert fields476 is not None - unwrapped_fields477 = fields476 + fields475 = _t1277 + assert fields475 is not None + unwrapped_fields476 = fields475 self.write('(') self.write('export_csv_config') self.indent() self.newline() - field478 = unwrapped_fields477[0] - _t1278 = self.pretty_export_csv_path(field478) + field477 = unwrapped_fields476[0] + _t1278 = self.pretty_export_csv_path(field477) self.newline() - field479 = unwrapped_fields477[1] - _t1279 = self.pretty_export_csv_columns(field479) + field478 = unwrapped_fields476[1] + _t1279 = self.pretty_export_csv_columns(field478) self.newline() - field480 = unwrapped_fields477[2] - _t1280 = self.pretty_config_dict(field480) + field479 = unwrapped_fields476[2] + _t1280 = self.pretty_config_dict(field479) self.dedent() self.write(')') return None @@ -3991,14 +3946,14 @@ def pretty_export_csv_path(self, msg: str) -> Optional[Never]: def _t1281(_dollar_dollar): return _dollar_dollar _t1282 = _t1281(msg) - fields481 = _t1282 - assert fields481 is not None - unwrapped_fields482 = fields481 + fields480 = _t1282 + assert fields480 is not None + unwrapped_fields481 = fields480 self.write('(') self.write('path') self.indent() self.newline() - self.write(self.format_string_value(unwrapped_fields482)) + self.write(self.format_string_value(unwrapped_fields481)) self.dedent() self.write(')') return None @@ -4007,22 +3962,22 @@ def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) def _t1283(_dollar_dollar): return _dollar_dollar _t1284 = _t1283(msg) - fields483 = _t1284 - assert fields483 is not None - unwrapped_fields484 = fields483 + fields482 = _t1284 + assert fields482 is not None + unwrapped_fields483 = fields482 self.write('(') self.write('columns') self.indent() - if not len(unwrapped_fields484) == 0: + if not len(unwrapped_fields483) == 0: self.newline() - for i486, elem485 in enumerate(unwrapped_fields484): + for i485, elem484 in enumerate(unwrapped_fields483): - if (i486 > 0): + if (i485 > 0): self.newline() _t1285 = None else: _t1285 = None - _t1286 = self.pretty_export_csv_column(elem485) + _t1286 = self.pretty_export_csv_column(elem484) self.dedent() self.write(')') return None @@ -4031,18 +3986,18 @@ def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Opt def _t1287(_dollar_dollar): return (_dollar_dollar.column_name, _dollar_dollar.column_data,) _t1288 = _t1287(msg) - fields487 = _t1288 - assert fields487 is not None - unwrapped_fields488 = fields487 + fields486 = _t1288 + assert fields486 is not None + unwrapped_fields487 = fields486 self.write('(') self.write('column') self.indent() self.newline() - field489 = unwrapped_fields488[0] - self.write(self.format_string_value(field489)) + field488 = unwrapped_fields487[0] + self.write(self.format_string_value(field488)) self.newline() - field490 = unwrapped_fields488[1] - _t1289 = self.pretty_relation_id(field490) + field489 = unwrapped_fields487[1] + _t1289 = self.pretty_relation_id(field489) self.dedent() self.write(')') return None diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index 9f9c1104..481f750d 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -93,6 +93,7 @@ class BuiltinTemplate: "relation_id_to_uint128": BuiltinTemplate("self.relation_id_to_uint128({0})"), "subtract": BuiltinTemplate("({0} - {1})"), "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), + "list_sort": BuiltinTemplate("sorted({0})"), } @@ -168,6 +169,7 @@ class BuiltinTemplate: "relation_id_to_uint128": BuiltinTemplate("relation_id_to_uint128(pp, {0})"), "subtract": BuiltinTemplate("({0} - {1})"), "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), + "list_sort": BuiltinTemplate("sort({0})"), } @@ -206,6 +208,7 @@ class BuiltinTemplate: "map": BuiltinTemplate("mapSlice({1}, {0})"), "list_push": BuiltinTemplate("nil", ["{0} = append({0}, {1})"]), "list_concat": BuiltinTemplate("listConcat({0}, {1})"), + "list_sort": BuiltinTemplate("listSort({0})"), "fragment_id_from_string": BuiltinTemplate("&pb.FragmentId{{Id: []byte({0})}}"), "relation_id_from_string": BuiltinTemplate("p.relationIdFromString({0})"), "relation_id_from_int": BuiltinTemplate( diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 1ede4c90..8bf0507e 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -259,14 +259,17 @@ datetime $6: Int64 = builtin.int32_to_int64($$.hour) $7: Int64 = builtin.int32_to_int64($$.minute) $8: Int64 = builtin.int32_to_int64($$.second) - $9: Optional[Int64] = builtin.int32_to_int64($$.microsecond) if $$.microsecond != 0 else None + $9: Optional[Int64] = builtin.some(builtin.int32_to_int64($$.microsecond)) boolean_value : "true" construct: $$ = True deconstruct if $$: + pass | "false" construct: $$ = False + deconstruct if not $$: + pass sync : "(" "sync" fragment_id* ")" @@ -1069,6 +1072,12 @@ export_csv_column %% +def _extract_value_int32(value: Optional[logic.Value], default: int) -> int: + if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'int_value'): + return builtin.int64_to_int32(builtin.unwrap_option(value).int_value) + return default + + def _extract_value_int64(value: Optional[logic.Value], default: int) -> int: if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'int_value'): return builtin.unwrap_option(value).int_value @@ -1147,7 +1156,7 @@ def _try_extract_value_string_list(value: Optional[logic.Value]) -> Optional[Lis def construct_csv_config(config_dict: List[Tuple[String, logic.Value]]) -> logic.CSVConfig: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) - header_row: int = _extract_value_int64(builtin.dict_get(config, "csv_header_row"), 1) + header_row: int = _extract_value_int32(builtin.dict_get(config, "csv_header_row"), 1) skip: int = _extract_value_int64(builtin.dict_get(config, "csv_skip"), 0) new_line: str = _extract_value_string(builtin.dict_get(config, "csv_new_line"), "") delimiter: str = _extract_value_string(builtin.dict_get(config, "csv_delimiter"), ",") @@ -1159,7 +1168,7 @@ def construct_csv_config(config_dict: List[Tuple[String, logic.Value]]) -> logic encoding: str = _extract_value_string(builtin.dict_get(config, "csv_encoding"), "utf-8") compression: str = _extract_value_string(builtin.dict_get(config, "csv_compression"), "auto") return logic.CSVConfig( - header_row=builtin.int64_to_int32(header_row), + header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, @@ -1262,6 +1271,10 @@ def export_csv_config( ) +def _make_value_int32(v: int) -> logic.Value: + return logic.Value(int_value=builtin.int32_to_int64(v)) + + def _make_value_int64(v: int) -> logic.Value: return logic.Value(int_value=v) @@ -1299,34 +1312,24 @@ def deconstruct_configure(msg: transactions.Configure) -> List[Tuple[String, log elif msg.ivm_config.level == transactions.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: builtin.list_push(result, builtin.tuple("ivm.maintenance_level", _make_value_string("off"))) builtin.list_push(result, builtin.tuple("semantics_version", _make_value_int64(msg.semantics_version))) - return result + return builtin.list_sort(result) def deconstruct_csv_config(msg: logic.CSVConfig) -> List[Tuple[String, logic.Value]]: result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() - if msg.header_row != 1: - builtin.list_push(result, builtin.tuple("csv_header_row", _make_value_int64(builtin.int32_to_int64(msg.header_row)))) - if msg.skip != 0: - builtin.list_push(result, builtin.tuple("csv_skip", _make_value_int64(msg.skip))) - if msg.new_line != "": - builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) - if msg.delimiter != ",": - builtin.list_push(result, builtin.tuple("csv_delimiter", _make_value_string(msg.delimiter))) - if msg.quotechar != "\"": - builtin.list_push(result, builtin.tuple("csv_quotechar", _make_value_string(msg.quotechar))) - if msg.escapechar != "\"": - builtin.list_push(result, builtin.tuple("csv_escapechar", _make_value_string(msg.escapechar))) - if msg.comment != "": - builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) - if not builtin.is_empty(msg.missing_strings): - builtin.list_push(result, builtin.tuple("csv_missing_strings", _make_value_string(msg.missing_strings[0]))) - if msg.decimal_separator != ".": - builtin.list_push(result, builtin.tuple("csv_decimal_separator", _make_value_string(msg.decimal_separator))) - if msg.encoding != "utf-8": - builtin.list_push(result, builtin.tuple("csv_encoding", _make_value_string(msg.encoding))) - if msg.compression != "auto": - builtin.list_push(result, builtin.tuple("csv_compression", _make_value_string(msg.compression))) - return result + builtin.list_push(result, builtin.tuple("csv_header_row", _make_value_int32(msg.header_row))) + builtin.list_push(result, builtin.tuple("csv_skip", _make_value_int64(msg.skip))) + builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) + builtin.list_push(result, builtin.tuple("csv_delimiter", _make_value_string(msg.delimiter))) + builtin.list_push(result, builtin.tuple("csv_quotechar", _make_value_string(msg.quotechar))) + builtin.list_push(result, builtin.tuple("csv_escapechar", _make_value_string(msg.escapechar))) + builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) + for missing_string in msg.missing_strings: + builtin.list_push(result, builtin.tuple("csv_missing_strings", _make_value_string(missing_string))) + builtin.list_push(result, builtin.tuple("csv_decimal_separator", _make_value_string(msg.decimal_separator))) + builtin.list_push(result, builtin.tuple("csv_encoding", _make_value_string(msg.encoding))) + builtin.list_push(result, builtin.tuple("csv_compression", _make_value_string(msg.compression))) + return builtin.list_sort(result) def _maybe_push_float64(result: List[Tuple[String, logic.Value]], key: String, val: Optional[float]) -> None: @@ -1365,26 +1368,26 @@ def deconstruct_betree_info_config(msg: logic.BeTreeInfo) -> List[Tuple[String, _maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.inline_data) _maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.element_count) _maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.tree_height) - return result + return builtin.list_sort(result) def deconstruct_export_csv_config(msg: transactions.ExportCSVConfig) -> List[Tuple[String, logic.Value]]: result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() - if msg.partition_size is not None and builtin.unwrap_option(msg.partition_size) != 0: + if msg.partition_size is not None: builtin.list_push(result, builtin.tuple("partition_size", _make_value_int64(builtin.unwrap_option(msg.partition_size)))) - if msg.compression is not None and builtin.unwrap_option(msg.compression) != "": + if msg.compression is not None: builtin.list_push(result, builtin.tuple("compression", _make_value_string(builtin.unwrap_option(msg.compression)))) if msg.syntax_header_row is not None: builtin.list_push(result, builtin.tuple("syntax_header_row", _make_value_boolean(builtin.unwrap_option(msg.syntax_header_row)))) - if msg.syntax_missing_string is not None and builtin.unwrap_option(msg.syntax_missing_string) != "": + if msg.syntax_missing_string is not None: builtin.list_push(result, builtin.tuple("syntax_missing_string", _make_value_string(builtin.unwrap_option(msg.syntax_missing_string)))) - if msg.syntax_delim is not None and builtin.unwrap_option(msg.syntax_delim) != ",": + if msg.syntax_delim is not None: builtin.list_push(result, builtin.tuple("syntax_delim", _make_value_string(builtin.unwrap_option(msg.syntax_delim)))) - if msg.syntax_quotechar is not None and builtin.unwrap_option(msg.syntax_quotechar) != '"': + if msg.syntax_quotechar is not None: builtin.list_push(result, builtin.tuple("syntax_quotechar", _make_value_string(builtin.unwrap_option(msg.syntax_quotechar)))) - if msg.syntax_escapechar is not None and builtin.unwrap_option(msg.syntax_escapechar) != "\\": + if msg.syntax_escapechar is not None: builtin.list_push(result, builtin.tuple("syntax_escapechar", _make_value_string(builtin.unwrap_option(msg.syntax_escapechar)))) - return result + return builtin.list_sort(result) def deconstruct_relation_id_string(msg: logic.RelationId) -> Optional[String]: diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index 5bbac2d6..7d00e9db 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -292,8 +292,10 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, # Compute leading whitespace for this element leading_ws: List[TargetExpr] = [] if isinstance(elem, LitTerminal): - # Non-sexp spacing before literals - if not is_sexp and stmts: + if is_sexp and i >= 2 and elem.name not in NO_LEADING_SPACE: + # Sexp spacing: newline before non-bracket-closing literals + stmts.append(Call(make_builtin('newline_io'), [])) + elif not is_sexp and stmts: cur_lit_name = elem.name suppress = False if prev_lit_name in NO_TRAILING_SPACE: diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index 80ac0031..0e60ebe6 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -113,6 +113,7 @@ def is_builtin(name: str) -> bool: register_builtin("list_concat", [ListType(T), ListType(T)], ListType(T)) register_builtin("list_push", [ListType(T), T], VOID) # Mutating push: list.append(item) / push!(list, item) register_builtin("list_slice", [ListType(T), INT64, INT64], ListType(T)) # list[start:end] +register_builtin("list_sort", [ListType(T)], ListType(T)) register_builtin("length", [ListType(T)], INT64) register_builtin("map", [FunctionType([T1], T2), ListType(T1)], ListType(T2)) register_builtin("append", [ListType(T), T], ListType(T)) # list.append(item) diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 03648427..4cc8f25d 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -26,7 +26,8 @@ from .target import ( TargetType, BaseType, MessageType, ListType, OptionType, TupleType, DictType, FunctionType, TargetExpr, Var, Lit, NamedFun, NewMessage, EnumValue, Call, Lambda, - Let, IfElse, Seq, ListExpr, GetElement, GetField, FunDef, OneOf, Assign, Return + Let, IfElse, Seq, ListExpr, GetElement, GetField, FunDef, OneOf, Assign, Return, + Foreach, ForeachEnumerated ) from .target_builtins import make_builtin from .target_utils import type_join, is_subtype @@ -650,6 +651,8 @@ def parse_deconstruct_action(text: str, lhs_type: TargetType, rhs: 'Rhs', "assert in deconstruct blocks is no longer supported. " "Use 'deconstruct if COND:' syntax instead.", line) + if isinstance(stmt, ast.Pass): + continue if isinstance(stmt, ast.Expr): side_effects.append(stmt.value) continue @@ -983,6 +986,34 @@ def _convert_stmt(stmt: ast.stmt, ctx: 'TypeContext', line: int, value = _convert_func_expr(stmt.value, ctx, line, local_vars) return Assign(Var(var_name, var_type), value) + elif isinstance(stmt, ast.For): + if stmt.orelse: + raise YaccGrammarError("for/else not supported", line) + collection = _convert_func_expr(stmt.iter, ctx, line, local_vars) + col_type = collection.target_type() + if isinstance(col_type, ListType): + elem_type = col_type.element_type + else: + elem_type = BaseType("Unknown") + if isinstance(stmt.target, ast.Tuple) and len(stmt.target.elts) == 2: + # for (i, x) in enumerate(collection) + idx_target, val_target = stmt.target.elts + if not isinstance(idx_target, ast.Name) or not isinstance(val_target, ast.Name): + raise YaccGrammarError("Only simple variable names supported in for loop", line) + idx_var = Var(idx_target.id, BaseType("Int64")) + val_var = Var(val_target.id, elem_type) + local_vars[idx_target.id] = idx_var.type + local_vars[val_target.id] = val_var.type + body = _convert_function_body(stmt.body, ctx, line, local_vars) + return ForeachEnumerated(idx_var, val_var, collection, body) + elif isinstance(stmt.target, ast.Name): + var = Var(stmt.target.id, elem_type) + local_vars[stmt.target.id] = elem_type + body = _convert_function_body(stmt.body, ctx, line, local_vars) + return Foreach(var, collection, body) + else: + raise YaccGrammarError("Only simple variable names supported in for loop", line) + elif isinstance(stmt, ast.Expr): # Expression statement (e.g., function call with side effects) return _convert_func_expr(stmt.value, ctx, line, local_vars) diff --git a/python-tools/src/meta/yacc_parser.py b/python-tools/src/meta/yacc_parser.py index 75d69a3a..352c98c7 100644 --- a/python-tools/src/meta/yacc_parser.py +++ b/python-tools/src/meta/yacc_parser.py @@ -348,6 +348,26 @@ def parse_rhs(text: str, ctx: TypeContext) -> Rhs: return Sequence(tuple(elements)) +def _strip_comment(line: str) -> str: + """Strip a #-comment from a line, respecting quoted strings.""" + in_single = False + in_double = False + i = 0 + while i < len(line): + c = line[i] + if c == '\\' and (in_single or in_double): + i += 2 + continue + if c == "'" and not in_double: + in_single = not in_single + elif c == '"' and not in_single: + in_double = not in_double + elif c == '#' and not in_single and not in_double: + return line[:i].rstrip() + i += 1 + return line + + def _get_indent(line: str) -> int: """Get the indentation level (number of leading spaces) of a line.""" return len(line) - len(line.lstrip()) @@ -725,6 +745,9 @@ def load_yacc_grammar( if '\t' in line: raise YaccGrammarError("Tabs are not allowed in grammar files. Semantic actions are sensitive to indentation.", line_num) + # Strip comments + lines = [_strip_comment(line) for line in lines] + # Parse directives ctx, ignored_completeness, rules_start = parse_directives(lines) diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index d35926cb..850d3acc 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -65,8 +65,10 @@ def _normalize_formulas(s: str) -> str: def _normalize_ws(s: str) -> str: - """Collapse all whitespace sequences to a single space.""" - return re.sub(r'\s+', ' ', s).strip() + """Collapse all whitespace sequences to a single space, strip spaces before closing brackets.""" + s = re.sub(r'\s+', ' ', s).strip() + s = re.sub(r'\s+([)\]}])', r'\1', s) + return s def _clear_debug_info(proto): From 0a011848a97b9e83aee99c96e9e2b442fc425ff7 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 19:38:14 +0100 Subject: [PATCH 15/25] fixed and/or short-circuiting --- python-tools/src/lqp/gen/parser.py | 478 ++++++++++-------- python-tools/src/lqp/gen/pretty.py | 478 ++++++++++-------- python-tools/src/meta/codegen_base.py | 50 ++ .../tests/meta/test_codegen_python.py | 86 ++++ 4 files changed, 684 insertions(+), 408 deletions(-) diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 1372cfed..19cd2fe4 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -278,160 +278,230 @@ def relation_id_to_uint128(self, msg): # --- Helper functions --- def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t945 = value.HasField('int_value') + else: + _t945 = False + if _t945: assert value is not None return int(value.int_value) return default def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t946 = value.HasField('int_value') + else: + _t946 = False + if _t946: assert value is not None return value.int_value return default def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: - assert value is not None - if (value is not None and value.HasField('float_value')): + + if value is not None: + assert value is not None + _t947 = value.HasField('float_value') + else: + _t947 = False + if _t947: assert value is not None return value.float_value return default def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t948 = value.HasField('string_value') + else: + _t948 = False + if _t948: assert value is not None return value.string_value return default def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: - assert value is not None - if (value is not None and value.HasField('boolean_value')): + + if value is not None: + assert value is not None + _t949 = value.HasField('boolean_value') + else: + _t949 = False + if _t949: assert value is not None return value.boolean_value return default def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t950 = value.HasField('string_value') + else: + _t950 = False + if _t950: assert value is not None return value.string_value.encode() return default def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: - assert value is not None - if (value is not None and value.HasField('uint128_value')): + + if value is not None: + assert value is not None + _t951 = value.HasField('uint128_value') + else: + _t951 = False + if _t951: assert value is not None return value.uint128_value return default def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t952 = value.HasField('string_value') + else: + _t952 = False + if _t952: assert value is not None return [value.string_value] return default def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t953 = value.HasField('int_value') + else: + _t953 = False + if _t953: assert value is not None return value.int_value return None def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: - assert value is not None - if (value is not None and value.HasField('float_value')): + + if value is not None: + assert value is not None + _t954 = value.HasField('float_value') + else: + _t954 = False + if _t954: assert value is not None return value.float_value return None def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t955 = value.HasField('string_value') + else: + _t955 = False + if _t955: assert value is not None return value.string_value return None def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t956 = value.HasField('string_value') + else: + _t956 = False + if _t956: assert value is not None return value.string_value.encode() return None def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: - assert value is not None - if (value is not None and value.HasField('uint128_value')): + + if value is not None: + assert value is not None + _t957 = value.HasField('uint128_value') + else: + _t957 = False + if _t957: assert value is not None return value.uint128_value return None def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t958 = value.HasField('string_value') + else: + _t958 = False + if _t958: assert value is not None return [value.string_value] return None def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t945 = self._extract_value_int32(config.get('csv_header_row'), 1) - header_row = _t945 - _t946 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t946 - _t947 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t947 - _t948 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t948 - _t949 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t949 - _t950 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t950 - _t951 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t951 - _t952 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t952 - _t953 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t953 - _t954 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t954 - _t955 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t955 - _t956 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t956 + _t959 = self._extract_value_int32(config.get('csv_header_row'), 1) + header_row = _t959 + _t960 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t960 + _t961 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t961 + _t962 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t962 + _t963 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t963 + _t964 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t964 + _t965 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t965 + _t966 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t966 + _t967 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t967 + _t968 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t968 + _t969 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t969 + _t970 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t970 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t957 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t957 - _t958 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t958 - _t959 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t959 - _t960 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t960 - _t961 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t961 - _t962 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t962 - _t963 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t963 - _t964 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t964 - _t965 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t965 - _t966 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t966 - _t967 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t967 + _t971 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t971 + _t972 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t972 + _t973 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t973 + _t974 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t974 + _t975 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t975 + _t976 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t976 + _t977 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t977 + _t978 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t978 + _t979 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t979 + _t980 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t980 + _t981 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t981 def default_configure(self) -> transactions_pb2.Configure: - _t968 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t968 - _t969 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t969 + _t982 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t982 + _t983 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t983 def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -448,55 +518,55 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t970 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t970 - _t971 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t971 - _t972 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t972 + _t984 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t984 + _t985 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t985 + _t986 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t986 def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t973 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t973 - _t974 = self._extract_value_string(config.get('compression'), '') - compression = _t974 - _t975 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t975 - _t976 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t976 - _t977 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t977 - _t978 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t978 - _t979 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t979 - _t980 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t980 + _t987 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t987 + _t988 = self._extract_value_string(config.get('compression'), '') + compression = _t988 + _t989 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t989 + _t990 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t990 + _t991 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t991 + _t992 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t992 + _t993 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t993 + _t994 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t994 def _make_value_int32(self, v: int) -> logic_pb2.Value: - _t981 = logic_pb2.Value(int_value=int(v)) - return _t981 + _t995 = logic_pb2.Value(int_value=int(v)) + return _t995 def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t982 = logic_pb2.Value(int_value=v) - return _t982 + _t996 = logic_pb2.Value(int_value=v) + return _t996 def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t983 = logic_pb2.Value(float_value=v) - return _t983 + _t997 = logic_pb2.Value(float_value=v) + return _t997 def _make_value_string(self, v: str) -> logic_pb2.Value: - _t984 = logic_pb2.Value(string_value=v) - return _t984 + _t998 = logic_pb2.Value(string_value=v) + return _t998 def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t985 = logic_pb2.Value(boolean_value=v) - return _t985 + _t999 = logic_pb2.Value(boolean_value=v) + return _t999 def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t986 = logic_pb2.Value(uint128_value=v) - return _t986 + _t1000 = logic_pb2.Value(uint128_value=v) + return _t1000 def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: @@ -509,120 +579,120 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t988 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t988,)) - _t987 = None + _t1002 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1002,)) + _t1001 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t990 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t990,)) - _t989 = None + _t1004 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1004,)) + _t1003 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t992 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t992,)) - _t991 = None + _t1006 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1006,)) + _t1005 = None else: - _t991 = None - _t989 = _t991 - _t987 = _t989 - _t993 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t993,)) + _t1005 = None + _t1003 = _t1005 + _t1001 = _t1003 + _t1007 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1007,)) return sorted(result) def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t994 = self._make_value_int32(msg.header_row) - result.append(('csv_header_row', _t994,)) - _t995 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t995,)) - _t996 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t996,)) - _t997 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t997,)) - _t998 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t998,)) - _t999 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t999,)) - _t1000 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1000,)) + _t1008 = self._make_value_int32(msg.header_row) + result.append(('csv_header_row', _t1008,)) + _t1009 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1009,)) + _t1010 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1010,)) + _t1011 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1011,)) + _t1012 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1012,)) + _t1013 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1013,)) + _t1014 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1014,)) for missing_string in msg.missing_strings: - _t1001 = self._make_value_string(missing_string) - result.append(('csv_missing_strings', _t1001,)) - _t1002 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1002,)) - _t1003 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1003,)) - _t1004 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1004,)) + _t1015 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1015,)) + _t1016 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1016,)) + _t1017 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1017,)) + _t1018 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1018,)) return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1006 = self._make_value_float64(val) - result.append((key, _t1006,)) - _t1005 = None + _t1020 = self._make_value_float64(val) + result.append((key, _t1020,)) + _t1019 = None else: - _t1005 = None + _t1019 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1008 = self._make_value_int64(val) - result.append((key, _t1008,)) - _t1007 = None + _t1022 = self._make_value_int64(val) + result.append((key, _t1022,)) + _t1021 = None else: - _t1007 = None + _t1021 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1010 = self._make_value_uint128(val) - result.append((key, _t1010,)) - _t1009 = None + _t1024 = self._make_value_uint128(val) + result.append((key, _t1024,)) + _t1023 = None else: - _t1009 = None + _t1023 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: assert val is not None - _t1012 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1012,)) - _t1011 = None + _t1026 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1026,)) + _t1025 = None else: - _t1011 = None + _t1025 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1013 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1014 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1015 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1016 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1027 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1028 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1029 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1030 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1018 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1017 = _t1018 + _t1032 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1031 = _t1032 else: - _t1017 = None + _t1031 = None if msg.relation_locator.HasField('inline_data'): - _t1020 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1019 = _t1020 + _t1034 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1033 = _t1034 else: - _t1019 = None - _t1021 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1022 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1033 = None + _t1035 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1036 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: @@ -630,59 +700,59 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - if msg.partition_size is not None: assert msg.partition_size is not None - _t1024 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1024,)) - _t1023 = None + _t1038 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1038,)) + _t1037 = None else: - _t1023 = None + _t1037 = None if msg.compression is not None: assert msg.compression is not None - _t1026 = self._make_value_string(msg.compression) - result.append(('compression', _t1026,)) - _t1025 = None + _t1040 = self._make_value_string(msg.compression) + result.append(('compression', _t1040,)) + _t1039 = None else: - _t1025 = None + _t1039 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1028 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1028,)) - _t1027 = None + _t1042 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1042,)) + _t1041 = None else: - _t1027 = None + _t1041 = None if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1030 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1030,)) - _t1029 = None + _t1044 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1044,)) + _t1043 = None else: - _t1029 = None + _t1043 = None if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1032 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1032,)) - _t1031 = None + _t1046 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1046,)) + _t1045 = None else: - _t1031 = None + _t1045 = None if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1034 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1034,)) - _t1033 = None + _t1048 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1048,)) + _t1047 = None else: - _t1033 = None + _t1047 = None if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1036 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1036,)) - _t1035 = None + _t1050 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1050,)) + _t1049 = None else: - _t1035 = None + _t1049 = None return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py index ca29e634..475a7016 100644 --- a/python-tools/src/lqp/gen/pretty.py +++ b/python-tools/src/lqp/gen/pretty.py @@ -118,160 +118,230 @@ def format_string_value(self, s: str) -> str: # --- Helper functions --- def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t1290 = value.HasField('int_value') + else: + _t1290 = False + if _t1290: assert value is not None return int(value.int_value) return default def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t1291 = value.HasField('int_value') + else: + _t1291 = False + if _t1291: assert value is not None return value.int_value return default def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: - assert value is not None - if (value is not None and value.HasField('float_value')): + + if value is not None: + assert value is not None + _t1292 = value.HasField('float_value') + else: + _t1292 = False + if _t1292: assert value is not None return value.float_value return default def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1293 = value.HasField('string_value') + else: + _t1293 = False + if _t1293: assert value is not None return value.string_value return default def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: - assert value is not None - if (value is not None and value.HasField('boolean_value')): + + if value is not None: + assert value is not None + _t1294 = value.HasField('boolean_value') + else: + _t1294 = False + if _t1294: assert value is not None return value.boolean_value return default def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1295 = value.HasField('string_value') + else: + _t1295 = False + if _t1295: assert value is not None return value.string_value.encode() return default def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: - assert value is not None - if (value is not None and value.HasField('uint128_value')): + + if value is not None: + assert value is not None + _t1296 = value.HasField('uint128_value') + else: + _t1296 = False + if _t1296: assert value is not None return value.uint128_value return default def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1297 = value.HasField('string_value') + else: + _t1297 = False + if _t1297: assert value is not None return [value.string_value] return default def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: - assert value is not None - if (value is not None and value.HasField('int_value')): + + if value is not None: + assert value is not None + _t1298 = value.HasField('int_value') + else: + _t1298 = False + if _t1298: assert value is not None return value.int_value return None def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: - assert value is not None - if (value is not None and value.HasField('float_value')): + + if value is not None: + assert value is not None + _t1299 = value.HasField('float_value') + else: + _t1299 = False + if _t1299: assert value is not None return value.float_value return None def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1300 = value.HasField('string_value') + else: + _t1300 = False + if _t1300: assert value is not None return value.string_value return None def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1301 = value.HasField('string_value') + else: + _t1301 = False + if _t1301: assert value is not None return value.string_value.encode() return None def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: - assert value is not None - if (value is not None and value.HasField('uint128_value')): + + if value is not None: + assert value is not None + _t1302 = value.HasField('uint128_value') + else: + _t1302 = False + if _t1302: assert value is not None return value.uint128_value return None def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: - assert value is not None - if (value is not None and value.HasField('string_value')): + + if value is not None: + assert value is not None + _t1303 = value.HasField('string_value') + else: + _t1303 = False + if _t1303: assert value is not None return [value.string_value] return None def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t1290 = self._extract_value_int32(config.get('csv_header_row'), 1) - header_row = _t1290 - _t1291 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t1291 - _t1292 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t1292 - _t1293 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t1293 - _t1294 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t1294 - _t1295 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t1295 - _t1296 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t1296 - _t1297 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t1297 - _t1298 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t1298 - _t1299 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t1299 - _t1300 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t1300 - _t1301 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1301 + _t1304 = self._extract_value_int32(config.get('csv_header_row'), 1) + header_row = _t1304 + _t1305 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1305 + _t1306 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1306 + _t1307 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1307 + _t1308 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1308 + _t1309 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1309 + _t1310 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1310 + _t1311 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1311 + _t1312 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1312 + _t1313 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1313 + _t1314 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1314 + _t1315 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1315 def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t1302 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t1302 - _t1303 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t1303 - _t1304 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t1304 - _t1305 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t1305 - _t1306 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1306 - _t1307 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t1307 - _t1308 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t1308 - _t1309 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t1309 - _t1310 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t1310 - _t1311 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1311 - _t1312 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1312 + _t1316 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1316 + _t1317 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1317 + _t1318 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1318 + _t1319 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1319 + _t1320 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1320 + _t1321 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1321 + _t1322 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1322 + _t1323 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1323 + _t1324 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1324 + _t1325 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1325 + _t1326 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1326 def default_configure(self) -> transactions_pb2.Configure: - _t1313 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1313 - _t1314 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1314 + _t1327 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1327 + _t1328 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1328 def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -288,55 +358,55 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1315 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1315 - _t1316 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t1316 - _t1317 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1317 + _t1329 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1329 + _t1330 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1330 + _t1331 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1331 def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t1318 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t1318 - _t1319 = self._extract_value_string(config.get('compression'), '') - compression = _t1319 - _t1320 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t1320 - _t1321 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t1321 - _t1322 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t1322 - _t1323 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t1323 - _t1324 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t1324 - _t1325 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1325 + _t1332 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1332 + _t1333 = self._extract_value_string(config.get('compression'), '') + compression = _t1333 + _t1334 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1334 + _t1335 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1335 + _t1336 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1336 + _t1337 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1337 + _t1338 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1338 + _t1339 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1339 def _make_value_int32(self, v: int) -> logic_pb2.Value: - _t1326 = logic_pb2.Value(int_value=int(v)) - return _t1326 + _t1340 = logic_pb2.Value(int_value=int(v)) + return _t1340 def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t1327 = logic_pb2.Value(int_value=v) - return _t1327 + _t1341 = logic_pb2.Value(int_value=v) + return _t1341 def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t1328 = logic_pb2.Value(float_value=v) - return _t1328 + _t1342 = logic_pb2.Value(float_value=v) + return _t1342 def _make_value_string(self, v: str) -> logic_pb2.Value: - _t1329 = logic_pb2.Value(string_value=v) - return _t1329 + _t1343 = logic_pb2.Value(string_value=v) + return _t1343 def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t1330 = logic_pb2.Value(boolean_value=v) - return _t1330 + _t1344 = logic_pb2.Value(boolean_value=v) + return _t1344 def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1331 = logic_pb2.Value(uint128_value=v) - return _t1331 + _t1345 = logic_pb2.Value(uint128_value=v) + return _t1345 def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: @@ -349,120 +419,120 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1333 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1333,)) - _t1332 = None + _t1347 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1347,)) + _t1346 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1335 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1335,)) - _t1334 = None + _t1349 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1349,)) + _t1348 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1337 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1337,)) - _t1336 = None + _t1351 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1351,)) + _t1350 = None else: - _t1336 = None - _t1334 = _t1336 - _t1332 = _t1334 - _t1338 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1338,)) + _t1350 = None + _t1348 = _t1350 + _t1346 = _t1348 + _t1352 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1352,)) return sorted(result) def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1339 = self._make_value_int32(msg.header_row) - result.append(('csv_header_row', _t1339,)) - _t1340 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1340,)) - _t1341 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1341,)) - _t1342 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1342,)) - _t1343 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1343,)) - _t1344 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1344,)) - _t1345 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1345,)) + _t1353 = self._make_value_int32(msg.header_row) + result.append(('csv_header_row', _t1353,)) + _t1354 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1354,)) + _t1355 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1355,)) + _t1356 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1356,)) + _t1357 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1357,)) + _t1358 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1358,)) + _t1359 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1359,)) for missing_string in msg.missing_strings: - _t1346 = self._make_value_string(missing_string) - result.append(('csv_missing_strings', _t1346,)) - _t1347 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1347,)) - _t1348 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1348,)) - _t1349 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1349,)) + _t1360 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1360,)) + _t1361 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1361,)) + _t1362 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1362,)) + _t1363 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1363,)) return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1351 = self._make_value_float64(val) - result.append((key, _t1351,)) - _t1350 = None + _t1365 = self._make_value_float64(val) + result.append((key, _t1365,)) + _t1364 = None else: - _t1350 = None + _t1364 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1353 = self._make_value_int64(val) - result.append((key, _t1353,)) - _t1352 = None + _t1367 = self._make_value_int64(val) + result.append((key, _t1367,)) + _t1366 = None else: - _t1352 = None + _t1366 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1355 = self._make_value_uint128(val) - result.append((key, _t1355,)) - _t1354 = None + _t1369 = self._make_value_uint128(val) + result.append((key, _t1369,)) + _t1368 = None else: - _t1354 = None + _t1368 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: assert val is not None - _t1357 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1357,)) - _t1356 = None + _t1371 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1371,)) + _t1370 = None else: - _t1356 = None + _t1370 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1358 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1359 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1360 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1361 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1372 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1373 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1374 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1375 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1363 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1362 = _t1363 + _t1377 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1376 = _t1377 else: - _t1362 = None + _t1376 = None if msg.relation_locator.HasField('inline_data'): - _t1365 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1364 = _t1365 + _t1379 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1378 = _t1379 else: - _t1364 = None - _t1366 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1367 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1378 = None + _t1380 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1381 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: @@ -470,59 +540,59 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - if msg.partition_size is not None: assert msg.partition_size is not None - _t1369 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1369,)) - _t1368 = None + _t1383 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1383,)) + _t1382 = None else: - _t1368 = None + _t1382 = None if msg.compression is not None: assert msg.compression is not None - _t1371 = self._make_value_string(msg.compression) - result.append(('compression', _t1371,)) - _t1370 = None + _t1385 = self._make_value_string(msg.compression) + result.append(('compression', _t1385,)) + _t1384 = None else: - _t1370 = None + _t1384 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1373 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1373,)) - _t1372 = None + _t1387 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1387,)) + _t1386 = None else: - _t1372 = None + _t1386 = None if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1375 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1375,)) - _t1374 = None + _t1389 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1389,)) + _t1388 = None else: - _t1374 = None + _t1388 = None if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1377 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1377,)) - _t1376 = None + _t1391 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1391,)) + _t1390 = None else: - _t1376 = None + _t1390 = None if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1379 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1379,)) - _t1378 = None + _t1393 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1393,)) + _t1392 = None else: - _t1378 = None + _t1392 = None if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1381 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1381,)) - _t1380 = None + _t1395 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1395,)) + _t1394 = None else: - _t1380 = None + _t1394 = None return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: diff --git a/python-tools/src/meta/codegen_base.py b/python-tools/src/meta/codegen_base.py index 820c1e79..efe9372b 100644 --- a/python-tools/src/meta/codegen_base.py +++ b/python-tools/src/meta/codegen_base.py @@ -476,6 +476,11 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ # First, check for builtin special cases if isinstance(expr.func, Builtin): + # Short-circuit builtins: evaluate RHS lazily to preserve semantics + if expr.func.name in ('and', 'or') and len(expr.args) == 2: + return self._generate_short_circuit_call( + expr.func.name, expr.args[0], expr.args[1], lines, indent) + # Evaluate arguments (they should not contain return statements) args: List[str] = [] for arg in expr.args: @@ -510,6 +515,51 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ lines.append(f"{indent}{self.gen_assignment(tmp, f'{f}({args_code})', is_declaration=True)}") return tmp + def _generate_short_circuit_call(self, op: str, left: TargetExpr, right: TargetExpr, + lines: List[str], indent: str) -> str: + """Generate and/or with short-circuit semantics. + + Evaluates the LHS normally, then checks whether the RHS has + side-effects. If not, uses the language template (e.g., `a and b`). + If the RHS does have side-effects, emits an if-else so those + side-effects only execute when the LHS permits. + """ + left_code = self.generate_lines(left, lines, indent) + assert left_code is not None, "Short-circuit LHS should not contain a return" + + body_indent = indent + self.indent_str + rhs_lines: List[str] = [] + right_code = self.generate_lines(right, rhs_lines, body_indent) + assert right_code is not None, "Short-circuit RHS should not contain a return" + + if not rhs_lines: + # No side-effects in RHS — use the language template + result = self.gen_builtin_call(op, [left_code, right_code], lines, indent) + if result is not None and result.value is not None: + for stmt in result.statements: + lines.append(f"{indent}{stmt}") + return result.value + + # RHS has side-effects — guard them with an if-else + tmp = gensym() + lines.append(f"{indent}{self.gen_var_declaration(tmp)}") + if op == 'and': + lines.append(f"{indent}{self.gen_if_start(left_code)}") + lines.extend(rhs_lines) + lines.append(f"{body_indent}{self.gen_assignment(tmp, right_code)}") + lines.append(f"{indent}{self.gen_else()}") + lines.append(f"{body_indent}{self.gen_assignment(tmp, self.gen_literal(False))}") + else: + lines.append(f"{indent}{self.gen_if_start(left_code)}") + lines.append(f"{body_indent}{self.gen_assignment(tmp, self.gen_literal(True))}") + lines.append(f"{indent}{self.gen_else()}") + lines.extend(rhs_lines) + lines.append(f"{body_indent}{self.gen_assignment(tmp, right_code)}") + end = self.gen_if_end() + if end: + lines.append(f"{indent}{end}") + return tmp + def _generate_newmessage(self, expr: NewMessage, lines: List[str], indent: str) -> str: """Generate code for a NewMessage expression. diff --git a/python-tools/tests/meta/test_codegen_python.py b/python-tools/tests/meta/test_codegen_python.py index 2638c3ea..67879f4b 100644 --- a/python-tools/tests/meta/test_codegen_python.py +++ b/python-tools/tests/meta/test_codegen_python.py @@ -524,6 +524,92 @@ def test_python_helper_function_calling_another(): assert "Parser.helper(x)" in code +def test_python_and_short_circuit_with_side_effects(): + """Test that 'and' preserves short-circuit semantics when RHS has side-effects. + + When the RHS of 'and' contains a builtin like unwrap_option that emits + side-effect statements (e.g., assert), those side-effects must not be + hoisted above the 'and' — they should only execute when the LHS is truthy. + """ + gen = PythonCodeGenerator() + reset_gensym() + lines = [] + + # and(x is not None, unwrap_option(x) == 42) + # unwrap_option emits `assert x is not None` as a side-effect. + # That assert must NOT execute when x is None. + expr = Call(make_builtin("and"), [ + Call(make_builtin("is_some"), [Var("x", OptionType(_int_type))]), + Call(make_builtin("equal"), [ + Call(make_builtin("unwrap_option"), [Var("x", OptionType(_int_type))]), + Lit(42), + ]), + ]) + result = gen.generate_lines(expr, lines, "") + code = "\n".join(lines) + + # The assert from unwrap_option must be inside the if body, not at the top + assert result is not None + assert "assert" not in code.split("if ")[0], \ + f"assert was hoisted above the if guard:\n{code}" + assert "if " in code, f"Expected if-else for short-circuit, got:\n{code}" + + +def test_python_or_short_circuit_with_side_effects(): + """Test that 'or' preserves short-circuit semantics when RHS has side-effects.""" + gen = PythonCodeGenerator() + reset_gensym() + lines = [] + + # or(x is None, unwrap_option(x) == 42) + # unwrap_option side-effects must only execute when x is NOT None. + expr = Call(make_builtin("or"), [ + Call(make_builtin("is_none"), [Var("x", OptionType(_int_type))]), + Call(make_builtin("equal"), [ + Call(make_builtin("unwrap_option"), [Var("x", OptionType(_int_type))]), + Lit(42), + ]), + ]) + result = gen.generate_lines(expr, lines, "") + code = "\n".join(lines) + + assert result is not None + assert "assert" not in code.split("if ")[0], \ + f"assert was hoisted above the if guard:\n{code}" + assert "if " in code, f"Expected if-else for short-circuit, got:\n{code}" + + +def test_python_and_without_side_effects_uses_template(): + """Test that 'and' without side-effects uses the simple template.""" + gen = PythonCodeGenerator() + reset_gensym() + lines = [] + + # and(a, b) with no side-effects should produce (a and b) + expr = Call(make_builtin("and"), [ + Var("a", _bool_type), + Var("b", _bool_type), + ]) + result = gen.generate_lines(expr, lines, "") + assert result == "(a and b)" + assert len(lines) == 0 + + +def test_python_or_without_side_effects_uses_template(): + """Test that 'or' without side-effects uses the simple template.""" + gen = PythonCodeGenerator() + reset_gensym() + lines = [] + + expr = Call(make_builtin("or"), [ + Var("a", _bool_type), + Var("b", _bool_type), + ]) + result = gen.generate_lines(expr, lines, "") + assert result == "(a or b)" + assert len(lines) == 0 + + if __name__ == "__main__": test_python_keyword_escaping() test_python_call_generation() From c1217fbef5440cd0de085ded02bd81fc256487f3 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 19:43:09 +0100 Subject: [PATCH 16/25] fix test --- python-tools/tests/meta/test_codegen_python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-tools/tests/meta/test_codegen_python.py b/python-tools/tests/meta/test_codegen_python.py index 67879f4b..705cf0d8 100644 --- a/python-tools/tests/meta/test_codegen_python.py +++ b/python-tools/tests/meta/test_codegen_python.py @@ -521,7 +521,7 @@ def test_python_helper_function_calling_another(): ) code = gen.generate_def(func) assert "def wrapper(x: int) -> int:" in code - assert "Parser.helper(x)" in code + assert "self.helper(x)" in code def test_python_and_short_circuit_with_side_effects(): From 3b3ce182fddf553263772e14f04f8f95dc40d3ca Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 11 Feb 2026 19:54:54 +0100 Subject: [PATCH 17/25] get more tests passing --- go/src/parser.go | 342 ++++++++---------- julia/LQPParser/src/parser.jl | 310 +++++++--------- python-tools/src/lqp/gen/parser.py | 158 ++++---- python-tools/src/lqp/gen/pretty.py | 176 ++++----- python-tools/src/meta/grammar.y | 6 +- python-tools/src/meta/pretty_gen.py | 9 +- .../tests/test_generated_pretty_printer.py | 11 + 7 files changed, 492 insertions(+), 520 deletions(-) diff --git a/go/src/parser.go b/go/src/parser.go index 4d7cfe49..57ce61b2 100644 --- a/go/src/parser.go +++ b/go/src/parser.go @@ -607,6 +607,13 @@ func toPascalCase(s string) string { // --- Helper functions --- +func (p *Parser) _extract_value_int32(value *pb.Value, default_ int64) int64 { + if (value != nil && hasProtoField(value, "int_value")) { + return int32(value.GetIntValue()) + } + return default_ +} + func (p *Parser) _extract_value_int64(value *pb.Value, default_ int64) int64 { if (value != nil && hasProtoField(value, "int_value")) { return value.GetIntValue() @@ -700,7 +707,7 @@ func (p *Parser) _try_extract_value_string_list(value *pb.Value) []string { func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig { config := dictFromList(config_dict) - _t956 := p._extract_value_int64(dictGetValue(config, "csv_header_row"), 1) + _t956 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) header_row := _t956 _t957 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) skip := _t957 @@ -722,7 +729,7 @@ func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig encoding := _t965 _t966 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") compression := _t966 - _t967 := &pb.CSVConfig{HeaderRow: int32(header_row), Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} + _t967 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} return _t967 } @@ -811,36 +818,43 @@ func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, c return _t991 } -func (p *Parser) _make_value_int64(v int64) *pb.Value { - _t992 := &pb.Value{} - _t992.Value = &pb.Value_IntValue{IntValue: v} - return _t992 -} - -func (p *Parser) _make_value_float64(v float64) *pb.Value { +func (p *Parser) _make_value_int32(v int64) *pb.Value { + _t992 := p.int32_to_int64(v) _t993 := &pb.Value{} - _t993.Value = &pb.Value_FloatValue{FloatValue: v} + _t993.Value = &pb.Value_IntValue{IntValue: _t992} return _t993 } -func (p *Parser) _make_value_string(v string) *pb.Value { +func (p *Parser) _make_value_int64(v int64) *pb.Value { _t994 := &pb.Value{} - _t994.Value = &pb.Value_StringValue{StringValue: v} + _t994.Value = &pb.Value_IntValue{IntValue: v} return _t994 } -func (p *Parser) _make_value_boolean(v bool) *pb.Value { +func (p *Parser) _make_value_float64(v float64) *pb.Value { _t995 := &pb.Value{} - _t995.Value = &pb.Value_BooleanValue{BooleanValue: v} + _t995.Value = &pb.Value_FloatValue{FloatValue: v} return _t995 } -func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { +func (p *Parser) _make_value_string(v string) *pb.Value { _t996 := &pb.Value{} - _t996.Value = &pb.Value_Uint128Value{Uint128Value: v} + _t996.Value = &pb.Value_StringValue{StringValue: v} return _t996 } +func (p *Parser) _make_value_boolean(v bool) *pb.Value { + _t997 := &pb.Value{} + _t997.Value = &pb.Value_BooleanValue{BooleanValue: v} + return _t997 +} + +func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { + _t998 := &pb.Value{} + _t998.Value = &pb.Value_Uint128Value{Uint128Value: v} + return _t998 +} + func (p *Parser) is_default_configure(cfg *pb.Configure) bool { if cfg.GetSemanticsVersion() != 0 { return false @@ -853,218 +867,182 @@ func (p *Parser) is_default_configure(cfg *pb.Configure) bool { func (p *Parser) deconstruct_configure(msg *pb.Configure) [][]interface{} { result := [][]interface{}{} - var _t997 interface{} + var _t999 interface{} if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_AUTO { - _t998 := p._make_value_string("auto") - result = append(result, []interface{}{"ivm.maintenance_level", _t998}) - _t997 = nil + _t1000 := p._make_value_string("auto") + result = append(result, []interface{}{"ivm.maintenance_level", _t1000}) + _t999 = nil } else { - var _t999 interface{} + var _t1001 interface{} if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_ALL { - _t1000 := p._make_value_string("all") - result = append(result, []interface{}{"ivm.maintenance_level", _t1000}) - _t999 = nil + _t1002 := p._make_value_string("all") + result = append(result, []interface{}{"ivm.maintenance_level", _t1002}) + _t1001 = nil } else { - var _t1001 interface{} + var _t1003 interface{} if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { - _t1002 := p._make_value_string("off") - result = append(result, []interface{}{"ivm.maintenance_level", _t1002}) - _t1001 = nil + _t1004 := p._make_value_string("off") + result = append(result, []interface{}{"ivm.maintenance_level", _t1004}) + _t1003 = nil } - _t999 = _t1001 + _t1001 = _t1003 } - _t997 = _t999 + _t999 = _t1001 } - _t1003 := p._make_value_int64(msg.GetSemanticsVersion()) - result = append(result, []interface{}{"semantics_version", _t1003}) - return result + _t1005 := p._make_value_int64(msg.GetSemanticsVersion()) + result = append(result, []interface{}{"semantics_version", _t1005}) + return listSort(result) } func (p *Parser) deconstruct_csv_config(msg *pb.CSVConfig) [][]interface{} { result := [][]interface{}{} - var _t1004 interface{} - if msg.GetHeaderRow() != 1 { - _t1005 := p.int32_to_int64(msg.GetHeaderRow()) - _t1006 := p._make_value_int64(_t1005) - result = append(result, []interface{}{"csv_header_row", _t1006}) - _t1004 = nil - } - var _t1007 interface{} - if msg.GetSkip() != 0 { - _t1008 := p._make_value_int64(msg.GetSkip()) - result = append(result, []interface{}{"csv_skip", _t1008}) - _t1007 = nil - } - var _t1009 interface{} - if msg.GetNewLine() != "" { - _t1010 := p._make_value_string(msg.GetNewLine()) - result = append(result, []interface{}{"csv_new_line", _t1010}) - _t1009 = nil - } - var _t1011 interface{} - if msg.GetDelimiter() != "," { - _t1012 := p._make_value_string(msg.GetDelimiter()) - result = append(result, []interface{}{"csv_delimiter", _t1012}) - _t1011 = nil - } + _t1006 := p._make_value_int32(msg.GetHeaderRow()) + result = append(result, []interface{}{"csv_header_row", _t1006}) + _t1007 := p._make_value_int64(msg.GetSkip()) + result = append(result, []interface{}{"csv_skip", _t1007}) + var _t1008 interface{} + if (msg.GetNewLine() != nil && msg.GetNewLine() != "") { + _t1009 := p._make_value_string(msg.GetNewLine()) + result = append(result, []interface{}{"csv_new_line", _t1009}) + _t1008 = nil + } + _t1010 := p._make_value_string(msg.GetDelimiter()) + result = append(result, []interface{}{"csv_delimiter", _t1010}) + _t1011 := p._make_value_string(msg.GetQuotechar()) + result = append(result, []interface{}{"csv_quotechar", _t1011}) + _t1012 := p._make_value_string(msg.GetEscapechar()) + result = append(result, []interface{}{"csv_escapechar", _t1012}) var _t1013 interface{} - if msg.GetQuotechar() != "\"" { - _t1014 := p._make_value_string(msg.GetQuotechar()) - result = append(result, []interface{}{"csv_quotechar", _t1014}) + if (msg.GetComment() != nil && msg.GetComment() != "") { + _t1014 := p._make_value_string(msg.GetComment()) + result = append(result, []interface{}{"csv_comment", _t1014}) _t1013 = nil } - var _t1015 interface{} - if msg.GetEscapechar() != "\"" { - _t1016 := p._make_value_string(msg.GetEscapechar()) - result = append(result, []interface{}{"csv_escapechar", _t1016}) - _t1015 = nil - } - var _t1017 interface{} - if msg.GetComment() != "" { - _t1018 := p._make_value_string(msg.GetComment()) - result = append(result, []interface{}{"csv_comment", _t1018}) - _t1017 = nil - } - _t1019 := p.is_empty(msg.GetMissingStrings()) - var _t1020 interface{} - if !_t1019 { - _t1021 := p._make_value_string(msg.GetMissingStrings()[0].(string)) - result = append(result, []interface{}{"csv_missing_strings", _t1021}) - _t1020 = nil - } - var _t1022 interface{} - if msg.GetDecimalSeparator() != "." { - _t1023 := p._make_value_string(msg.GetDecimalSeparator()) - result = append(result, []interface{}{"csv_decimal_separator", _t1023}) - _t1022 = nil - } - var _t1024 interface{} - if msg.GetEncoding() != "utf-8" { - _t1025 := p._make_value_string(msg.GetEncoding()) - result = append(result, []interface{}{"csv_encoding", _t1025}) - _t1024 = nil - } - var _t1026 interface{} - if msg.GetCompression() != "auto" { - _t1027 := p._make_value_string(msg.GetCompression()) - result = append(result, []interface{}{"csv_compression", _t1027}) - _t1026 = nil + for _, missing_string := range msg.GetMissingStrings() { + _t1015 := p._make_value_string(missing_string) + result = append(result, []interface{}{"csv_missing_strings", _t1015}) } - return result + _t1016 := p._make_value_string(msg.GetDecimalSeparator()) + result = append(result, []interface{}{"csv_decimal_separator", _t1016}) + _t1017 := p._make_value_string(msg.GetEncoding()) + result = append(result, []interface{}{"csv_encoding", _t1017}) + _t1018 := p._make_value_string(msg.GetCompression()) + result = append(result, []interface{}{"csv_compression", _t1018}) + return listSort(result) } func (p *Parser) _maybe_push_float64(result [][]interface{}, key string, val *float64) interface{} { - var _t1028 interface{} + var _t1019 interface{} if val != nil { - _t1029 := p._make_value_float64(*val) - result = append(result, []interface{}{key, _t1029}) - _t1028 = nil + _t1020 := p._make_value_float64(*val) + result = append(result, []interface{}{key, _t1020}) + _t1019 = nil } return nil } func (p *Parser) _maybe_push_int64(result [][]interface{}, key string, val *int64) interface{} { - var _t1030 interface{} + var _t1021 interface{} if val != nil { - _t1031 := p._make_value_int64(*val) - result = append(result, []interface{}{key, _t1031}) - _t1030 = nil + _t1022 := p._make_value_int64(*val) + result = append(result, []interface{}{key, _t1022}) + _t1021 = nil } return nil } func (p *Parser) _maybe_push_uint128(result [][]interface{}, key string, val *pb.UInt128Value) interface{} { - var _t1032 interface{} + var _t1023 interface{} if val != nil { - _t1033 := p._make_value_uint128(val) - result = append(result, []interface{}{key, _t1033}) - _t1032 = nil + _t1024 := p._make_value_uint128(val) + result = append(result, []interface{}{key, _t1024}) + _t1023 = nil } return nil } func (p *Parser) _maybe_push_bytes_as_string(result [][]interface{}, key string, val []byte) interface{} { - var _t1034 interface{} + var _t1025 interface{} if val != nil { - _t1035 := p.decode_string(val) - _t1036 := p._make_value_string(_t1035) - result = append(result, []interface{}{key, _t1036}) - _t1034 = nil + _t1026 := p.decode_string(val) + _t1027 := p._make_value_string(_t1026) + result = append(result, []interface{}{key, _t1027}) + _t1025 = nil } return nil } func (p *Parser) deconstruct_betree_info_config(msg *pb.BeTreeInfo) [][]interface{} { result := [][]interface{}{} - _t1037 := p._maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.GetEpsilon()) - _t1038 := p._maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.GetMaxPivots()) - _t1039 := p._maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.GetMaxDeltas()) - _t1040 := p._maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.GetMaxLeaf()) - var _t1041 interface{} + _t1028 := p._maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.GetEpsilon()) + _t1029 := p._maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.GetMaxPivots()) + _t1030 := p._maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.GetMaxDeltas()) + _t1031 := p._maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.GetMaxLeaf()) + var _t1032 interface{} if hasProtoField(msg.GetRelationLocator(), "root_pageid") { - _t1042 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.GetRootPageid()) - _t1041 = _t1042 + _t1033 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.GetRootPageid()) + _t1032 = _t1033 } - var _t1043 interface{} + var _t1034 interface{} if hasProtoField(msg.GetRelationLocator(), "inline_data") { - _t1044 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.GetInlineData()) - _t1043 = _t1044 + _t1035 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.GetInlineData()) + _t1034 = _t1035 } - _t1045 := p._maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.GetElementCount()) - _t1046 := p._maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.GetTreeHeight()) - return result + _t1036 := p._maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.GetElementCount()) + _t1037 := p._maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.GetTreeHeight()) + return listSort(result) } func (p *Parser) deconstruct_export_csv_config(msg *pb.ExportCSVConfig) [][]interface{} { result := [][]interface{}{} - var _t1047 interface{} - if (msg.GetPartitionSize() != nil && *msg.GetPartitionSize() != 0) { - _t1048 := p._make_value_int64(*msg.GetPartitionSize()) - result = append(result, []interface{}{"partition_size", _t1048}) - _t1047 = nil - } - var _t1049 interface{} - if (msg.GetCompression() != nil && *msg.GetCompression() != "") { - _t1050 := p._make_value_string(*msg.GetCompression()) - result = append(result, []interface{}{"compression", _t1050}) - _t1049 = nil - } - var _t1051 interface{} + var _t1038 interface{} + if msg.GetPartitionSize() != nil { + _t1039 := p._make_value_int64(*msg.GetPartitionSize()) + result = append(result, []interface{}{"partition_size", _t1039}) + _t1038 = nil + } + var _t1040 interface{} + if msg.GetCompression() != nil { + _t1041 := p._make_value_string(*msg.GetCompression()) + result = append(result, []interface{}{"compression", _t1041}) + _t1040 = nil + } + var _t1042 interface{} if msg.GetSyntaxHeaderRow() != nil { - _t1052 := p._make_value_boolean(*msg.GetSyntaxHeaderRow()) - result = append(result, []interface{}{"syntax_header_row", _t1052}) - _t1051 = nil - } - var _t1053 interface{} - if (msg.GetSyntaxMissingString() != nil && *msg.GetSyntaxMissingString() != "") { - _t1054 := p._make_value_string(*msg.GetSyntaxMissingString()) - result = append(result, []interface{}{"syntax_missing_string", _t1054}) - _t1053 = nil - } - var _t1055 interface{} - if (msg.GetSyntaxDelim() != nil && *msg.GetSyntaxDelim() != ",") { - _t1056 := p._make_value_string(*msg.GetSyntaxDelim()) - result = append(result, []interface{}{"syntax_delim", _t1056}) - _t1055 = nil - } - var _t1057 interface{} - if (msg.GetSyntaxQuotechar() != nil && *msg.GetSyntaxQuotechar() != "\"") { - _t1058 := p._make_value_string(*msg.GetSyntaxQuotechar()) - result = append(result, []interface{}{"syntax_quotechar", _t1058}) - _t1057 = nil - } - var _t1059 interface{} - if (msg.GetSyntaxEscapechar() != nil && *msg.GetSyntaxEscapechar() != "\\") { - _t1060 := p._make_value_string(*msg.GetSyntaxEscapechar()) - result = append(result, []interface{}{"syntax_escapechar", _t1060}) - _t1059 = nil + _t1043 := p._make_value_boolean(*msg.GetSyntaxHeaderRow()) + result = append(result, []interface{}{"syntax_header_row", _t1043}) + _t1042 = nil } - return result + var _t1044 interface{} + if msg.GetSyntaxMissingString() != nil { + _t1045 := p._make_value_string(*msg.GetSyntaxMissingString()) + result = append(result, []interface{}{"syntax_missing_string", _t1045}) + _t1044 = nil + } + var _t1046 interface{} + if msg.GetSyntaxDelim() != nil { + _t1047 := p._make_value_string(*msg.GetSyntaxDelim()) + result = append(result, []interface{}{"syntax_delim", _t1047}) + _t1046 = nil + } + var _t1048 interface{} + if msg.GetSyntaxQuotechar() != nil { + _t1049 := p._make_value_string(*msg.GetSyntaxQuotechar()) + result = append(result, []interface{}{"syntax_quotechar", _t1049}) + _t1048 = nil + } + var _t1050 interface{} + if msg.GetSyntaxEscapechar() != nil { + _t1051 := p._make_value_string(*msg.GetSyntaxEscapechar()) + result = append(result, []interface{}{"syntax_escapechar", _t1051}) + _t1050 = nil + } + return listSort(result) } func (p *Parser) deconstruct_relation_id_string(msg *pb.RelationId) *string { - _t1061 := p.relation_id_to_string(msg) - name := _t1061 + _t1052 := p.relation_id_to_string(msg) + name := _t1052 if name != "" { return ptr(name) } @@ -1072,28 +1050,28 @@ func (p *Parser) deconstruct_relation_id_string(msg *pb.RelationId) *string { } func (p *Parser) deconstruct_relation_id_uint128(msg *pb.RelationId) *pb.UInt128Value { - _t1062 := p.relation_id_to_string(msg) - name := _t1062 + _t1053 := p.relation_id_to_string(msg) + name := _t1053 if name == "" { - _t1063 := p.relation_id_to_uint128(msg) - return _t1063 + _t1054 := p.relation_id_to_uint128(msg) + return _t1054 } return nil } func (p *Parser) deconstruct_bindings(abs *pb.Abstraction) []interface{} { n := int64(len(abs.GetVars())) - _t1064 := p.list_slice(abs.GetVars(), 0, n) - return []interface{}{_t1064, []*pb.Binding{}} + _t1055 := p.list_slice(abs.GetVars(), 0, n) + return []interface{}{_t1055, []*pb.Binding{}} } func (p *Parser) deconstruct_bindings_with_arity(abs *pb.Abstraction, value_arity int64) []interface{} { n := int64(len(abs.GetVars())) - _t1065 := p.subtract(n, value_arity) - key_end := _t1065 - _t1066 := p.list_slice(abs.GetVars(), 0, key_end) - _t1067 := p.list_slice(abs.GetVars(), key_end, n) - return []interface{}{_t1066, _t1067} + _t1056 := p.subtract(n, value_arity) + key_end := _t1056 + _t1057 := p.list_slice(abs.GetVars(), 0, key_end) + _t1058 := p.list_slice(abs.GetVars(), key_end, n) + return []interface{}{_t1057, _t1058} } // --- Parse functions --- diff --git a/julia/LQPParser/src/parser.jl b/julia/LQPParser/src/parser.jl index 81a19df6..00e9df0b 100644 --- a/julia/LQPParser/src/parser.jl +++ b/julia/LQPParser/src/parser.jl @@ -325,6 +325,13 @@ end # --- Helper functions --- +function _extract_value_int32(parser::Parser, value::Union{Nothing, Proto.Value}, default::Int64)::Int64 + if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) + return Int32(_get_oneof_field(value, :int_value)) + end + return default +end + function _extract_value_int64(parser::Parser, value::Union{Nothing, Proto.Value}, default::Int64)::Int64 if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return _get_oneof_field(value, :int_value) @@ -418,7 +425,7 @@ end function construct_csv_config(parser::Parser, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.CSVConfig config = Dict(config_dict) - _t945 = _extract_value_int64(parser, get(config, "csv_header_row", nothing), 1) + _t945 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) header_row = _t945 _t946 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) skip = _t946 @@ -440,7 +447,7 @@ function construct_csv_config(parser::Parser, config_dict::Vector{Tuple{String, encoding = _t954 _t955 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") compression = _t955 - _t956 = Proto.CSVConfig(header_row=Int32(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + _t956 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t956 end @@ -524,31 +531,36 @@ function export_csv_config(parser::Parser, path::String, columns::Vector{Proto.E return _t980 end -function _make_value_int64(parser::Parser, v::Int64)::Proto.Value - _t981 = Proto.Value(value=OneOf(:int_value, v)) +function _make_value_int32(parser::Parser, v::Int64)::Proto.Value + _t981 = Proto.Value(value=OneOf(:int_value, Int64(v))) return _t981 end -function _make_value_float64(parser::Parser, v::Float64)::Proto.Value - _t982 = Proto.Value(value=OneOf(:float_value, v)) +function _make_value_int64(parser::Parser, v::Int64)::Proto.Value + _t982 = Proto.Value(value=OneOf(:int_value, v)) return _t982 end -function _make_value_string(parser::Parser, v::String)::Proto.Value - _t983 = Proto.Value(value=OneOf(:string_value, v)) +function _make_value_float64(parser::Parser, v::Float64)::Proto.Value + _t983 = Proto.Value(value=OneOf(:float_value, v)) return _t983 end -function _make_value_boolean(parser::Parser, v::Bool)::Proto.Value - _t984 = Proto.Value(value=OneOf(:boolean_value, v)) +function _make_value_string(parser::Parser, v::String)::Proto.Value + _t984 = Proto.Value(value=OneOf(:string_value, v)) return _t984 end -function _make_value_uint128(parser::Parser, v::Proto.UInt128Value)::Proto.Value - _t985 = Proto.Value(value=OneOf(:uint128_value, v)) +function _make_value_boolean(parser::Parser, v::Bool)::Proto.Value + _t985 = Proto.Value(value=OneOf(:boolean_value, v)) return _t985 end +function _make_value_uint128(parser::Parser, v::Proto.UInt128Value)::Proto.Value + _t986 = Proto.Value(value=OneOf(:uint128_value, v)) + return _t986 +end + function is_default_configure(parser::Parser, cfg::Proto.Configure)::Bool if cfg.semantics_version != 0 return false @@ -563,134 +575,82 @@ function deconstruct_configure(parser::Parser, msg::Proto.Configure)::Vector{Tup result = Tuple{String, Proto.Value}[] if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO - _t987 = _make_value_string(parser, "auto") - push!(result, ("ivm.maintenance_level", _t987,)) - _t986 = nothing + _t988 = _make_value_string(parser, "auto") + push!(result, ("ivm.maintenance_level", _t988,)) + _t987 = nothing else if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_ALL - _t989 = _make_value_string(parser, "all") - push!(result, ("ivm.maintenance_level", _t989,)) - _t988 = nothing + _t990 = _make_value_string(parser, "all") + push!(result, ("ivm.maintenance_level", _t990,)) + _t989 = nothing else if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t991 = _make_value_string(parser, "off") - push!(result, ("ivm.maintenance_level", _t991,)) - _t990 = nothing + _t992 = _make_value_string(parser, "off") + push!(result, ("ivm.maintenance_level", _t992,)) + _t991 = nothing else - _t990 = nothing + _t991 = nothing end - _t988 = _t990 + _t989 = _t991 end - _t986 = _t988 + _t987 = _t989 end - _t992 = _make_value_int64(parser, msg.semantics_version) - push!(result, ("semantics_version", _t992,)) - return result + _t993 = _make_value_int64(parser, msg.semantics_version) + push!(result, ("semantics_version", _t993,)) + return sort(result) end function deconstruct_csv_config(parser::Parser, msg::Proto.CSVConfig)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - - if msg.header_row != 1 - _t994 = _make_value_int64(parser, Int64(msg.header_row)) - push!(result, ("csv_header_row", _t994,)) - _t993 = nothing - else - _t993 = nothing - end - - if msg.skip != 0 - _t996 = _make_value_int64(parser, msg.skip) - push!(result, ("csv_skip", _t996,)) - _t995 = nothing - else - _t995 = nothing - end - - if msg.new_line != "" - _t998 = _make_value_string(parser, msg.new_line) - push!(result, ("csv_new_line", _t998,)) - _t997 = nothing - else - _t997 = nothing - end - - if msg.delimiter != "," - _t1000 = _make_value_string(parser, msg.delimiter) - push!(result, ("csv_delimiter", _t1000,)) - _t999 = nothing - else - _t999 = nothing - end - - if msg.quotechar != "\"" - _t1002 = _make_value_string(parser, msg.quotechar) - push!(result, ("csv_quotechar", _t1002,)) + _t994 = _make_value_int32(parser, msg.header_row) + push!(result, ("csv_header_row", _t994,)) + _t995 = _make_value_int64(parser, msg.skip) + push!(result, ("csv_skip", _t995,)) + + if (!isnothing(msg.new_line) && msg.new_line != "") + _t997 = _make_value_string(parser, msg.new_line) + push!(result, ("csv_new_line", _t997,)) + _t996 = nothing + else + _t996 = nothing + end + _t998 = _make_value_string(parser, msg.delimiter) + push!(result, ("csv_delimiter", _t998,)) + _t999 = _make_value_string(parser, msg.quotechar) + push!(result, ("csv_quotechar", _t999,)) + _t1000 = _make_value_string(parser, msg.escapechar) + push!(result, ("csv_escapechar", _t1000,)) + + if (!isnothing(msg.comment) && msg.comment != "") + _t1002 = _make_value_string(parser, msg.comment) + push!(result, ("csv_comment", _t1002,)) _t1001 = nothing else _t1001 = nothing end - - if msg.escapechar != "\"" - _t1004 = _make_value_string(parser, msg.escapechar) - push!(result, ("csv_escapechar", _t1004,)) - _t1003 = nothing - else - _t1003 = nothing - end - - if msg.comment != "" - _t1006 = _make_value_string(parser, msg.comment) - push!(result, ("csv_comment", _t1006,)) - _t1005 = nothing - else - _t1005 = nothing - end - - if !isempty(msg.missing_strings) - _t1008 = _make_value_string(parser, msg.missing_strings[1]) - push!(result, ("csv_missing_strings", _t1008,)) - _t1007 = nothing - else - _t1007 = nothing - end - - if msg.decimal_separator != "." - _t1010 = _make_value_string(parser, msg.decimal_separator) - push!(result, ("csv_decimal_separator", _t1010,)) - _t1009 = nothing - else - _t1009 = nothing + for missing_string in msg.missing_strings + _t1003 = _make_value_string(parser, missing_string) + push!(result, ("csv_missing_strings", _t1003,)) end - - if msg.encoding != "utf-8" - _t1012 = _make_value_string(parser, msg.encoding) - push!(result, ("csv_encoding", _t1012,)) - _t1011 = nothing - else - _t1011 = nothing - end - - if msg.compression != "auto" - _t1014 = _make_value_string(parser, msg.compression) - push!(result, ("csv_compression", _t1014,)) - _t1013 = nothing - else - _t1013 = nothing - end - return result + _t1004 = _make_value_string(parser, msg.decimal_separator) + push!(result, ("csv_decimal_separator", _t1004,)) + _t1005 = _make_value_string(parser, msg.encoding) + push!(result, ("csv_encoding", _t1005,)) + _t1006 = _make_value_string(parser, msg.compression) + push!(result, ("csv_compression", _t1006,)) + return sort(result) end function _maybe_push_float64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Float64})::Nothing if !isnothing(val) - _t1016 = _make_value_float64(parser, val) - push!(result, (key, _t1016,)) - _t1015 = nothing + _t1008 = _make_value_float64(parser, val) + push!(result, (key, _t1008,)) + _t1007 = nothing else - _t1015 = nothing + _t1007 = nothing end return nothing end @@ -698,11 +658,11 @@ end function _maybe_push_int64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Int64})::Nothing if !isnothing(val) - _t1018 = _make_value_int64(parser, val) - push!(result, (key, _t1018,)) - _t1017 = nothing + _t1010 = _make_value_int64(parser, val) + push!(result, (key, _t1010,)) + _t1009 = nothing else - _t1017 = nothing + _t1009 = nothing end return nothing end @@ -710,11 +670,11 @@ end function _maybe_push_uint128(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Proto.UInt128Value})::Nothing if !isnothing(val) - _t1020 = _make_value_uint128(parser, val) - push!(result, (key, _t1020,)) - _t1019 = nothing + _t1012 = _make_value_uint128(parser, val) + push!(result, (key, _t1012,)) + _t1011 = nothing else - _t1019 = nothing + _t1011 = nothing end return nothing end @@ -722,99 +682,99 @@ end function _maybe_push_bytes_as_string(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Vector{UInt8}})::Nothing if !isnothing(val) - _t1022 = _make_value_string(parser, String(val)) - push!(result, (key, _t1022,)) - _t1021 = nothing + _t1014 = _make_value_string(parser, String(val)) + push!(result, (key, _t1014,)) + _t1013 = nothing else - _t1021 = nothing + _t1013 = nothing end return nothing end function deconstruct_betree_info_config(parser::Parser, msg::Proto.BeTreeInfo)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - _t1023 = _maybe_push_float64(parser, result, "betree_config_epsilon", msg.storage_config.epsilon) - _t1024 = _maybe_push_int64(parser, result, "betree_config_max_pivots", msg.storage_config.max_pivots) - _t1025 = _maybe_push_int64(parser, result, "betree_config_max_deltas", msg.storage_config.max_deltas) - _t1026 = _maybe_push_int64(parser, result, "betree_config_max_leaf", msg.storage_config.max_leaf) + _t1015 = _maybe_push_float64(parser, result, "betree_config_epsilon", msg.storage_config.epsilon) + _t1016 = _maybe_push_int64(parser, result, "betree_config_max_pivots", msg.storage_config.max_pivots) + _t1017 = _maybe_push_int64(parser, result, "betree_config_max_deltas", msg.storage_config.max_deltas) + _t1018 = _maybe_push_int64(parser, result, "betree_config_max_leaf", msg.storage_config.max_leaf) if _has_proto_field(msg.relation_locator, Symbol("root_pageid")) - _t1028 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) - _t1027 = _t1028 + _t1020 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) + _t1019 = _t1020 else - _t1027 = nothing + _t1019 = nothing end if _has_proto_field(msg.relation_locator, Symbol("inline_data")) - _t1030 = _maybe_push_bytes_as_string(parser, result, "betree_locator_inline_data", _get_oneof_field(msg.relation_locator, :inline_data)) - _t1029 = _t1030 + _t1022 = _maybe_push_bytes_as_string(parser, result, "betree_locator_inline_data", _get_oneof_field(msg.relation_locator, :inline_data)) + _t1021 = _t1022 else - _t1029 = nothing + _t1021 = nothing end - _t1031 = _maybe_push_int64(parser, result, "betree_locator_element_count", msg.relation_locator.element_count) - _t1032 = _maybe_push_int64(parser, result, "betree_locator_tree_height", msg.relation_locator.tree_height) - return result + _t1023 = _maybe_push_int64(parser, result, "betree_locator_element_count", msg.relation_locator.element_count) + _t1024 = _maybe_push_int64(parser, result, "betree_locator_tree_height", msg.relation_locator.tree_height) + return sort(result) end function deconstruct_export_csv_config(parser::Parser, msg::Proto.ExportCSVConfig)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - if (!isnothing(msg.partition_size) && msg.partition_size != 0) - _t1034 = _make_value_int64(parser, msg.partition_size) - push!(result, ("partition_size", _t1034,)) - _t1033 = nothing + if !isnothing(msg.partition_size) + _t1026 = _make_value_int64(parser, msg.partition_size) + push!(result, ("partition_size", _t1026,)) + _t1025 = nothing else - _t1033 = nothing + _t1025 = nothing end - if (!isnothing(msg.compression) && msg.compression != "") - _t1036 = _make_value_string(parser, msg.compression) - push!(result, ("compression", _t1036,)) - _t1035 = nothing + if !isnothing(msg.compression) + _t1028 = _make_value_string(parser, msg.compression) + push!(result, ("compression", _t1028,)) + _t1027 = nothing else - _t1035 = nothing + _t1027 = nothing end if !isnothing(msg.syntax_header_row) - _t1038 = _make_value_boolean(parser, msg.syntax_header_row) - push!(result, ("syntax_header_row", _t1038,)) - _t1037 = nothing + _t1030 = _make_value_boolean(parser, msg.syntax_header_row) + push!(result, ("syntax_header_row", _t1030,)) + _t1029 = nothing else - _t1037 = nothing + _t1029 = nothing end - if (!isnothing(msg.syntax_missing_string) && msg.syntax_missing_string != "") - _t1040 = _make_value_string(parser, msg.syntax_missing_string) - push!(result, ("syntax_missing_string", _t1040,)) - _t1039 = nothing + if !isnothing(msg.syntax_missing_string) + _t1032 = _make_value_string(parser, msg.syntax_missing_string) + push!(result, ("syntax_missing_string", _t1032,)) + _t1031 = nothing else - _t1039 = nothing + _t1031 = nothing end - if (!isnothing(msg.syntax_delim) && msg.syntax_delim != ",") - _t1042 = _make_value_string(parser, msg.syntax_delim) - push!(result, ("syntax_delim", _t1042,)) - _t1041 = nothing + if !isnothing(msg.syntax_delim) + _t1034 = _make_value_string(parser, msg.syntax_delim) + push!(result, ("syntax_delim", _t1034,)) + _t1033 = nothing else - _t1041 = nothing + _t1033 = nothing end - if (!isnothing(msg.syntax_quotechar) && msg.syntax_quotechar != "\"") - _t1044 = _make_value_string(parser, msg.syntax_quotechar) - push!(result, ("syntax_quotechar", _t1044,)) - _t1043 = nothing + if !isnothing(msg.syntax_quotechar) + _t1036 = _make_value_string(parser, msg.syntax_quotechar) + push!(result, ("syntax_quotechar", _t1036,)) + _t1035 = nothing else - _t1043 = nothing + _t1035 = nothing end - if (!isnothing(msg.syntax_escapechar) && msg.syntax_escapechar != "\\") - _t1046 = _make_value_string(parser, msg.syntax_escapechar) - push!(result, ("syntax_escapechar", _t1046,)) - _t1045 = nothing + if !isnothing(msg.syntax_escapechar) + _t1038 = _make_value_string(parser, msg.syntax_escapechar) + push!(result, ("syntax_escapechar", _t1038,)) + _t1037 = nothing else - _t1045 = nothing + _t1037 = nothing end - return result + return sort(result) end function deconstruct_relation_id_string(parser::Parser, msg::Proto.RelationId)::Union{Nothing, String} diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 19cd2fe4..7e013866 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -608,91 +608,101 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo result.append(('csv_header_row', _t1008,)) _t1009 = self._make_value_int64(msg.skip) result.append(('csv_skip', _t1009,)) - _t1010 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1010,)) - _t1011 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1011,)) - _t1012 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1012,)) - _t1013 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1013,)) - _t1014 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1014,)) + + if (msg.new_line is not None and msg.new_line != ''): + _t1011 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1011,)) + _t1010 = None + else: + _t1010 = None + _t1012 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1012,)) + _t1013 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1013,)) + _t1014 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1014,)) + + if (msg.comment is not None and msg.comment != ''): + _t1016 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1016,)) + _t1015 = None + else: + _t1015 = None for missing_string in msg.missing_strings: - _t1015 = self._make_value_string(missing_string) - result.append(('csv_missing_strings', _t1015,)) - _t1016 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1016,)) - _t1017 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1017,)) - _t1018 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1018,)) + _t1017 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1017,)) + _t1018 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1018,)) + _t1019 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1019,)) + _t1020 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1020,)) return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1020 = self._make_value_float64(val) - result.append((key, _t1020,)) - _t1019 = None - else: - _t1019 = None - return None - - def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: - - if val is not None: - assert val is not None - _t1022 = self._make_value_int64(val) + _t1022 = self._make_value_float64(val) result.append((key, _t1022,)) _t1021 = None else: _t1021 = None return None - def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1024 = self._make_value_uint128(val) + _t1024 = self._make_value_int64(val) result.append((key, _t1024,)) _t1023 = None else: _t1023 = None return None - def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1026 = self._make_value_string(val.decode('utf-8')) + _t1026 = self._make_value_uint128(val) result.append((key, _t1026,)) _t1025 = None else: _t1025 = None return None + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + assert val is not None + _t1028 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1028,)) + _t1027 = None + else: + _t1027 = None + return None + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1027 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1028 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1029 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1030 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1029 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1030 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1031 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1032 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1032 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1031 = _t1032 + _t1034 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1033 = _t1034 else: - _t1031 = None + _t1033 = None if msg.relation_locator.HasField('inline_data'): - _t1034 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1033 = _t1034 + _t1036 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1035 = _t1036 else: - _t1033 = None - _t1035 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1036 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1035 = None + _t1037 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1038 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: @@ -700,59 +710,59 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - if msg.partition_size is not None: assert msg.partition_size is not None - _t1038 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1038,)) - _t1037 = None + _t1040 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1040,)) + _t1039 = None else: - _t1037 = None + _t1039 = None if msg.compression is not None: assert msg.compression is not None - _t1040 = self._make_value_string(msg.compression) - result.append(('compression', _t1040,)) - _t1039 = None + _t1042 = self._make_value_string(msg.compression) + result.append(('compression', _t1042,)) + _t1041 = None else: - _t1039 = None + _t1041 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1042 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1042,)) - _t1041 = None + _t1044 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1044,)) + _t1043 = None else: - _t1041 = None + _t1043 = None if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1044 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1044,)) - _t1043 = None + _t1046 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1046,)) + _t1045 = None else: - _t1043 = None + _t1045 = None if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1046 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1046,)) - _t1045 = None + _t1048 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1048,)) + _t1047 = None else: - _t1045 = None + _t1047 = None if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1048 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1048,)) - _t1047 = None + _t1050 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1050,)) + _t1049 = None else: - _t1047 = None + _t1049 = None if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1050 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1050,)) - _t1049 = None + _t1052 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1052,)) + _t1051 = None else: - _t1049 = None + _t1051 = None return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py index 475a7016..1571239d 100644 --- a/python-tools/src/lqp/gen/pretty.py +++ b/python-tools/src/lqp/gen/pretty.py @@ -448,91 +448,101 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo result.append(('csv_header_row', _t1353,)) _t1354 = self._make_value_int64(msg.skip) result.append(('csv_skip', _t1354,)) - _t1355 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1355,)) - _t1356 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1356,)) - _t1357 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1357,)) - _t1358 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1358,)) - _t1359 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1359,)) + + if (msg.new_line is not None and msg.new_line != ''): + _t1356 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1356,)) + _t1355 = None + else: + _t1355 = None + _t1357 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1357,)) + _t1358 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1358,)) + _t1359 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1359,)) + + if (msg.comment is not None and msg.comment != ''): + _t1361 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1361,)) + _t1360 = None + else: + _t1360 = None for missing_string in msg.missing_strings: - _t1360 = self._make_value_string(missing_string) - result.append(('csv_missing_strings', _t1360,)) - _t1361 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1361,)) - _t1362 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1362,)) - _t1363 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1363,)) + _t1362 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1362,)) + _t1363 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1363,)) + _t1364 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1364,)) + _t1365 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1365,)) return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1365 = self._make_value_float64(val) - result.append((key, _t1365,)) - _t1364 = None - else: - _t1364 = None - return None - - def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: - - if val is not None: - assert val is not None - _t1367 = self._make_value_int64(val) + _t1367 = self._make_value_float64(val) result.append((key, _t1367,)) _t1366 = None else: _t1366 = None return None - def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: + def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1369 = self._make_value_uint128(val) + _t1369 = self._make_value_int64(val) result.append((key, _t1369,)) _t1368 = None else: _t1368 = None return None - def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1371 = self._make_value_string(val.decode('utf-8')) + _t1371 = self._make_value_uint128(val) result.append((key, _t1371,)) _t1370 = None else: _t1370 = None return None + def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: + + if val is not None: + assert val is not None + _t1373 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1373,)) + _t1372 = None + else: + _t1372 = None + return None + def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1372 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1373 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1374 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1375 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1374 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) + _t1375 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) + _t1376 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) + _t1377 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) if msg.relation_locator.HasField('root_pageid'): - _t1377 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1376 = _t1377 + _t1379 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1378 = _t1379 else: - _t1376 = None + _t1378 = None if msg.relation_locator.HasField('inline_data'): - _t1379 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1378 = _t1379 + _t1381 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1380 = _t1381 else: - _t1378 = None - _t1380 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1381 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1380 = None + _t1382 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) + _t1383 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: @@ -540,59 +550,59 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - if msg.partition_size is not None: assert msg.partition_size is not None - _t1383 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1383,)) - _t1382 = None + _t1385 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1385,)) + _t1384 = None else: - _t1382 = None + _t1384 = None if msg.compression is not None: assert msg.compression is not None - _t1385 = self._make_value_string(msg.compression) - result.append(('compression', _t1385,)) - _t1384 = None + _t1387 = self._make_value_string(msg.compression) + result.append(('compression', _t1387,)) + _t1386 = None else: - _t1384 = None + _t1386 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1387 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1387,)) - _t1386 = None + _t1389 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1389,)) + _t1388 = None else: - _t1386 = None + _t1388 = None if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1389 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1389,)) - _t1388 = None + _t1391 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1391,)) + _t1390 = None else: - _t1388 = None + _t1390 = None if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1391 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1391,)) - _t1390 = None + _t1393 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1393,)) + _t1392 = None else: - _t1390 = None + _t1392 = None if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1393 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1393,)) - _t1392 = None + _t1395 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1395,)) + _t1394 = None else: - _t1392 = None + _t1394 = None if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1395 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1395,)) - _t1394 = None + _t1397 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1397,)) + _t1396 = None else: - _t1394 = None + _t1396 = None return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: @@ -3711,16 +3721,14 @@ def _t1212(_dollar_dollar): self.newline() self.write('[') field438 = unwrapped_fields435[2] - if not len(field438) == 0: - self.newline() - for i440, elem439 in enumerate(field438): - - if (i440 > 0): - self.newline() - _t1215 = None - else: - _t1215 = None - _t1216 = self.pretty_type(elem439) + for i440, elem439 in enumerate(field438): + + if (i440 > 0): + self.newline() + _t1215 = None + else: + _t1215 = None + _t1216 = self.pretty_type(elem439) self.write(']') self.dedent() self.write(')') diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 8bf0507e..2b35e97b 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -1319,11 +1319,13 @@ def deconstruct_csv_config(msg: logic.CSVConfig) -> List[Tuple[String, logic.Val result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() builtin.list_push(result, builtin.tuple("csv_header_row", _make_value_int32(msg.header_row))) builtin.list_push(result, builtin.tuple("csv_skip", _make_value_int64(msg.skip))) - builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) + if msg.new_line is not None and msg.new_line != "": + builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) builtin.list_push(result, builtin.tuple("csv_delimiter", _make_value_string(msg.delimiter))) builtin.list_push(result, builtin.tuple("csv_quotechar", _make_value_string(msg.quotechar))) builtin.list_push(result, builtin.tuple("csv_escapechar", _make_value_string(msg.escapechar))) - builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) + if msg.comment is not None and msg.comment != "": + builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) for missing_string in msg.missing_strings: builtin.list_push(result, builtin.tuple("csv_missing_strings", _make_value_string(missing_string))) builtin.list_push(result, builtin.tuple("csv_decimal_separator", _make_value_string(msg.decimal_separator))) diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index 7d00e9db..2dba7e21 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -306,9 +306,12 @@ def _generate_pretty_sequence_from_fields(rhs: Sequence, fields_var: Var, stmts.append(Call(make_builtin('write_io'), [Lit(' ')])) else: if is_sexp: - # Sexp spacing: newline before each non-literal - # (indent is emitted unconditionally after the keyword) - leading_ws = [Call(make_builtin('newline_io'), [])] + if prev_lit_name in NO_TRAILING_SPACE: + # After opening brackets, no whitespace + pass + else: + # Sexp spacing: newline before each non-literal + leading_ws = [Call(make_builtin('newline_io'), [])] elif stmts: # Non-sexp spacing between elements cur_lit_name = None diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index 850d3acc..7dadd83e 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -64,6 +64,16 @@ def _normalize_formulas(s: str) -> str: return s +def _normalize_header_row(s: str) -> str: + """Normalize :syntax_header_row 1 to :syntax_header_row true. + + The proto type is bool, but the old printer formats it as an int. + """ + s = re.sub(r':syntax_header_row\s+1\b', ':syntax_header_row true', s) + s = re.sub(r':syntax_header_row\s+0\b', ':syntax_header_row false', s) + return s + + def _normalize_ws(s: str) -> str: """Collapse all whitespace sequences to a single space, strip spaces before closing brackets.""" s = re.sub(r'\s+', ' ', s).strip() @@ -121,6 +131,7 @@ def test_matches_old_pretty_printer(input_file): generated_output = _normalize_formulas(generated_output) old_output = _normalize_primitives(old_output) old_output = _normalize_formulas(old_output) + old_output = _normalize_header_row(old_output) assert _normalize_ws(generated_output) == _normalize_ws(old_output), ( f"Outputs differ for {stem}.\n" From c68e680b10c6db6c278ac37037108b9d527cedb2 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Thu, 12 Feb 2026 09:56:58 +0100 Subject: [PATCH 18/25] makefile cleanup --- Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 079a15b4..423127fd 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,15 @@ JL_PROTO_DIR := julia/LQPParser/src/relationalai/lqp/v1 GO_PROTO_DIR := go/src/lqp/v1 # Representative generated protobuf files (used as make targets) -PY_GO_PROTO_GEN := $(PY_PROTO_DIR)/logic_pb2.py -JL_PROTO_GEN := $(JL_PROTO_DIR)/logic_pb.jl +PY_PROTO_GEN := $(PY_PROTO_DIR)/logic_pb2.py \ + $(PY_PROTO_DIR)/fragments_pb2.py \ + $(PY_PROTO_DIR)/transactions_pb2.py +GO_PROTO_GEN := $(GO_PROTO_DIR)/logic.pb.go \ + $(GO_PROTO_DIR)/fragments.pb.go \ + $(GO_PROTO_DIR)/transctions.pb.go +JL_PROTO_GEN := $(JL_PROTO_DIR)/logic_pb.jl \ + $(JL_PROTO_DIR)/fragments_pb.jl \ + $(JL_PROTO_DIR)/transactions_pb.jl # Generated parser outputs PY_PARSER := python-tools/src/lqp/gen/parser.py @@ -55,7 +62,7 @@ META_PROTO_ARGS := \ --grammar src/meta/grammar.y -.PHONY: all build protobuf protobuf-lint protobuf-py-go protobuf-julia \ +.PHONY: all protobuf protobuf-lint protobuf-py-go protobuf-julia \ parsers parser-python parser-julia parser-go \ force-parsers force-parser-python force-parser-julia force-parser-go \ printers printer-python printer-julia printer-go \ @@ -63,7 +70,7 @@ META_PROTO_ARGS := \ test test-python test-julia test-go check-python \ clean -all: build parsers printers +all: protobuf parsers printers # ---------- protobuf build (replaces ./build script) ---------- @@ -72,12 +79,12 @@ protobuf-lint: $(PROTO_FILES) buf breaking --against ".git#branch=main,subdir=proto" # Convenience phony targets -protobuf: $(PY_GO_PROTO_GEN) $(JL_PROTO_GEN) -protobuf-py-go: $(PY_GO_PROTO_GEN) +protobuf: $(PY_PROTO_GEN) $(GO_PROTO_GEN) $(JL_PROTO_GEN) +protobuf-py-go: $(PY_PROTO_GEN) $(GO_PROTO_GEN) protobuf-julia: $(JL_PROTO_GEN) # Only regenerate when .proto files are newer than the generated output -$(PY_GO_PROTO_GEN): $(PROTO_FILES) +$(PY_PROTO_GEN) $(GO_PROTO_GEN): $(PROTO_FILES) buf lint buf breaking --against ".git#branch=main,subdir=proto" buf generate From 6416e471fefd12a67527f78e5aa5e7afedbeec4d Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Thu, 12 Feb 2026 10:04:57 +0100 Subject: [PATCH 19/25] Change List to Sequence for read-only lists. --- python-tools/src/lqp/gen/parser.py | 59 +++---- python-tools/src/lqp/gen/pretty.py | 53 ++++--- python-tools/src/meta/__init__.py | 2 + python-tools/src/meta/codegen_base.py | 11 +- python-tools/src/meta/codegen_go.py | 7 +- python-tools/src/meta/codegen_julia.py | 3 + python-tools/src/meta/codegen_python.py | 3 + python-tools/src/meta/codegen_templates.py | 2 +- python-tools/src/meta/grammar.py | 6 +- python-tools/src/meta/grammar.y | 148 +++++++++--------- python-tools/src/meta/grammar_validator.py | 30 ++-- python-tools/src/meta/pretty_gen.py | 4 +- python-tools/src/meta/target.py | 38 ++++- python-tools/src/meta/target_builtins.py | 24 +-- python-tools/src/meta/target_print.py | 5 +- python-tools/src/meta/target_utils.py | 18 ++- .../src/meta/templates/parser.py.template | 1 + .../meta/templates/pretty_printer.py.template | 1 + python-tools/src/meta/type_env.py | 6 +- python-tools/src/meta/yacc_action_parser.py | 7 +- python-tools/src/meta/yacc_parser.py | 11 +- .../tests/meta/test_codegen_python.py | 2 +- .../tests/meta/test_end_to_end_validation.py | 2 +- python-tools/tests/meta/test_grammar.py | 6 +- .../tests/meta/test_grammar_validator.py | 115 +++++++++----- 25 files changed, 343 insertions(+), 221 deletions(-) diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 7e013866..4fbe99d9 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -12,6 +12,7 @@ import ast import hashlib import re +from collections.abc import Sequence from typing import List, Optional, Any, Tuple, Callable from decimal import Decimal @@ -361,7 +362,7 @@ def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logi return value.uint128_value return default - def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: Sequence[str]) -> Sequence[str]: if value is not None: assert value is not None @@ -433,7 +434,7 @@ def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Option return value.uint128_value return None - def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[Sequence[str]]: if value is not None: assert value is not None @@ -445,7 +446,7 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op return [value.string_value] return None - def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + def construct_csv_config(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) _t959 = self._extract_value_int32(config.get('csv_header_row'), 1) header_row = _t959 @@ -472,7 +473,7 @@ def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) - _t970 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t970 - def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + def construct_betree_info(self, key_types: Sequence[logic_pb2.Type], value_types: Sequence[logic_pb2.Type], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) _t971 = self._try_extract_value_float64(config.get('betree_config_epsilon')) epsilon = _t971 @@ -503,7 +504,7 @@ def default_configure(self) -> transactions_pb2.Configure: _t983 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) return _t983 - def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) maintenance_level_val = config.get('ivm.maintenance_level') maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF @@ -525,7 +526,7 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> _t986 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) return _t986 - def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + def export_csv_config(self, path: str, columns: Sequence[transactions_pb2.ExportCSVColumn], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) _t987 = self._extract_value_int64(config.get('partition_size'), 0) partition_size = _t987 @@ -777,11 +778,11 @@ def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional return self.relation_id_to_uint128(msg) return None - def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: n = len(abs.vars) return (abs.vars[0:n], [],) - def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: n = len(abs.vars) key_end = (n - value_arity) return (abs.vars[0:key_end], abs.vars[key_end:n],) @@ -827,7 +828,7 @@ def parse_configure(self) -> transactions_pb2.Configure: _t361 = self.construct_configure(config_dict6) return _t361 - def parse_config_dict(self) -> list[tuple[str, logic_pb2.Value]]: + def parse_config_dict(self) -> Sequence[tuple[str, logic_pb2.Value]]: self.consume_literal('{') xs7 = [] cond8 = self.match_lookahead_literal(':', 0) @@ -1081,7 +1082,7 @@ def parse_epoch(self) -> transactions_pb2.Epoch: _t413 = transactions_pb2.Epoch(writes=(epoch_writes39 if epoch_writes39 is not None else []), reads=(epoch_reads40 if epoch_reads40 is not None else [])) return _t413 - def parse_epoch_writes(self) -> list[transactions_pb2.Write]: + def parse_epoch_writes(self) -> Sequence[transactions_pb2.Write]: self.consume_literal('(') self.consume_literal('writes') xs41 = [] @@ -1298,10 +1299,10 @@ def parse_abstraction(self) -> logic_pb2.Abstraction: _t462 = self.parse_formula() formula68 = _t462 self.consume_literal(')') - _t463 = logic_pb2.Abstraction(vars=(bindings67[0] + (bindings67[1] if bindings67[1] is not None else [])), value=formula68) + _t463 = logic_pb2.Abstraction(vars=(list(bindings67[0]) + list(bindings67[1] if bindings67[1] is not None else [])), value=formula68) return _t463 - def parse_bindings(self) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + def parse_bindings(self) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: self.consume_literal('[') xs69 = [] cond70 = self.match_lookahead_terminal('SYMBOL', 0) @@ -1536,7 +1537,7 @@ def parse_boolean_type(self) -> logic_pb2.BooleanType: _t524 = logic_pb2.BooleanType() return _t524 - def parse_value_bindings(self) -> list[logic_pb2.Binding]: + def parse_value_bindings(self) -> Sequence[logic_pb2.Binding]: self.consume_literal('|') xs90 = [] cond91 = self.match_lookahead_terminal('SYMBOL', 0) @@ -1794,7 +1795,7 @@ def parse_exists(self) -> logic_pb2.Exists: _t591 = self.parse_formula() formula109 = _t591 self.consume_literal(')') - _t592 = logic_pb2.Abstraction(vars=(bindings108[0] + (bindings108[1] if bindings108[1] is not None else [])), value=formula109) + _t592 = logic_pb2.Abstraction(vars=(list(bindings108[0]) + list(bindings108[1] if bindings108[1] is not None else [])), value=formula109) _t593 = logic_pb2.Exists(body=_t592) return _t593 @@ -1811,7 +1812,7 @@ def parse_reduce(self) -> logic_pb2.Reduce: _t597 = logic_pb2.Reduce(op=abstraction110, body=abstraction_3111, terms=terms112) return _t597 - def parse_terms(self) -> list[logic_pb2.Term]: + def parse_terms(self) -> Sequence[logic_pb2.Term]: self.consume_literal('(') self.consume_literal('terms') xs113 = [] @@ -1967,7 +1968,7 @@ def parse_name(self) -> str: symbol134 = self.consume_terminal('SYMBOL') return symbol134 - def parse_ffi_args(self) -> list[logic_pb2.Abstraction]: + def parse_ffi_args(self) -> Sequence[logic_pb2.Abstraction]: self.consume_literal('(') self.consume_literal('args') xs135 = [] @@ -2399,7 +2400,7 @@ def parse_cast(self) -> logic_pb2.Cast: _t745 = logic_pb2.Cast(input=term195, result=term_3196) return _t745 - def parse_attrs(self) -> list[logic_pb2.Attribute]: + def parse_attrs(self) -> Sequence[logic_pb2.Attribute]: self.consume_literal('(') self.consume_literal('attrs') xs197 = [] @@ -2529,7 +2530,7 @@ def parse_loop(self) -> logic_pb2.Loop: _t770 = logic_pb2.Loop(init=init218, body=script219) return _t770 - def parse_init(self) -> list[logic_pb2.Instruction]: + def parse_init(self) -> Sequence[logic_pb2.Instruction]: self.consume_literal('(') self.consume_literal('init') xs220 = [] @@ -2661,7 +2662,7 @@ def parse_abstraction_with_arity(self) -> tuple[logic_pb2.Abstraction, int]: _t804 = self.parse_formula() formula237 = _t804 self.consume_literal(')') - _t805 = logic_pb2.Abstraction(vars=(bindings236[0] + (bindings236[1] if bindings236[1] is not None else [])), value=formula237) + _t805 = logic_pb2.Abstraction(vars=(list(bindings236[0]) + list(bindings236[1] if bindings236[1] is not None else [])), value=formula237) return (_t805, len(bindings236[1]),) def parse_break(self) -> logic_pb2.Break: @@ -2833,7 +2834,7 @@ def parse_constraint(self) -> logic_pb2.Constraint: _t852 = logic_pb2.Constraint(name=relation_id257, functional_dependency=_t851) return _t852 - def parse_functional_dependency_keys(self) -> list[logic_pb2.Var]: + def parse_functional_dependency_keys(self) -> Sequence[logic_pb2.Var]: self.consume_literal('(') self.consume_literal('keys') xs261 = [] @@ -2847,7 +2848,7 @@ def parse_functional_dependency_keys(self) -> list[logic_pb2.Var]: self.consume_literal(')') return vars264 - def parse_functional_dependency_values(self) -> list[logic_pb2.Var]: + def parse_functional_dependency_values(self) -> Sequence[logic_pb2.Var]: self.consume_literal('(') self.consume_literal('values') xs265 = [] @@ -2922,7 +2923,7 @@ def parse_rel_edb(self) -> logic_pb2.RelEDB: _t871 = logic_pb2.RelEDB(target_id=relation_id273, path=rel_edb_path274, types=rel_edb_types275) return _t871 - def parse_rel_edb_path(self) -> list[str]: + def parse_rel_edb_path(self) -> Sequence[str]: self.consume_literal('[') xs276 = [] cond277 = self.match_lookahead_terminal('STRING', 0) @@ -2934,7 +2935,7 @@ def parse_rel_edb_path(self) -> list[str]: self.consume_literal(']') return strings279 - def parse_rel_edb_types(self) -> list[logic_pb2.Type]: + def parse_rel_edb_types(self) -> Sequence[logic_pb2.Type]: self.consume_literal('[') xs280 = [] cond281 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) @@ -2971,7 +2972,7 @@ def parse_betree_info(self) -> logic_pb2.BeTreeInfo: _t879 = self.construct_betree_info(betree_info_key_types286, betree_info_value_types287, config_dict288) return _t879 - def parse_betree_info_key_types(self) -> list[logic_pb2.Type]: + def parse_betree_info_key_types(self) -> Sequence[logic_pb2.Type]: self.consume_literal('(') self.consume_literal('key_types') xs289 = [] @@ -2985,7 +2986,7 @@ def parse_betree_info_key_types(self) -> list[logic_pb2.Type]: self.consume_literal(')') return types292 - def parse_betree_info_value_types(self) -> list[logic_pb2.Type]: + def parse_betree_info_value_types(self) -> Sequence[logic_pb2.Type]: self.consume_literal('(') self.consume_literal('value_types') xs293 = [] @@ -3035,7 +3036,7 @@ def parse_csvlocator(self) -> logic_pb2.CSVLocator: _t891 = logic_pb2.CSVLocator(paths=(csv_locator_paths301 if csv_locator_paths301 is not None else []), inline_data=(csv_locator_inline_data302 if csv_locator_inline_data302 is not None else '').encode()) return _t891 - def parse_csv_locator_paths(self) -> list[str]: + def parse_csv_locator_paths(self) -> Sequence[str]: self.consume_literal('(') self.consume_literal('paths') xs303 = [] @@ -3064,7 +3065,7 @@ def parse_csv_config(self) -> logic_pb2.CSVConfig: _t893 = self.construct_csv_config(config_dict308) return _t893 - def parse_csv_columns(self) -> list[logic_pb2.CSVColumn]: + def parse_csv_columns(self) -> Sequence[logic_pb2.CSVColumn]: self.consume_literal('(') self.consume_literal('columns') xs309 = [] @@ -3129,7 +3130,7 @@ def parse_context(self) -> transactions_pb2.Context: _t901 = transactions_pb2.Context(relations=relation_ids324) return _t901 - def parse_epoch_reads(self) -> list[transactions_pb2.Read]: + def parse_epoch_reads(self) -> Sequence[transactions_pb2.Read]: self.consume_literal('(') self.consume_literal('reads') xs325 = [] @@ -3293,7 +3294,7 @@ def parse_export_csv_path(self) -> str: self.consume_literal(')') return string346 - def parse_export_csv_columns(self) -> list[transactions_pb2.ExportCSVColumn]: + def parse_export_csv_columns(self) -> Sequence[transactions_pb2.ExportCSVColumn]: self.consume_literal('(') self.consume_literal('columns') xs347 = [] diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py index 1571239d..4246af90 100644 --- a/python-tools/src/lqp/gen/pretty.py +++ b/python-tools/src/lqp/gen/pretty.py @@ -10,6 +10,7 @@ """ from io import StringIO +from collections.abc import Sequence from typing import Any, IO, Never, Optional from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -201,7 +202,7 @@ def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logi return value.uint128_value return default - def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: + def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: Sequence[str]) -> Sequence[str]: if value is not None: assert value is not None @@ -273,7 +274,7 @@ def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Option return value.uint128_value return None - def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: + def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[Sequence[str]]: if value is not None: assert value is not None @@ -285,7 +286,7 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op return [value.string_value] return None - def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: + def construct_csv_config(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) _t1304 = self._extract_value_int32(config.get('csv_header_row'), 1) header_row = _t1304 @@ -312,7 +313,7 @@ def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) - _t1315 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) return _t1315 - def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: + def construct_betree_info(self, key_types: Sequence[logic_pb2.Type], value_types: Sequence[logic_pb2.Type], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) _t1316 = self._try_extract_value_float64(config.get('betree_config_epsilon')) epsilon = _t1316 @@ -343,7 +344,7 @@ def default_configure(self) -> transactions_pb2.Configure: _t1328 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) return _t1328 - def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: + def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) maintenance_level_val = config.get('ivm.maintenance_level') maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF @@ -365,7 +366,7 @@ def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> _t1331 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) return _t1331 - def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: + def export_csv_config(self, path: str, columns: Sequence[transactions_pb2.ExportCSVColumn], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) _t1332 = self._extract_value_int64(config.get('partition_size'), 0) partition_size = _t1332 @@ -617,11 +618,11 @@ def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional return self.relation_id_to_uint128(msg) return None - def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: n = len(abs.vars) return (abs.vars[0:n], [],) - def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: + def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: n = len(abs.vars) key_end = (n - value_arity) return (abs.vars[0:key_end], abs.vars[key_end:n],) @@ -700,7 +701,7 @@ def _t500(_dollar_dollar): self.write(')') return None - def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: + def pretty_config_dict(self, msg: Sequence[tuple[str, logic_pb2.Value]]) -> Optional[Never]: def _t504(_dollar_dollar): return _dollar_dollar _t505 = _t504(msg) @@ -1058,7 +1059,7 @@ def _t571(_dollar_dollar): self.write(')') return None - def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: + def pretty_epoch_writes(self, msg: Sequence[transactions_pb2.Write]) -> Optional[Never]: def _t579(_dollar_dollar): return _dollar_dollar _t580 = _t579(msg) @@ -1326,7 +1327,7 @@ def _t645(_dollar_dollar): self.write(')') return None - def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: + def pretty_bindings(self, msg: tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]) -> Optional[Never]: def _t650(_dollar_dollar): if not len(_dollar_dollar[1]) == 0: @@ -1663,7 +1664,7 @@ def _t735(_dollar_dollar): self.write('BOOLEAN') return None - def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: + def pretty_value_bindings(self, msg: Sequence[logic_pb2.Binding]) -> Optional[Never]: def _t737(_dollar_dollar): return _dollar_dollar _t738 = _t737(msg) @@ -1949,7 +1950,7 @@ def _t815(_dollar_dollar): self.write(')') return None - def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: + def pretty_terms(self, msg: Sequence[logic_pb2.Term]) -> Optional[Never]: def _t820(_dollar_dollar): return _dollar_dollar _t821 = _t820(msg) @@ -2124,7 +2125,7 @@ def _t855(_dollar_dollar): self.write(unwrapped_fields194) return None - def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: + def pretty_ffi_args(self, msg: Sequence[logic_pb2.Abstraction]) -> Optional[Never]: def _t857(_dollar_dollar): return _dollar_dollar _t858 = _t857(msg) @@ -2696,7 +2697,7 @@ def _t988(_dollar_dollar): self.write(')') return None - def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: + def pretty_attrs(self, msg: Sequence[logic_pb2.Attribute]) -> Optional[Never]: def _t992(_dollar_dollar): return _dollar_dollar _t993 = _t992(msg) @@ -2853,7 +2854,7 @@ def _t1020(_dollar_dollar): self.write(')') return None - def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: + def pretty_init(self, msg: Sequence[logic_pb2.Instruction]) -> Optional[Never]: def _t1024(_dollar_dollar): return _dollar_dollar _t1025 = _t1024(msg) @@ -3302,7 +3303,7 @@ def _t1126(_dollar_dollar): self.write(')') return None - def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def pretty_functional_dependency_keys(self, msg: Sequence[logic_pb2.Var]) -> Optional[Never]: def _t1132(_dollar_dollar): return _dollar_dollar _t1133 = _t1132(msg) @@ -3326,7 +3327,7 @@ def _t1132(_dollar_dollar): self.write(')') return None - def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: + def pretty_functional_dependency_values(self, msg: Sequence[logic_pb2.Var]) -> Optional[Never]: def _t1136(_dollar_dollar): return _dollar_dollar _t1137 = _t1136(msg) @@ -3421,7 +3422,7 @@ def _t1155(_dollar_dollar): self.write(')') return None - def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: + def pretty_rel_edb_path(self, msg: Sequence[str]) -> Optional[Never]: def _t1160(_dollar_dollar): return _dollar_dollar _t1161 = _t1160(msg) @@ -3440,7 +3441,7 @@ def _t1160(_dollar_dollar): self.write(']') return None - def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def pretty_rel_edb_types(self, msg: Sequence[logic_pb2.Type]) -> Optional[Never]: def _t1163(_dollar_dollar): return _dollar_dollar _t1164 = _t1163(msg) @@ -3503,7 +3504,7 @@ def _t1171(_dollar_dollar): self.write(')') return None - def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def pretty_betree_info_key_types(self, msg: Sequence[logic_pb2.Type]) -> Optional[Never]: def _t1177(_dollar_dollar): return _dollar_dollar _t1178 = _t1177(msg) @@ -3527,7 +3528,7 @@ def _t1177(_dollar_dollar): self.write(')') return None - def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: + def pretty_betree_info_value_types(self, msg: Sequence[logic_pb2.Type]) -> Optional[Never]: def _t1181(_dollar_dollar): return _dollar_dollar _t1182 = _t1181(msg) @@ -3621,7 +3622,7 @@ def _t1191(_dollar_dollar): self.write(')') return None - def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: + def pretty_csv_locator_paths(self, msg: Sequence[str]) -> Optional[Never]: def _t1199(_dollar_dollar): return _dollar_dollar _t1200 = _t1199(msg) @@ -3678,7 +3679,7 @@ def _t1204(_dollar_dollar): self.write(')') return None - def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: + def pretty_csv_columns(self, msg: Sequence[logic_pb2.CSVColumn]) -> Optional[Never]: def _t1208(_dollar_dollar): return _dollar_dollar _t1209 = _t1208(msg) @@ -3790,7 +3791,7 @@ def _t1222(_dollar_dollar): self.write(')') return None - def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: + def pretty_epoch_reads(self, msg: Sequence[transactions_pb2.Read]) -> Optional[Never]: def _t1226(_dollar_dollar): return _dollar_dollar _t1227 = _t1226(msg) @@ -4036,7 +4037,7 @@ def _t1281(_dollar_dollar): self.write(')') return None - def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: + def pretty_export_csv_columns(self, msg: Sequence[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: def _t1283(_dollar_dollar): return _dollar_dollar _t1284 = _t1283(msg) diff --git a/python-tools/src/meta/__init__.py b/python-tools/src/meta/__init__.py index fa702970..f391d6ff 100644 --- a/python-tools/src/meta/__init__.py +++ b/python-tools/src/meta/__init__.py @@ -25,6 +25,7 @@ TargetType, BaseType, TupleType, + SequenceType, ListType, FunDef, ParseNonterminalDef, @@ -97,6 +98,7 @@ 'TargetType', 'BaseType', 'TupleType', + 'SequenceType', 'ListType', 'FunDef', 'ParseNonterminalDef', diff --git a/python-tools/src/meta/codegen_base.py b/python-tools/src/meta/codegen_base.py index efe9372b..a3246f13 100644 --- a/python-tools/src/meta/codegen_base.py +++ b/python-tools/src/meta/codegen_base.py @@ -14,7 +14,7 @@ IfElse, Seq, While, Foreach, ForeachEnumerated, Assign, Return, FunDef, ParseNonterminalDef, PrintNonterminalDef, ParseNonterminal, PrintNonterminal, - TargetType, BaseType, TupleType, ListType, DictType, OptionType, + TargetType, BaseType, TupleType, SequenceType, ListType, DictType, OptionType, MessageType, EnumType, FunctionType, VarType, GetField, GetElement ) from .target_builtins import get_builtin @@ -168,9 +168,14 @@ def gen_tuple_type(self, element_types: List[str]) -> str: """Generate a tuple type with the given element types.""" pass + @abstractmethod + def gen_sequence_type(self, element_type: str) -> str: + """Generate a read-only sequence type.""" + pass + @abstractmethod def gen_list_type(self, element_type: str) -> str: - """Generate a list/array type.""" + """Generate a mutable list/array type.""" pass @abstractmethod @@ -204,6 +209,8 @@ def gen_type(self, typ: TargetType) -> str: elif isinstance(typ, TupleType): element_types = [self.gen_type(e) for e in typ.elements] return self.gen_tuple_type(element_types) + elif isinstance(typ, SequenceType): + return self.gen_sequence_type(self.gen_type(typ.element_type)) elif isinstance(typ, ListType): return self.gen_list_type(self.gen_type(typ.element_type)) elif isinstance(typ, DictType): diff --git a/python-tools/src/meta/codegen_go.py b/python-tools/src/meta/codegen_go.py index e53d81a0..e3522481 100644 --- a/python-tools/src/meta/codegen_go.py +++ b/python-tools/src/meta/codegen_go.py @@ -233,6 +233,9 @@ def gen_tuple_type(self, element_types: List[str]) -> str: # Go doesn't have tuples, use a struct or interface slice return f"[]interface{{}}" + def gen_sequence_type(self, element_type: str) -> str: + return f"[]{element_type}" + def gen_list_type(self, element_type: str) -> str: return f"[]{element_type}" @@ -502,7 +505,7 @@ def unwrap_if_option(field_expr, field_value: str) -> Tuple[str, str]: def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[str]: """Override to handle OneOf, VisitNonterminal, NamedFun, and option builtins for Go.""" - from .target import NamedFun, FunctionType, ListType, BaseType, Builtin, OptionType + from .target import NamedFun, FunctionType, SequenceType, ListType, BaseType, Builtin, OptionType # Intercept option-related builtins to use pointer/nil idioms if isinstance(expr.func, Builtin) and expr.func.name in ( @@ -541,7 +544,7 @@ def _generate_call(self, expr: Call, lines: List[str], indent: str) -> Optional[ # Try to get expected type from parameter if i < len(func_type.param_types): param_type = func_type.param_types[i] - if isinstance(param_type, ListType): + if isinstance(param_type, (SequenceType, ListType)): # Generate list with correct element type arg_code = self.gen_list_literal([], param_type.element_type) args.append(arg_code) diff --git a/python-tools/src/meta/codegen_julia.py b/python-tools/src/meta/codegen_julia.py index 64fb4ab4..861ee35f 100644 --- a/python-tools/src/meta/codegen_julia.py +++ b/python-tools/src/meta/codegen_julia.py @@ -164,6 +164,9 @@ def gen_tuple_type(self, element_types: List[str]) -> str: return 'Tuple{}' return f"Tuple{{{', '.join(element_types)}}}" + def gen_sequence_type(self, element_type: str) -> str: + return f"Vector{{{element_type}}}" + def gen_list_type(self, element_type: str) -> str: return f"Vector{{{element_type}}}" diff --git a/python-tools/src/meta/codegen_python.py b/python-tools/src/meta/codegen_python.py index 86be5345..4c76d44b 100644 --- a/python-tools/src/meta/codegen_python.py +++ b/python-tools/src/meta/codegen_python.py @@ -127,6 +127,9 @@ def gen_tuple_type(self, element_types: List[str]) -> str: return 'tuple[()]' return f"tuple[{', '.join(element_types)}]" + def gen_sequence_type(self, element_type: str) -> str: + return f"Sequence[{element_type}]" + def gen_list_type(self, element_type: str) -> str: return f"list[{element_type}]" diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index 481f750d..162abb41 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -48,7 +48,7 @@ class BuiltinTemplate: "to_ptr_string": BuiltinTemplate("{0}"), "to_ptr_bool": BuiltinTemplate("{0}"), "map": BuiltinTemplate("[{0}(x) for x in {1}]"), - "list_concat": BuiltinTemplate("({0} + ({1} if {1} is not None else []))"), + "list_concat": BuiltinTemplate("(list({0}) + list({1} if {1} is not None else []))"), "list_push": BuiltinTemplate("None", ["{0}.append({1})"]), "fragment_id_from_string": BuiltinTemplate("fragments_pb2.FragmentId(id={0}.encode())"), "relation_id_from_string": BuiltinTemplate("self.relation_id_from_string({0})"), diff --git a/python-tools/src/meta/grammar.py b/python-tools/src/meta/grammar.py index 120ca163..7cd712e3 100644 --- a/python-tools/src/meta/grammar.py +++ b/python-tools/src/meta/grammar.py @@ -8,7 +8,7 @@ from typing import Dict, List, Optional, Tuple, TYPE_CHECKING # Import action AST types -from .target import Lambda, TargetType, ListType, OptionType, TupleType, FunDef +from .target import Lambda, TargetType, SequenceType, ListType, OptionType, TupleType, FunDef # Use TYPE_CHECKING to avoid circular import: GrammarAnalysis imports Grammar, # but we need GrammarAnalysis type hints here. These imports only exist during @@ -121,8 +121,8 @@ def __str__(self) -> str: return f"{self.rhs}*" def target_type(self) -> TargetType: - """Return list type of the element type.""" - return ListType(self.rhs.target_type()) + """Return sequence type of the element type.""" + return SequenceType(self.rhs.target_type()) @dataclass(frozen=True) diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index 2b35e97b..aa189efe 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -51,18 +51,18 @@ %nonterm assign logic.Assign %nonterm atom logic.Atom %nonterm attribute logic.Attribute -%nonterm attrs List[logic.Attribute] +%nonterm attrs Sequence[logic.Attribute] %nonterm betree_info logic.BeTreeInfo -%nonterm betree_info_key_types List[logic.Type] -%nonterm betree_info_value_types List[logic.Type] +%nonterm betree_info_key_types Sequence[logic.Type] +%nonterm betree_info_value_types Sequence[logic.Type] %nonterm betree_relation logic.BeTreeRelation %nonterm binding logic.Binding -%nonterm bindings Tuple[List[logic.Binding], List[logic.Binding]] +%nonterm bindings Tuple[Sequence[logic.Binding], Sequence[logic.Binding]] %nonterm boolean_type logic.BooleanType %nonterm boolean_value Boolean %nonterm break logic.Break %nonterm cast logic.Cast -%nonterm config_dict List[Tuple[String, logic.Value]] +%nonterm config_dict Sequence[Tuple[String, logic.Value]] %nonterm config_key_value Tuple[String, logic.Value] %nonterm configure transactions.Configure %nonterm conjunction logic.Conjunction @@ -72,11 +72,11 @@ %nonterm context transactions.Context %nonterm csv_asof String %nonterm csv_column logic.CSVColumn -%nonterm csv_columns List[logic.CSVColumn] +%nonterm csv_columns Sequence[logic.CSVColumn] %nonterm csv_config logic.CSVConfig %nonterm csv_data logic.CSVData %nonterm csv_locator_inline_data String -%nonterm csv_locator_paths List[String] +%nonterm csv_locator_paths Sequence[String] %nonterm csvlocator logic.CSVLocator %nonterm data logic.Data %nonterm date logic.DateValue @@ -92,27 +92,27 @@ %nonterm divide logic.Primitive %nonterm abort transactions.Abort %nonterm epoch transactions.Epoch -%nonterm epoch_reads List[transactions.Read] -%nonterm epoch_writes List[transactions.Write] +%nonterm epoch_reads Sequence[transactions.Read] +%nonterm epoch_writes Sequence[transactions.Write] %nonterm eq logic.Primitive %nonterm exists logic.Exists %nonterm export transactions.Export %nonterm export_csv_column transactions.ExportCSVColumn -%nonterm export_csv_columns List[transactions.ExportCSVColumn] +%nonterm export_csv_columns Sequence[transactions.ExportCSVColumn] %nonterm export_csv_config transactions.ExportCSVConfig %nonterm export_csv_path String %nonterm false logic.Disjunction %nonterm ffi logic.FFI -%nonterm ffi_args List[logic.Abstraction] +%nonterm ffi_args Sequence[logic.Abstraction] %nonterm float_type logic.FloatType %nonterm formula logic.Formula %nonterm fragment fragments.Fragment %nonterm fragment_id fragments.FragmentId -%nonterm functional_dependency_keys List[logic.Var] -%nonterm functional_dependency_values List[logic.Var] +%nonterm functional_dependency_keys Sequence[logic.Var] +%nonterm functional_dependency_values Sequence[logic.Var] %nonterm gt logic.Primitive %nonterm gt_eq logic.Primitive -%nonterm init List[logic.Instruction] +%nonterm init Sequence[logic.Instruction] %nonterm instruction logic.Instruction %nonterm int_type logic.IntType %nonterm int128_type logic.Int128Type @@ -138,8 +138,8 @@ %nonterm reduce logic.Reduce %nonterm rel_atom logic.RelAtom %nonterm rel_edb logic.RelEDB -%nonterm rel_edb_path List[String] -%nonterm rel_edb_types List[logic.Type] +%nonterm rel_edb_path Sequence[String] +%nonterm rel_edb_types Sequence[logic.Type] %nonterm rel_term logic.RelTerm %nonterm relation_id logic.RelationId %nonterm script logic.Script @@ -148,7 +148,7 @@ %nonterm sum_monoid logic.SumMonoid %nonterm sync transactions.Sync %nonterm term logic.Term -%nonterm terms List[logic.Term] +%nonterm terms Sequence[logic.Term] %nonterm transaction transactions.Transaction %nonterm true logic.Conjunction %nonterm type logic.Type @@ -157,7 +157,7 @@ %nonterm unspecified_type logic.UnspecifiedType %nonterm upsert logic.Upsert %nonterm value logic.Value -%nonterm value_bindings List[logic.Binding] +%nonterm value_bindings Sequence[logic.Binding] %nonterm var logic.Var %nonterm what_if transactions.WhatIf %nonterm write transactions.Write @@ -184,12 +184,12 @@ transaction deconstruct: $3: Optional[transactions.Configure] = $$.configure if builtin.has_proto_field($$, "configure") else None $4: Optional[transactions.Sync] = $$.sync if builtin.has_proto_field($$, "sync") else None - $5: List[transactions.Epoch] = $$.epochs + $5: Sequence[transactions.Epoch] = $$.epochs configure : "(" "configure" config_dict ")" construct: $$ = construct_configure($3) - deconstruct: $3: List[Tuple[String, logic.Value]] = deconstruct_configure($$) + deconstruct: $3: Sequence[Tuple[String, logic.Value]] = deconstruct_configure($$) config_dict : "{" config_key_value* "}" @@ -274,7 +274,7 @@ boolean_value sync : "(" "sync" fragment_id* ")" construct: $$ = transactions.Sync(fragments=$3) - deconstruct: $3: List[fragments.FragmentId] = $$.fragments + deconstruct: $3: Sequence[fragments.FragmentId] = $$.fragments fragment_id : ":" SYMBOL @@ -285,8 +285,8 @@ epoch : "(" "epoch" epoch_writes? epoch_reads? ")" construct: $$ = transactions.Epoch(writes=builtin.unwrap_option_or($3, list[transactions.Write]()), reads=builtin.unwrap_option_or($4, list[transactions.Read]())) deconstruct: - $3: Optional[List[transactions.Write]] = $$.writes if not builtin.is_empty($$.writes) else None - $4: Optional[List[transactions.Read]] = $$.reads if not builtin.is_empty($$.reads) else None + $3: Optional[Sequence[transactions.Write]] = $$.writes if not builtin.is_empty($$.writes) else None + $4: Optional[Sequence[transactions.Read]] = $$.reads if not builtin.is_empty($$.reads) else None epoch_writes : "(" "writes" write* ")" @@ -316,7 +316,7 @@ fragment deconstruct: builtin.start_pretty_fragment($$) $3: fragments.FragmentId = $$.id - $4: List[logic.Declaration] = $$.declarations + $4: Sequence[logic.Declaration] = $$.declarations new_fragment_id : fragment_id @@ -348,7 +348,7 @@ def deconstruct: $3: logic.RelationId = $$.name $4: logic.Abstraction = $$.body - $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None relation_id : ":" SYMBOL @@ -362,15 +362,15 @@ abstraction : "(" bindings formula ")" construct: $$ = logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3) deconstruct: - $2: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings($$) + $2: Tuple[Sequence[logic.Binding], Sequence[logic.Binding]] = deconstruct_bindings($$) $3: logic.Formula = $$.value bindings : "[" binding* value_bindings? "]" construct: $$ = builtin.tuple($2, builtin.unwrap_option_or($3, list[logic.Binding]())) deconstruct: - $2: List[logic.Binding] = $$[0] - $3: Optional[List[logic.Binding]] = $$[1] if not builtin.is_empty($$[1]) else None + $2: Sequence[logic.Binding] = $$[0] + $3: Optional[Sequence[logic.Binding]] = $$[1] if not builtin.is_empty($$[1]) else None binding : SYMBOL "::" type @@ -541,7 +541,7 @@ exists : "(" "exists" bindings formula ")" construct: $$ = logic.Exists(body=logic.Abstraction(vars=builtin.list_concat($3[0], $3[1]), value=$4)) deconstruct: - $3: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings($$.body) + $3: Tuple[Sequence[logic.Binding], Sequence[logic.Binding]] = deconstruct_bindings($$.body) $4: logic.Formula = $$.body.value reduce @@ -550,7 +550,7 @@ reduce deconstruct: $3: logic.Abstraction = $$.op $4: logic.Abstraction = $$.body - $5: List[logic.Term] = $$.terms + $5: Sequence[logic.Term] = $$.terms term : var @@ -573,12 +573,12 @@ constant conjunction : "(" "and" formula* ")" construct: $$ = logic.Conjunction(args=$3) - deconstruct: $3: List[logic.Formula] = $$.args + deconstruct: $3: Sequence[logic.Formula] = $$.args disjunction : "(" "or" formula* ")" construct: $$ = logic.Disjunction(args=$3) - deconstruct: $3: List[logic.Formula] = $$.args + deconstruct: $3: Sequence[logic.Formula] = $$.args not : "(" "not" formula ")" @@ -590,8 +590,8 @@ ffi construct: $$ = logic.FFI(name=$3, args=$4, terms=$5) deconstruct: $3: String = $$.name - $4: List[logic.Abstraction] = $$.args - $5: List[logic.Term] = $$.terms + $4: Sequence[logic.Abstraction] = $$.args + $5: Sequence[logic.Term] = $$.terms ffi_args : "(" "args" abstraction* ")" @@ -607,14 +607,14 @@ atom construct: $$ = logic.Atom(name=$3, terms=$4) deconstruct: $3: logic.RelationId = $$.name - $4: List[logic.Term] = $$.terms + $4: Sequence[logic.Term] = $$.terms pragma : "(" "pragma" name term* ")" construct: $$ = logic.Pragma(name=$3, terms=$4) deconstruct: $3: String = $$.name - $4: List[logic.Term] = $$.terms + $4: Sequence[logic.Term] = $$.terms primitive : eq @@ -630,7 +630,7 @@ primitive construct: $$ = logic.Primitive(name=$3, terms=$4) deconstruct: $3: String = $$.name - $4: List[logic.RelTerm] = $$.terms + $4: Sequence[logic.RelTerm] = $$.terms eq : "(" "=" term term ")" @@ -717,7 +717,7 @@ rel_atom construct: $$ = logic.RelAtom(name=$3, terms=$4) deconstruct: $3: String = $$.name - $4: List[logic.RelTerm] = $$.terms + $4: Sequence[logic.RelTerm] = $$.terms cast : "(" "cast" term term ")" @@ -734,19 +734,19 @@ attribute construct: $$ = logic.Attribute(name=$3, args=$4) deconstruct: $3: String = $$.name - $4: List[logic.Value] = $$.args + $4: Sequence[logic.Value] = $$.args algorithm : "(" "algorithm" relation_id* script ")" construct: $$ = logic.Algorithm(global=$3, body=$4) deconstruct: - $3: List[logic.RelationId] = $$.global + $3: Sequence[logic.RelationId] = $$.global $4: logic.Script = $$.body script : "(" "script" construct* ")" construct: $$ = logic.Script(constructs=$3) - deconstruct: $3: List[logic.Construct] = $$.constructs + deconstruct: $3: Sequence[logic.Construct] = $$.constructs construct : loop @@ -762,7 +762,7 @@ loop : "(" "loop" init script ")" construct: $$ = logic.Loop(init=$3, body=$4) deconstruct: - $3: List[logic.Instruction] = $$.init + $3: Sequence[logic.Instruction] = $$.init $4: logic.Script = $$.body init @@ -796,7 +796,7 @@ assign deconstruct: $3: logic.RelationId = $$.name $4: logic.Abstraction = $$.body - $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None upsert : "(" "upsert" relation_id abstraction_with_arity attrs? ")" @@ -804,13 +804,13 @@ upsert deconstruct: $3: logic.RelationId = $$.name $4: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) - $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None abstraction_with_arity : "(" bindings formula ")" construct: $$ = builtin.tuple(logic.Abstraction(vars=builtin.list_concat($2[0], $2[1]), value=$3), builtin.length($2[1])) deconstruct: - $2: Tuple[List[logic.Binding], List[logic.Binding]] = deconstruct_bindings_with_arity($$[0], $$[1]) + $2: Tuple[Sequence[logic.Binding], Sequence[logic.Binding]] = deconstruct_bindings_with_arity($$[0], $$[1]) $3: logic.Formula = $$[0].value break @@ -819,7 +819,7 @@ break deconstruct: $3: logic.RelationId = $$.name $4: logic.Abstraction = $$.body - $5: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None monoid_def : "(" "monoid" monoid relation_id abstraction_with_arity attrs? ")" @@ -828,7 +828,7 @@ monoid_def $3: logic.Monoid = $$.monoid $4: logic.RelationId = $$.name $5: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) - $6: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $6: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None monoid : or_monoid @@ -874,7 +874,7 @@ monus_def $3: logic.Monoid = $$.monoid $4: logic.RelationId = $$.name $5: Tuple[logic.Abstraction, Int64] = builtin.tuple($$.body, $$.value_arity) - $6: Optional[List[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None + $6: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None constraint : "(" "functional_dependency" relation_id abstraction functional_dependency_keys functional_dependency_values ")" @@ -882,8 +882,8 @@ constraint deconstruct: $3: logic.RelationId = $$.name $4: logic.Abstraction = $$.functional_dependency.guard - $5: List[logic.Var] = $$.functional_dependency.keys - $6: List[logic.Var] = $$.functional_dependency.values + $5: Sequence[logic.Var] = $$.functional_dependency.keys + $6: Sequence[logic.Var] = $$.functional_dependency.values functional_dependency_keys : "(" "keys" var* ")" @@ -916,8 +916,8 @@ rel_edb construct: $$ = logic.RelEDB(target_id=$3, path=$4, types=$5) deconstruct: $3: logic.RelationId = $$.target_id - $4: List[String] = $$.path - $5: List[logic.Type] = $$.types + $4: Sequence[String] = $$.path + $5: Sequence[logic.Type] = $$.types betree_relation : "(" "betree_relation" relation_id betree_info ")" @@ -930,9 +930,9 @@ betree_info : "(" "betree_info" betree_info_key_types betree_info_value_types config_dict ")" construct: $$ = construct_betree_info($3, $4, $5) deconstruct: - $3: List[logic.Type] = $$.key_types - $4: List[logic.Type] = $$.value_types - $5: List[Tuple[String, logic.Value]] = deconstruct_betree_info_config($$) + $3: Sequence[logic.Type] = $$.key_types + $4: Sequence[logic.Type] = $$.value_types + $5: Sequence[Tuple[String, logic.Value]] = deconstruct_betree_info_config($$) betree_info_key_types : "(" "key_types" type* ")" @@ -952,7 +952,7 @@ csv_data deconstruct: $3: logic.CSVLocator = $$.locator $4: logic.CSVConfig = $$.config - $5: List[logic.CSVColumn] = $$.columns + $5: Sequence[logic.CSVColumn] = $$.columns $6: String = $$.asof csv_locator_paths @@ -965,13 +965,13 @@ csvlocator : "(" "csv_locator" csv_locator_paths? csv_locator_inline_data? ")" construct: $$ = logic.CSVLocator(paths=builtin.unwrap_option_or($3, list[str]()), inline_data=builtin.encode_string(builtin.unwrap_option_or($4, ""))) deconstruct: - $3: Optional[List[String]] = $$.paths if not builtin.is_empty($$.paths) else None + $3: Optional[Sequence[String]] = $$.paths if not builtin.is_empty($$.paths) else None $4: Optional[String] = builtin.decode_string($$.inline_data) if builtin.decode_string($$.inline_data) != "" else None csv_config : "(" "csv_config" config_dict ")" construct: $$ = construct_csv_config($3) - deconstruct: $3: List[Tuple[String, logic.Value]] = deconstruct_csv_config($$) + deconstruct: $3: Sequence[Tuple[String, logic.Value]] = deconstruct_csv_config($$) csv_column : "(" "column" STRING relation_id "[" type* "]" ")" @@ -979,7 +979,7 @@ csv_column deconstruct: $3: String = $$.column_name $4: logic.RelationId = $$.target_id - $6: List[logic.Type] = $$.types + $6: Sequence[logic.Type] = $$.types undefine : "(" "undefine" fragment_id ")" @@ -989,7 +989,7 @@ undefine context : "(" "context" relation_id* ")" construct: $$ = transactions.Context(relations=$3) - deconstruct: $3: List[logic.RelationId] = $$.relations + deconstruct: $3: Sequence[logic.RelationId] = $$.relations epoch_reads : "(" "reads" read* ")" @@ -1052,8 +1052,8 @@ export_csv_config construct: $$ = export_csv_config($3, $4, $5) deconstruct: $3: String = $$.path - $4: List[transactions.ExportCSVColumn] = $$.data_columns - $5: List[Tuple[String, logic.Value]] = deconstruct_export_csv_config($$) + $4: Sequence[transactions.ExportCSVColumn] = $$.data_columns + $5: Sequence[Tuple[String, logic.Value]] = deconstruct_export_csv_config($$) export_csv_path : "(" "path" STRING ")" @@ -1113,7 +1113,7 @@ def _extract_value_uint128(value: Optional[logic.Value], default: logic.UInt128V return builtin.unwrap_option(value).uint128_value return default -def _extract_value_string_list(value: Optional[logic.Value], default: List[String]) -> List[String]: +def _extract_value_string_list(value: Optional[logic.Value], default: Sequence[String]) -> Sequence[String]: if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'string_value'): return [builtin.unwrap_option(value).string_value] return default @@ -1148,13 +1148,13 @@ def _try_extract_value_uint128(value: Optional[logic.Value]) -> Optional[logic.U return None -def _try_extract_value_string_list(value: Optional[logic.Value]) -> Optional[List[String]]: +def _try_extract_value_string_list(value: Optional[logic.Value]) -> Optional[Sequence[String]]: if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'string_value'): return [builtin.unwrap_option(value).string_value] return None -def construct_csv_config(config_dict: List[Tuple[String, logic.Value]]) -> logic.CSVConfig: +def construct_csv_config(config_dict: Sequence[Tuple[String, logic.Value]]) -> logic.CSVConfig: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) header_row: int = _extract_value_int32(builtin.dict_get(config, "csv_header_row"), 1) skip: int = _extract_value_int64(builtin.dict_get(config, "csv_skip"), 0) @@ -1163,7 +1163,7 @@ def construct_csv_config(config_dict: List[Tuple[String, logic.Value]]) -> logic quotechar: str = _extract_value_string(builtin.dict_get(config, "csv_quotechar"), "\"") escapechar: str = _extract_value_string(builtin.dict_get(config, "csv_escapechar"), "\"") comment: str = _extract_value_string(builtin.dict_get(config, "csv_comment"), "") - missing_strings: List[String] = _extract_value_string_list(builtin.dict_get(config, "csv_missing_strings"), list[str]()) + missing_strings: Sequence[String] = _extract_value_string_list(builtin.dict_get(config, "csv_missing_strings"), list[str]()) decimal_separator: str = _extract_value_string(builtin.dict_get(config, "csv_decimal_separator"), ".") encoding: str = _extract_value_string(builtin.dict_get(config, "csv_encoding"), "utf-8") compression: str = _extract_value_string(builtin.dict_get(config, "csv_compression"), "auto") @@ -1183,9 +1183,9 @@ def construct_csv_config(config_dict: List[Tuple[String, logic.Value]]) -> logic def construct_betree_info( - key_types: List[logic.Type], - value_types: List[logic.Type], - config_dict: List[Tuple[String, logic.Value]], + key_types: Sequence[logic.Type], + value_types: Sequence[logic.Type], + config_dict: Sequence[Tuple[String, logic.Value]], ) -> logic.BeTreeInfo: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) epsilon: Optional[float] = _try_extract_value_float64(builtin.dict_get(config, "betree_config_epsilon")) @@ -1223,7 +1223,7 @@ def default_configure() -> transactions.Configure: ivm_config=ivm_config, ) -def construct_configure(config_dict: List[Tuple[String, logic.Value]]) -> transactions.Configure: +def construct_configure(config_dict: Sequence[Tuple[String, logic.Value]]) -> transactions.Configure: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) maintenance_level_val: Optional[logic.Value] = builtin.dict_get(config, "ivm.maintenance_level") maintenance_level: transactions.MaintenanceLevel = transactions.MaintenanceLevel.MAINTENANCE_LEVEL_OFF @@ -1247,8 +1247,8 @@ def construct_configure(config_dict: List[Tuple[String, logic.Value]]) -> transa def export_csv_config( path: String, - columns: List[transactions.ExportCSVColumn], - config_dict: List[Tuple[String, logic.Value]], + columns: Sequence[transactions.ExportCSVColumn], + config_dict: Sequence[Tuple[String, logic.Value]], ) -> transactions.ExportCSVConfig: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) partition_size: int = _extract_value_int64(builtin.dict_get(config, "partition_size"), 0) @@ -1406,12 +1406,12 @@ def deconstruct_relation_id_uint128(msg: logic.RelationId) -> Optional[logic.UIn return None -def deconstruct_bindings(abs: logic.Abstraction) -> Tuple[List[logic.Binding], List[logic.Binding]]: +def deconstruct_bindings(abs: logic.Abstraction) -> Tuple[Sequence[logic.Binding], Sequence[logic.Binding]]: n: int = builtin.length(abs.vars) return builtin.tuple(builtin.list_slice(abs.vars, 0, n), list[logic.Binding]()) -def deconstruct_bindings_with_arity(abs: logic.Abstraction, value_arity: int) -> Tuple[List[logic.Binding], List[logic.Binding]]: +def deconstruct_bindings_with_arity(abs: logic.Abstraction, value_arity: int) -> Tuple[Sequence[logic.Binding], Sequence[logic.Binding]]: n: int = builtin.length(abs.vars) key_end: int = n - value_arity return builtin.tuple(builtin.list_slice(abs.vars, 0, key_end), builtin.list_slice(abs.vars, key_end, n)) diff --git a/python-tools/src/meta/grammar_validator.py b/python-tools/src/meta/grammar_validator.py index a9174907..ae90f907 100644 --- a/python-tools/src/meta/grammar_validator.py +++ b/python-tools/src/meta/grammar_validator.py @@ -27,7 +27,7 @@ from .proto_ast import ProtoMessage, ProtoField from .target import ( TargetType, TargetExpr, Call, NewMessage, Builtin, IfElse, Let, Seq, ListExpr, GetField, - GetElement, BaseType, VarType, MessageType, ListType, OptionType, TupleType, Lambda, OneOf + GetElement, BaseType, VarType, MessageType, SequenceType, ListType, OptionType, TupleType, Lambda, OneOf ) from .type_env import TypeEnv from .validation_result import ValidationResult @@ -391,19 +391,19 @@ def _check_builtin_call_types(self, builtin: Builtin, args: PySequence[TargetExp else: arg0_type = self._infer_expr_type(args[0]) arg1_type = self._infer_expr_type(args[1]) - if arg0_type is not None and not isinstance(arg0_type, ListType): + if arg0_type is not None and not isinstance(arg0_type, (SequenceType, ListType)): self.result.add_error( "type_builtin_arg", - f"In {context}: builtin 'list_concat' arg 0 has type {arg0_type}, expected List[T]", + f"In {context}: builtin 'list_concat' arg 0 has type {arg0_type}, expected Sequence[T]", rule_name=context ) - if arg1_type is not None and not isinstance(arg1_type, ListType): + if arg1_type is not None and not isinstance(arg1_type, (SequenceType, ListType)): self.result.add_error( "type_builtin_arg", - f"In {context}: builtin 'list_concat' arg 1 has type {arg1_type}, expected List[T]", + f"In {context}: builtin 'list_concat' arg 1 has type {arg1_type}, expected Sequence[T]", rule_name=context ) - if arg0_type is not None and arg1_type is not None and isinstance(arg0_type, ListType) and isinstance(arg1_type, ListType): + if arg0_type is not None and arg1_type is not None and isinstance(arg0_type, (SequenceType, ListType)) and isinstance(arg1_type, (SequenceType, ListType)): # Check that element types have a common supertype t = arg0_type.element_type u = arg1_type.element_type @@ -424,10 +424,10 @@ def _check_builtin_call_types(self, builtin: Builtin, args: PySequence[TargetExp ) else: arg_type = self._infer_expr_type(args[0]) - if arg_type is not None and not isinstance(arg_type, ListType): + if arg_type is not None and not isinstance(arg_type, (SequenceType, ListType)): self.result.add_error( "type_builtin_arg", - f"In {context}: builtin 'length' arg has type {arg_type}, expected List[T]", + f"In {context}: builtin 'length' arg has type {arg_type}, expected Sequence[T]", rule_name=context ) @@ -514,9 +514,15 @@ def _is_subtype(self, t1: TargetType, t2: TargetType) -> bool: # T <: Any for all T (Any is the top type) if isinstance(t2, BaseType) and t2.name == "Any": return True - # List is covariant: List[A] <: List[B] if A <: B - if isinstance(t1, ListType) and isinstance(t2, ListType): + # List[T] <: Sequence[U] if T <: U + if isinstance(t1, ListType) and isinstance(t2, SequenceType): + return self._is_subtype(t1.element_type, t2.element_type) + # Sequence is covariant: Sequence[A] <: Sequence[B] if A <: B + if isinstance(t1, SequenceType) and isinstance(t2, SequenceType): return self._is_subtype(t1.element_type, t2.element_type) + # List is invariant: List[A] <: List[B] only if A == B + if isinstance(t1, ListType) and isinstance(t2, ListType): + return t1.element_type == t2.element_type # Option is covariant: Option[A] <: Option[B] if A <: B if isinstance(t1, OptionType) and isinstance(t2, OptionType): return self._is_subtype(t1.element_type, t2.element_type) @@ -704,8 +710,10 @@ def _is_valid_type(self, typ: TargetType) -> bool: return True return False + if isinstance(typ, SequenceType): + return self._is_valid_type(typ.element_type) + if isinstance(typ, ListType): - # List is valid if element type is valid return self._is_valid_type(typ.element_type) if isinstance(typ, OptionType): diff --git a/python-tools/src/meta/pretty_gen.py b/python-tools/src/meta/pretty_gen.py index 2dba7e21..eb7f84b5 100644 --- a/python-tools/src/meta/pretty_gen.py +++ b/python-tools/src/meta/pretty_gen.py @@ -13,7 +13,7 @@ from .grammar_utils import is_epsilon, rhs_elements from .target import ( Lambda, Call, PrintNonterminalDef, Var, Lit, Builtin, Let, IfElse, - BaseType, ListType, TupleType, TargetExpr, Seq, PrintNonterminal, gensym, + BaseType, SequenceType, ListType, TupleType, TargetExpr, Seq, PrintNonterminal, gensym, OptionType, ForeachEnumerated, GetElement ) from .target_builtins import make_builtin @@ -426,7 +426,7 @@ def _generate_pretty_star_from_field(rhs: Star, field_var: Var, leading_ws: Optional[List[TargetExpr]] = None) -> TargetExpr: """Generate pretty printing for a repeated field.""" list_type = field_var.type - if isinstance(list_type, ListType): + if isinstance(list_type, (SequenceType, ListType)): elem_type = list_type.element_type else: elem_type = BaseType('Any') diff --git a/python-tools/src/meta/target.py b/python-tools/src/meta/target.py index 5c50b4db..d50274f3 100644 --- a/python-tools/src/meta/target.py +++ b/python-tools/src/meta/target.py @@ -32,7 +32,8 @@ VarType - Type variable for polymorphic types MessageType - Protobuf message types TupleType - Tuple type with fixed number of element types - ListType - Parameterized list/array type + SequenceType - Read-only sequence type (covariant) + ListType - Mutable list/array type (invariant, subtype of Sequence) OptionType - Optional/Maybe type for values that may be None FunctionType - Function type with parameter types and return type """ @@ -394,7 +395,7 @@ def target_type(self) -> 'TargetType': if 0 <= self.index < len(expr_type.elements): return expr_type.elements[self.index] raise ValueError(f"Tuple index {self.index} out of range for {expr_type}") - if isinstance(expr_type, ListType): + if isinstance(expr_type, (SequenceType, ListType)): return expr_type.element_type if isinstance(expr_type, BaseType) and expr_type.name == "Unknown": return BaseType("Unknown") @@ -651,9 +652,31 @@ def __post_init__(self): _freeze_sequence(self, 'elements') +@dataclass(frozen=True) +class SequenceType(TargetType): + """Read-only sequence type (covariant on element type). + + Sequence[T] is the read-only counterpart of List[T]. + List[T] is a subtype of Sequence[T]. + Sequence is covariant: Sequence[A] <: Sequence[B] if A <: B. + + Example: + SequenceType(BaseType("Int64")) # Sequence[Int64] + SequenceType(MessageType("logic", "Expr")) # Sequence[logic.Expr] + """ + element_type: TargetType + + def __str__(self) -> str: + return f"Sequence[{self.element_type}]" + + @dataclass(frozen=True) class ListType(TargetType): - """Parameterized list/array type. + """Mutable list/array type (invariant on element type). + + List[T] is a subtype of Sequence[T]. + Use List[T] when mutation (e.g., list_push) is needed. + Use Sequence[T] for read-only access to repeated fields. Example: ListType(BaseType("Int64")) # List[Int64] @@ -714,6 +737,8 @@ def subst_type(typ: 'TargetType', mapping: dict[str, 'TargetType']) -> 'TargetTy return mapping.get(typ.name, typ) if isinstance(typ, (BaseType, MessageType, EnumType)): return typ + if isinstance(typ, SequenceType): + return SequenceType(subst_type(typ.element_type, mapping)) if isinstance(typ, ListType): return ListType(subst_type(typ.element_type, mapping)) if isinstance(typ, OptionType): @@ -740,7 +765,11 @@ def match_types(param_type: 'TargetType', arg_type: 'TargetType', mapping: dict[ if param_type.name not in mapping: mapping[param_type.name] = arg_type return - if isinstance(param_type, ListType) and isinstance(arg_type, ListType): + if isinstance(param_type, SequenceType) and isinstance(arg_type, SequenceType): + match_types(param_type.element_type, arg_type.element_type, mapping) + elif isinstance(param_type, SequenceType) and isinstance(arg_type, ListType): + match_types(param_type.element_type, arg_type.element_type, mapping) + elif isinstance(param_type, ListType) and isinstance(arg_type, ListType): match_types(param_type.element_type, arg_type.element_type, mapping) elif isinstance(param_type, OptionType) and isinstance(arg_type, OptionType): match_types(param_type.element_type, arg_type.element_type, mapping) @@ -850,6 +879,7 @@ def function_type(self) -> 'FunctionType': 'MessageType', 'EnumType', 'TupleType', + 'SequenceType', 'ListType', 'DictType', 'OptionType', diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index 0e60ebe6..3f6aa586 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -12,7 +12,7 @@ from dataclasses import dataclass from typing import Dict, List, Optional, Union -from .target import TargetType, BaseType, VarType, MessageType, ListType, TupleType, OptionType, FunctionType, DictType, Builtin +from .target import TargetType, BaseType, VarType, MessageType, SequenceType, ListType, TupleType, OptionType, FunctionType, DictType, Builtin # Type aliases for convenience ANY = VarType("Any") @@ -109,14 +109,14 @@ def is_builtin(name: str) -> bool: register_builtin("unwrap_option", [OptionType(T)], T) register_builtin("unwrap_option_or", [OptionType(T), T], T) -# === List operations === -register_builtin("list_concat", [ListType(T), ListType(T)], ListType(T)) +# === List/Sequence operations === +register_builtin("list_concat", [SequenceType(T), SequenceType(T)], ListType(T)) register_builtin("list_push", [ListType(T), T], VOID) # Mutating push: list.append(item) / push!(list, item) -register_builtin("list_slice", [ListType(T), INT64, INT64], ListType(T)) # list[start:end] -register_builtin("list_sort", [ListType(T)], ListType(T)) -register_builtin("length", [ListType(T)], INT64) -register_builtin("map", [FunctionType([T1], T2), ListType(T1)], ListType(T2)) -register_builtin("append", [ListType(T), T], ListType(T)) # list.append(item) +register_builtin("list_slice", [SequenceType(T), INT64, INT64], ListType(T)) # list[start:end] +register_builtin("list_sort", [SequenceType(T)], ListType(T)) +register_builtin("length", [SequenceType(T)], INT64) +register_builtin("map", [FunctionType([T1], T2), SequenceType(T1)], ListType(T2)) +register_builtin("append", [SequenceType(T), T], ListType(T)) # non-mutating append # === Tuple operations === register_builtin("tuple", -1, T) # Variadic: makes tuple from arguments @@ -125,7 +125,7 @@ def is_builtin(name: str) -> bool: register_builtin("string_concat", [STRING, STRING], STRING) register_builtin("string_to_upper", [STRING], STRING) register_builtin("string_to_lower", [STRING], STRING) -register_builtin("string_in_list", [STRING, ListType(STRING)], BOOLEAN) +register_builtin("string_in_list", [STRING, SequenceType(STRING)], BOOLEAN) register_builtin("encode_string", [STRING], BYTES) # === Type conversions === @@ -159,13 +159,13 @@ def is_builtin(name: str) -> bool: register_builtin("relation_id_to_uint128", [MessageType("logic", "RelationId")], MessageType("logic", "UInt128Value")) register_builtin("construct_fragment", [MessageType("fragments", "FragmentId"), - ListType(MessageType("logic", "Declaration"))], + SequenceType(MessageType("logic", "Declaration"))], MessageType("fragments", "Fragment")) register_builtin("start_fragment", [MessageType("fragments", "FragmentId")], BaseType("None")) register_builtin("start_pretty_fragment", [MessageType("fragments", "Fragment")], BaseType("None")) # === Dict operations === -register_builtin("dict_from_list", [ListType(TupleType([K, V]))], DictType(K, V)) +register_builtin("dict_from_list", [SequenceType(TupleType([K, V]))], DictType(K, V)) register_builtin("dict_get", [DictType(K, V), K], OptionType(V)) # === Protobuf operations === @@ -173,7 +173,7 @@ def is_builtin(name: str) -> bool: register_builtin("which_one_of", [T, STRING], STRING) # msg.WhichOneof(oneof_name) # === General helpers === -register_builtin("is_empty", [ListType(T)], BOOLEAN) # len(list) == 0 +register_builtin("is_empty", [SequenceType(T)], BOOLEAN) # len(list) == 0 register_builtin("enum_value", [STRING, STRING], T) # enum_value(EnumType, ValueName) register_builtin("greater", [INT64, INT64], BOOLEAN) register_builtin("to_string", [T], STRING) diff --git a/python-tools/src/meta/target_print.py b/python-tools/src/meta/target_print.py index 99212d88..cb2832c9 100644 --- a/python-tools/src/meta/target_print.py +++ b/python-tools/src/meta/target_print.py @@ -5,7 +5,7 @@ """ from .target import ( - TargetType, BaseType, VarType, MessageType, ListType, DictType, + TargetType, BaseType, VarType, MessageType, SequenceType, ListType, DictType, OptionType, TupleType, FunctionType, TargetExpr, Var, Lit, Symbol, Builtin, NamedFun, NewMessage, OneOf, ListExpr, Call, Lambda, Let, IfElse, Seq, While, @@ -33,6 +33,9 @@ def type_to_str(typ: TargetType) -> str: elif isinstance(typ, MessageType): return f"{typ.module}.{typ.name}" + elif isinstance(typ, SequenceType): + return f"Sequence[{type_to_str(typ.element_type)}]" + elif isinstance(typ, ListType): return f"List[{type_to_str(typ.element_type)}]" diff --git a/python-tools/src/meta/target_utils.py b/python-tools/src/meta/target_utils.py index 910a201e..569f9bdd 100644 --- a/python-tools/src/meta/target_utils.py +++ b/python-tools/src/meta/target_utils.py @@ -24,7 +24,7 @@ from .target import ( BaseType, Builtin, Lambda, Var, Lit, Call, TargetExpr, TargetType, - ListType, OptionType, TupleType, DictType, VarType + SequenceType, ListType, OptionType, TupleType, DictType, VarType ) from .target_builtins import make_builtin @@ -52,9 +52,15 @@ def is_subtype(t1: TargetType, t2: TargetType) -> bool: # T <: VarType for all T (type variables are wildcards) if isinstance(t2, VarType): return True - # List is covariant: List[A] <: List[B] if A <: B - if isinstance(t1, ListType) and isinstance(t2, ListType): + # List[T] <: Sequence[U] if T <: U + if isinstance(t1, ListType) and isinstance(t2, SequenceType): + return is_subtype(t1.element_type, t2.element_type) + # Sequence is covariant: Sequence[A] <: Sequence[B] if A <: B + if isinstance(t1, SequenceType) and isinstance(t2, SequenceType): return is_subtype(t1.element_type, t2.element_type) + # List is invariant: List[A] <: List[B] only if A == B + if isinstance(t1, ListType) and isinstance(t2, ListType): + return t1.element_type == t2.element_type # Option is covariant: Option[A] <: Option[B] if A <: B if isinstance(t1, OptionType) and isinstance(t2, OptionType): return is_subtype(t1.element_type, t2.element_type) @@ -87,6 +93,12 @@ def type_join(t1: TargetType, t2: TargetType) -> TargetType: return t2 if isinstance(t1, OptionType) and isinstance(t2, OptionType): return OptionType(type_join(t1.element_type, t2.element_type)) + if isinstance(t1, SequenceType) and isinstance(t2, SequenceType): + return SequenceType(type_join(t1.element_type, t2.element_type)) + if isinstance(t1, ListType) and isinstance(t2, SequenceType): + return SequenceType(type_join(t1.element_type, t2.element_type)) + if isinstance(t1, SequenceType) and isinstance(t2, ListType): + return SequenceType(type_join(t1.element_type, t2.element_type)) if isinstance(t1, ListType) and isinstance(t2, ListType): return ListType(type_join(t1.element_type, t2.element_type)) if isinstance(t1, TupleType) and isinstance(t2, TupleType): diff --git a/python-tools/src/meta/templates/parser.py.template b/python-tools/src/meta/templates/parser.py.template index c10759fc..5fd019a3 100644 --- a/python-tools/src/meta/templates/parser.py.template +++ b/python-tools/src/meta/templates/parser.py.template @@ -10,6 +10,7 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. import ast import hashlib import re +from collections.abc import Sequence from typing import List, Optional, Any, Tuple, Callable from decimal import Decimal diff --git a/python-tools/src/meta/templates/pretty_printer.py.template b/python-tools/src/meta/templates/pretty_printer.py.template index 925e8bcd..90f724c4 100644 --- a/python-tools/src/meta/templates/pretty_printer.py.template +++ b/python-tools/src/meta/templates/pretty_printer.py.template @@ -8,6 +8,7 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. {command_line_comment}""" from io import StringIO +from collections.abc import Sequence from typing import Any, IO, Never, Optional from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 diff --git a/python-tools/src/meta/type_env.py b/python-tools/src/meta/type_env.py index f3181f64..6b1303a9 100644 --- a/python-tools/src/meta/type_env.py +++ b/python-tools/src/meta/type_env.py @@ -5,7 +5,7 @@ from .proto_parser import ProtoParser from .proto_ast import ProtoMessage, ProtoField from .target import ( - TargetType, BaseType, MessageType, ListType, OptionType, FunctionType + TargetType, BaseType, MessageType, SequenceType, ListType, OptionType, FunctionType ) from .target_builtins import BUILTIN_REGISTRY @@ -99,9 +99,9 @@ def _proto_type_to_target(self, proto_field: ProtoField) -> TargetType: if proto_field.is_optional: base_type = OptionType(base_type) - # Wrap in List if repeated + # Wrap in Sequence if repeated (read-only access) if proto_field.is_repeated: - base_type = ListType(base_type) + base_type = SequenceType(base_type) return base_type diff --git a/python-tools/src/meta/yacc_action_parser.py b/python-tools/src/meta/yacc_action_parser.py index 4cc8f25d..86c689ad 100644 --- a/python-tools/src/meta/yacc_action_parser.py +++ b/python-tools/src/meta/yacc_action_parser.py @@ -24,7 +24,7 @@ from .grammar import Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence from .target import ( - TargetType, BaseType, MessageType, ListType, OptionType, TupleType, DictType, FunctionType, + TargetType, BaseType, MessageType, SequenceType, ListType, OptionType, TupleType, DictType, FunctionType, TargetExpr, Var, Lit, NamedFun, NewMessage, EnumValue, Call, Lambda, Let, IfElse, Seq, ListExpr, GetElement, GetField, FunDef, OneOf, Assign, Return, Foreach, ForeachEnumerated @@ -1301,7 +1301,10 @@ def _annotation_to_type(node: ast.AST, line: int) -> TargetType: elif isinstance(node, ast.Subscript): if isinstance(node.value, ast.Name): container = node.value.id - if container == 'List' or container == 'list': + if container == 'Sequence': + elem_type = _annotation_to_type(node.slice, line) + return SequenceType(elem_type) + elif container == 'List' or container == 'list': elem_type = _annotation_to_type(node.slice, line) return ListType(elem_type) elif container == 'Optional': diff --git a/python-tools/src/meta/yacc_parser.py b/python-tools/src/meta/yacc_parser.py index 352c98c7..e8deeef1 100644 --- a/python-tools/src/meta/yacc_parser.py +++ b/python-tools/src/meta/yacc_parser.py @@ -59,7 +59,7 @@ Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Sequence, Rule, GrammarConfig, TerminalDef, ) -from .target import TargetType, BaseType, MessageType, ListType, OptionType, TupleType +from .target import TargetType, BaseType, MessageType, SequenceType, ListType, OptionType, TupleType # Import from action parser from .yacc_action_parser import ( @@ -78,6 +78,7 @@ def parse_type(text: str) -> TargetType: Syntax: String, Int64, Float64, Boolean -> BaseType module.MessageName -> MessageType + Sequence[Type] -> SequenceType List[Type] -> ListType Tuple[Type1, Type2, ...] -> TupleType Optional[Type] -> OptionType @@ -91,7 +92,11 @@ def parse_type(text: str) -> TargetType: args_text = bracket_match.group(2) args = _split_bracket_type_args(args_text) - if constructor == "List": + if constructor == "Sequence": + if len(args) != 1: + raise YaccGrammarError(f"Sequence type requires exactly one argument: {text}") + return SequenceType(parse_type(args[0])) + elif constructor == "List": if len(args) != 1: raise YaccGrammarError(f"List type requires exactly one argument: {text}") return ListType(parse_type(args[0])) @@ -674,7 +679,7 @@ def _proto_type_to_target_type(proto_type: str, is_repeated: bool) -> TargetType base_type = MessageType('logic', proto_type) if is_repeated: - return ListType(base_type) + return SequenceType(base_type) return base_type diff --git a/python-tools/tests/meta/test_codegen_python.py b/python-tools/tests/meta/test_codegen_python.py index 705cf0d8..983cd1fd 100644 --- a/python-tools/tests/meta/test_codegen_python.py +++ b/python-tools/tests/meta/test_codegen_python.py @@ -122,7 +122,7 @@ def test_python_builtin_generation(): lines = [] expr = Call(make_builtin("list_concat"), [Var("lst", ListType(_int_type)), Var("other", ListType(_int_type))]) result = gen.generate_lines(expr, lines, "") - assert result == "(lst + (other if other is not None else []))" + assert result == "(list(lst) + list(other if other is not None else []))" # Test 'list_push' builtin (mutating push with statement) reset_gensym() diff --git a/python-tools/tests/meta/test_end_to_end_validation.py b/python-tools/tests/meta/test_end_to_end_validation.py index 2edb0f07..9e2b8767 100644 --- a/python-tools/tests/meta/test_end_to_end_validation.py +++ b/python-tools/tests/meta/test_end_to_end_validation.py @@ -327,7 +327,7 @@ def test_builtin_length_non_list_arg(self): result = parse_and_validate(grammar_content, proto_content) assert not result.is_valid assert any(e.category == "type_builtin_arg" for e in result.errors) - assert any("expected List" in e.message for e in result.errors) + assert any("expected Sequence" in e.message for e in result.errors) class TestOneofCoverage: diff --git a/python-tools/tests/meta/test_grammar.py b/python-tools/tests/meta/test_grammar.py index ddf913cc..4613ba22 100644 --- a/python-tools/tests/meta/test_grammar.py +++ b/python-tools/tests/meta/test_grammar.py @@ -12,7 +12,7 @@ get_nonterminals, get_literals, is_epsilon, rhs_elements, count_nonliteral_rhs_elements, ) -from meta.target import BaseType, MessageType, TupleType, ListType, OptionType, Lambda, Var +from meta.target import BaseType, MessageType, TupleType, SequenceType, ListType, OptionType, Lambda, Var class TestLitTerminal: @@ -131,11 +131,11 @@ def test_str(self): assert str(star) == "Item*" def test_target_type(self): - """Test Star returns list type.""" + """Test Star returns sequence type.""" nt = Nonterminal("Item", MessageType("proto", "Item")) star = Star(nt) result = star.target_type() - assert isinstance(result, ListType) + assert isinstance(result, SequenceType) assert result.element_type == MessageType("proto", "Item") diff --git a/python-tools/tests/meta/test_grammar_validator.py b/python-tools/tests/meta/test_grammar_validator.py index 7dd47ae9..8ae14573 100644 --- a/python-tools/tests/meta/test_grammar_validator.py +++ b/python-tools/tests/meta/test_grammar_validator.py @@ -4,7 +4,7 @@ import pytest from meta.target import ( - BaseType, MessageType, TupleType, ListType, OptionType, FunctionType, + BaseType, MessageType, TupleType, SequenceType, ListType, OptionType, FunctionType, Var, GetElement, Call, Builtin, NewMessage, Lambda, Lit, IfElse, Let, ListExpr, NamedFun, FunDef ) @@ -488,7 +488,7 @@ def test_builtin_length_non_list(self, validator): validator._check_builtin_call_types(builtin, args, 'test_rule') assert not validator.result.is_valid - assert any("expected List" in e.message for e in validator.result.errors) + assert any("expected Sequence" in e.message for e in validator.result.errors) class TestRuleTypeChecking: @@ -974,35 +974,35 @@ def test_list_reflexivity(self, validator): for t in types: assert validator._is_subtype(ListType(t), ListType(t)) - def test_list_never_is_bottom(self, validator): - """List[Never] <: List[T].""" + def test_list_invariant(self, validator): + """List is invariant: List[T] <: List[U] only if T == U.""" never = BaseType("Never") - types = [ - BaseType("Any"), - BaseType("Int64"), - BaseType("String"), - ] - for t in types: - assert validator._is_subtype(ListType(never), ListType(t)) - - def test_list_any_is_top(self, validator): - """List[T] <: List[Any].""" any_type = BaseType("Any") - types = [ - BaseType("Never"), - BaseType("Int64"), - BaseType("String"), - ] - for t in types: - assert validator._is_subtype(ListType(t), ListType(any_type)) - - def test_list_concrete_not_subtype(self, validator): - """List[T] is not a subtype of List[U] for distinct concrete T, U.""" int64 = BaseType("Int64") string = BaseType("String") + # List[Never] is NOT a subtype of List[Any] (invariant) + assert not validator._is_subtype(ListType(never), ListType(any_type)) + # List[Int64] is NOT a subtype of List[Any] (invariant) + assert not validator._is_subtype(ListType(int64), ListType(any_type)) + # Distinct concrete types are not subtypes assert not validator._is_subtype(ListType(int64), ListType(string)) assert not validator._is_subtype(ListType(string), ListType(int64)) + def test_list_subtype_of_sequence(self, validator): + """List[T] <: Sequence[T].""" + int64 = BaseType("Int64") + assert validator._is_subtype(ListType(int64), SequenceType(int64)) + + def test_sequence_covariant(self, validator): + """Sequence is covariant: Sequence[Never] <: Sequence[T].""" + never = BaseType("Never") + any_type = BaseType("Any") + int64 = BaseType("Int64") + assert validator._is_subtype(SequenceType(never), SequenceType(int64)) + assert validator._is_subtype(SequenceType(int64), SequenceType(any_type)) + # Sequence[Int64] is NOT a subtype of Sequence[String] + assert not validator._is_subtype(SequenceType(int64), SequenceType(BaseType("String"))) + def test_list_not_subtype_of_element(self, validator): """List[T] is not a subtype of T.""" int64 = BaseType("Int64") @@ -1063,15 +1063,24 @@ def test_element_not_subtype_of_option(self, validator): int64 = BaseType("Int64") assert not validator._is_subtype(int64, OptionType(int64)) - def test_nested_list_covariance(self, validator): - """List[List[Never]] <: List[List[Int64]].""" + def test_nested_list_invariance(self, validator): + """List is invariant: List[List[Never]] is NOT a subtype of List[List[Int64]].""" never = BaseType("Never") int64 = BaseType("Int64") - assert validator._is_subtype( + assert not validator._is_subtype( ListType(ListType(never)), ListType(ListType(int64)) ) + def test_nested_sequence_covariance(self, validator): + """Sequence[Sequence[Never]] <: Sequence[Sequence[Int64]].""" + never = BaseType("Never") + int64 = BaseType("Int64") + assert validator._is_subtype( + SequenceType(SequenceType(never)), + SequenceType(SequenceType(int64)) + ) + def test_nested_option_covariance(self, validator): """Option[Option[Never]] <: Option[Option[Int64]].""" never = BaseType("Never") @@ -1081,24 +1090,42 @@ def test_nested_option_covariance(self, validator): OptionType(OptionType(int64)) ) - def test_list_of_option_covariance(self, validator): - """List[Option[Never]] <: List[Option[Int64]].""" + def test_list_of_option_invariance(self, validator): + """List is invariant, so List[Option[Never]] is NOT <: List[Option[Int64]].""" never = BaseType("Never") int64 = BaseType("Int64") - assert validator._is_subtype( + assert not validator._is_subtype( ListType(OptionType(never)), ListType(OptionType(int64)) ) - def test_option_of_list_covariance(self, validator): - """Option[List[Never]] <: Option[List[Int64]].""" + def test_sequence_of_option_covariance(self, validator): + """Sequence[Option[Never]] <: Sequence[Option[Int64]].""" never = BaseType("Never") int64 = BaseType("Int64") assert validator._is_subtype( + SequenceType(OptionType(never)), + SequenceType(OptionType(int64)) + ) + + def test_option_of_list_invariance(self, validator): + """Option[List[Never]] is NOT <: Option[List[Int64]] because List is invariant.""" + never = BaseType("Never") + int64 = BaseType("Int64") + assert not validator._is_subtype( OptionType(ListType(never)), OptionType(ListType(int64)) ) + def test_option_of_sequence_covariance(self, validator): + """Option[Sequence[Never]] <: Option[Sequence[Int64]].""" + never = BaseType("Never") + int64 = BaseType("Int64") + assert validator._is_subtype( + OptionType(SequenceType(never)), + OptionType(SequenceType(int64)) + ) + def test_tuple_reflexivity(self, validator): """(T, U) <: (T, U).""" int64 = BaseType("Int64") @@ -1212,17 +1239,29 @@ def test_distinct_concrete_not_compatible(self, validator): string = BaseType("String") assert not validator._types_compatible(int64, string) - def test_list_compatible_via_never(self, validator): - """List[Never] is compatible with List[Int64].""" + def test_list_not_compatible_via_never(self, validator): + """List[Never] is NOT compatible with List[Int64] (List is invariant).""" + never = BaseType("Never") + int64 = BaseType("Int64") + assert not validator._types_compatible(ListType(never), ListType(int64)) + + def test_list_not_compatible_via_any(self, validator): + """List[Int64] is NOT compatible with List[Any] (List is invariant).""" + any_type = BaseType("Any") + int64 = BaseType("Int64") + assert not validator._types_compatible(ListType(int64), ListType(any_type)) + + def test_sequence_compatible_via_never(self, validator): + """Sequence[Never] is compatible with Sequence[Int64] (covariant).""" never = BaseType("Never") int64 = BaseType("Int64") - assert validator._types_compatible(ListType(never), ListType(int64)) + assert validator._types_compatible(SequenceType(never), SequenceType(int64)) - def test_list_compatible_via_any(self, validator): - """List[Int64] is compatible with List[Any].""" + def test_sequence_compatible_via_any(self, validator): + """Sequence[Int64] is compatible with Sequence[Any] (covariant).""" any_type = BaseType("Any") int64 = BaseType("Int64") - assert validator._types_compatible(ListType(int64), ListType(any_type)) + assert validator._types_compatible(SequenceType(int64), SequenceType(any_type)) def test_list_incompatible_elements(self, validator): """List[Int64] is not compatible with List[String].""" From 1e875d1917b6084902e9b5abdf14d00910e162ce Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Thu, 12 Feb 2026 12:49:56 +0100 Subject: [PATCH 20/25] add missing int32 conversions --- go/src/parser.go | 317 ++++++++++-------- julia/LQPParser/src/parser.jl | 28 +- python-tools/src/lqp/gen/parser.py | 24 +- python-tools/src/lqp/gen/pretty.py | 24 +- python-tools/src/meta/codegen_go.py | 53 ++- python-tools/src/meta/codegen_templates.py | 26 ++ python-tools/src/meta/grammar.y | 24 +- .../src/meta/templates/parser.go.template | 32 ++ python-tools/src/meta/yacc_parser.py | 7 +- 9 files changed, 349 insertions(+), 186 deletions(-) diff --git a/go/src/parser.go b/go/src/parser.go index 57ce61b2..77cb8b3f 100644 --- a/go/src/parser.go +++ b/go/src/parser.go @@ -15,6 +15,7 @@ import ( "math/big" "reflect" "regexp" + "sort" "strconv" "strings" @@ -441,6 +442,28 @@ func (p *Parser) constructFragment(fragmentID *pb.FragmentId, declarations []*pb return &pb.Fragment{Id: fragmentID, Declarations: declarations, DebugInfo: debugInfo} } +func (p *Parser) relationIdToString(msg *pb.RelationId) string { + key := relationIdKey{Low: msg.GetIdLow(), High: msg.GetIdHigh()} + for _, debugInfoMap := range p.idToDebugInfo { + if name, ok := debugInfoMap[key]; ok { + return name + } + } + return "" +} + +func (p *Parser) relationIdToUint128(msg *pb.RelationId) *pb.UInt128Value { + return &pb.UInt128Value{Low: msg.GetIdLow(), High: msg.GetIdHigh()} +} + +func (p *Parser) relationIdToInt(msg *pb.RelationId) *int64 { + value := int64(msg.GetIdHigh()<<64 | msg.GetIdLow()) + if value >= 0 { + return &value + } + return nil +} + // Helper functions func dictFromList(pairs [][]interface{}) map[string]interface{} { result := make(map[string]interface{}) @@ -534,6 +557,15 @@ func mapSlice[T any, U any](slice []T, f func(T) U) []U { return result } +func listSort(s [][]interface{}) [][]interface{} { + sort.Slice(s, func(i, j int) bool { + ki, _ := s[i][0].(string) + kj, _ := s[j][0].(string) + return ki < kj + }) + return s +} + func listConcat[T any](a []T, b []T) []T { if b == nil { return a @@ -607,11 +639,11 @@ func toPascalCase(s string) string { // --- Helper functions --- -func (p *Parser) _extract_value_int32(value *pb.Value, default_ int64) int64 { +func (p *Parser) _extract_value_int32(value *pb.Value, default_ int64) int32 { if (value != nil && hasProtoField(value, "int_value")) { return int32(value.GetIntValue()) } - return default_ + return int32(default_) } func (p *Parser) _extract_value_int64(value *pb.Value, default_ int64) int64 { @@ -818,48 +850,47 @@ func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, c return _t991 } -func (p *Parser) _make_value_int32(v int64) *pb.Value { - _t992 := p.int32_to_int64(v) +func (p *Parser) _make_value_int32(v int32) *pb.Value { + _t992 := &pb.Value{} + _t992.Value = &pb.Value_IntValue{IntValue: int64(v)} + return _t992 +} + +func (p *Parser) _make_value_int64(v int64) *pb.Value { _t993 := &pb.Value{} - _t993.Value = &pb.Value_IntValue{IntValue: _t992} + _t993.Value = &pb.Value_IntValue{IntValue: v} return _t993 } -func (p *Parser) _make_value_int64(v int64) *pb.Value { +func (p *Parser) _make_value_float64(v float64) *pb.Value { _t994 := &pb.Value{} - _t994.Value = &pb.Value_IntValue{IntValue: v} + _t994.Value = &pb.Value_FloatValue{FloatValue: v} return _t994 } -func (p *Parser) _make_value_float64(v float64) *pb.Value { +func (p *Parser) _make_value_string(v string) *pb.Value { _t995 := &pb.Value{} - _t995.Value = &pb.Value_FloatValue{FloatValue: v} + _t995.Value = &pb.Value_StringValue{StringValue: v} return _t995 } -func (p *Parser) _make_value_string(v string) *pb.Value { +func (p *Parser) _make_value_boolean(v bool) *pb.Value { _t996 := &pb.Value{} - _t996.Value = &pb.Value_StringValue{StringValue: v} + _t996.Value = &pb.Value_BooleanValue{BooleanValue: v} return _t996 } -func (p *Parser) _make_value_boolean(v bool) *pb.Value { +func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { _t997 := &pb.Value{} - _t997.Value = &pb.Value_BooleanValue{BooleanValue: v} + _t997.Value = &pb.Value_Uint128Value{Uint128Value: v} return _t997 } -func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { - _t998 := &pb.Value{} - _t998.Value = &pb.Value_Uint128Value{Uint128Value: v} - return _t998 -} - func (p *Parser) is_default_configure(cfg *pb.Configure) bool { if cfg.GetSemanticsVersion() != 0 { return false } - if cfg.ivm_config.GetLevel() != pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { + if cfg.GetIvmConfig().GetLevel() != pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { return false } return true @@ -867,182 +898,202 @@ func (p *Parser) is_default_configure(cfg *pb.Configure) bool { func (p *Parser) deconstruct_configure(msg *pb.Configure) [][]interface{} { result := [][]interface{}{} - var _t999 interface{} - if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_AUTO { - _t1000 := p._make_value_string("auto") - result = append(result, []interface{}{"ivm.maintenance_level", _t1000}) - _t999 = nil + var _t998 interface{} + if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_AUTO { + _t999 := p._make_value_string("auto") + result = append(result, []interface{}{"ivm.maintenance_level", _t999}) + _t998 = nil } else { - var _t1001 interface{} - if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_ALL { - _t1002 := p._make_value_string("all") - result = append(result, []interface{}{"ivm.maintenance_level", _t1002}) - _t1001 = nil + var _t1000 interface{} + if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_ALL { + _t1001 := p._make_value_string("all") + result = append(result, []interface{}{"ivm.maintenance_level", _t1001}) + _t1000 = nil } else { - var _t1003 interface{} - if msg.ivm_config.GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { - _t1004 := p._make_value_string("off") - result = append(result, []interface{}{"ivm.maintenance_level", _t1004}) - _t1003 = nil + var _t1002 interface{} + if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { + _t1003 := p._make_value_string("off") + result = append(result, []interface{}{"ivm.maintenance_level", _t1003}) + _t1002 = nil } - _t1001 = _t1003 + _t1000 = _t1002 } - _t999 = _t1001 + _t998 = _t1000 } - _t1005 := p._make_value_int64(msg.GetSemanticsVersion()) - result = append(result, []interface{}{"semantics_version", _t1005}) + _ = _t998 + _t1004 := p._make_value_int64(msg.GetSemanticsVersion()) + result = append(result, []interface{}{"semantics_version", _t1004}) return listSort(result) } func (p *Parser) deconstruct_csv_config(msg *pb.CSVConfig) [][]interface{} { result := [][]interface{}{} - _t1006 := p._make_value_int32(msg.GetHeaderRow()) - result = append(result, []interface{}{"csv_header_row", _t1006}) - _t1007 := p._make_value_int64(msg.GetSkip()) - result = append(result, []interface{}{"csv_skip", _t1007}) - var _t1008 interface{} - if (msg.GetNewLine() != nil && msg.GetNewLine() != "") { - _t1009 := p._make_value_string(msg.GetNewLine()) - result = append(result, []interface{}{"csv_new_line", _t1009}) - _t1008 = nil - } - _t1010 := p._make_value_string(msg.GetDelimiter()) - result = append(result, []interface{}{"csv_delimiter", _t1010}) - _t1011 := p._make_value_string(msg.GetQuotechar()) - result = append(result, []interface{}{"csv_quotechar", _t1011}) - _t1012 := p._make_value_string(msg.GetEscapechar()) - result = append(result, []interface{}{"csv_escapechar", _t1012}) - var _t1013 interface{} - if (msg.GetComment() != nil && msg.GetComment() != "") { - _t1014 := p._make_value_string(msg.GetComment()) - result = append(result, []interface{}{"csv_comment", _t1014}) - _t1013 = nil - } + _t1005 := p._make_value_int32(msg.GetHeaderRow()) + result = append(result, []interface{}{"csv_header_row", _t1005}) + _t1006 := p._make_value_int64(msg.GetSkip()) + result = append(result, []interface{}{"csv_skip", _t1006}) + var _t1007 interface{} + if msg.GetNewLine() != "" { + _t1008 := p._make_value_string(msg.GetNewLine()) + result = append(result, []interface{}{"csv_new_line", _t1008}) + _t1007 = nil + } + _ = _t1007 + _t1009 := p._make_value_string(msg.GetDelimiter()) + result = append(result, []interface{}{"csv_delimiter", _t1009}) + _t1010 := p._make_value_string(msg.GetQuotechar()) + result = append(result, []interface{}{"csv_quotechar", _t1010}) + _t1011 := p._make_value_string(msg.GetEscapechar()) + result = append(result, []interface{}{"csv_escapechar", _t1011}) + var _t1012 interface{} + if msg.GetComment() != "" { + _t1013 := p._make_value_string(msg.GetComment()) + result = append(result, []interface{}{"csv_comment", _t1013}) + _t1012 = nil + } + _ = _t1012 for _, missing_string := range msg.GetMissingStrings() { - _t1015 := p._make_value_string(missing_string) - result = append(result, []interface{}{"csv_missing_strings", _t1015}) - } - _t1016 := p._make_value_string(msg.GetDecimalSeparator()) - result = append(result, []interface{}{"csv_decimal_separator", _t1016}) - _t1017 := p._make_value_string(msg.GetEncoding()) - result = append(result, []interface{}{"csv_encoding", _t1017}) - _t1018 := p._make_value_string(msg.GetCompression()) - result = append(result, []interface{}{"csv_compression", _t1018}) + _t1014 := p._make_value_string(missing_string) + result = append(result, []interface{}{"csv_missing_strings", _t1014}) + } + _t1015 := p._make_value_string(msg.GetDecimalSeparator()) + result = append(result, []interface{}{"csv_decimal_separator", _t1015}) + _t1016 := p._make_value_string(msg.GetEncoding()) + result = append(result, []interface{}{"csv_encoding", _t1016}) + _t1017 := p._make_value_string(msg.GetCompression()) + result = append(result, []interface{}{"csv_compression", _t1017}) return listSort(result) } func (p *Parser) _maybe_push_float64(result [][]interface{}, key string, val *float64) interface{} { - var _t1019 interface{} + var _t1018 interface{} if val != nil { - _t1020 := p._make_value_float64(*val) - result = append(result, []interface{}{key, _t1020}) - _t1019 = nil + _t1019 := p._make_value_float64(*val) + result = append(result, []interface{}{key, _t1019}) + _t1018 = nil } + _ = _t1018 return nil } func (p *Parser) _maybe_push_int64(result [][]interface{}, key string, val *int64) interface{} { - var _t1021 interface{} + var _t1020 interface{} if val != nil { - _t1022 := p._make_value_int64(*val) - result = append(result, []interface{}{key, _t1022}) - _t1021 = nil + _t1021 := p._make_value_int64(*val) + result = append(result, []interface{}{key, _t1021}) + _t1020 = nil } + _ = _t1020 return nil } func (p *Parser) _maybe_push_uint128(result [][]interface{}, key string, val *pb.UInt128Value) interface{} { - var _t1023 interface{} + var _t1022 interface{} if val != nil { - _t1024 := p._make_value_uint128(val) - result = append(result, []interface{}{key, _t1024}) - _t1023 = nil + _t1023 := p._make_value_uint128(val) + result = append(result, []interface{}{key, _t1023}) + _t1022 = nil } + _ = _t1022 return nil } func (p *Parser) _maybe_push_bytes_as_string(result [][]interface{}, key string, val []byte) interface{} { - var _t1025 interface{} + var _t1024 interface{} if val != nil { - _t1026 := p.decode_string(val) - _t1027 := p._make_value_string(_t1026) - result = append(result, []interface{}{key, _t1027}) - _t1025 = nil + _t1025 := p._make_value_string(string(val)) + result = append(result, []interface{}{key, _t1025}) + _t1024 = nil } + _ = _t1024 return nil } func (p *Parser) deconstruct_betree_info_config(msg *pb.BeTreeInfo) [][]interface{} { result := [][]interface{}{} - _t1028 := p._maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.GetEpsilon()) - _t1029 := p._maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.GetMaxPivots()) - _t1030 := p._maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.GetMaxDeltas()) - _t1031 := p._maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.GetMaxLeaf()) - var _t1032 interface{} + _t1026 := p._make_value_float64(msg.GetStorageConfig().GetEpsilon()) + result = append(result, []interface{}{"betree_config_epsilon", _t1026}) + _t1027 := p._make_value_int64(msg.GetStorageConfig().GetMaxPivots()) + result = append(result, []interface{}{"betree_config_max_pivots", _t1027}) + _t1028 := p._make_value_int64(msg.GetStorageConfig().GetMaxDeltas()) + result = append(result, []interface{}{"betree_config_max_deltas", _t1028}) + _t1029 := p._make_value_int64(msg.GetStorageConfig().GetMaxLeaf()) + result = append(result, []interface{}{"betree_config_max_leaf", _t1029}) + var _t1030 interface{} if hasProtoField(msg.GetRelationLocator(), "root_pageid") { - _t1033 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.GetRootPageid()) - _t1032 = _t1033 + _t1031 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.GetRelationLocator().GetRootPageid()) + _t1030 = _t1031 } - var _t1034 interface{} + _ = _t1030 + var _t1032 interface{} if hasProtoField(msg.GetRelationLocator(), "inline_data") { - _t1035 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.GetInlineData()) - _t1034 = _t1035 + _t1033 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.GetRelationLocator().GetInlineData()) + _t1032 = _t1033 } - _t1036 := p._maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.GetElementCount()) - _t1037 := p._maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.GetTreeHeight()) + _ = _t1032 + _t1034 := p._make_value_int64(msg.GetRelationLocator().GetElementCount()) + result = append(result, []interface{}{"betree_locator_element_count", _t1034}) + _t1035 := p._make_value_int64(msg.GetRelationLocator().GetTreeHeight()) + result = append(result, []interface{}{"betree_locator_tree_height", _t1035}) return listSort(result) } func (p *Parser) deconstruct_export_csv_config(msg *pb.ExportCSVConfig) [][]interface{} { result := [][]interface{}{} + var _t1036 interface{} + if msg.PartitionSize != nil { + _t1037 := p._make_value_int64(*msg.PartitionSize) + result = append(result, []interface{}{"partition_size", _t1037}) + _t1036 = nil + } + _ = _t1036 var _t1038 interface{} - if msg.GetPartitionSize() != nil { - _t1039 := p._make_value_int64(*msg.GetPartitionSize()) - result = append(result, []interface{}{"partition_size", _t1039}) + if msg.Compression != nil { + _t1039 := p._make_value_string(*msg.Compression) + result = append(result, []interface{}{"compression", _t1039}) _t1038 = nil } + _ = _t1038 var _t1040 interface{} - if msg.GetCompression() != nil { - _t1041 := p._make_value_string(*msg.GetCompression()) - result = append(result, []interface{}{"compression", _t1041}) + if msg.SyntaxHeaderRow != nil { + _t1041 := p._make_value_boolean(*msg.SyntaxHeaderRow) + result = append(result, []interface{}{"syntax_header_row", _t1041}) _t1040 = nil } + _ = _t1040 var _t1042 interface{} - if msg.GetSyntaxHeaderRow() != nil { - _t1043 := p._make_value_boolean(*msg.GetSyntaxHeaderRow()) - result = append(result, []interface{}{"syntax_header_row", _t1043}) + if msg.SyntaxMissingString != nil { + _t1043 := p._make_value_string(*msg.SyntaxMissingString) + result = append(result, []interface{}{"syntax_missing_string", _t1043}) _t1042 = nil } + _ = _t1042 var _t1044 interface{} - if msg.GetSyntaxMissingString() != nil { - _t1045 := p._make_value_string(*msg.GetSyntaxMissingString()) - result = append(result, []interface{}{"syntax_missing_string", _t1045}) + if msg.SyntaxDelim != nil { + _t1045 := p._make_value_string(*msg.SyntaxDelim) + result = append(result, []interface{}{"syntax_delim", _t1045}) _t1044 = nil } + _ = _t1044 var _t1046 interface{} - if msg.GetSyntaxDelim() != nil { - _t1047 := p._make_value_string(*msg.GetSyntaxDelim()) - result = append(result, []interface{}{"syntax_delim", _t1047}) + if msg.SyntaxQuotechar != nil { + _t1047 := p._make_value_string(*msg.SyntaxQuotechar) + result = append(result, []interface{}{"syntax_quotechar", _t1047}) _t1046 = nil } + _ = _t1046 var _t1048 interface{} - if msg.GetSyntaxQuotechar() != nil { - _t1049 := p._make_value_string(*msg.GetSyntaxQuotechar()) - result = append(result, []interface{}{"syntax_quotechar", _t1049}) + if msg.SyntaxEscapechar != nil { + _t1049 := p._make_value_string(*msg.SyntaxEscapechar) + result = append(result, []interface{}{"syntax_escapechar", _t1049}) _t1048 = nil } - var _t1050 interface{} - if msg.GetSyntaxEscapechar() != nil { - _t1051 := p._make_value_string(*msg.GetSyntaxEscapechar()) - result = append(result, []interface{}{"syntax_escapechar", _t1051}) - _t1050 = nil - } + _ = _t1048 return listSort(result) } func (p *Parser) deconstruct_relation_id_string(msg *pb.RelationId) *string { - _t1052 := p.relation_id_to_string(msg) - name := _t1052 + name := p.relationIdToString(msg) if name != "" { return ptr(name) } @@ -1050,28 +1101,22 @@ func (p *Parser) deconstruct_relation_id_string(msg *pb.RelationId) *string { } func (p *Parser) deconstruct_relation_id_uint128(msg *pb.RelationId) *pb.UInt128Value { - _t1053 := p.relation_id_to_string(msg) - name := _t1053 + name := p.relationIdToString(msg) if name == "" { - _t1054 := p.relation_id_to_uint128(msg) - return _t1054 + return p.relationIdToUint128(msg) } return nil } func (p *Parser) deconstruct_bindings(abs *pb.Abstraction) []interface{} { n := int64(len(abs.GetVars())) - _t1055 := p.list_slice(abs.GetVars(), 0, n) - return []interface{}{_t1055, []*pb.Binding{}} + return []interface{}{abs.GetVars()[0:n], []*pb.Binding{}} } func (p *Parser) deconstruct_bindings_with_arity(abs *pb.Abstraction, value_arity int64) []interface{} { n := int64(len(abs.GetVars())) - _t1056 := p.subtract(n, value_arity) - key_end := _t1056 - _t1057 := p.list_slice(abs.GetVars(), 0, key_end) - _t1058 := p.list_slice(abs.GetVars(), key_end, n) - return []interface{}{_t1057, _t1058} + key_end := (n - value_arity) + return []interface{}{abs.GetVars()[0:key_end], abs.GetVars()[key_end:n]} } // --- Parse functions --- diff --git a/julia/LQPParser/src/parser.jl b/julia/LQPParser/src/parser.jl index 00e9df0b..d2119ad0 100644 --- a/julia/LQPParser/src/parser.jl +++ b/julia/LQPParser/src/parser.jl @@ -325,11 +325,11 @@ end # --- Helper functions --- -function _extract_value_int32(parser::Parser, value::Union{Nothing, Proto.Value}, default::Int64)::Int64 +function _extract_value_int32(parser::Parser, value::Union{Nothing, Proto.Value}, default::Int64)::Int32 if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return Int32(_get_oneof_field(value, :int_value)) end - return default + return Int32(default) end function _extract_value_int64(parser::Parser, value::Union{Nothing, Proto.Value}, default::Int64)::Int64 @@ -531,7 +531,7 @@ function export_csv_config(parser::Parser, path::String, columns::Vector{Proto.E return _t980 end -function _make_value_int32(parser::Parser, v::Int64)::Proto.Value +function _make_value_int32(parser::Parser, v::Int32)::Proto.Value _t981 = Proto.Value(value=OneOf(:int_value, Int64(v))) return _t981 end @@ -609,7 +609,7 @@ function deconstruct_csv_config(parser::Parser, msg::Proto.CSVConfig)::Vector{Tu _t995 = _make_value_int64(parser, msg.skip) push!(result, ("csv_skip", _t995,)) - if (!isnothing(msg.new_line) && msg.new_line != "") + if msg.new_line != "" _t997 = _make_value_string(parser, msg.new_line) push!(result, ("csv_new_line", _t997,)) _t996 = nothing @@ -623,7 +623,7 @@ function deconstruct_csv_config(parser::Parser, msg::Proto.CSVConfig)::Vector{Tu _t1000 = _make_value_string(parser, msg.escapechar) push!(result, ("csv_escapechar", _t1000,)) - if (!isnothing(msg.comment) && msg.comment != "") + if msg.comment != "" _t1002 = _make_value_string(parser, msg.comment) push!(result, ("csv_comment", _t1002,)) _t1001 = nothing @@ -693,10 +693,14 @@ end function deconstruct_betree_info_config(parser::Parser, msg::Proto.BeTreeInfo)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - _t1015 = _maybe_push_float64(parser, result, "betree_config_epsilon", msg.storage_config.epsilon) - _t1016 = _maybe_push_int64(parser, result, "betree_config_max_pivots", msg.storage_config.max_pivots) - _t1017 = _maybe_push_int64(parser, result, "betree_config_max_deltas", msg.storage_config.max_deltas) - _t1018 = _maybe_push_int64(parser, result, "betree_config_max_leaf", msg.storage_config.max_leaf) + _t1015 = _make_value_float64(parser, msg.storage_config.epsilon) + push!(result, ("betree_config_epsilon", _t1015,)) + _t1016 = _make_value_int64(parser, msg.storage_config.max_pivots) + push!(result, ("betree_config_max_pivots", _t1016,)) + _t1017 = _make_value_int64(parser, msg.storage_config.max_deltas) + push!(result, ("betree_config_max_deltas", _t1017,)) + _t1018 = _make_value_int64(parser, msg.storage_config.max_leaf) + push!(result, ("betree_config_max_leaf", _t1018,)) if _has_proto_field(msg.relation_locator, Symbol("root_pageid")) _t1020 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) @@ -711,8 +715,10 @@ function deconstruct_betree_info_config(parser::Parser, msg::Proto.BeTreeInfo):: else _t1021 = nothing end - _t1023 = _maybe_push_int64(parser, result, "betree_locator_element_count", msg.relation_locator.element_count) - _t1024 = _maybe_push_int64(parser, result, "betree_locator_tree_height", msg.relation_locator.tree_height) + _t1023 = _make_value_int64(parser, msg.relation_locator.element_count) + push!(result, ("betree_locator_element_count", _t1023,)) + _t1024 = _make_value_int64(parser, msg.relation_locator.tree_height) + push!(result, ("betree_locator_tree_height", _t1024,)) return sort(result) end diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 4fbe99d9..8a2cbf55 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -288,7 +288,7 @@ def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) - if _t945: assert value is not None return int(value.int_value) - return default + return int(default) def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: @@ -610,7 +610,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo _t1009 = self._make_value_int64(msg.skip) result.append(('csv_skip', _t1009,)) - if (msg.new_line is not None and msg.new_line != ''): + if msg.new_line != '': _t1011 = self._make_value_string(msg.new_line) result.append(('csv_new_line', _t1011,)) _t1010 = None @@ -623,7 +623,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo _t1014 = self._make_value_string(msg.escapechar) result.append(('csv_escapechar', _t1014,)) - if (msg.comment is not None and msg.comment != ''): + if msg.comment != '': _t1016 = self._make_value_string(msg.comment) result.append(('csv_comment', _t1016,)) _t1015 = None @@ -686,10 +686,14 @@ def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1029 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1030 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1031 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1032 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1029 = self._make_value_float64(msg.storage_config.epsilon) + result.append(('betree_config_epsilon', _t1029,)) + _t1030 = self._make_value_int64(msg.storage_config.max_pivots) + result.append(('betree_config_max_pivots', _t1030,)) + _t1031 = self._make_value_int64(msg.storage_config.max_deltas) + result.append(('betree_config_max_deltas', _t1031,)) + _t1032 = self._make_value_int64(msg.storage_config.max_leaf) + result.append(('betree_config_max_leaf', _t1032,)) if msg.relation_locator.HasField('root_pageid'): _t1034 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) @@ -702,8 +706,10 @@ def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tupl _t1035 = _t1036 else: _t1035 = None - _t1037 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1038 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1037 = self._make_value_int64(msg.relation_locator.element_count) + result.append(('betree_locator_element_count', _t1037,)) + _t1038 = self._make_value_int64(msg.relation_locator.tree_height) + result.append(('betree_locator_tree_height', _t1038,)) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: diff --git a/python-tools/src/lqp/gen/pretty.py b/python-tools/src/lqp/gen/pretty.py index 4246af90..be4c96d7 100644 --- a/python-tools/src/lqp/gen/pretty.py +++ b/python-tools/src/lqp/gen/pretty.py @@ -128,7 +128,7 @@ def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) - if _t1290: assert value is not None return int(value.int_value) - return default + return int(default) def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: @@ -450,7 +450,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo _t1354 = self._make_value_int64(msg.skip) result.append(('csv_skip', _t1354,)) - if (msg.new_line is not None and msg.new_line != ''): + if msg.new_line != '': _t1356 = self._make_value_string(msg.new_line) result.append(('csv_new_line', _t1356,)) _t1355 = None @@ -463,7 +463,7 @@ def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, lo _t1359 = self._make_value_string(msg.escapechar) result.append(('csv_escapechar', _t1359,)) - if (msg.comment is not None and msg.comment != ''): + if msg.comment != '': _t1361 = self._make_value_string(msg.comment) result.append(('csv_comment', _t1361,)) _t1360 = None @@ -526,10 +526,14 @@ def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1374 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1375 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1376 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1377 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) + _t1374 = self._make_value_float64(msg.storage_config.epsilon) + result.append(('betree_config_epsilon', _t1374,)) + _t1375 = self._make_value_int64(msg.storage_config.max_pivots) + result.append(('betree_config_max_pivots', _t1375,)) + _t1376 = self._make_value_int64(msg.storage_config.max_deltas) + result.append(('betree_config_max_deltas', _t1376,)) + _t1377 = self._make_value_int64(msg.storage_config.max_leaf) + result.append(('betree_config_max_leaf', _t1377,)) if msg.relation_locator.HasField('root_pageid'): _t1379 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) @@ -542,8 +546,10 @@ def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tupl _t1380 = _t1381 else: _t1380 = None - _t1382 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1383 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) + _t1382 = self._make_value_int64(msg.relation_locator.element_count) + result.append(('betree_locator_element_count', _t1382,)) + _t1383 = self._make_value_int64(msg.relation_locator.tree_height) + result.append(('betree_locator_tree_height', _t1383,)) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: diff --git a/python-tools/src/meta/codegen_go.py b/python-tools/src/meta/codegen_go.py index e3522481..26165cd4 100644 --- a/python-tools/src/meta/codegen_go.py +++ b/python-tools/src/meta/codegen_go.py @@ -9,9 +9,9 @@ from .codegen_base import CodeGenerator from .codegen_templates import GO_TEMPLATES from .target import ( - TargetExpr, Var, Symbol, NewMessage, OneOf, ListExpr, Call, Lambda, Let, + TargetExpr, NewMessage, OneOf, ListExpr, Call, Seq, FunDef, VisitNonterminalDef, PrintNonterminalDef, VisitNonterminal, - GetElement, GetField, TargetType, + GetElement, TargetType, ) from .gensym import gensym @@ -347,15 +347,54 @@ def _generate_get_element(self, expr: GetElement, lines: List[str], indent: str) pass return f"{tuple_code}[{expr.index}]" + def gen_field_access(self, obj_code: str, field_name: str) -> str: + """Generate Go field access using getter methods (nil-safe).""" + pascal_field = to_pascal_case(field_name) + return f"{obj_code}.Get{pascal_field}()" + + def _is_optional_scalar_field(self, expr) -> bool: + """Check if a GetField accesses an optional scalar proto field. + + Go protobuf getters strip pointer types from optional scalars, + returning plain values instead of *T. For nil checks and unwrap, + we need direct PascalCase field access to preserve the pointer type. + """ + from .target import GetField, OptionType + if not isinstance(expr, GetField): + return False + if not isinstance(expr.field_type, OptionType): + return False + inner_go = self.gen_type(expr.field_type.element_type) + return not self._is_nullable_go_type(inner_go) + def generate_lines(self, expr: TargetExpr, lines: List[str], indent: str = "") -> Optional[str]: - """Override to handle Go-specific GetField with getter methods.""" - if isinstance(expr, GetField): - obj_code = super().generate_lines(expr.object, lines, indent) + from .target import GetField + # For optional scalar proto fields, use direct PascalCase access + # to preserve pointer type (getters strip it). + if isinstance(expr, GetField) and self._is_optional_scalar_field(expr): + obj_code = self.generate_lines(expr.object, lines, indent) + assert obj_code is not None pascal_field = to_pascal_case(expr.field_name) - return f"{obj_code}.Get{pascal_field}()" - + return f"{obj_code}.{pascal_field}" return super().generate_lines(expr, lines, indent) + def _generate_seq(self, expr: Seq, lines: List[str], indent: str) -> Optional[str]: + """Generate Go sequence, suppressing unused variable errors. + + In Go, declared-but-unused variables are compile errors. When an + intermediate expression in a Seq produces a temp variable (e.g., from + an IfElse used for side effects), we emit `_ = var` to suppress it. + """ + result: Optional[str] = self.gen_none() + for i, e in enumerate(expr.exprs): + result = self.generate_lines(e, lines, indent) + if result is None: + break + # Suppress unused temp variable from non-final expressions + if i < len(expr.exprs) - 1 and result is not None and result.startswith("_t"): + lines.append(f"{indent}_ = {result}") + return result + def _generate_newmessage(self, expr: NewMessage, lines: List[str], indent: str) -> str: """Generate Go code for NewMessage with fields containing OneOf calls. diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index 162abb41..859ea135 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -226,6 +226,32 @@ class BuiltinTemplate: "error_with_token": BuiltinTemplate( None, ['panic(ParseError{{msg: fmt.Sprintf("%s: %s=`%v`", {0}, {1}.Type, {1}.Value)}})' ]), + # Pretty-printing builtins + "write_io": BuiltinTemplate("nil", ["p.write({0})"]), + "newline_io": BuiltinTemplate("nil", ["p.newline()"]), + "indent_io": BuiltinTemplate("nil", ["p.indent()"]), + "dedent_io": BuiltinTemplate("nil", ["p.dedent()"]), + "format_int64": BuiltinTemplate('fmt.Sprintf("%d", {0})'), + "format_int32": BuiltinTemplate('fmt.Sprintf("%d", {0})'), + "format_float64": BuiltinTemplate('fmt.Sprintf("%g", {0})'), + "format_string": BuiltinTemplate("p.formatStringValue({0})"), + "format_symbol": BuiltinTemplate("{0}"), + "format_bool": BuiltinTemplate('formatBool({0})'), + "format_decimal": BuiltinTemplate("p.formatDecimal({0})"), + "format_int128": BuiltinTemplate("p.formatInt128({0})"), + "format_uint128": BuiltinTemplate("p.formatUint128({0})"), + "greater": BuiltinTemplate("({0} > {1})"), + "to_string": BuiltinTemplate('fmt.Sprintf("%v", {0})'), + # Type conversions used by pretty printer + "int32_to_int64": BuiltinTemplate("int64({0})"), + "is_empty": BuiltinTemplate("len({0}) == 0"), + "decode_string": BuiltinTemplate("string({0})"), + "fragment_id_to_string": BuiltinTemplate("p.fragmentIdToString({0})"), + "relation_id_to_string": BuiltinTemplate("p.relationIdToString({0})"), + "relation_id_to_int": BuiltinTemplate("p.relationIdToInt({0})"), + "relation_id_to_uint128": BuiltinTemplate("p.relationIdToUint128({0})"), + "subtract": BuiltinTemplate("({0} - {1})"), + "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), } __all__ = [ diff --git a/python-tools/src/meta/grammar.y b/python-tools/src/meta/grammar.y index aa189efe..42969adc 100644 --- a/python-tools/src/meta/grammar.y +++ b/python-tools/src/meta/grammar.y @@ -1072,10 +1072,10 @@ export_csv_column %% -def _extract_value_int32(value: Optional[logic.Value], default: int) -> int: +def _extract_value_int32(value: Optional[logic.Value], default: int) -> Int32: if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'int_value'): return builtin.int64_to_int32(builtin.unwrap_option(value).int_value) - return default + return builtin.int64_to_int32(default) def _extract_value_int64(value: Optional[logic.Value], default: int) -> int: @@ -1156,7 +1156,7 @@ def _try_extract_value_string_list(value: Optional[logic.Value]) -> Optional[Seq def construct_csv_config(config_dict: Sequence[Tuple[String, logic.Value]]) -> logic.CSVConfig: config: Dict[String, logic.Value] = builtin.dict_from_list(config_dict) - header_row: int = _extract_value_int32(builtin.dict_get(config, "csv_header_row"), 1) + header_row: Int32 = _extract_value_int32(builtin.dict_get(config, "csv_header_row"), 1) skip: int = _extract_value_int64(builtin.dict_get(config, "csv_skip"), 0) new_line: str = _extract_value_string(builtin.dict_get(config, "csv_new_line"), "") delimiter: str = _extract_value_string(builtin.dict_get(config, "csv_delimiter"), ",") @@ -1271,7 +1271,7 @@ def export_csv_config( ) -def _make_value_int32(v: int) -> logic.Value: +def _make_value_int32(v: Int32) -> logic.Value: return logic.Value(int_value=builtin.int32_to_int64(v)) @@ -1319,12 +1319,12 @@ def deconstruct_csv_config(msg: logic.CSVConfig) -> List[Tuple[String, logic.Val result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() builtin.list_push(result, builtin.tuple("csv_header_row", _make_value_int32(msg.header_row))) builtin.list_push(result, builtin.tuple("csv_skip", _make_value_int64(msg.skip))) - if msg.new_line is not None and msg.new_line != "": + if msg.new_line != "": builtin.list_push(result, builtin.tuple("csv_new_line", _make_value_string(msg.new_line))) builtin.list_push(result, builtin.tuple("csv_delimiter", _make_value_string(msg.delimiter))) builtin.list_push(result, builtin.tuple("csv_quotechar", _make_value_string(msg.quotechar))) builtin.list_push(result, builtin.tuple("csv_escapechar", _make_value_string(msg.escapechar))) - if msg.comment is not None and msg.comment != "": + if msg.comment != "": builtin.list_push(result, builtin.tuple("csv_comment", _make_value_string(msg.comment))) for missing_string in msg.missing_strings: builtin.list_push(result, builtin.tuple("csv_missing_strings", _make_value_string(missing_string))) @@ -1360,16 +1360,16 @@ def _maybe_push_bytes_as_string(result: List[Tuple[String, logic.Value]], key: S def deconstruct_betree_info_config(msg: logic.BeTreeInfo) -> List[Tuple[String, logic.Value]]: result: List[Tuple[String, logic.Value]] = list[Tuple[String, logic.Value]]() - _maybe_push_float64(result, "betree_config_epsilon", msg.storage_config.epsilon) - _maybe_push_int64(result, "betree_config_max_pivots", msg.storage_config.max_pivots) - _maybe_push_int64(result, "betree_config_max_deltas", msg.storage_config.max_deltas) - _maybe_push_int64(result, "betree_config_max_leaf", msg.storage_config.max_leaf) + builtin.list_push(result, builtin.tuple("betree_config_epsilon", _make_value_float64(msg.storage_config.epsilon))) + builtin.list_push(result, builtin.tuple("betree_config_max_pivots", _make_value_int64(msg.storage_config.max_pivots))) + builtin.list_push(result, builtin.tuple("betree_config_max_deltas", _make_value_int64(msg.storage_config.max_deltas))) + builtin.list_push(result, builtin.tuple("betree_config_max_leaf", _make_value_int64(msg.storage_config.max_leaf))) if builtin.has_proto_field(msg.relation_locator, "root_pageid"): _maybe_push_uint128(result, "betree_locator_root_pageid", msg.relation_locator.root_pageid) if builtin.has_proto_field(msg.relation_locator, "inline_data"): _maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.relation_locator.inline_data) - _maybe_push_int64(result, "betree_locator_element_count", msg.relation_locator.element_count) - _maybe_push_int64(result, "betree_locator_tree_height", msg.relation_locator.tree_height) + builtin.list_push(result, builtin.tuple("betree_locator_element_count", _make_value_int64(msg.relation_locator.element_count))) + builtin.list_push(result, builtin.tuple("betree_locator_tree_height", _make_value_int64(msg.relation_locator.tree_height))) return builtin.list_sort(result) diff --git a/python-tools/src/meta/templates/parser.go.template b/python-tools/src/meta/templates/parser.go.template index edee3ef9..22ba88bb 100644 --- a/python-tools/src/meta/templates/parser.go.template +++ b/python-tools/src/meta/templates/parser.go.template @@ -15,6 +15,7 @@ import ( "math/big" "reflect" "regexp" + "sort" "strconv" "strings" @@ -415,6 +416,28 @@ func (p *Parser) constructFragment(fragmentID *pb.FragmentId, declarations []*pb return &pb.Fragment{{Id: fragmentID, Declarations: declarations, DebugInfo: debugInfo}} }} +func (p *Parser) relationIdToString(msg *pb.RelationId) string {{ + key := relationIdKey{{Low: msg.GetIdLow(), High: msg.GetIdHigh()}} + for _, debugInfoMap := range p.idToDebugInfo {{ + if name, ok := debugInfoMap[key]; ok {{ + return name + }} + }} + return "" +}} + +func (p *Parser) relationIdToUint128(msg *pb.RelationId) *pb.UInt128Value {{ + return &pb.UInt128Value{{Low: msg.GetIdLow(), High: msg.GetIdHigh()}} +}} + +func (p *Parser) relationIdToInt(msg *pb.RelationId) *int64 {{ + value := int64(msg.GetIdHigh()<<64 | msg.GetIdLow()) + if value >= 0 {{ + return &value + }} + return nil +}} + // Helper functions func dictFromList(pairs [][]interface{{}}) map[string]interface{{}} {{ result := make(map[string]interface{{}}) @@ -508,6 +531,15 @@ func mapSlice[T any, U any](slice []T, f func(T) U) []U {{ return result }} +func listSort(s [][]interface{{}}) [][]interface{{}} {{ + sort.Slice(s, func(i, j int) bool {{ + ki, _ := s[i][0].(string) + kj, _ := s[j][0].(string) + return ki < kj + }}) + return s +}} + func listConcat[T any](a []T, b []T) []T {{ if b == nil {{ return a diff --git a/python-tools/src/meta/yacc_parser.py b/python-tools/src/meta/yacc_parser.py index e8deeef1..639f3256 100644 --- a/python-tools/src/meta/yacc_parser.py +++ b/python-tools/src/meta/yacc_parser.py @@ -637,7 +637,7 @@ def _make_field_type_lookup( for (module, msg_name), proto_msg in proto_messages.items(): for field in proto_msg.fields: - field_type = _proto_type_to_target_type(field.type, field.is_repeated) + field_type = _proto_type_to_target_type(field.type, field.is_repeated, field.is_optional) field_types[(module, msg_name, field.name)] = field_type # Also add oneof fields @@ -653,7 +653,8 @@ def lookup(message_type: MessageType, field_name: str) -> Optional[TargetType]: return lookup -def _proto_type_to_target_type(proto_type: str, is_repeated: bool) -> TargetType: +def _proto_type_to_target_type(proto_type: str, is_repeated: bool, + is_optional: bool = False) -> TargetType: """Convert a proto field type string to TargetType.""" # Map proto scalar types to target base types scalar_map = { @@ -680,6 +681,8 @@ def _proto_type_to_target_type(proto_type: str, is_repeated: bool) -> TargetType if is_repeated: return SequenceType(base_type) + if is_optional: + return OptionType(base_type) return base_type From 2c98af7acbd37883c1c744295a072f7ae9069417 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Thu, 12 Feb 2026 16:18:18 +0100 Subject: [PATCH 21/25] Have the generated parser produce provenence information for diags --- go/src/parser.go | 4800 ++++++++++------- go/test/parser_test.go | 4 +- julia/LQPParser/src/parser.jl | 3992 ++++++++------ julia/LQPParser/test/runtests.jl | 4 +- python-tools/src/lqp/cli.py | 4 +- python-tools/src/lqp/gen/parser.py | 4211 +++++++++------ python-tools/src/lqp/proto_validator.py | 178 +- python-tools/src/meta/codegen_templates.py | 15 + python-tools/src/meta/parser_gen.py | 143 +- python-tools/src/meta/parser_gen_common.py | 2 +- python-tools/src/meta/target_builtins.py | 6 + .../src/meta/templates/parser.go.template | 113 +- .../src/meta/templates/parser.jl.template | 77 +- .../src/meta/templates/parser.py.template | 78 +- python-tools/tests/test_generated_parser.py | 4 +- .../tests/test_generated_pretty_printer.py | 4 +- python-tools/tests/test_proto_validator.py | 18 +- 17 files changed, 8087 insertions(+), 5566 deletions(-) diff --git a/go/src/parser.go b/go/src/parser.go index 77cb8b3f..22b2b062 100644 --- a/go/src/parser.go +++ b/go/src/parser.go @@ -96,13 +96,27 @@ func (tv TokenValue) String() string { // Token represents a lexer token type Token struct { - Type string - Value TokenValue - Pos int + Type string + Value TokenValue + StartPos int + EndPos int } func (t Token) String() string { - return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.Pos) + return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.StartPos) +} + +// Location represents a source position with 1-based line and column. +type Location struct { + Line int + Column int + Offset int +} + +// Span represents a source range. +type Span struct { + Start Location + End Location } // tokenSpec represents a token specification for the lexer @@ -212,14 +226,15 @@ func (l *Lexer) tokenize() { } l.tokens = append(l.tokens, Token{ - Type: best.tokenType, - Value: best.action(best.value), - Pos: l.pos, + Type: best.tokenType, + Value: best.action(best.value), + StartPos: l.pos, + EndPos: best.endPos, }) l.pos = best.endPos } - l.tokens = append(l.tokens, Token{Type: "$", Value: stringTokenValue(""), Pos: l.pos}) + l.tokens = append(l.tokens, Token{Type: "$", Value: stringTokenValue(""), StartPos: l.pos, EndPos: l.pos}) } // Scanner functions for each token type @@ -340,16 +355,43 @@ type Parser struct { pos int idToDebugInfo map[string]map[relationIdKey]string currentFragmentID []byte + Provenance map[string]Span + path []int + lineStarts []int } // NewParser creates a new parser -func NewParser(tokens []Token) *Parser { +func NewParser(tokens []Token, input string) *Parser { return &Parser{ tokens: tokens, pos: 0, idToDebugInfo: make(map[string]map[relationIdKey]string), currentFragmentID: nil, + Provenance: make(map[string]Span), + path: make([]int, 0), + lineStarts: computeLineStarts(input), + } +} + +func computeLineStarts(text string) []int { + starts := []int{0} + for i, ch := range text { + if ch == '\n' { + starts = append(starts, i+1) + } } + return starts +} + +func pathKey(path []int) string { + if len(path) == 0 { + return "" + } + parts := make([]string, len(path)) + for i, v := range path { + parts[i] = strconv.Itoa(v) + } + return strings.Join(parts, ",") } func (p *Parser) lookahead(k int) Token { @@ -357,13 +399,13 @@ func (p *Parser) lookahead(k int) Token { if idx < len(p.tokens) { return p.tokens[idx] } - return Token{Type: "$", Value: stringTokenValue(""), Pos: -1} + return Token{Type: "$", Value: stringTokenValue(""), StartPos: -1, EndPos: -1} } func (p *Parser) consumeLiteral(expected string) { if !p.matchLookaheadLiteral(expected, 0) { token := p.lookahead(0) - panic(ParseError{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}) + panic(ParseError{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}) } p.pos++ } @@ -371,7 +413,7 @@ func (p *Parser) consumeLiteral(expected string) { func (p *Parser) consumeTerminal(expected string) Token { if !p.matchLookaheadTerminal(expected, 0) { token := p.lookahead(0) - panic(ParseError{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}) + panic(ParseError{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}) } token := p.lookahead(0) p.pos++ @@ -395,6 +437,43 @@ func (p *Parser) matchLookaheadTerminal(terminal string, k int) bool { return token.Type == terminal } +func (p *Parser) pushPath(n int) { + p.path = append(p.path, n) +} + +func (p *Parser) popPath() { + p.path = p.path[:len(p.path)-1] +} + +func (p *Parser) spanStart() int { + return p.tokens[p.pos].StartPos +} + +func (p *Parser) recordSpan(startOffset int) { + endOffset := p.tokens[p.pos-1].EndPos + key := pathKey(p.path) + p.Provenance[key] = Span{ + Start: p.makeLocation(startOffset), + End: p.makeLocation(endOffset), + } +} + +func (p *Parser) makeLocation(offset int) Location { + // Binary search for the line containing offset + lo, hi := 0, len(p.lineStarts)-1 + for lo < hi { + mid := (lo + hi + 1) / 2 + if p.lineStarts[mid] <= offset { + lo = mid + } else { + hi = mid - 1 + } + } + line := lo + 1 + column := offset - p.lineStarts[lo] + 1 + return Location{Line: line, Column: column, Offset: offset} +} + func (p *Parser) startFragment(fragmentID *pb.FragmentId) *pb.FragmentId { p.currentFragmentID = fragmentID.Id return fragmentID @@ -739,68 +818,68 @@ func (p *Parser) _try_extract_value_string_list(value *pb.Value) []string { func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig { config := dictFromList(config_dict) - _t956 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) - header_row := _t956 - _t957 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) - skip := _t957 - _t958 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") - new_line := _t958 - _t959 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") - delimiter := _t959 - _t960 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") - quotechar := _t960 - _t961 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") - escapechar := _t961 - _t962 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") - comment := _t962 - _t963 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) - missing_strings := _t963 - _t964 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") - decimal_separator := _t964 - _t965 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") - encoding := _t965 - _t966 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") - compression := _t966 - _t967 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} - return _t967 + _t1222 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) + header_row := _t1222 + _t1223 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) + skip := _t1223 + _t1224 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") + new_line := _t1224 + _t1225 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") + delimiter := _t1225 + _t1226 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") + quotechar := _t1226 + _t1227 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") + escapechar := _t1227 + _t1228 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") + comment := _t1228 + _t1229 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) + missing_strings := _t1229 + _t1230 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") + decimal_separator := _t1230 + _t1231 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") + encoding := _t1231 + _t1232 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") + compression := _t1232 + _t1233 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} + return _t1233 } func (p *Parser) construct_betree_info(key_types []*pb.Type, value_types []*pb.Type, config_dict [][]interface{}) *pb.BeTreeInfo { config := dictFromList(config_dict) - _t968 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) - epsilon := _t968 - _t969 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) - max_pivots := _t969 - _t970 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) - max_deltas := _t970 - _t971 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) - max_leaf := _t971 - _t972 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} - storage_config := _t972 - _t973 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) - root_pageid := _t973 - _t974 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) - inline_data := _t974 - _t975 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) - element_count := _t975 - _t976 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) - tree_height := _t976 - _t977 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} + _t1234 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) + epsilon := _t1234 + _t1235 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) + max_pivots := _t1235 + _t1236 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) + max_deltas := _t1236 + _t1237 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) + max_leaf := _t1237 + _t1238 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} + storage_config := _t1238 + _t1239 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) + root_pageid := _t1239 + _t1240 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) + inline_data := _t1240 + _t1241 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) + element_count := _t1241 + _t1242 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) + tree_height := _t1242 + _t1243 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} if root_pageid != nil { - _t977.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} + _t1243.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} } else { - _t977.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} + _t1243.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} } - relation_locator := _t977 - _t978 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} - return _t978 + relation_locator := _t1243 + _t1244 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} + return _t1244 } func (p *Parser) default_configure() *pb.Configure { - _t979 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} - ivm_config := _t979 - _t980 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} - return _t980 + _t1245 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} + ivm_config := _t1245 + _t1246 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} + return _t1246 } func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure { @@ -822,68 +901,68 @@ func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure } } } - _t981 := &pb.IVMConfig{Level: maintenance_level} - ivm_config := _t981 - _t982 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) - semantics_version := _t982 - _t983 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} - return _t983 + _t1247 := &pb.IVMConfig{Level: maintenance_level} + ivm_config := _t1247 + _t1248 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) + semantics_version := _t1248 + _t1249 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} + return _t1249 } func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, config_dict [][]interface{}) *pb.ExportCSVConfig { config := dictFromList(config_dict) - _t984 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) - partition_size := _t984 - _t985 := p._extract_value_string(dictGetValue(config, "compression"), "") - compression := _t985 - _t986 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) - syntax_header_row := _t986 - _t987 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") - syntax_missing_string := _t987 - _t988 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") - syntax_delim := _t988 - _t989 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") - syntax_quotechar := _t989 - _t990 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") - syntax_escapechar := _t990 - _t991 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} - return _t991 + _t1250 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) + partition_size := _t1250 + _t1251 := p._extract_value_string(dictGetValue(config, "compression"), "") + compression := _t1251 + _t1252 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) + syntax_header_row := _t1252 + _t1253 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") + syntax_missing_string := _t1253 + _t1254 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") + syntax_delim := _t1254 + _t1255 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") + syntax_quotechar := _t1255 + _t1256 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") + syntax_escapechar := _t1256 + _t1257 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} + return _t1257 } func (p *Parser) _make_value_int32(v int32) *pb.Value { - _t992 := &pb.Value{} - _t992.Value = &pb.Value_IntValue{IntValue: int64(v)} - return _t992 + _t1258 := &pb.Value{} + _t1258.Value = &pb.Value_IntValue{IntValue: int64(v)} + return _t1258 } func (p *Parser) _make_value_int64(v int64) *pb.Value { - _t993 := &pb.Value{} - _t993.Value = &pb.Value_IntValue{IntValue: v} - return _t993 + _t1259 := &pb.Value{} + _t1259.Value = &pb.Value_IntValue{IntValue: v} + return _t1259 } func (p *Parser) _make_value_float64(v float64) *pb.Value { - _t994 := &pb.Value{} - _t994.Value = &pb.Value_FloatValue{FloatValue: v} - return _t994 + _t1260 := &pb.Value{} + _t1260.Value = &pb.Value_FloatValue{FloatValue: v} + return _t1260 } func (p *Parser) _make_value_string(v string) *pb.Value { - _t995 := &pb.Value{} - _t995.Value = &pb.Value_StringValue{StringValue: v} - return _t995 + _t1261 := &pb.Value{} + _t1261.Value = &pb.Value_StringValue{StringValue: v} + return _t1261 } func (p *Parser) _make_value_boolean(v bool) *pb.Value { - _t996 := &pb.Value{} - _t996.Value = &pb.Value_BooleanValue{BooleanValue: v} - return _t996 + _t1262 := &pb.Value{} + _t1262.Value = &pb.Value_BooleanValue{BooleanValue: v} + return _t1262 } func (p *Parser) _make_value_uint128(v *pb.UInt128Value) *pb.Value { - _t997 := &pb.Value{} - _t997.Value = &pb.Value_Uint128Value{Uint128Value: v} - return _t997 + _t1263 := &pb.Value{} + _t1263.Value = &pb.Value_Uint128Value{Uint128Value: v} + return _t1263 } func (p *Parser) is_default_configure(cfg *pb.Configure) bool { @@ -898,197 +977,197 @@ func (p *Parser) is_default_configure(cfg *pb.Configure) bool { func (p *Parser) deconstruct_configure(msg *pb.Configure) [][]interface{} { result := [][]interface{}{} - var _t998 interface{} + var _t1264 interface{} if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_AUTO { - _t999 := p._make_value_string("auto") - result = append(result, []interface{}{"ivm.maintenance_level", _t999}) - _t998 = nil + _t1265 := p._make_value_string("auto") + result = append(result, []interface{}{"ivm.maintenance_level", _t1265}) + _t1264 = nil } else { - var _t1000 interface{} + var _t1266 interface{} if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_ALL { - _t1001 := p._make_value_string("all") - result = append(result, []interface{}{"ivm.maintenance_level", _t1001}) - _t1000 = nil + _t1267 := p._make_value_string("all") + result = append(result, []interface{}{"ivm.maintenance_level", _t1267}) + _t1266 = nil } else { - var _t1002 interface{} + var _t1268 interface{} if msg.GetIvmConfig().GetLevel() == pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF { - _t1003 := p._make_value_string("off") - result = append(result, []interface{}{"ivm.maintenance_level", _t1003}) - _t1002 = nil + _t1269 := p._make_value_string("off") + result = append(result, []interface{}{"ivm.maintenance_level", _t1269}) + _t1268 = nil } - _t1000 = _t1002 + _t1266 = _t1268 } - _t998 = _t1000 + _t1264 = _t1266 } - _ = _t998 - _t1004 := p._make_value_int64(msg.GetSemanticsVersion()) - result = append(result, []interface{}{"semantics_version", _t1004}) + _ = _t1264 + _t1270 := p._make_value_int64(msg.GetSemanticsVersion()) + result = append(result, []interface{}{"semantics_version", _t1270}) return listSort(result) } func (p *Parser) deconstruct_csv_config(msg *pb.CSVConfig) [][]interface{} { result := [][]interface{}{} - _t1005 := p._make_value_int32(msg.GetHeaderRow()) - result = append(result, []interface{}{"csv_header_row", _t1005}) - _t1006 := p._make_value_int64(msg.GetSkip()) - result = append(result, []interface{}{"csv_skip", _t1006}) - var _t1007 interface{} + _t1271 := p._make_value_int32(msg.GetHeaderRow()) + result = append(result, []interface{}{"csv_header_row", _t1271}) + _t1272 := p._make_value_int64(msg.GetSkip()) + result = append(result, []interface{}{"csv_skip", _t1272}) + var _t1273 interface{} if msg.GetNewLine() != "" { - _t1008 := p._make_value_string(msg.GetNewLine()) - result = append(result, []interface{}{"csv_new_line", _t1008}) - _t1007 = nil - } - _ = _t1007 - _t1009 := p._make_value_string(msg.GetDelimiter()) - result = append(result, []interface{}{"csv_delimiter", _t1009}) - _t1010 := p._make_value_string(msg.GetQuotechar()) - result = append(result, []interface{}{"csv_quotechar", _t1010}) - _t1011 := p._make_value_string(msg.GetEscapechar()) - result = append(result, []interface{}{"csv_escapechar", _t1011}) - var _t1012 interface{} + _t1274 := p._make_value_string(msg.GetNewLine()) + result = append(result, []interface{}{"csv_new_line", _t1274}) + _t1273 = nil + } + _ = _t1273 + _t1275 := p._make_value_string(msg.GetDelimiter()) + result = append(result, []interface{}{"csv_delimiter", _t1275}) + _t1276 := p._make_value_string(msg.GetQuotechar()) + result = append(result, []interface{}{"csv_quotechar", _t1276}) + _t1277 := p._make_value_string(msg.GetEscapechar()) + result = append(result, []interface{}{"csv_escapechar", _t1277}) + var _t1278 interface{} if msg.GetComment() != "" { - _t1013 := p._make_value_string(msg.GetComment()) - result = append(result, []interface{}{"csv_comment", _t1013}) - _t1012 = nil + _t1279 := p._make_value_string(msg.GetComment()) + result = append(result, []interface{}{"csv_comment", _t1279}) + _t1278 = nil } - _ = _t1012 + _ = _t1278 for _, missing_string := range msg.GetMissingStrings() { - _t1014 := p._make_value_string(missing_string) - result = append(result, []interface{}{"csv_missing_strings", _t1014}) - } - _t1015 := p._make_value_string(msg.GetDecimalSeparator()) - result = append(result, []interface{}{"csv_decimal_separator", _t1015}) - _t1016 := p._make_value_string(msg.GetEncoding()) - result = append(result, []interface{}{"csv_encoding", _t1016}) - _t1017 := p._make_value_string(msg.GetCompression()) - result = append(result, []interface{}{"csv_compression", _t1017}) + _t1280 := p._make_value_string(missing_string) + result = append(result, []interface{}{"csv_missing_strings", _t1280}) + } + _t1281 := p._make_value_string(msg.GetDecimalSeparator()) + result = append(result, []interface{}{"csv_decimal_separator", _t1281}) + _t1282 := p._make_value_string(msg.GetEncoding()) + result = append(result, []interface{}{"csv_encoding", _t1282}) + _t1283 := p._make_value_string(msg.GetCompression()) + result = append(result, []interface{}{"csv_compression", _t1283}) return listSort(result) } func (p *Parser) _maybe_push_float64(result [][]interface{}, key string, val *float64) interface{} { - var _t1018 interface{} + var _t1284 interface{} if val != nil { - _t1019 := p._make_value_float64(*val) - result = append(result, []interface{}{key, _t1019}) - _t1018 = nil + _t1285 := p._make_value_float64(*val) + result = append(result, []interface{}{key, _t1285}) + _t1284 = nil } - _ = _t1018 + _ = _t1284 return nil } func (p *Parser) _maybe_push_int64(result [][]interface{}, key string, val *int64) interface{} { - var _t1020 interface{} + var _t1286 interface{} if val != nil { - _t1021 := p._make_value_int64(*val) - result = append(result, []interface{}{key, _t1021}) - _t1020 = nil + _t1287 := p._make_value_int64(*val) + result = append(result, []interface{}{key, _t1287}) + _t1286 = nil } - _ = _t1020 + _ = _t1286 return nil } func (p *Parser) _maybe_push_uint128(result [][]interface{}, key string, val *pb.UInt128Value) interface{} { - var _t1022 interface{} + var _t1288 interface{} if val != nil { - _t1023 := p._make_value_uint128(val) - result = append(result, []interface{}{key, _t1023}) - _t1022 = nil + _t1289 := p._make_value_uint128(val) + result = append(result, []interface{}{key, _t1289}) + _t1288 = nil } - _ = _t1022 + _ = _t1288 return nil } func (p *Parser) _maybe_push_bytes_as_string(result [][]interface{}, key string, val []byte) interface{} { - var _t1024 interface{} + var _t1290 interface{} if val != nil { - _t1025 := p._make_value_string(string(val)) - result = append(result, []interface{}{key, _t1025}) - _t1024 = nil + _t1291 := p._make_value_string(string(val)) + result = append(result, []interface{}{key, _t1291}) + _t1290 = nil } - _ = _t1024 + _ = _t1290 return nil } func (p *Parser) deconstruct_betree_info_config(msg *pb.BeTreeInfo) [][]interface{} { result := [][]interface{}{} - _t1026 := p._make_value_float64(msg.GetStorageConfig().GetEpsilon()) - result = append(result, []interface{}{"betree_config_epsilon", _t1026}) - _t1027 := p._make_value_int64(msg.GetStorageConfig().GetMaxPivots()) - result = append(result, []interface{}{"betree_config_max_pivots", _t1027}) - _t1028 := p._make_value_int64(msg.GetStorageConfig().GetMaxDeltas()) - result = append(result, []interface{}{"betree_config_max_deltas", _t1028}) - _t1029 := p._make_value_int64(msg.GetStorageConfig().GetMaxLeaf()) - result = append(result, []interface{}{"betree_config_max_leaf", _t1029}) - var _t1030 interface{} + _t1292 := p._make_value_float64(msg.GetStorageConfig().GetEpsilon()) + result = append(result, []interface{}{"betree_config_epsilon", _t1292}) + _t1293 := p._make_value_int64(msg.GetStorageConfig().GetMaxPivots()) + result = append(result, []interface{}{"betree_config_max_pivots", _t1293}) + _t1294 := p._make_value_int64(msg.GetStorageConfig().GetMaxDeltas()) + result = append(result, []interface{}{"betree_config_max_deltas", _t1294}) + _t1295 := p._make_value_int64(msg.GetStorageConfig().GetMaxLeaf()) + result = append(result, []interface{}{"betree_config_max_leaf", _t1295}) + var _t1296 interface{} if hasProtoField(msg.GetRelationLocator(), "root_pageid") { - _t1031 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.GetRelationLocator().GetRootPageid()) - _t1030 = _t1031 + _t1297 := p._maybe_push_uint128(result, "betree_locator_root_pageid", msg.GetRelationLocator().GetRootPageid()) + _t1296 = _t1297 } - _ = _t1030 - var _t1032 interface{} + _ = _t1296 + var _t1298 interface{} if hasProtoField(msg.GetRelationLocator(), "inline_data") { - _t1033 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.GetRelationLocator().GetInlineData()) - _t1032 = _t1033 - } - _ = _t1032 - _t1034 := p._make_value_int64(msg.GetRelationLocator().GetElementCount()) - result = append(result, []interface{}{"betree_locator_element_count", _t1034}) - _t1035 := p._make_value_int64(msg.GetRelationLocator().GetTreeHeight()) - result = append(result, []interface{}{"betree_locator_tree_height", _t1035}) + _t1299 := p._maybe_push_bytes_as_string(result, "betree_locator_inline_data", msg.GetRelationLocator().GetInlineData()) + _t1298 = _t1299 + } + _ = _t1298 + _t1300 := p._make_value_int64(msg.GetRelationLocator().GetElementCount()) + result = append(result, []interface{}{"betree_locator_element_count", _t1300}) + _t1301 := p._make_value_int64(msg.GetRelationLocator().GetTreeHeight()) + result = append(result, []interface{}{"betree_locator_tree_height", _t1301}) return listSort(result) } func (p *Parser) deconstruct_export_csv_config(msg *pb.ExportCSVConfig) [][]interface{} { result := [][]interface{}{} - var _t1036 interface{} + var _t1302 interface{} if msg.PartitionSize != nil { - _t1037 := p._make_value_int64(*msg.PartitionSize) - result = append(result, []interface{}{"partition_size", _t1037}) - _t1036 = nil + _t1303 := p._make_value_int64(*msg.PartitionSize) + result = append(result, []interface{}{"partition_size", _t1303}) + _t1302 = nil } - _ = _t1036 - var _t1038 interface{} + _ = _t1302 + var _t1304 interface{} if msg.Compression != nil { - _t1039 := p._make_value_string(*msg.Compression) - result = append(result, []interface{}{"compression", _t1039}) - _t1038 = nil + _t1305 := p._make_value_string(*msg.Compression) + result = append(result, []interface{}{"compression", _t1305}) + _t1304 = nil } - _ = _t1038 - var _t1040 interface{} + _ = _t1304 + var _t1306 interface{} if msg.SyntaxHeaderRow != nil { - _t1041 := p._make_value_boolean(*msg.SyntaxHeaderRow) - result = append(result, []interface{}{"syntax_header_row", _t1041}) - _t1040 = nil + _t1307 := p._make_value_boolean(*msg.SyntaxHeaderRow) + result = append(result, []interface{}{"syntax_header_row", _t1307}) + _t1306 = nil } - _ = _t1040 - var _t1042 interface{} + _ = _t1306 + var _t1308 interface{} if msg.SyntaxMissingString != nil { - _t1043 := p._make_value_string(*msg.SyntaxMissingString) - result = append(result, []interface{}{"syntax_missing_string", _t1043}) - _t1042 = nil + _t1309 := p._make_value_string(*msg.SyntaxMissingString) + result = append(result, []interface{}{"syntax_missing_string", _t1309}) + _t1308 = nil } - _ = _t1042 - var _t1044 interface{} + _ = _t1308 + var _t1310 interface{} if msg.SyntaxDelim != nil { - _t1045 := p._make_value_string(*msg.SyntaxDelim) - result = append(result, []interface{}{"syntax_delim", _t1045}) - _t1044 = nil + _t1311 := p._make_value_string(*msg.SyntaxDelim) + result = append(result, []interface{}{"syntax_delim", _t1311}) + _t1310 = nil } - _ = _t1044 - var _t1046 interface{} + _ = _t1310 + var _t1312 interface{} if msg.SyntaxQuotechar != nil { - _t1047 := p._make_value_string(*msg.SyntaxQuotechar) - result = append(result, []interface{}{"syntax_quotechar", _t1047}) - _t1046 = nil + _t1313 := p._make_value_string(*msg.SyntaxQuotechar) + result = append(result, []interface{}{"syntax_quotechar", _t1313}) + _t1312 = nil } - _ = _t1046 - var _t1048 interface{} + _ = _t1312 + var _t1314 interface{} if msg.SyntaxEscapechar != nil { - _t1049 := p._make_value_string(*msg.SyntaxEscapechar) - result = append(result, []interface{}{"syntax_escapechar", _t1049}) - _t1048 = nil + _t1315 := p._make_value_string(*msg.SyntaxEscapechar) + result = append(result, []interface{}{"syntax_escapechar", _t1315}) + _t1314 = nil } - _ = _t1048 + _ = _t1314 return listSort(result) } @@ -1122,3000 +1201,3663 @@ func (p *Parser) deconstruct_bindings_with_arity(abs *pb.Abstraction, value_arit // --- Parse functions --- func (p *Parser) parse_transaction() *pb.Transaction { + span_start7 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("transaction") - var _t353 *pb.Configure + p.pushPath(2) + var _t619 *pb.Configure if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("configure", 1)) { - _t354 := p.parse_configure() - _t353 = _t354 + _t620 := p.parse_configure() + _t619 = _t620 } - configure0 := _t353 - var _t355 *pb.Sync + configure0 := _t619 + p.popPath() + p.pushPath(3) + var _t621 *pb.Sync if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("sync", 1)) { - _t356 := p.parse_sync() - _t355 = _t356 + _t622 := p.parse_sync() + _t621 = _t622 } - sync1 := _t355 + sync1 := _t621 + p.popPath() + p.pushPath(1) xs2 := []*pb.Epoch{} cond3 := p.matchLookaheadLiteral("(", 0) + idx5 := 0 for cond3 { - _t357 := p.parse_epoch() - item4 := _t357 + p.pushPath(idx5) + _t623 := p.parse_epoch() + item4 := _t623 + p.popPath() xs2 = append(xs2, item4) + idx5 = (idx5 + 1) cond3 = p.matchLookaheadLiteral("(", 0) } - epochs5 := xs2 + p.popPath() + epochs6 := xs2 p.consumeLiteral(")") - _t358 := p.default_configure() - _t359 := configure0 + _t624 := p.default_configure() + _t625 := configure0 if configure0 == nil { - _t359 = _t358 + _t625 = _t624 } - _t360 := &pb.Transaction{Epochs: epochs5, Configure: _t359, Sync: sync1} - return _t360 + _t626 := &pb.Transaction{Epochs: epochs6, Configure: _t625, Sync: sync1} + result8 := _t626 + p.recordSpan(span_start7) + return result8 } func (p *Parser) parse_configure() *pb.Configure { + span_start10 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("configure") - _t361 := p.parse_config_dict() - config_dict6 := _t361 + _t627 := p.parse_config_dict() + config_dict9 := _t627 p.consumeLiteral(")") - _t362 := p.construct_configure(config_dict6) - return _t362 + _t628 := p.construct_configure(config_dict9) + result11 := _t628 + p.recordSpan(span_start10) + return result11 } func (p *Parser) parse_config_dict() [][]interface{} { + span_start17 := p.spanStart() p.consumeLiteral("{") - xs7 := [][]interface{}{} - cond8 := p.matchLookaheadLiteral(":", 0) - for cond8 { - _t363 := p.parse_config_key_value() - item9 := _t363 - xs7 = append(xs7, item9) - cond8 = p.matchLookaheadLiteral(":", 0) - } - config_key_values10 := xs7 + xs12 := [][]interface{}{} + cond13 := p.matchLookaheadLiteral(":", 0) + idx15 := 0 + for cond13 { + p.pushPath(idx15) + _t629 := p.parse_config_key_value() + item14 := _t629 + p.popPath() + xs12 = append(xs12, item14) + idx15 = (idx15 + 1) + cond13 = p.matchLookaheadLiteral(":", 0) + } + config_key_values16 := xs12 p.consumeLiteral("}") - return config_key_values10 + result18 := config_key_values16 + p.recordSpan(span_start17) + return result18 } func (p *Parser) parse_config_key_value() []interface{} { + span_start21 := p.spanStart() p.consumeLiteral(":") - symbol11 := p.consumeTerminal("SYMBOL").Value.AsString() - _t364 := p.parse_value() - value12 := _t364 - return []interface{}{symbol11, value12} + symbol19 := p.consumeTerminal("SYMBOL").Value.AsString() + _t630 := p.parse_value() + value20 := _t630 + result22 := []interface{}{symbol19, value20} + p.recordSpan(span_start21) + return result22 } func (p *Parser) parse_value() *pb.Value { - var _t365 int64 + span_start33 := p.spanStart() + var _t631 int64 if p.matchLookaheadLiteral("true", 0) { - _t365 = 9 + _t631 = 9 } else { - var _t366 int64 + var _t632 int64 if p.matchLookaheadLiteral("missing", 0) { - _t366 = 8 + _t632 = 8 } else { - var _t367 int64 + var _t633 int64 if p.matchLookaheadLiteral("false", 0) { - _t367 = 9 + _t633 = 9 } else { - var _t368 int64 + var _t634 int64 if p.matchLookaheadLiteral("(", 0) { - var _t369 int64 + var _t635 int64 if p.matchLookaheadLiteral("datetime", 1) { - _t369 = 1 + _t635 = 1 } else { - var _t370 int64 + var _t636 int64 if p.matchLookaheadLiteral("date", 1) { - _t370 = 0 + _t636 = 0 } else { - _t370 = -1 + _t636 = -1 } - _t369 = _t370 + _t635 = _t636 } - _t368 = _t369 + _t634 = _t635 } else { - var _t371 int64 + var _t637 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t371 = 5 + _t637 = 5 } else { - var _t372 int64 + var _t638 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t372 = 2 + _t638 = 2 } else { - var _t373 int64 + var _t639 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t373 = 6 + _t639 = 6 } else { - var _t374 int64 + var _t640 int64 if p.matchLookaheadTerminal("INT", 0) { - _t374 = 3 + _t640 = 3 } else { - var _t375 int64 + var _t641 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t375 = 4 + _t641 = 4 } else { - var _t376 int64 + var _t642 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t376 = 7 + _t642 = 7 } else { - _t376 = -1 + _t642 = -1 } - _t375 = _t376 + _t641 = _t642 } - _t374 = _t375 + _t640 = _t641 } - _t373 = _t374 + _t639 = _t640 } - _t372 = _t373 + _t638 = _t639 } - _t371 = _t372 + _t637 = _t638 } - _t368 = _t371 + _t634 = _t637 } - _t367 = _t368 + _t633 = _t634 } - _t366 = _t367 + _t632 = _t633 } - _t365 = _t366 - } - prediction13 := _t365 - var _t377 *pb.Value - if prediction13 == 9 { - _t378 := p.parse_boolean_value() - boolean_value22 := _t378 - _t379 := &pb.Value{} - _t379.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value22} - _t377 = _t379 + _t631 = _t632 + } + prediction23 := _t631 + var _t643 *pb.Value + if prediction23 == 9 { + _t644 := p.parse_boolean_value() + boolean_value32 := _t644 + _t645 := &pb.Value{} + _t645.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value32} + _t643 = _t645 } else { - var _t380 *pb.Value - if prediction13 == 8 { + var _t646 *pb.Value + if prediction23 == 8 { p.consumeLiteral("missing") - _t381 := &pb.MissingValue{} - _t382 := &pb.Value{} - _t382.Value = &pb.Value_MissingValue{MissingValue: _t381} - _t380 = _t382 + _t647 := &pb.MissingValue{} + _t648 := &pb.Value{} + _t648.Value = &pb.Value_MissingValue{MissingValue: _t647} + _t646 = _t648 } else { - var _t383 *pb.Value - if prediction13 == 7 { - decimal21 := p.consumeTerminal("DECIMAL").Value.AsDecimal() - _t384 := &pb.Value{} - _t384.Value = &pb.Value_DecimalValue{DecimalValue: decimal21} - _t383 = _t384 + var _t649 *pb.Value + if prediction23 == 7 { + decimal31 := p.consumeTerminal("DECIMAL").Value.AsDecimal() + _t650 := &pb.Value{} + _t650.Value = &pb.Value_DecimalValue{DecimalValue: decimal31} + _t649 = _t650 } else { - var _t385 *pb.Value - if prediction13 == 6 { - int12820 := p.consumeTerminal("INT128").Value.AsInt128() - _t386 := &pb.Value{} - _t386.Value = &pb.Value_Int128Value{Int128Value: int12820} - _t385 = _t386 + var _t651 *pb.Value + if prediction23 == 6 { + int12830 := p.consumeTerminal("INT128").Value.AsInt128() + _t652 := &pb.Value{} + _t652.Value = &pb.Value_Int128Value{Int128Value: int12830} + _t651 = _t652 } else { - var _t387 *pb.Value - if prediction13 == 5 { - uint12819 := p.consumeTerminal("UINT128").Value.AsUint128() - _t388 := &pb.Value{} - _t388.Value = &pb.Value_Uint128Value{Uint128Value: uint12819} - _t387 = _t388 + var _t653 *pb.Value + if prediction23 == 5 { + uint12829 := p.consumeTerminal("UINT128").Value.AsUint128() + _t654 := &pb.Value{} + _t654.Value = &pb.Value_Uint128Value{Uint128Value: uint12829} + _t653 = _t654 } else { - var _t389 *pb.Value - if prediction13 == 4 { - float18 := p.consumeTerminal("FLOAT").Value.AsFloat64() - _t390 := &pb.Value{} - _t390.Value = &pb.Value_FloatValue{FloatValue: float18} - _t389 = _t390 + var _t655 *pb.Value + if prediction23 == 4 { + float28 := p.consumeTerminal("FLOAT").Value.AsFloat64() + _t656 := &pb.Value{} + _t656.Value = &pb.Value_FloatValue{FloatValue: float28} + _t655 = _t656 } else { - var _t391 *pb.Value - if prediction13 == 3 { - int17 := p.consumeTerminal("INT").Value.AsInt64() - _t392 := &pb.Value{} - _t392.Value = &pb.Value_IntValue{IntValue: int17} - _t391 = _t392 + var _t657 *pb.Value + if prediction23 == 3 { + int27 := p.consumeTerminal("INT").Value.AsInt64() + _t658 := &pb.Value{} + _t658.Value = &pb.Value_IntValue{IntValue: int27} + _t657 = _t658 } else { - var _t393 *pb.Value - if prediction13 == 2 { - string16 := p.consumeTerminal("STRING").Value.AsString() - _t394 := &pb.Value{} - _t394.Value = &pb.Value_StringValue{StringValue: string16} - _t393 = _t394 + var _t659 *pb.Value + if prediction23 == 2 { + string26 := p.consumeTerminal("STRING").Value.AsString() + _t660 := &pb.Value{} + _t660.Value = &pb.Value_StringValue{StringValue: string26} + _t659 = _t660 } else { - var _t395 *pb.Value - if prediction13 == 1 { - _t396 := p.parse_datetime() - datetime15 := _t396 - _t397 := &pb.Value{} - _t397.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime15} - _t395 = _t397 + var _t661 *pb.Value + if prediction23 == 1 { + _t662 := p.parse_datetime() + datetime25 := _t662 + _t663 := &pb.Value{} + _t663.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime25} + _t661 = _t663 } else { - var _t398 *pb.Value - if prediction13 == 0 { - _t399 := p.parse_date() - date14 := _t399 - _t400 := &pb.Value{} - _t400.Value = &pb.Value_DateValue{DateValue: date14} - _t398 = _t400 + var _t664 *pb.Value + if prediction23 == 0 { + _t665 := p.parse_date() + date24 := _t665 + _t666 := &pb.Value{} + _t666.Value = &pb.Value_DateValue{DateValue: date24} + _t664 = _t666 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t395 = _t398 + _t661 = _t664 } - _t393 = _t395 + _t659 = _t661 } - _t391 = _t393 + _t657 = _t659 } - _t389 = _t391 + _t655 = _t657 } - _t387 = _t389 + _t653 = _t655 } - _t385 = _t387 + _t651 = _t653 } - _t383 = _t385 + _t649 = _t651 } - _t380 = _t383 + _t646 = _t649 } - _t377 = _t380 + _t643 = _t646 } - return _t377 + result34 := _t643 + p.recordSpan(span_start33) + return result34 } func (p *Parser) parse_date() *pb.DateValue { + span_start38 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("date") - int23 := p.consumeTerminal("INT").Value.AsInt64() - int_324 := p.consumeTerminal("INT").Value.AsInt64() - int_425 := p.consumeTerminal("INT").Value.AsInt64() + p.pushPath(1) + int35 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(2) + int_336 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(3) + int_437 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() p.consumeLiteral(")") - _t401 := &pb.DateValue{Year: int32(int23), Month: int32(int_324), Day: int32(int_425)} - return _t401 + _t667 := &pb.DateValue{Year: int32(int35), Month: int32(int_336), Day: int32(int_437)} + result39 := _t667 + p.recordSpan(span_start38) + return result39 } func (p *Parser) parse_datetime() *pb.DateTimeValue { + span_start47 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("datetime") - int26 := p.consumeTerminal("INT").Value.AsInt64() - int_327 := p.consumeTerminal("INT").Value.AsInt64() - int_428 := p.consumeTerminal("INT").Value.AsInt64() - int_529 := p.consumeTerminal("INT").Value.AsInt64() - int_630 := p.consumeTerminal("INT").Value.AsInt64() - int_731 := p.consumeTerminal("INT").Value.AsInt64() - var _t402 *int64 + p.pushPath(1) + int40 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(2) + int_341 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(3) + int_442 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(4) + int_543 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(5) + int_644 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(6) + int_745 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + var _t668 *int64 if p.matchLookaheadTerminal("INT", 0) { - _t402 = ptr(p.consumeTerminal("INT").Value.AsInt64()) + _t668 = ptr(p.consumeTerminal("INT").Value.AsInt64()) } - int_832 := _t402 + int_846 := _t668 p.consumeLiteral(")") - _t403 := &pb.DateTimeValue{Year: int32(int26), Month: int32(int_327), Day: int32(int_428), Hour: int32(int_529), Minute: int32(int_630), Second: int32(int_731), Microsecond: int32(deref(int_832, 0))} - return _t403 + _t669 := &pb.DateTimeValue{Year: int32(int40), Month: int32(int_341), Day: int32(int_442), Hour: int32(int_543), Minute: int32(int_644), Second: int32(int_745), Microsecond: int32(deref(int_846, 0))} + result48 := _t669 + p.recordSpan(span_start47) + return result48 } func (p *Parser) parse_boolean_value() bool { - var _t404 int64 + span_start50 := p.spanStart() + var _t670 int64 if p.matchLookaheadLiteral("true", 0) { - _t404 = 0 + _t670 = 0 } else { - var _t405 int64 + var _t671 int64 if p.matchLookaheadLiteral("false", 0) { - _t405 = 1 + _t671 = 1 } else { - _t405 = -1 + _t671 = -1 } - _t404 = _t405 + _t670 = _t671 } - prediction33 := _t404 - var _t406 bool - if prediction33 == 1 { + prediction49 := _t670 + var _t672 bool + if prediction49 == 1 { p.consumeLiteral("false") - _t406 = false + _t672 = false } else { - var _t407 bool - if prediction33 == 0 { + var _t673 bool + if prediction49 == 0 { p.consumeLiteral("true") - _t407 = true + _t673 = true } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in boolean_value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t406 = _t407 + _t672 = _t673 } - return _t406 + result51 := _t672 + p.recordSpan(span_start50) + return result51 } func (p *Parser) parse_sync() *pb.Sync { + span_start57 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("sync") - xs34 := []*pb.FragmentId{} - cond35 := p.matchLookaheadLiteral(":", 0) - for cond35 { - _t408 := p.parse_fragment_id() - item36 := _t408 - xs34 = append(xs34, item36) - cond35 = p.matchLookaheadLiteral(":", 0) - } - fragment_ids37 := xs34 + p.pushPath(1) + xs52 := []*pb.FragmentId{} + cond53 := p.matchLookaheadLiteral(":", 0) + idx55 := 0 + for cond53 { + p.pushPath(idx55) + _t674 := p.parse_fragment_id() + item54 := _t674 + p.popPath() + xs52 = append(xs52, item54) + idx55 = (idx55 + 1) + cond53 = p.matchLookaheadLiteral(":", 0) + } + p.popPath() + fragment_ids56 := xs52 p.consumeLiteral(")") - _t409 := &pb.Sync{Fragments: fragment_ids37} - return _t409 + _t675 := &pb.Sync{Fragments: fragment_ids56} + result58 := _t675 + p.recordSpan(span_start57) + return result58 } func (p *Parser) parse_fragment_id() *pb.FragmentId { + span_start60 := p.spanStart() p.consumeLiteral(":") - symbol38 := p.consumeTerminal("SYMBOL").Value.AsString() - return &pb.FragmentId{Id: []byte(symbol38)} + symbol59 := p.consumeTerminal("SYMBOL").Value.AsString() + result61 := &pb.FragmentId{Id: []byte(symbol59)} + p.recordSpan(span_start60) + return result61 } func (p *Parser) parse_epoch() *pb.Epoch { + span_start64 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("epoch") - var _t410 []*pb.Write + p.pushPath(1) + var _t676 []*pb.Write if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("writes", 1)) { - _t411 := p.parse_epoch_writes() - _t410 = _t411 + _t677 := p.parse_epoch_writes() + _t676 = _t677 } - epoch_writes39 := _t410 - var _t412 []*pb.Read + epoch_writes62 := _t676 + p.popPath() + p.pushPath(2) + var _t678 []*pb.Read if p.matchLookaheadLiteral("(", 0) { - _t413 := p.parse_epoch_reads() - _t412 = _t413 + _t679 := p.parse_epoch_reads() + _t678 = _t679 } - epoch_reads40 := _t412 + epoch_reads63 := _t678 + p.popPath() p.consumeLiteral(")") - _t414 := epoch_writes39 - if epoch_writes39 == nil { - _t414 = []*pb.Write{} + _t680 := epoch_writes62 + if epoch_writes62 == nil { + _t680 = []*pb.Write{} } - _t415 := epoch_reads40 - if epoch_reads40 == nil { - _t415 = []*pb.Read{} + _t681 := epoch_reads63 + if epoch_reads63 == nil { + _t681 = []*pb.Read{} } - _t416 := &pb.Epoch{Writes: _t414, Reads: _t415} - return _t416 + _t682 := &pb.Epoch{Writes: _t680, Reads: _t681} + result65 := _t682 + p.recordSpan(span_start64) + return result65 } func (p *Parser) parse_epoch_writes() []*pb.Write { + span_start71 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("writes") - xs41 := []*pb.Write{} - cond42 := p.matchLookaheadLiteral("(", 0) - for cond42 { - _t417 := p.parse_write() - item43 := _t417 - xs41 = append(xs41, item43) - cond42 = p.matchLookaheadLiteral("(", 0) - } - writes44 := xs41 + xs66 := []*pb.Write{} + cond67 := p.matchLookaheadLiteral("(", 0) + idx69 := 0 + for cond67 { + p.pushPath(idx69) + _t683 := p.parse_write() + item68 := _t683 + p.popPath() + xs66 = append(xs66, item68) + idx69 = (idx69 + 1) + cond67 = p.matchLookaheadLiteral("(", 0) + } + writes70 := xs66 p.consumeLiteral(")") - return writes44 + result72 := writes70 + p.recordSpan(span_start71) + return result72 } func (p *Parser) parse_write() *pb.Write { - var _t418 int64 + span_start77 := p.spanStart() + var _t684 int64 if p.matchLookaheadLiteral("(", 0) { - var _t419 int64 + var _t685 int64 if p.matchLookaheadLiteral("undefine", 1) { - _t419 = 1 + _t685 = 1 } else { - var _t420 int64 + var _t686 int64 if p.matchLookaheadLiteral("define", 1) { - _t420 = 0 + _t686 = 0 } else { - var _t421 int64 + var _t687 int64 if p.matchLookaheadLiteral("context", 1) { - _t421 = 2 + _t687 = 2 } else { - _t421 = -1 + _t687 = -1 } - _t420 = _t421 + _t686 = _t687 } - _t419 = _t420 + _t685 = _t686 } - _t418 = _t419 + _t684 = _t685 } else { - _t418 = -1 - } - prediction45 := _t418 - var _t422 *pb.Write - if prediction45 == 2 { - _t423 := p.parse_context() - context48 := _t423 - _t424 := &pb.Write{} - _t424.WriteType = &pb.Write_Context{Context: context48} - _t422 = _t424 + _t684 = -1 + } + prediction73 := _t684 + var _t688 *pb.Write + if prediction73 == 2 { + _t689 := p.parse_context() + context76 := _t689 + _t690 := &pb.Write{} + _t690.WriteType = &pb.Write_Context{Context: context76} + _t688 = _t690 } else { - var _t425 *pb.Write - if prediction45 == 1 { - _t426 := p.parse_undefine() - undefine47 := _t426 - _t427 := &pb.Write{} - _t427.WriteType = &pb.Write_Undefine{Undefine: undefine47} - _t425 = _t427 + var _t691 *pb.Write + if prediction73 == 1 { + _t692 := p.parse_undefine() + undefine75 := _t692 + _t693 := &pb.Write{} + _t693.WriteType = &pb.Write_Undefine{Undefine: undefine75} + _t691 = _t693 } else { - var _t428 *pb.Write - if prediction45 == 0 { - _t429 := p.parse_define() - define46 := _t429 - _t430 := &pb.Write{} - _t430.WriteType = &pb.Write_Define{Define: define46} - _t428 = _t430 + var _t694 *pb.Write + if prediction73 == 0 { + _t695 := p.parse_define() + define74 := _t695 + _t696 := &pb.Write{} + _t696.WriteType = &pb.Write_Define{Define: define74} + _t694 = _t696 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in write", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t425 = _t428 + _t691 = _t694 } - _t422 = _t425 + _t688 = _t691 } - return _t422 + result78 := _t688 + p.recordSpan(span_start77) + return result78 } func (p *Parser) parse_define() *pb.Define { + span_start80 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("define") - _t431 := p.parse_fragment() - fragment49 := _t431 + p.pushPath(1) + _t697 := p.parse_fragment() + fragment79 := _t697 + p.popPath() p.consumeLiteral(")") - _t432 := &pb.Define{Fragment: fragment49} - return _t432 + _t698 := &pb.Define{Fragment: fragment79} + result81 := _t698 + p.recordSpan(span_start80) + return result81 } func (p *Parser) parse_fragment() *pb.Fragment { + span_start88 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("fragment") - _t433 := p.parse_new_fragment_id() - new_fragment_id50 := _t433 - xs51 := []*pb.Declaration{} - cond52 := p.matchLookaheadLiteral("(", 0) - for cond52 { - _t434 := p.parse_declaration() - item53 := _t434 - xs51 = append(xs51, item53) - cond52 = p.matchLookaheadLiteral("(", 0) - } - declarations54 := xs51 + _t699 := p.parse_new_fragment_id() + new_fragment_id82 := _t699 + xs83 := []*pb.Declaration{} + cond84 := p.matchLookaheadLiteral("(", 0) + idx86 := 0 + for cond84 { + p.pushPath(idx86) + _t700 := p.parse_declaration() + item85 := _t700 + p.popPath() + xs83 = append(xs83, item85) + idx86 = (idx86 + 1) + cond84 = p.matchLookaheadLiteral("(", 0) + } + declarations87 := xs83 p.consumeLiteral(")") - return p.constructFragment(new_fragment_id50, declarations54) + result89 := p.constructFragment(new_fragment_id82, declarations87) + p.recordSpan(span_start88) + return result89 } func (p *Parser) parse_new_fragment_id() *pb.FragmentId { - _t435 := p.parse_fragment_id() - fragment_id55 := _t435 - p.startFragment(fragment_id55) - return fragment_id55 + span_start91 := p.spanStart() + _t701 := p.parse_fragment_id() + fragment_id90 := _t701 + p.startFragment(fragment_id90) + result92 := fragment_id90 + p.recordSpan(span_start91) + return result92 } func (p *Parser) parse_declaration() *pb.Declaration { - var _t436 int64 + span_start98 := p.spanStart() + var _t702 int64 if p.matchLookaheadLiteral("(", 0) { - var _t437 int64 + var _t703 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t437 = 3 + _t703 = 3 } else { - var _t438 int64 + var _t704 int64 if p.matchLookaheadLiteral("functional_dependency", 1) { - _t438 = 2 + _t704 = 2 } else { - var _t439 int64 + var _t705 int64 if p.matchLookaheadLiteral("def", 1) { - _t439 = 0 + _t705 = 0 } else { - var _t440 int64 + var _t706 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t440 = 3 + _t706 = 3 } else { - var _t441 int64 + var _t707 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t441 = 3 + _t707 = 3 } else { - var _t442 int64 + var _t708 int64 if p.matchLookaheadLiteral("algorithm", 1) { - _t442 = 1 + _t708 = 1 } else { - _t442 = -1 + _t708 = -1 } - _t441 = _t442 + _t707 = _t708 } - _t440 = _t441 + _t706 = _t707 } - _t439 = _t440 + _t705 = _t706 } - _t438 = _t439 + _t704 = _t705 } - _t437 = _t438 + _t703 = _t704 } - _t436 = _t437 + _t702 = _t703 } else { - _t436 = -1 - } - prediction56 := _t436 - var _t443 *pb.Declaration - if prediction56 == 3 { - _t444 := p.parse_data() - data60 := _t444 - _t445 := &pb.Declaration{} - _t445.DeclarationType = &pb.Declaration_Data{Data: data60} - _t443 = _t445 + _t702 = -1 + } + prediction93 := _t702 + var _t709 *pb.Declaration + if prediction93 == 3 { + _t710 := p.parse_data() + data97 := _t710 + _t711 := &pb.Declaration{} + _t711.DeclarationType = &pb.Declaration_Data{Data: data97} + _t709 = _t711 } else { - var _t446 *pb.Declaration - if prediction56 == 2 { - _t447 := p.parse_constraint() - constraint59 := _t447 - _t448 := &pb.Declaration{} - _t448.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint59} - _t446 = _t448 + var _t712 *pb.Declaration + if prediction93 == 2 { + _t713 := p.parse_constraint() + constraint96 := _t713 + _t714 := &pb.Declaration{} + _t714.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint96} + _t712 = _t714 } else { - var _t449 *pb.Declaration - if prediction56 == 1 { - _t450 := p.parse_algorithm() - algorithm58 := _t450 - _t451 := &pb.Declaration{} - _t451.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm58} - _t449 = _t451 + var _t715 *pb.Declaration + if prediction93 == 1 { + _t716 := p.parse_algorithm() + algorithm95 := _t716 + _t717 := &pb.Declaration{} + _t717.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm95} + _t715 = _t717 } else { - var _t452 *pb.Declaration - if prediction56 == 0 { - _t453 := p.parse_def() - def57 := _t453 - _t454 := &pb.Declaration{} - _t454.DeclarationType = &pb.Declaration_Def{Def: def57} - _t452 = _t454 + var _t718 *pb.Declaration + if prediction93 == 0 { + _t719 := p.parse_def() + def94 := _t719 + _t720 := &pb.Declaration{} + _t720.DeclarationType = &pb.Declaration_Def{Def: def94} + _t718 = _t720 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in declaration", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t449 = _t452 + _t715 = _t718 } - _t446 = _t449 + _t712 = _t715 } - _t443 = _t446 + _t709 = _t712 } - return _t443 + result99 := _t709 + p.recordSpan(span_start98) + return result99 } func (p *Parser) parse_def() *pb.Def { + span_start103 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("def") - _t455 := p.parse_relation_id() - relation_id61 := _t455 - _t456 := p.parse_abstraction() - abstraction62 := _t456 - var _t457 []*pb.Attribute + p.pushPath(1) + _t721 := p.parse_relation_id() + relation_id100 := _t721 + p.popPath() + p.pushPath(2) + _t722 := p.parse_abstraction() + abstraction101 := _t722 + p.popPath() + p.pushPath(3) + var _t723 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t458 := p.parse_attrs() - _t457 = _t458 + _t724 := p.parse_attrs() + _t723 = _t724 } - attrs63 := _t457 + attrs102 := _t723 + p.popPath() p.consumeLiteral(")") - _t459 := attrs63 - if attrs63 == nil { - _t459 = []*pb.Attribute{} + _t725 := attrs102 + if attrs102 == nil { + _t725 = []*pb.Attribute{} } - _t460 := &pb.Def{Name: relation_id61, Body: abstraction62, Attrs: _t459} - return _t460 + _t726 := &pb.Def{Name: relation_id100, Body: abstraction101, Attrs: _t725} + result104 := _t726 + p.recordSpan(span_start103) + return result104 } func (p *Parser) parse_relation_id() *pb.RelationId { - var _t461 int64 + span_start108 := p.spanStart() + var _t727 int64 if p.matchLookaheadLiteral(":", 0) { - _t461 = 0 + _t727 = 0 } else { - var _t462 int64 + var _t728 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t462 = 1 + _t728 = 1 } else { - _t462 = -1 + _t728 = -1 } - _t461 = _t462 + _t727 = _t728 } - prediction64 := _t461 - var _t463 *pb.RelationId - if prediction64 == 1 { - uint12866 := p.consumeTerminal("UINT128").Value.AsUint128() - _t463 = &pb.RelationId{IdLow: uint12866.Low, IdHigh: uint12866.High} + prediction105 := _t727 + var _t729 *pb.RelationId + if prediction105 == 1 { + uint128107 := p.consumeTerminal("UINT128").Value.AsUint128() + _t729 = &pb.RelationId{IdLow: uint128107.Low, IdHigh: uint128107.High} } else { - var _t464 *pb.RelationId - if prediction64 == 0 { + var _t730 *pb.RelationId + if prediction105 == 0 { p.consumeLiteral(":") - symbol65 := p.consumeTerminal("SYMBOL").Value.AsString() - _t464 = p.relationIdFromString(symbol65) + symbol106 := p.consumeTerminal("SYMBOL").Value.AsString() + _t730 = p.relationIdFromString(symbol106) } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in relation_id", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t463 = _t464 + _t729 = _t730 } - return _t463 + result109 := _t729 + p.recordSpan(span_start108) + return result109 } func (p *Parser) parse_abstraction() *pb.Abstraction { + span_start112 := p.spanStart() p.consumeLiteral("(") - _t465 := p.parse_bindings() - bindings67 := _t465 - _t466 := p.parse_formula() - formula68 := _t466 + _t731 := p.parse_bindings() + bindings110 := _t731 + p.pushPath(2) + _t732 := p.parse_formula() + formula111 := _t732 + p.popPath() p.consumeLiteral(")") - _t467 := &pb.Abstraction{Vars: listConcat(bindings67[0].([]*pb.Binding), bindings67[1].([]*pb.Binding)), Value: formula68} - return _t467 + _t733 := &pb.Abstraction{Vars: listConcat(bindings110[0].([]*pb.Binding), bindings110[1].([]*pb.Binding)), Value: formula111} + result113 := _t733 + p.recordSpan(span_start112) + return result113 } func (p *Parser) parse_bindings() []interface{} { + span_start120 := p.spanStart() p.consumeLiteral("[") - xs69 := []*pb.Binding{} - cond70 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond70 { - _t468 := p.parse_binding() - item71 := _t468 - xs69 = append(xs69, item71) - cond70 = p.matchLookaheadTerminal("SYMBOL", 0) - } - bindings72 := xs69 - var _t469 []*pb.Binding + xs114 := []*pb.Binding{} + cond115 := p.matchLookaheadTerminal("SYMBOL", 0) + idx117 := 0 + for cond115 { + p.pushPath(idx117) + _t734 := p.parse_binding() + item116 := _t734 + p.popPath() + xs114 = append(xs114, item116) + idx117 = (idx117 + 1) + cond115 = p.matchLookaheadTerminal("SYMBOL", 0) + } + bindings118 := xs114 + var _t735 []*pb.Binding if p.matchLookaheadLiteral("|", 0) { - _t470 := p.parse_value_bindings() - _t469 = _t470 + _t736 := p.parse_value_bindings() + _t735 = _t736 } - value_bindings73 := _t469 + value_bindings119 := _t735 p.consumeLiteral("]") - _t471 := value_bindings73 - if value_bindings73 == nil { - _t471 = []*pb.Binding{} + _t737 := value_bindings119 + if value_bindings119 == nil { + _t737 = []*pb.Binding{} } - return []interface{}{bindings72, _t471} + result121 := []interface{}{bindings118, _t737} + p.recordSpan(span_start120) + return result121 } func (p *Parser) parse_binding() *pb.Binding { - symbol74 := p.consumeTerminal("SYMBOL").Value.AsString() + span_start124 := p.spanStart() + symbol122 := p.consumeTerminal("SYMBOL").Value.AsString() p.consumeLiteral("::") - _t472 := p.parse_type() - type75 := _t472 - _t473 := &pb.Var{Name: symbol74} - _t474 := &pb.Binding{Var: _t473, Type: type75} - return _t474 + p.pushPath(2) + _t738 := p.parse_type() + type123 := _t738 + p.popPath() + _t739 := &pb.Var{Name: symbol122} + _t740 := &pb.Binding{Var: _t739, Type: type123} + result125 := _t740 + p.recordSpan(span_start124) + return result125 } func (p *Parser) parse_type() *pb.Type { - var _t475 int64 + span_start138 := p.spanStart() + var _t741 int64 if p.matchLookaheadLiteral("UNKNOWN", 0) { - _t475 = 0 + _t741 = 0 } else { - var _t476 int64 + var _t742 int64 if p.matchLookaheadLiteral("UINT128", 0) { - _t476 = 4 + _t742 = 4 } else { - var _t477 int64 + var _t743 int64 if p.matchLookaheadLiteral("STRING", 0) { - _t477 = 1 + _t743 = 1 } else { - var _t478 int64 + var _t744 int64 if p.matchLookaheadLiteral("MISSING", 0) { - _t478 = 8 + _t744 = 8 } else { - var _t479 int64 + var _t745 int64 if p.matchLookaheadLiteral("INT128", 0) { - _t479 = 5 + _t745 = 5 } else { - var _t480 int64 + var _t746 int64 if p.matchLookaheadLiteral("INT", 0) { - _t480 = 2 + _t746 = 2 } else { - var _t481 int64 + var _t747 int64 if p.matchLookaheadLiteral("FLOAT", 0) { - _t481 = 3 + _t747 = 3 } else { - var _t482 int64 + var _t748 int64 if p.matchLookaheadLiteral("DATETIME", 0) { - _t482 = 7 + _t748 = 7 } else { - var _t483 int64 + var _t749 int64 if p.matchLookaheadLiteral("DATE", 0) { - _t483 = 6 + _t749 = 6 } else { - var _t484 int64 + var _t750 int64 if p.matchLookaheadLiteral("BOOLEAN", 0) { - _t484 = 10 + _t750 = 10 } else { - var _t485 int64 + var _t751 int64 if p.matchLookaheadLiteral("(", 0) { - _t485 = 9 + _t751 = 9 } else { - _t485 = -1 + _t751 = -1 } - _t484 = _t485 + _t750 = _t751 } - _t483 = _t484 + _t749 = _t750 } - _t482 = _t483 + _t748 = _t749 } - _t481 = _t482 + _t747 = _t748 } - _t480 = _t481 + _t746 = _t747 } - _t479 = _t480 + _t745 = _t746 } - _t478 = _t479 + _t744 = _t745 } - _t477 = _t478 + _t743 = _t744 } - _t476 = _t477 + _t742 = _t743 } - _t475 = _t476 - } - prediction76 := _t475 - var _t486 *pb.Type - if prediction76 == 10 { - _t487 := p.parse_boolean_type() - boolean_type87 := _t487 - _t488 := &pb.Type{} - _t488.Type = &pb.Type_BooleanType{BooleanType: boolean_type87} - _t486 = _t488 + _t741 = _t742 + } + prediction126 := _t741 + var _t752 *pb.Type + if prediction126 == 10 { + _t753 := p.parse_boolean_type() + boolean_type137 := _t753 + _t754 := &pb.Type{} + _t754.Type = &pb.Type_BooleanType{BooleanType: boolean_type137} + _t752 = _t754 } else { - var _t489 *pb.Type - if prediction76 == 9 { - _t490 := p.parse_decimal_type() - decimal_type86 := _t490 - _t491 := &pb.Type{} - _t491.Type = &pb.Type_DecimalType{DecimalType: decimal_type86} - _t489 = _t491 + var _t755 *pb.Type + if prediction126 == 9 { + _t756 := p.parse_decimal_type() + decimal_type136 := _t756 + _t757 := &pb.Type{} + _t757.Type = &pb.Type_DecimalType{DecimalType: decimal_type136} + _t755 = _t757 } else { - var _t492 *pb.Type - if prediction76 == 8 { - _t493 := p.parse_missing_type() - missing_type85 := _t493 - _t494 := &pb.Type{} - _t494.Type = &pb.Type_MissingType{MissingType: missing_type85} - _t492 = _t494 + var _t758 *pb.Type + if prediction126 == 8 { + _t759 := p.parse_missing_type() + missing_type135 := _t759 + _t760 := &pb.Type{} + _t760.Type = &pb.Type_MissingType{MissingType: missing_type135} + _t758 = _t760 } else { - var _t495 *pb.Type - if prediction76 == 7 { - _t496 := p.parse_datetime_type() - datetime_type84 := _t496 - _t497 := &pb.Type{} - _t497.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type84} - _t495 = _t497 + var _t761 *pb.Type + if prediction126 == 7 { + _t762 := p.parse_datetime_type() + datetime_type134 := _t762 + _t763 := &pb.Type{} + _t763.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type134} + _t761 = _t763 } else { - var _t498 *pb.Type - if prediction76 == 6 { - _t499 := p.parse_date_type() - date_type83 := _t499 - _t500 := &pb.Type{} - _t500.Type = &pb.Type_DateType{DateType: date_type83} - _t498 = _t500 + var _t764 *pb.Type + if prediction126 == 6 { + _t765 := p.parse_date_type() + date_type133 := _t765 + _t766 := &pb.Type{} + _t766.Type = &pb.Type_DateType{DateType: date_type133} + _t764 = _t766 } else { - var _t501 *pb.Type - if prediction76 == 5 { - _t502 := p.parse_int128_type() - int128_type82 := _t502 - _t503 := &pb.Type{} - _t503.Type = &pb.Type_Int128Type{Int128Type: int128_type82} - _t501 = _t503 + var _t767 *pb.Type + if prediction126 == 5 { + _t768 := p.parse_int128_type() + int128_type132 := _t768 + _t769 := &pb.Type{} + _t769.Type = &pb.Type_Int128Type{Int128Type: int128_type132} + _t767 = _t769 } else { - var _t504 *pb.Type - if prediction76 == 4 { - _t505 := p.parse_uint128_type() - uint128_type81 := _t505 - _t506 := &pb.Type{} - _t506.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type81} - _t504 = _t506 + var _t770 *pb.Type + if prediction126 == 4 { + _t771 := p.parse_uint128_type() + uint128_type131 := _t771 + _t772 := &pb.Type{} + _t772.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type131} + _t770 = _t772 } else { - var _t507 *pb.Type - if prediction76 == 3 { - _t508 := p.parse_float_type() - float_type80 := _t508 - _t509 := &pb.Type{} - _t509.Type = &pb.Type_FloatType{FloatType: float_type80} - _t507 = _t509 + var _t773 *pb.Type + if prediction126 == 3 { + _t774 := p.parse_float_type() + float_type130 := _t774 + _t775 := &pb.Type{} + _t775.Type = &pb.Type_FloatType{FloatType: float_type130} + _t773 = _t775 } else { - var _t510 *pb.Type - if prediction76 == 2 { - _t511 := p.parse_int_type() - int_type79 := _t511 - _t512 := &pb.Type{} - _t512.Type = &pb.Type_IntType{IntType: int_type79} - _t510 = _t512 + var _t776 *pb.Type + if prediction126 == 2 { + _t777 := p.parse_int_type() + int_type129 := _t777 + _t778 := &pb.Type{} + _t778.Type = &pb.Type_IntType{IntType: int_type129} + _t776 = _t778 } else { - var _t513 *pb.Type - if prediction76 == 1 { - _t514 := p.parse_string_type() - string_type78 := _t514 - _t515 := &pb.Type{} - _t515.Type = &pb.Type_StringType{StringType: string_type78} - _t513 = _t515 + var _t779 *pb.Type + if prediction126 == 1 { + _t780 := p.parse_string_type() + string_type128 := _t780 + _t781 := &pb.Type{} + _t781.Type = &pb.Type_StringType{StringType: string_type128} + _t779 = _t781 } else { - var _t516 *pb.Type - if prediction76 == 0 { - _t517 := p.parse_unspecified_type() - unspecified_type77 := _t517 - _t518 := &pb.Type{} - _t518.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type77} - _t516 = _t518 + var _t782 *pb.Type + if prediction126 == 0 { + _t783 := p.parse_unspecified_type() + unspecified_type127 := _t783 + _t784 := &pb.Type{} + _t784.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type127} + _t782 = _t784 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in type", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t513 = _t516 + _t779 = _t782 } - _t510 = _t513 + _t776 = _t779 } - _t507 = _t510 + _t773 = _t776 } - _t504 = _t507 + _t770 = _t773 } - _t501 = _t504 + _t767 = _t770 } - _t498 = _t501 + _t764 = _t767 } - _t495 = _t498 + _t761 = _t764 } - _t492 = _t495 + _t758 = _t761 } - _t489 = _t492 + _t755 = _t758 } - _t486 = _t489 + _t752 = _t755 } - return _t486 + result139 := _t752 + p.recordSpan(span_start138) + return result139 } func (p *Parser) parse_unspecified_type() *pb.UnspecifiedType { + span_start140 := p.spanStart() p.consumeLiteral("UNKNOWN") - _t519 := &pb.UnspecifiedType{} - return _t519 + _t785 := &pb.UnspecifiedType{} + result141 := _t785 + p.recordSpan(span_start140) + return result141 } func (p *Parser) parse_string_type() *pb.StringType { + span_start142 := p.spanStart() p.consumeLiteral("STRING") - _t520 := &pb.StringType{} - return _t520 + _t786 := &pb.StringType{} + result143 := _t786 + p.recordSpan(span_start142) + return result143 } func (p *Parser) parse_int_type() *pb.IntType { + span_start144 := p.spanStart() p.consumeLiteral("INT") - _t521 := &pb.IntType{} - return _t521 + _t787 := &pb.IntType{} + result145 := _t787 + p.recordSpan(span_start144) + return result145 } func (p *Parser) parse_float_type() *pb.FloatType { + span_start146 := p.spanStart() p.consumeLiteral("FLOAT") - _t522 := &pb.FloatType{} - return _t522 + _t788 := &pb.FloatType{} + result147 := _t788 + p.recordSpan(span_start146) + return result147 } func (p *Parser) parse_uint128_type() *pb.UInt128Type { + span_start148 := p.spanStart() p.consumeLiteral("UINT128") - _t523 := &pb.UInt128Type{} - return _t523 + _t789 := &pb.UInt128Type{} + result149 := _t789 + p.recordSpan(span_start148) + return result149 } func (p *Parser) parse_int128_type() *pb.Int128Type { + span_start150 := p.spanStart() p.consumeLiteral("INT128") - _t524 := &pb.Int128Type{} - return _t524 + _t790 := &pb.Int128Type{} + result151 := _t790 + p.recordSpan(span_start150) + return result151 } func (p *Parser) parse_date_type() *pb.DateType { + span_start152 := p.spanStart() p.consumeLiteral("DATE") - _t525 := &pb.DateType{} - return _t525 + _t791 := &pb.DateType{} + result153 := _t791 + p.recordSpan(span_start152) + return result153 } func (p *Parser) parse_datetime_type() *pb.DateTimeType { + span_start154 := p.spanStart() p.consumeLiteral("DATETIME") - _t526 := &pb.DateTimeType{} - return _t526 + _t792 := &pb.DateTimeType{} + result155 := _t792 + p.recordSpan(span_start154) + return result155 } func (p *Parser) parse_missing_type() *pb.MissingType { + span_start156 := p.spanStart() p.consumeLiteral("MISSING") - _t527 := &pb.MissingType{} - return _t527 + _t793 := &pb.MissingType{} + result157 := _t793 + p.recordSpan(span_start156) + return result157 } func (p *Parser) parse_decimal_type() *pb.DecimalType { + span_start160 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("DECIMAL") - int88 := p.consumeTerminal("INT").Value.AsInt64() - int_389 := p.consumeTerminal("INT").Value.AsInt64() + p.pushPath(1) + int158 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() + p.pushPath(2) + int_3159 := p.consumeTerminal("INT").Value.AsInt64() + p.popPath() p.consumeLiteral(")") - _t528 := &pb.DecimalType{Precision: int32(int88), Scale: int32(int_389)} - return _t528 + _t794 := &pb.DecimalType{Precision: int32(int158), Scale: int32(int_3159)} + result161 := _t794 + p.recordSpan(span_start160) + return result161 } func (p *Parser) parse_boolean_type() *pb.BooleanType { + span_start162 := p.spanStart() p.consumeLiteral("BOOLEAN") - _t529 := &pb.BooleanType{} - return _t529 + _t795 := &pb.BooleanType{} + result163 := _t795 + p.recordSpan(span_start162) + return result163 } func (p *Parser) parse_value_bindings() []*pb.Binding { + span_start169 := p.spanStart() p.consumeLiteral("|") - xs90 := []*pb.Binding{} - cond91 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond91 { - _t530 := p.parse_binding() - item92 := _t530 - xs90 = append(xs90, item92) - cond91 = p.matchLookaheadTerminal("SYMBOL", 0) - } - bindings93 := xs90 - return bindings93 + xs164 := []*pb.Binding{} + cond165 := p.matchLookaheadTerminal("SYMBOL", 0) + idx167 := 0 + for cond165 { + p.pushPath(idx167) + _t796 := p.parse_binding() + item166 := _t796 + p.popPath() + xs164 = append(xs164, item166) + idx167 = (idx167 + 1) + cond165 = p.matchLookaheadTerminal("SYMBOL", 0) + } + bindings168 := xs164 + result170 := bindings168 + p.recordSpan(span_start169) + return result170 } func (p *Parser) parse_formula() *pb.Formula { - var _t531 int64 + span_start185 := p.spanStart() + var _t797 int64 if p.matchLookaheadLiteral("(", 0) { - var _t532 int64 + var _t798 int64 if p.matchLookaheadLiteral("true", 1) { - _t532 = 0 + _t798 = 0 } else { - var _t533 int64 + var _t799 int64 if p.matchLookaheadLiteral("relatom", 1) { - _t533 = 11 + _t799 = 11 } else { - var _t534 int64 + var _t800 int64 if p.matchLookaheadLiteral("reduce", 1) { - _t534 = 3 + _t800 = 3 } else { - var _t535 int64 + var _t801 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t535 = 10 + _t801 = 10 } else { - var _t536 int64 + var _t802 int64 if p.matchLookaheadLiteral("pragma", 1) { - _t536 = 9 + _t802 = 9 } else { - var _t537 int64 + var _t803 int64 if p.matchLookaheadLiteral("or", 1) { - _t537 = 5 + _t803 = 5 } else { - var _t538 int64 + var _t804 int64 if p.matchLookaheadLiteral("not", 1) { - _t538 = 6 + _t804 = 6 } else { - var _t539 int64 + var _t805 int64 if p.matchLookaheadLiteral("ffi", 1) { - _t539 = 7 + _t805 = 7 } else { - var _t540 int64 + var _t806 int64 if p.matchLookaheadLiteral("false", 1) { - _t540 = 1 + _t806 = 1 } else { - var _t541 int64 + var _t807 int64 if p.matchLookaheadLiteral("exists", 1) { - _t541 = 2 + _t807 = 2 } else { - var _t542 int64 + var _t808 int64 if p.matchLookaheadLiteral("cast", 1) { - _t542 = 12 + _t808 = 12 } else { - var _t543 int64 + var _t809 int64 if p.matchLookaheadLiteral("atom", 1) { - _t543 = 8 + _t809 = 8 } else { - var _t544 int64 + var _t810 int64 if p.matchLookaheadLiteral("and", 1) { - _t544 = 4 + _t810 = 4 } else { - var _t545 int64 + var _t811 int64 if p.matchLookaheadLiteral(">=", 1) { - _t545 = 10 + _t811 = 10 } else { - var _t546 int64 + var _t812 int64 if p.matchLookaheadLiteral(">", 1) { - _t546 = 10 + _t812 = 10 } else { - var _t547 int64 + var _t813 int64 if p.matchLookaheadLiteral("=", 1) { - _t547 = 10 + _t813 = 10 } else { - var _t548 int64 + var _t814 int64 if p.matchLookaheadLiteral("<=", 1) { - _t548 = 10 + _t814 = 10 } else { - var _t549 int64 + var _t815 int64 if p.matchLookaheadLiteral("<", 1) { - _t549 = 10 + _t815 = 10 } else { - var _t550 int64 + var _t816 int64 if p.matchLookaheadLiteral("/", 1) { - _t550 = 10 + _t816 = 10 } else { - var _t551 int64 + var _t817 int64 if p.matchLookaheadLiteral("-", 1) { - _t551 = 10 + _t817 = 10 } else { - var _t552 int64 + var _t818 int64 if p.matchLookaheadLiteral("+", 1) { - _t552 = 10 + _t818 = 10 } else { - var _t553 int64 + var _t819 int64 if p.matchLookaheadLiteral("*", 1) { - _t553 = 10 + _t819 = 10 } else { - _t553 = -1 + _t819 = -1 } - _t552 = _t553 + _t818 = _t819 } - _t551 = _t552 + _t817 = _t818 } - _t550 = _t551 + _t816 = _t817 } - _t549 = _t550 + _t815 = _t816 } - _t548 = _t549 + _t814 = _t815 } - _t547 = _t548 + _t813 = _t814 } - _t546 = _t547 + _t812 = _t813 } - _t545 = _t546 + _t811 = _t812 } - _t544 = _t545 + _t810 = _t811 } - _t543 = _t544 + _t809 = _t810 } - _t542 = _t543 + _t808 = _t809 } - _t541 = _t542 + _t807 = _t808 } - _t540 = _t541 + _t806 = _t807 } - _t539 = _t540 + _t805 = _t806 } - _t538 = _t539 + _t804 = _t805 } - _t537 = _t538 + _t803 = _t804 } - _t536 = _t537 + _t802 = _t803 } - _t535 = _t536 + _t801 = _t802 } - _t534 = _t535 + _t800 = _t801 } - _t533 = _t534 + _t799 = _t800 } - _t532 = _t533 + _t798 = _t799 } - _t531 = _t532 + _t797 = _t798 } else { - _t531 = -1 - } - prediction94 := _t531 - var _t554 *pb.Formula - if prediction94 == 12 { - _t555 := p.parse_cast() - cast107 := _t555 - _t556 := &pb.Formula{} - _t556.FormulaType = &pb.Formula_Cast{Cast: cast107} - _t554 = _t556 + _t797 = -1 + } + prediction171 := _t797 + var _t820 *pb.Formula + if prediction171 == 12 { + _t821 := p.parse_cast() + cast184 := _t821 + _t822 := &pb.Formula{} + _t822.FormulaType = &pb.Formula_Cast{Cast: cast184} + _t820 = _t822 } else { - var _t557 *pb.Formula - if prediction94 == 11 { - _t558 := p.parse_rel_atom() - rel_atom106 := _t558 - _t559 := &pb.Formula{} - _t559.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom106} - _t557 = _t559 + var _t823 *pb.Formula + if prediction171 == 11 { + _t824 := p.parse_rel_atom() + rel_atom183 := _t824 + _t825 := &pb.Formula{} + _t825.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom183} + _t823 = _t825 } else { - var _t560 *pb.Formula - if prediction94 == 10 { - _t561 := p.parse_primitive() - primitive105 := _t561 - _t562 := &pb.Formula{} - _t562.FormulaType = &pb.Formula_Primitive{Primitive: primitive105} - _t560 = _t562 + var _t826 *pb.Formula + if prediction171 == 10 { + _t827 := p.parse_primitive() + primitive182 := _t827 + _t828 := &pb.Formula{} + _t828.FormulaType = &pb.Formula_Primitive{Primitive: primitive182} + _t826 = _t828 } else { - var _t563 *pb.Formula - if prediction94 == 9 { - _t564 := p.parse_pragma() - pragma104 := _t564 - _t565 := &pb.Formula{} - _t565.FormulaType = &pb.Formula_Pragma{Pragma: pragma104} - _t563 = _t565 + var _t829 *pb.Formula + if prediction171 == 9 { + _t830 := p.parse_pragma() + pragma181 := _t830 + _t831 := &pb.Formula{} + _t831.FormulaType = &pb.Formula_Pragma{Pragma: pragma181} + _t829 = _t831 } else { - var _t566 *pb.Formula - if prediction94 == 8 { - _t567 := p.parse_atom() - atom103 := _t567 - _t568 := &pb.Formula{} - _t568.FormulaType = &pb.Formula_Atom{Atom: atom103} - _t566 = _t568 + var _t832 *pb.Formula + if prediction171 == 8 { + _t833 := p.parse_atom() + atom180 := _t833 + _t834 := &pb.Formula{} + _t834.FormulaType = &pb.Formula_Atom{Atom: atom180} + _t832 = _t834 } else { - var _t569 *pb.Formula - if prediction94 == 7 { - _t570 := p.parse_ffi() - ffi102 := _t570 - _t571 := &pb.Formula{} - _t571.FormulaType = &pb.Formula_Ffi{Ffi: ffi102} - _t569 = _t571 + var _t835 *pb.Formula + if prediction171 == 7 { + _t836 := p.parse_ffi() + ffi179 := _t836 + _t837 := &pb.Formula{} + _t837.FormulaType = &pb.Formula_Ffi{Ffi: ffi179} + _t835 = _t837 } else { - var _t572 *pb.Formula - if prediction94 == 6 { - _t573 := p.parse_not() - not101 := _t573 - _t574 := &pb.Formula{} - _t574.FormulaType = &pb.Formula_Not{Not: not101} - _t572 = _t574 + var _t838 *pb.Formula + if prediction171 == 6 { + _t839 := p.parse_not() + not178 := _t839 + _t840 := &pb.Formula{} + _t840.FormulaType = &pb.Formula_Not{Not: not178} + _t838 = _t840 } else { - var _t575 *pb.Formula - if prediction94 == 5 { - _t576 := p.parse_disjunction() - disjunction100 := _t576 - _t577 := &pb.Formula{} - _t577.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction100} - _t575 = _t577 + var _t841 *pb.Formula + if prediction171 == 5 { + _t842 := p.parse_disjunction() + disjunction177 := _t842 + _t843 := &pb.Formula{} + _t843.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction177} + _t841 = _t843 } else { - var _t578 *pb.Formula - if prediction94 == 4 { - _t579 := p.parse_conjunction() - conjunction99 := _t579 - _t580 := &pb.Formula{} - _t580.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction99} - _t578 = _t580 + var _t844 *pb.Formula + if prediction171 == 4 { + _t845 := p.parse_conjunction() + conjunction176 := _t845 + _t846 := &pb.Formula{} + _t846.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction176} + _t844 = _t846 } else { - var _t581 *pb.Formula - if prediction94 == 3 { - _t582 := p.parse_reduce() - reduce98 := _t582 - _t583 := &pb.Formula{} - _t583.FormulaType = &pb.Formula_Reduce{Reduce: reduce98} - _t581 = _t583 + var _t847 *pb.Formula + if prediction171 == 3 { + _t848 := p.parse_reduce() + reduce175 := _t848 + _t849 := &pb.Formula{} + _t849.FormulaType = &pb.Formula_Reduce{Reduce: reduce175} + _t847 = _t849 } else { - var _t584 *pb.Formula - if prediction94 == 2 { - _t585 := p.parse_exists() - exists97 := _t585 - _t586 := &pb.Formula{} - _t586.FormulaType = &pb.Formula_Exists{Exists: exists97} - _t584 = _t586 + var _t850 *pb.Formula + if prediction171 == 2 { + _t851 := p.parse_exists() + exists174 := _t851 + _t852 := &pb.Formula{} + _t852.FormulaType = &pb.Formula_Exists{Exists: exists174} + _t850 = _t852 } else { - var _t587 *pb.Formula - if prediction94 == 1 { - _t588 := p.parse_false() - false96 := _t588 - _t589 := &pb.Formula{} - _t589.FormulaType = &pb.Formula_Disjunction{Disjunction: false96} - _t587 = _t589 + var _t853 *pb.Formula + if prediction171 == 1 { + _t854 := p.parse_false() + false173 := _t854 + _t855 := &pb.Formula{} + _t855.FormulaType = &pb.Formula_Disjunction{Disjunction: false173} + _t853 = _t855 } else { - var _t590 *pb.Formula - if prediction94 == 0 { - _t591 := p.parse_true() - true95 := _t591 - _t592 := &pb.Formula{} - _t592.FormulaType = &pb.Formula_Conjunction{Conjunction: true95} - _t590 = _t592 + var _t856 *pb.Formula + if prediction171 == 0 { + _t857 := p.parse_true() + true172 := _t857 + _t858 := &pb.Formula{} + _t858.FormulaType = &pb.Formula_Conjunction{Conjunction: true172} + _t856 = _t858 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in formula", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t587 = _t590 + _t853 = _t856 } - _t584 = _t587 + _t850 = _t853 } - _t581 = _t584 + _t847 = _t850 } - _t578 = _t581 + _t844 = _t847 } - _t575 = _t578 + _t841 = _t844 } - _t572 = _t575 + _t838 = _t841 } - _t569 = _t572 + _t835 = _t838 } - _t566 = _t569 + _t832 = _t835 } - _t563 = _t566 + _t829 = _t832 } - _t560 = _t563 + _t826 = _t829 } - _t557 = _t560 + _t823 = _t826 } - _t554 = _t557 + _t820 = _t823 } - return _t554 + result186 := _t820 + p.recordSpan(span_start185) + return result186 } func (p *Parser) parse_true() *pb.Conjunction { + span_start187 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("true") p.consumeLiteral(")") - _t593 := &pb.Conjunction{Args: []*pb.Formula{}} - return _t593 + _t859 := &pb.Conjunction{Args: []*pb.Formula{}} + result188 := _t859 + p.recordSpan(span_start187) + return result188 } func (p *Parser) parse_false() *pb.Disjunction { + span_start189 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("false") p.consumeLiteral(")") - _t594 := &pb.Disjunction{Args: []*pb.Formula{}} - return _t594 + _t860 := &pb.Disjunction{Args: []*pb.Formula{}} + result190 := _t860 + p.recordSpan(span_start189) + return result190 } func (p *Parser) parse_exists() *pb.Exists { + span_start193 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("exists") - _t595 := p.parse_bindings() - bindings108 := _t595 - _t596 := p.parse_formula() - formula109 := _t596 + _t861 := p.parse_bindings() + bindings191 := _t861 + _t862 := p.parse_formula() + formula192 := _t862 p.consumeLiteral(")") - _t597 := &pb.Abstraction{Vars: listConcat(bindings108[0].([]*pb.Binding), bindings108[1].([]*pb.Binding)), Value: formula109} - _t598 := &pb.Exists{Body: _t597} - return _t598 + _t863 := &pb.Abstraction{Vars: listConcat(bindings191[0].([]*pb.Binding), bindings191[1].([]*pb.Binding)), Value: formula192} + _t864 := &pb.Exists{Body: _t863} + result194 := _t864 + p.recordSpan(span_start193) + return result194 } func (p *Parser) parse_reduce() *pb.Reduce { + span_start198 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("reduce") - _t599 := p.parse_abstraction() - abstraction110 := _t599 - _t600 := p.parse_abstraction() - abstraction_3111 := _t600 - _t601 := p.parse_terms() - terms112 := _t601 + p.pushPath(1) + _t865 := p.parse_abstraction() + abstraction195 := _t865 + p.popPath() + p.pushPath(2) + _t866 := p.parse_abstraction() + abstraction_3196 := _t866 + p.popPath() + p.pushPath(3) + _t867 := p.parse_terms() + terms197 := _t867 + p.popPath() p.consumeLiteral(")") - _t602 := &pb.Reduce{Op: abstraction110, Body: abstraction_3111, Terms: terms112} - return _t602 + _t868 := &pb.Reduce{Op: abstraction195, Body: abstraction_3196, Terms: terms197} + result199 := _t868 + p.recordSpan(span_start198) + return result199 } func (p *Parser) parse_terms() []*pb.Term { + span_start205 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("terms") - xs113 := []*pb.Term{} - cond114 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond114 { - _t603 := p.parse_term() - item115 := _t603 - xs113 = append(xs113, item115) - cond114 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms116 := xs113 + xs200 := []*pb.Term{} + cond201 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx203 := 0 + for cond201 { + p.pushPath(idx203) + _t869 := p.parse_term() + item202 := _t869 + p.popPath() + xs200 = append(xs200, item202) + idx203 = (idx203 + 1) + cond201 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + terms204 := xs200 p.consumeLiteral(")") - return terms116 + result206 := terms204 + p.recordSpan(span_start205) + return result206 } func (p *Parser) parse_term() *pb.Term { - var _t604 int64 + span_start210 := p.spanStart() + var _t870 int64 if p.matchLookaheadLiteral("true", 0) { - _t604 = 1 + _t870 = 1 } else { - var _t605 int64 + var _t871 int64 if p.matchLookaheadLiteral("missing", 0) { - _t605 = 1 + _t871 = 1 } else { - var _t606 int64 + var _t872 int64 if p.matchLookaheadLiteral("false", 0) { - _t606 = 1 + _t872 = 1 } else { - var _t607 int64 + var _t873 int64 if p.matchLookaheadLiteral("(", 0) { - _t607 = 1 + _t873 = 1 } else { - var _t608 int64 + var _t874 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t608 = 1 + _t874 = 1 } else { - var _t609 int64 + var _t875 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t609 = 0 + _t875 = 0 } else { - var _t610 int64 + var _t876 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t610 = 1 + _t876 = 1 } else { - var _t611 int64 + var _t877 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t611 = 1 + _t877 = 1 } else { - var _t612 int64 + var _t878 int64 if p.matchLookaheadTerminal("INT", 0) { - _t612 = 1 + _t878 = 1 } else { - var _t613 int64 + var _t879 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t613 = 1 + _t879 = 1 } else { - var _t614 int64 + var _t880 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t614 = 1 + _t880 = 1 } else { - _t614 = -1 + _t880 = -1 } - _t613 = _t614 + _t879 = _t880 } - _t612 = _t613 + _t878 = _t879 } - _t611 = _t612 + _t877 = _t878 } - _t610 = _t611 + _t876 = _t877 } - _t609 = _t610 + _t875 = _t876 } - _t608 = _t609 + _t874 = _t875 } - _t607 = _t608 + _t873 = _t874 } - _t606 = _t607 + _t872 = _t873 } - _t605 = _t606 + _t871 = _t872 } - _t604 = _t605 - } - prediction117 := _t604 - var _t615 *pb.Term - if prediction117 == 1 { - _t616 := p.parse_constant() - constant119 := _t616 - _t617 := &pb.Term{} - _t617.TermType = &pb.Term_Constant{Constant: constant119} - _t615 = _t617 + _t870 = _t871 + } + prediction207 := _t870 + var _t881 *pb.Term + if prediction207 == 1 { + _t882 := p.parse_constant() + constant209 := _t882 + _t883 := &pb.Term{} + _t883.TermType = &pb.Term_Constant{Constant: constant209} + _t881 = _t883 } else { - var _t618 *pb.Term - if prediction117 == 0 { - _t619 := p.parse_var() - var118 := _t619 - _t620 := &pb.Term{} - _t620.TermType = &pb.Term_Var{Var: var118} - _t618 = _t620 + var _t884 *pb.Term + if prediction207 == 0 { + _t885 := p.parse_var() + var208 := _t885 + _t886 := &pb.Term{} + _t886.TermType = &pb.Term_Var{Var: var208} + _t884 = _t886 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t615 = _t618 + _t881 = _t884 } - return _t615 + result211 := _t881 + p.recordSpan(span_start210) + return result211 } func (p *Parser) parse_var() *pb.Var { - symbol120 := p.consumeTerminal("SYMBOL").Value.AsString() - _t621 := &pb.Var{Name: symbol120} - return _t621 + span_start213 := p.spanStart() + symbol212 := p.consumeTerminal("SYMBOL").Value.AsString() + _t887 := &pb.Var{Name: symbol212} + result214 := _t887 + p.recordSpan(span_start213) + return result214 } func (p *Parser) parse_constant() *pb.Value { - _t622 := p.parse_value() - value121 := _t622 - return value121 + span_start216 := p.spanStart() + _t888 := p.parse_value() + value215 := _t888 + result217 := value215 + p.recordSpan(span_start216) + return result217 } func (p *Parser) parse_conjunction() *pb.Conjunction { + span_start223 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("and") - xs122 := []*pb.Formula{} - cond123 := p.matchLookaheadLiteral("(", 0) - for cond123 { - _t623 := p.parse_formula() - item124 := _t623 - xs122 = append(xs122, item124) - cond123 = p.matchLookaheadLiteral("(", 0) - } - formulas125 := xs122 + p.pushPath(1) + xs218 := []*pb.Formula{} + cond219 := p.matchLookaheadLiteral("(", 0) + idx221 := 0 + for cond219 { + p.pushPath(idx221) + _t889 := p.parse_formula() + item220 := _t889 + p.popPath() + xs218 = append(xs218, item220) + idx221 = (idx221 + 1) + cond219 = p.matchLookaheadLiteral("(", 0) + } + p.popPath() + formulas222 := xs218 p.consumeLiteral(")") - _t624 := &pb.Conjunction{Args: formulas125} - return _t624 + _t890 := &pb.Conjunction{Args: formulas222} + result224 := _t890 + p.recordSpan(span_start223) + return result224 } func (p *Parser) parse_disjunction() *pb.Disjunction { + span_start230 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("or") - xs126 := []*pb.Formula{} - cond127 := p.matchLookaheadLiteral("(", 0) - for cond127 { - _t625 := p.parse_formula() - item128 := _t625 - xs126 = append(xs126, item128) - cond127 = p.matchLookaheadLiteral("(", 0) - } - formulas129 := xs126 + p.pushPath(1) + xs225 := []*pb.Formula{} + cond226 := p.matchLookaheadLiteral("(", 0) + idx228 := 0 + for cond226 { + p.pushPath(idx228) + _t891 := p.parse_formula() + item227 := _t891 + p.popPath() + xs225 = append(xs225, item227) + idx228 = (idx228 + 1) + cond226 = p.matchLookaheadLiteral("(", 0) + } + p.popPath() + formulas229 := xs225 p.consumeLiteral(")") - _t626 := &pb.Disjunction{Args: formulas129} - return _t626 + _t892 := &pb.Disjunction{Args: formulas229} + result231 := _t892 + p.recordSpan(span_start230) + return result231 } func (p *Parser) parse_not() *pb.Not { + span_start233 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("not") - _t627 := p.parse_formula() - formula130 := _t627 + p.pushPath(1) + _t893 := p.parse_formula() + formula232 := _t893 + p.popPath() p.consumeLiteral(")") - _t628 := &pb.Not{Arg: formula130} - return _t628 + _t894 := &pb.Not{Arg: formula232} + result234 := _t894 + p.recordSpan(span_start233) + return result234 } func (p *Parser) parse_ffi() *pb.FFI { + span_start238 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("ffi") - _t629 := p.parse_name() - name131 := _t629 - _t630 := p.parse_ffi_args() - ffi_args132 := _t630 - _t631 := p.parse_terms() - terms133 := _t631 + p.pushPath(1) + _t895 := p.parse_name() + name235 := _t895 + p.popPath() + p.pushPath(2) + _t896 := p.parse_ffi_args() + ffi_args236 := _t896 + p.popPath() + p.pushPath(3) + _t897 := p.parse_terms() + terms237 := _t897 + p.popPath() p.consumeLiteral(")") - _t632 := &pb.FFI{Name: name131, Args: ffi_args132, Terms: terms133} - return _t632 + _t898 := &pb.FFI{Name: name235, Args: ffi_args236, Terms: terms237} + result239 := _t898 + p.recordSpan(span_start238) + return result239 } func (p *Parser) parse_name() string { + span_start241 := p.spanStart() p.consumeLiteral(":") - symbol134 := p.consumeTerminal("SYMBOL").Value.AsString() - return symbol134 + symbol240 := p.consumeTerminal("SYMBOL").Value.AsString() + result242 := symbol240 + p.recordSpan(span_start241) + return result242 } func (p *Parser) parse_ffi_args() []*pb.Abstraction { + span_start248 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("args") - xs135 := []*pb.Abstraction{} - cond136 := p.matchLookaheadLiteral("(", 0) - for cond136 { - _t633 := p.parse_abstraction() - item137 := _t633 - xs135 = append(xs135, item137) - cond136 = p.matchLookaheadLiteral("(", 0) - } - abstractions138 := xs135 + xs243 := []*pb.Abstraction{} + cond244 := p.matchLookaheadLiteral("(", 0) + idx246 := 0 + for cond244 { + p.pushPath(idx246) + _t899 := p.parse_abstraction() + item245 := _t899 + p.popPath() + xs243 = append(xs243, item245) + idx246 = (idx246 + 1) + cond244 = p.matchLookaheadLiteral("(", 0) + } + abstractions247 := xs243 p.consumeLiteral(")") - return abstractions138 + result249 := abstractions247 + p.recordSpan(span_start248) + return result249 } func (p *Parser) parse_atom() *pb.Atom { + span_start256 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("atom") - _t634 := p.parse_relation_id() - relation_id139 := _t634 - xs140 := []*pb.Term{} - cond141 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond141 { - _t635 := p.parse_term() - item142 := _t635 - xs140 = append(xs140, item142) - cond141 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms143 := xs140 + p.pushPath(1) + _t900 := p.parse_relation_id() + relation_id250 := _t900 + p.popPath() + p.pushPath(2) + xs251 := []*pb.Term{} + cond252 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx254 := 0 + for cond252 { + p.pushPath(idx254) + _t901 := p.parse_term() + item253 := _t901 + p.popPath() + xs251 = append(xs251, item253) + idx254 = (idx254 + 1) + cond252 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + terms255 := xs251 p.consumeLiteral(")") - _t636 := &pb.Atom{Name: relation_id139, Terms: terms143} - return _t636 + _t902 := &pb.Atom{Name: relation_id250, Terms: terms255} + result257 := _t902 + p.recordSpan(span_start256) + return result257 } func (p *Parser) parse_pragma() *pb.Pragma { + span_start264 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("pragma") - _t637 := p.parse_name() - name144 := _t637 - xs145 := []*pb.Term{} - cond146 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond146 { - _t638 := p.parse_term() - item147 := _t638 - xs145 = append(xs145, item147) - cond146 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms148 := xs145 + p.pushPath(1) + _t903 := p.parse_name() + name258 := _t903 + p.popPath() + p.pushPath(2) + xs259 := []*pb.Term{} + cond260 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx262 := 0 + for cond260 { + p.pushPath(idx262) + _t904 := p.parse_term() + item261 := _t904 + p.popPath() + xs259 = append(xs259, item261) + idx262 = (idx262 + 1) + cond260 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + terms263 := xs259 p.consumeLiteral(")") - _t639 := &pb.Pragma{Name: name144, Terms: terms148} - return _t639 + _t905 := &pb.Pragma{Name: name258, Terms: terms263} + result265 := _t905 + p.recordSpan(span_start264) + return result265 } func (p *Parser) parse_primitive() *pb.Primitive { - var _t640 int64 + span_start282 := p.spanStart() + var _t906 int64 if p.matchLookaheadLiteral("(", 0) { - var _t641 int64 + var _t907 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t641 = 9 + _t907 = 9 } else { - var _t642 int64 + var _t908 int64 if p.matchLookaheadLiteral(">=", 1) { - _t642 = 4 + _t908 = 4 } else { - var _t643 int64 + var _t909 int64 if p.matchLookaheadLiteral(">", 1) { - _t643 = 3 + _t909 = 3 } else { - var _t644 int64 + var _t910 int64 if p.matchLookaheadLiteral("=", 1) { - _t644 = 0 + _t910 = 0 } else { - var _t645 int64 + var _t911 int64 if p.matchLookaheadLiteral("<=", 1) { - _t645 = 2 + _t911 = 2 } else { - var _t646 int64 + var _t912 int64 if p.matchLookaheadLiteral("<", 1) { - _t646 = 1 + _t912 = 1 } else { - var _t647 int64 + var _t913 int64 if p.matchLookaheadLiteral("/", 1) { - _t647 = 8 + _t913 = 8 } else { - var _t648 int64 + var _t914 int64 if p.matchLookaheadLiteral("-", 1) { - _t648 = 6 + _t914 = 6 } else { - var _t649 int64 + var _t915 int64 if p.matchLookaheadLiteral("+", 1) { - _t649 = 5 + _t915 = 5 } else { - var _t650 int64 + var _t916 int64 if p.matchLookaheadLiteral("*", 1) { - _t650 = 7 + _t916 = 7 } else { - _t650 = -1 + _t916 = -1 } - _t649 = _t650 + _t915 = _t916 } - _t648 = _t649 + _t914 = _t915 } - _t647 = _t648 + _t913 = _t914 } - _t646 = _t647 + _t912 = _t913 } - _t645 = _t646 + _t911 = _t912 } - _t644 = _t645 + _t910 = _t911 } - _t643 = _t644 + _t909 = _t910 } - _t642 = _t643 + _t908 = _t909 } - _t641 = _t642 + _t907 = _t908 } - _t640 = _t641 + _t906 = _t907 } else { - _t640 = -1 + _t906 = -1 } - prediction149 := _t640 - var _t651 *pb.Primitive - if prediction149 == 9 { + prediction266 := _t906 + var _t917 *pb.Primitive + if prediction266 == 9 { p.consumeLiteral("(") p.consumeLiteral("primitive") - _t652 := p.parse_name() - name159 := _t652 - xs160 := []*pb.RelTerm{} - cond161 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond161 { - _t653 := p.parse_rel_term() - item162 := _t653 - xs160 = append(xs160, item162) - cond161 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + p.pushPath(1) + _t918 := p.parse_name() + name276 := _t918 + p.popPath() + p.pushPath(2) + xs277 := []*pb.RelTerm{} + cond278 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx280 := 0 + for cond278 { + p.pushPath(idx280) + _t919 := p.parse_rel_term() + item279 := _t919 + p.popPath() + xs277 = append(xs277, item279) + idx280 = (idx280 + 1) + cond278 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - rel_terms163 := xs160 + p.popPath() + rel_terms281 := xs277 p.consumeLiteral(")") - _t654 := &pb.Primitive{Name: name159, Terms: rel_terms163} - _t651 = _t654 + _t920 := &pb.Primitive{Name: name276, Terms: rel_terms281} + _t917 = _t920 } else { - var _t655 *pb.Primitive - if prediction149 == 8 { - _t656 := p.parse_divide() - divide158 := _t656 - _t655 = divide158 + var _t921 *pb.Primitive + if prediction266 == 8 { + _t922 := p.parse_divide() + divide275 := _t922 + _t921 = divide275 } else { - var _t657 *pb.Primitive - if prediction149 == 7 { - _t658 := p.parse_multiply() - multiply157 := _t658 - _t657 = multiply157 + var _t923 *pb.Primitive + if prediction266 == 7 { + _t924 := p.parse_multiply() + multiply274 := _t924 + _t923 = multiply274 } else { - var _t659 *pb.Primitive - if prediction149 == 6 { - _t660 := p.parse_minus() - minus156 := _t660 - _t659 = minus156 + var _t925 *pb.Primitive + if prediction266 == 6 { + _t926 := p.parse_minus() + minus273 := _t926 + _t925 = minus273 } else { - var _t661 *pb.Primitive - if prediction149 == 5 { - _t662 := p.parse_add() - add155 := _t662 - _t661 = add155 + var _t927 *pb.Primitive + if prediction266 == 5 { + _t928 := p.parse_add() + add272 := _t928 + _t927 = add272 } else { - var _t663 *pb.Primitive - if prediction149 == 4 { - _t664 := p.parse_gt_eq() - gt_eq154 := _t664 - _t663 = gt_eq154 + var _t929 *pb.Primitive + if prediction266 == 4 { + _t930 := p.parse_gt_eq() + gt_eq271 := _t930 + _t929 = gt_eq271 } else { - var _t665 *pb.Primitive - if prediction149 == 3 { - _t666 := p.parse_gt() - gt153 := _t666 - _t665 = gt153 + var _t931 *pb.Primitive + if prediction266 == 3 { + _t932 := p.parse_gt() + gt270 := _t932 + _t931 = gt270 } else { - var _t667 *pb.Primitive - if prediction149 == 2 { - _t668 := p.parse_lt_eq() - lt_eq152 := _t668 - _t667 = lt_eq152 + var _t933 *pb.Primitive + if prediction266 == 2 { + _t934 := p.parse_lt_eq() + lt_eq269 := _t934 + _t933 = lt_eq269 } else { - var _t669 *pb.Primitive - if prediction149 == 1 { - _t670 := p.parse_lt() - lt151 := _t670 - _t669 = lt151 + var _t935 *pb.Primitive + if prediction266 == 1 { + _t936 := p.parse_lt() + lt268 := _t936 + _t935 = lt268 } else { - var _t671 *pb.Primitive - if prediction149 == 0 { - _t672 := p.parse_eq() - eq150 := _t672 - _t671 = eq150 + var _t937 *pb.Primitive + if prediction266 == 0 { + _t938 := p.parse_eq() + eq267 := _t938 + _t937 = eq267 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in primitive", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t669 = _t671 + _t935 = _t937 } - _t667 = _t669 + _t933 = _t935 } - _t665 = _t667 + _t931 = _t933 } - _t663 = _t665 + _t929 = _t931 } - _t661 = _t663 + _t927 = _t929 } - _t659 = _t661 + _t925 = _t927 } - _t657 = _t659 + _t923 = _t925 } - _t655 = _t657 + _t921 = _t923 } - _t651 = _t655 + _t917 = _t921 } - return _t651 + result283 := _t917 + p.recordSpan(span_start282) + return result283 } func (p *Parser) parse_eq() *pb.Primitive { + span_start286 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("=") - _t673 := p.parse_term() - term164 := _t673 - _t674 := p.parse_term() - term_3165 := _t674 + _t939 := p.parse_term() + term284 := _t939 + _t940 := p.parse_term() + term_3285 := _t940 p.consumeLiteral(")") - _t675 := &pb.RelTerm{} - _t675.RelTermType = &pb.RelTerm_Term{Term: term164} - _t676 := &pb.RelTerm{} - _t676.RelTermType = &pb.RelTerm_Term{Term: term_3165} - _t677 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t675, _t676}} - return _t677 + _t941 := &pb.RelTerm{} + _t941.RelTermType = &pb.RelTerm_Term{Term: term284} + _t942 := &pb.RelTerm{} + _t942.RelTermType = &pb.RelTerm_Term{Term: term_3285} + _t943 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t941, _t942}} + result287 := _t943 + p.recordSpan(span_start286) + return result287 } func (p *Parser) parse_lt() *pb.Primitive { + span_start290 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("<") - _t678 := p.parse_term() - term166 := _t678 - _t679 := p.parse_term() - term_3167 := _t679 + _t944 := p.parse_term() + term288 := _t944 + _t945 := p.parse_term() + term_3289 := _t945 p.consumeLiteral(")") - _t680 := &pb.RelTerm{} - _t680.RelTermType = &pb.RelTerm_Term{Term: term166} - _t681 := &pb.RelTerm{} - _t681.RelTermType = &pb.RelTerm_Term{Term: term_3167} - _t682 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t680, _t681}} - return _t682 + _t946 := &pb.RelTerm{} + _t946.RelTermType = &pb.RelTerm_Term{Term: term288} + _t947 := &pb.RelTerm{} + _t947.RelTermType = &pb.RelTerm_Term{Term: term_3289} + _t948 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t946, _t947}} + result291 := _t948 + p.recordSpan(span_start290) + return result291 } func (p *Parser) parse_lt_eq() *pb.Primitive { + span_start294 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("<=") - _t683 := p.parse_term() - term168 := _t683 - _t684 := p.parse_term() - term_3169 := _t684 + _t949 := p.parse_term() + term292 := _t949 + _t950 := p.parse_term() + term_3293 := _t950 p.consumeLiteral(")") - _t685 := &pb.RelTerm{} - _t685.RelTermType = &pb.RelTerm_Term{Term: term168} - _t686 := &pb.RelTerm{} - _t686.RelTermType = &pb.RelTerm_Term{Term: term_3169} - _t687 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t685, _t686}} - return _t687 + _t951 := &pb.RelTerm{} + _t951.RelTermType = &pb.RelTerm_Term{Term: term292} + _t952 := &pb.RelTerm{} + _t952.RelTermType = &pb.RelTerm_Term{Term: term_3293} + _t953 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t951, _t952}} + result295 := _t953 + p.recordSpan(span_start294) + return result295 } func (p *Parser) parse_gt() *pb.Primitive { + span_start298 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral(">") - _t688 := p.parse_term() - term170 := _t688 - _t689 := p.parse_term() - term_3171 := _t689 + _t954 := p.parse_term() + term296 := _t954 + _t955 := p.parse_term() + term_3297 := _t955 p.consumeLiteral(")") - _t690 := &pb.RelTerm{} - _t690.RelTermType = &pb.RelTerm_Term{Term: term170} - _t691 := &pb.RelTerm{} - _t691.RelTermType = &pb.RelTerm_Term{Term: term_3171} - _t692 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t690, _t691}} - return _t692 + _t956 := &pb.RelTerm{} + _t956.RelTermType = &pb.RelTerm_Term{Term: term296} + _t957 := &pb.RelTerm{} + _t957.RelTermType = &pb.RelTerm_Term{Term: term_3297} + _t958 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t956, _t957}} + result299 := _t958 + p.recordSpan(span_start298) + return result299 } func (p *Parser) parse_gt_eq() *pb.Primitive { + span_start302 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral(">=") - _t693 := p.parse_term() - term172 := _t693 - _t694 := p.parse_term() - term_3173 := _t694 + _t959 := p.parse_term() + term300 := _t959 + _t960 := p.parse_term() + term_3301 := _t960 p.consumeLiteral(")") - _t695 := &pb.RelTerm{} - _t695.RelTermType = &pb.RelTerm_Term{Term: term172} - _t696 := &pb.RelTerm{} - _t696.RelTermType = &pb.RelTerm_Term{Term: term_3173} - _t697 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t695, _t696}} - return _t697 + _t961 := &pb.RelTerm{} + _t961.RelTermType = &pb.RelTerm_Term{Term: term300} + _t962 := &pb.RelTerm{} + _t962.RelTermType = &pb.RelTerm_Term{Term: term_3301} + _t963 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t961, _t962}} + result303 := _t963 + p.recordSpan(span_start302) + return result303 } func (p *Parser) parse_add() *pb.Primitive { + span_start307 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("+") - _t698 := p.parse_term() - term174 := _t698 - _t699 := p.parse_term() - term_3175 := _t699 - _t700 := p.parse_term() - term_4176 := _t700 + _t964 := p.parse_term() + term304 := _t964 + _t965 := p.parse_term() + term_3305 := _t965 + _t966 := p.parse_term() + term_4306 := _t966 p.consumeLiteral(")") - _t701 := &pb.RelTerm{} - _t701.RelTermType = &pb.RelTerm_Term{Term: term174} - _t702 := &pb.RelTerm{} - _t702.RelTermType = &pb.RelTerm_Term{Term: term_3175} - _t703 := &pb.RelTerm{} - _t703.RelTermType = &pb.RelTerm_Term{Term: term_4176} - _t704 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t701, _t702, _t703}} - return _t704 + _t967 := &pb.RelTerm{} + _t967.RelTermType = &pb.RelTerm_Term{Term: term304} + _t968 := &pb.RelTerm{} + _t968.RelTermType = &pb.RelTerm_Term{Term: term_3305} + _t969 := &pb.RelTerm{} + _t969.RelTermType = &pb.RelTerm_Term{Term: term_4306} + _t970 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t967, _t968, _t969}} + result308 := _t970 + p.recordSpan(span_start307) + return result308 } func (p *Parser) parse_minus() *pb.Primitive { + span_start312 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("-") - _t705 := p.parse_term() - term177 := _t705 - _t706 := p.parse_term() - term_3178 := _t706 - _t707 := p.parse_term() - term_4179 := _t707 + _t971 := p.parse_term() + term309 := _t971 + _t972 := p.parse_term() + term_3310 := _t972 + _t973 := p.parse_term() + term_4311 := _t973 p.consumeLiteral(")") - _t708 := &pb.RelTerm{} - _t708.RelTermType = &pb.RelTerm_Term{Term: term177} - _t709 := &pb.RelTerm{} - _t709.RelTermType = &pb.RelTerm_Term{Term: term_3178} - _t710 := &pb.RelTerm{} - _t710.RelTermType = &pb.RelTerm_Term{Term: term_4179} - _t711 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t708, _t709, _t710}} - return _t711 + _t974 := &pb.RelTerm{} + _t974.RelTermType = &pb.RelTerm_Term{Term: term309} + _t975 := &pb.RelTerm{} + _t975.RelTermType = &pb.RelTerm_Term{Term: term_3310} + _t976 := &pb.RelTerm{} + _t976.RelTermType = &pb.RelTerm_Term{Term: term_4311} + _t977 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t974, _t975, _t976}} + result313 := _t977 + p.recordSpan(span_start312) + return result313 } func (p *Parser) parse_multiply() *pb.Primitive { + span_start317 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("*") - _t712 := p.parse_term() - term180 := _t712 - _t713 := p.parse_term() - term_3181 := _t713 - _t714 := p.parse_term() - term_4182 := _t714 + _t978 := p.parse_term() + term314 := _t978 + _t979 := p.parse_term() + term_3315 := _t979 + _t980 := p.parse_term() + term_4316 := _t980 p.consumeLiteral(")") - _t715 := &pb.RelTerm{} - _t715.RelTermType = &pb.RelTerm_Term{Term: term180} - _t716 := &pb.RelTerm{} - _t716.RelTermType = &pb.RelTerm_Term{Term: term_3181} - _t717 := &pb.RelTerm{} - _t717.RelTermType = &pb.RelTerm_Term{Term: term_4182} - _t718 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t715, _t716, _t717}} - return _t718 + _t981 := &pb.RelTerm{} + _t981.RelTermType = &pb.RelTerm_Term{Term: term314} + _t982 := &pb.RelTerm{} + _t982.RelTermType = &pb.RelTerm_Term{Term: term_3315} + _t983 := &pb.RelTerm{} + _t983.RelTermType = &pb.RelTerm_Term{Term: term_4316} + _t984 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t981, _t982, _t983}} + result318 := _t984 + p.recordSpan(span_start317) + return result318 } func (p *Parser) parse_divide() *pb.Primitive { + span_start322 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("/") - _t719 := p.parse_term() - term183 := _t719 - _t720 := p.parse_term() - term_3184 := _t720 - _t721 := p.parse_term() - term_4185 := _t721 + _t985 := p.parse_term() + term319 := _t985 + _t986 := p.parse_term() + term_3320 := _t986 + _t987 := p.parse_term() + term_4321 := _t987 p.consumeLiteral(")") - _t722 := &pb.RelTerm{} - _t722.RelTermType = &pb.RelTerm_Term{Term: term183} - _t723 := &pb.RelTerm{} - _t723.RelTermType = &pb.RelTerm_Term{Term: term_3184} - _t724 := &pb.RelTerm{} - _t724.RelTermType = &pb.RelTerm_Term{Term: term_4185} - _t725 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t722, _t723, _t724}} - return _t725 + _t988 := &pb.RelTerm{} + _t988.RelTermType = &pb.RelTerm_Term{Term: term319} + _t989 := &pb.RelTerm{} + _t989.RelTermType = &pb.RelTerm_Term{Term: term_3320} + _t990 := &pb.RelTerm{} + _t990.RelTermType = &pb.RelTerm_Term{Term: term_4321} + _t991 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t988, _t989, _t990}} + result323 := _t991 + p.recordSpan(span_start322) + return result323 } func (p *Parser) parse_rel_term() *pb.RelTerm { - var _t726 int64 + span_start327 := p.spanStart() + var _t992 int64 if p.matchLookaheadLiteral("true", 0) { - _t726 = 1 + _t992 = 1 } else { - var _t727 int64 + var _t993 int64 if p.matchLookaheadLiteral("missing", 0) { - _t727 = 1 + _t993 = 1 } else { - var _t728 int64 + var _t994 int64 if p.matchLookaheadLiteral("false", 0) { - _t728 = 1 + _t994 = 1 } else { - var _t729 int64 + var _t995 int64 if p.matchLookaheadLiteral("(", 0) { - _t729 = 1 + _t995 = 1 } else { - var _t730 int64 + var _t996 int64 if p.matchLookaheadLiteral("#", 0) { - _t730 = 0 + _t996 = 0 } else { - var _t731 int64 + var _t997 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t731 = 1 + _t997 = 1 } else { - var _t732 int64 + var _t998 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t732 = 1 + _t998 = 1 } else { - var _t733 int64 + var _t999 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t733 = 1 + _t999 = 1 } else { - var _t734 int64 + var _t1000 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t734 = 1 + _t1000 = 1 } else { - var _t735 int64 + var _t1001 int64 if p.matchLookaheadTerminal("INT", 0) { - _t735 = 1 + _t1001 = 1 } else { - var _t736 int64 + var _t1002 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t736 = 1 + _t1002 = 1 } else { - var _t737 int64 + var _t1003 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t737 = 1 + _t1003 = 1 } else { - _t737 = -1 + _t1003 = -1 } - _t736 = _t737 + _t1002 = _t1003 } - _t735 = _t736 + _t1001 = _t1002 } - _t734 = _t735 + _t1000 = _t1001 } - _t733 = _t734 + _t999 = _t1000 } - _t732 = _t733 + _t998 = _t999 } - _t731 = _t732 + _t997 = _t998 } - _t730 = _t731 + _t996 = _t997 } - _t729 = _t730 + _t995 = _t996 } - _t728 = _t729 + _t994 = _t995 } - _t727 = _t728 + _t993 = _t994 } - _t726 = _t727 - } - prediction186 := _t726 - var _t738 *pb.RelTerm - if prediction186 == 1 { - _t739 := p.parse_term() - term188 := _t739 - _t740 := &pb.RelTerm{} - _t740.RelTermType = &pb.RelTerm_Term{Term: term188} - _t738 = _t740 + _t992 = _t993 + } + prediction324 := _t992 + var _t1004 *pb.RelTerm + if prediction324 == 1 { + _t1005 := p.parse_term() + term326 := _t1005 + _t1006 := &pb.RelTerm{} + _t1006.RelTermType = &pb.RelTerm_Term{Term: term326} + _t1004 = _t1006 } else { - var _t741 *pb.RelTerm - if prediction186 == 0 { - _t742 := p.parse_specialized_value() - specialized_value187 := _t742 - _t743 := &pb.RelTerm{} - _t743.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value187} - _t741 = _t743 + var _t1007 *pb.RelTerm + if prediction324 == 0 { + _t1008 := p.parse_specialized_value() + specialized_value325 := _t1008 + _t1009 := &pb.RelTerm{} + _t1009.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value325} + _t1007 = _t1009 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in rel_term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t738 = _t741 + _t1004 = _t1007 } - return _t738 + result328 := _t1004 + p.recordSpan(span_start327) + return result328 } func (p *Parser) parse_specialized_value() *pb.Value { + span_start330 := p.spanStart() p.consumeLiteral("#") - _t744 := p.parse_value() - value189 := _t744 - return value189 + _t1010 := p.parse_value() + value329 := _t1010 + result331 := value329 + p.recordSpan(span_start330) + return result331 } func (p *Parser) parse_rel_atom() *pb.RelAtom { + span_start338 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("relatom") - _t745 := p.parse_name() - name190 := _t745 - xs191 := []*pb.RelTerm{} - cond192 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond192 { - _t746 := p.parse_rel_term() - item193 := _t746 - xs191 = append(xs191, item193) - cond192 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - rel_terms194 := xs191 + p.pushPath(3) + _t1011 := p.parse_name() + name332 := _t1011 + p.popPath() + p.pushPath(2) + xs333 := []*pb.RelTerm{} + cond334 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx336 := 0 + for cond334 { + p.pushPath(idx336) + _t1012 := p.parse_rel_term() + item335 := _t1012 + p.popPath() + xs333 = append(xs333, item335) + idx336 = (idx336 + 1) + cond334 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + rel_terms337 := xs333 p.consumeLiteral(")") - _t747 := &pb.RelAtom{Name: name190, Terms: rel_terms194} - return _t747 + _t1013 := &pb.RelAtom{Name: name332, Terms: rel_terms337} + result339 := _t1013 + p.recordSpan(span_start338) + return result339 } func (p *Parser) parse_cast() *pb.Cast { + span_start342 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("cast") - _t748 := p.parse_term() - term195 := _t748 - _t749 := p.parse_term() - term_3196 := _t749 + p.pushPath(2) + _t1014 := p.parse_term() + term340 := _t1014 + p.popPath() + p.pushPath(3) + _t1015 := p.parse_term() + term_3341 := _t1015 + p.popPath() p.consumeLiteral(")") - _t750 := &pb.Cast{Input: term195, Result: term_3196} - return _t750 + _t1016 := &pb.Cast{Input: term340, Result: term_3341} + result343 := _t1016 + p.recordSpan(span_start342) + return result343 } func (p *Parser) parse_attrs() []*pb.Attribute { + span_start349 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("attrs") - xs197 := []*pb.Attribute{} - cond198 := p.matchLookaheadLiteral("(", 0) - for cond198 { - _t751 := p.parse_attribute() - item199 := _t751 - xs197 = append(xs197, item199) - cond198 = p.matchLookaheadLiteral("(", 0) - } - attributes200 := xs197 + xs344 := []*pb.Attribute{} + cond345 := p.matchLookaheadLiteral("(", 0) + idx347 := 0 + for cond345 { + p.pushPath(idx347) + _t1017 := p.parse_attribute() + item346 := _t1017 + p.popPath() + xs344 = append(xs344, item346) + idx347 = (idx347 + 1) + cond345 = p.matchLookaheadLiteral("(", 0) + } + attributes348 := xs344 p.consumeLiteral(")") - return attributes200 + result350 := attributes348 + p.recordSpan(span_start349) + return result350 } func (p *Parser) parse_attribute() *pb.Attribute { + span_start357 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("attribute") - _t752 := p.parse_name() - name201 := _t752 - xs202 := []*pb.Value{} - cond203 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond203 { - _t753 := p.parse_value() - item204 := _t753 - xs202 = append(xs202, item204) - cond203 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - values205 := xs202 + p.pushPath(1) + _t1018 := p.parse_name() + name351 := _t1018 + p.popPath() + p.pushPath(2) + xs352 := []*pb.Value{} + cond353 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx355 := 0 + for cond353 { + p.pushPath(idx355) + _t1019 := p.parse_value() + item354 := _t1019 + p.popPath() + xs352 = append(xs352, item354) + idx355 = (idx355 + 1) + cond353 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + values356 := xs352 p.consumeLiteral(")") - _t754 := &pb.Attribute{Name: name201, Args: values205} - return _t754 + _t1020 := &pb.Attribute{Name: name351, Args: values356} + result358 := _t1020 + p.recordSpan(span_start357) + return result358 } func (p *Parser) parse_algorithm() *pb.Algorithm { + span_start365 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("algorithm") - xs206 := []*pb.RelationId{} - cond207 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - for cond207 { - _t755 := p.parse_relation_id() - item208 := _t755 - xs206 = append(xs206, item208) - cond207 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - } - relation_ids209 := xs206 - _t756 := p.parse_script() - script210 := _t756 + p.pushPath(1) + xs359 := []*pb.RelationId{} + cond360 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx362 := 0 + for cond360 { + p.pushPath(idx362) + _t1021 := p.parse_relation_id() + item361 := _t1021 + p.popPath() + xs359 = append(xs359, item361) + idx362 = (idx362 + 1) + cond360 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + relation_ids363 := xs359 + p.pushPath(2) + _t1022 := p.parse_script() + script364 := _t1022 + p.popPath() p.consumeLiteral(")") - _t757 := &pb.Algorithm{Global: relation_ids209, Body: script210} - return _t757 + _t1023 := &pb.Algorithm{Global: relation_ids363, Body: script364} + result366 := _t1023 + p.recordSpan(span_start365) + return result366 } func (p *Parser) parse_script() *pb.Script { + span_start372 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("script") - xs211 := []*pb.Construct{} - cond212 := p.matchLookaheadLiteral("(", 0) - for cond212 { - _t758 := p.parse_construct() - item213 := _t758 - xs211 = append(xs211, item213) - cond212 = p.matchLookaheadLiteral("(", 0) - } - constructs214 := xs211 + p.pushPath(1) + xs367 := []*pb.Construct{} + cond368 := p.matchLookaheadLiteral("(", 0) + idx370 := 0 + for cond368 { + p.pushPath(idx370) + _t1024 := p.parse_construct() + item369 := _t1024 + p.popPath() + xs367 = append(xs367, item369) + idx370 = (idx370 + 1) + cond368 = p.matchLookaheadLiteral("(", 0) + } + p.popPath() + constructs371 := xs367 p.consumeLiteral(")") - _t759 := &pb.Script{Constructs: constructs214} - return _t759 + _t1025 := &pb.Script{Constructs: constructs371} + result373 := _t1025 + p.recordSpan(span_start372) + return result373 } func (p *Parser) parse_construct() *pb.Construct { - var _t760 int64 + span_start377 := p.spanStart() + var _t1026 int64 if p.matchLookaheadLiteral("(", 0) { - var _t761 int64 + var _t1027 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t761 = 1 + _t1027 = 1 } else { - var _t762 int64 + var _t1028 int64 if p.matchLookaheadLiteral("monus", 1) { - _t762 = 1 + _t1028 = 1 } else { - var _t763 int64 + var _t1029 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t763 = 1 + _t1029 = 1 } else { - var _t764 int64 + var _t1030 int64 if p.matchLookaheadLiteral("loop", 1) { - _t764 = 0 + _t1030 = 0 } else { - var _t765 int64 + var _t1031 int64 if p.matchLookaheadLiteral("break", 1) { - _t765 = 1 + _t1031 = 1 } else { - var _t766 int64 + var _t1032 int64 if p.matchLookaheadLiteral("assign", 1) { - _t766 = 1 + _t1032 = 1 } else { - _t766 = -1 + _t1032 = -1 } - _t765 = _t766 + _t1031 = _t1032 } - _t764 = _t765 + _t1030 = _t1031 } - _t763 = _t764 + _t1029 = _t1030 } - _t762 = _t763 + _t1028 = _t1029 } - _t761 = _t762 + _t1027 = _t1028 } - _t760 = _t761 + _t1026 = _t1027 } else { - _t760 = -1 - } - prediction215 := _t760 - var _t767 *pb.Construct - if prediction215 == 1 { - _t768 := p.parse_instruction() - instruction217 := _t768 - _t769 := &pb.Construct{} - _t769.ConstructType = &pb.Construct_Instruction{Instruction: instruction217} - _t767 = _t769 + _t1026 = -1 + } + prediction374 := _t1026 + var _t1033 *pb.Construct + if prediction374 == 1 { + _t1034 := p.parse_instruction() + instruction376 := _t1034 + _t1035 := &pb.Construct{} + _t1035.ConstructType = &pb.Construct_Instruction{Instruction: instruction376} + _t1033 = _t1035 } else { - var _t770 *pb.Construct - if prediction215 == 0 { - _t771 := p.parse_loop() - loop216 := _t771 - _t772 := &pb.Construct{} - _t772.ConstructType = &pb.Construct_Loop{Loop: loop216} - _t770 = _t772 + var _t1036 *pb.Construct + if prediction374 == 0 { + _t1037 := p.parse_loop() + loop375 := _t1037 + _t1038 := &pb.Construct{} + _t1038.ConstructType = &pb.Construct_Loop{Loop: loop375} + _t1036 = _t1038 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in construct", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t767 = _t770 + _t1033 = _t1036 } - return _t767 + result378 := _t1033 + p.recordSpan(span_start377) + return result378 } func (p *Parser) parse_loop() *pb.Loop { + span_start381 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("loop") - _t773 := p.parse_init() - init218 := _t773 - _t774 := p.parse_script() - script219 := _t774 + p.pushPath(1) + _t1039 := p.parse_init() + init379 := _t1039 + p.popPath() + p.pushPath(2) + _t1040 := p.parse_script() + script380 := _t1040 + p.popPath() p.consumeLiteral(")") - _t775 := &pb.Loop{Init: init218, Body: script219} - return _t775 + _t1041 := &pb.Loop{Init: init379, Body: script380} + result382 := _t1041 + p.recordSpan(span_start381) + return result382 } func (p *Parser) parse_init() []*pb.Instruction { + span_start388 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("init") - xs220 := []*pb.Instruction{} - cond221 := p.matchLookaheadLiteral("(", 0) - for cond221 { - _t776 := p.parse_instruction() - item222 := _t776 - xs220 = append(xs220, item222) - cond221 = p.matchLookaheadLiteral("(", 0) - } - instructions223 := xs220 + xs383 := []*pb.Instruction{} + cond384 := p.matchLookaheadLiteral("(", 0) + idx386 := 0 + for cond384 { + p.pushPath(idx386) + _t1042 := p.parse_instruction() + item385 := _t1042 + p.popPath() + xs383 = append(xs383, item385) + idx386 = (idx386 + 1) + cond384 = p.matchLookaheadLiteral("(", 0) + } + instructions387 := xs383 p.consumeLiteral(")") - return instructions223 + result389 := instructions387 + p.recordSpan(span_start388) + return result389 } func (p *Parser) parse_instruction() *pb.Instruction { - var _t777 int64 + span_start396 := p.spanStart() + var _t1043 int64 if p.matchLookaheadLiteral("(", 0) { - var _t778 int64 + var _t1044 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t778 = 1 + _t1044 = 1 } else { - var _t779 int64 + var _t1045 int64 if p.matchLookaheadLiteral("monus", 1) { - _t779 = 4 + _t1045 = 4 } else { - var _t780 int64 + var _t1046 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t780 = 3 + _t1046 = 3 } else { - var _t781 int64 + var _t1047 int64 if p.matchLookaheadLiteral("break", 1) { - _t781 = 2 + _t1047 = 2 } else { - var _t782 int64 + var _t1048 int64 if p.matchLookaheadLiteral("assign", 1) { - _t782 = 0 + _t1048 = 0 } else { - _t782 = -1 + _t1048 = -1 } - _t781 = _t782 + _t1047 = _t1048 } - _t780 = _t781 + _t1046 = _t1047 } - _t779 = _t780 + _t1045 = _t1046 } - _t778 = _t779 + _t1044 = _t1045 } - _t777 = _t778 + _t1043 = _t1044 } else { - _t777 = -1 - } - prediction224 := _t777 - var _t783 *pb.Instruction - if prediction224 == 4 { - _t784 := p.parse_monus_def() - monus_def229 := _t784 - _t785 := &pb.Instruction{} - _t785.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def229} - _t783 = _t785 + _t1043 = -1 + } + prediction390 := _t1043 + var _t1049 *pb.Instruction + if prediction390 == 4 { + _t1050 := p.parse_monus_def() + monus_def395 := _t1050 + _t1051 := &pb.Instruction{} + _t1051.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def395} + _t1049 = _t1051 } else { - var _t786 *pb.Instruction - if prediction224 == 3 { - _t787 := p.parse_monoid_def() - monoid_def228 := _t787 - _t788 := &pb.Instruction{} - _t788.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def228} - _t786 = _t788 + var _t1052 *pb.Instruction + if prediction390 == 3 { + _t1053 := p.parse_monoid_def() + monoid_def394 := _t1053 + _t1054 := &pb.Instruction{} + _t1054.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def394} + _t1052 = _t1054 } else { - var _t789 *pb.Instruction - if prediction224 == 2 { - _t790 := p.parse_break() - break227 := _t790 - _t791 := &pb.Instruction{} - _t791.InstrType = &pb.Instruction_Break{Break: break227} - _t789 = _t791 + var _t1055 *pb.Instruction + if prediction390 == 2 { + _t1056 := p.parse_break() + break393 := _t1056 + _t1057 := &pb.Instruction{} + _t1057.InstrType = &pb.Instruction_Break{Break: break393} + _t1055 = _t1057 } else { - var _t792 *pb.Instruction - if prediction224 == 1 { - _t793 := p.parse_upsert() - upsert226 := _t793 - _t794 := &pb.Instruction{} - _t794.InstrType = &pb.Instruction_Upsert{Upsert: upsert226} - _t792 = _t794 + var _t1058 *pb.Instruction + if prediction390 == 1 { + _t1059 := p.parse_upsert() + upsert392 := _t1059 + _t1060 := &pb.Instruction{} + _t1060.InstrType = &pb.Instruction_Upsert{Upsert: upsert392} + _t1058 = _t1060 } else { - var _t795 *pb.Instruction - if prediction224 == 0 { - _t796 := p.parse_assign() - assign225 := _t796 - _t797 := &pb.Instruction{} - _t797.InstrType = &pb.Instruction_Assign{Assign: assign225} - _t795 = _t797 + var _t1061 *pb.Instruction + if prediction390 == 0 { + _t1062 := p.parse_assign() + assign391 := _t1062 + _t1063 := &pb.Instruction{} + _t1063.InstrType = &pb.Instruction_Assign{Assign: assign391} + _t1061 = _t1063 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in instruction", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t792 = _t795 + _t1058 = _t1061 } - _t789 = _t792 + _t1055 = _t1058 } - _t786 = _t789 + _t1052 = _t1055 } - _t783 = _t786 + _t1049 = _t1052 } - return _t783 + result397 := _t1049 + p.recordSpan(span_start396) + return result397 } func (p *Parser) parse_assign() *pb.Assign { + span_start401 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("assign") - _t798 := p.parse_relation_id() - relation_id230 := _t798 - _t799 := p.parse_abstraction() - abstraction231 := _t799 - var _t800 []*pb.Attribute + p.pushPath(1) + _t1064 := p.parse_relation_id() + relation_id398 := _t1064 + p.popPath() + p.pushPath(2) + _t1065 := p.parse_abstraction() + abstraction399 := _t1065 + p.popPath() + p.pushPath(3) + var _t1066 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t801 := p.parse_attrs() - _t800 = _t801 + _t1067 := p.parse_attrs() + _t1066 = _t1067 } - attrs232 := _t800 + attrs400 := _t1066 + p.popPath() p.consumeLiteral(")") - _t802 := attrs232 - if attrs232 == nil { - _t802 = []*pb.Attribute{} + _t1068 := attrs400 + if attrs400 == nil { + _t1068 = []*pb.Attribute{} } - _t803 := &pb.Assign{Name: relation_id230, Body: abstraction231, Attrs: _t802} - return _t803 + _t1069 := &pb.Assign{Name: relation_id398, Body: abstraction399, Attrs: _t1068} + result402 := _t1069 + p.recordSpan(span_start401) + return result402 } func (p *Parser) parse_upsert() *pb.Upsert { + span_start406 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("upsert") - _t804 := p.parse_relation_id() - relation_id233 := _t804 - _t805 := p.parse_abstraction_with_arity() - abstraction_with_arity234 := _t805 - var _t806 []*pb.Attribute + p.pushPath(1) + _t1070 := p.parse_relation_id() + relation_id403 := _t1070 + p.popPath() + _t1071 := p.parse_abstraction_with_arity() + abstraction_with_arity404 := _t1071 + p.pushPath(3) + var _t1072 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t807 := p.parse_attrs() - _t806 = _t807 + _t1073 := p.parse_attrs() + _t1072 = _t1073 } - attrs235 := _t806 + attrs405 := _t1072 + p.popPath() p.consumeLiteral(")") - _t808 := attrs235 - if attrs235 == nil { - _t808 = []*pb.Attribute{} + _t1074 := attrs405 + if attrs405 == nil { + _t1074 = []*pb.Attribute{} } - _t809 := &pb.Upsert{Name: relation_id233, Body: abstraction_with_arity234[0].(*pb.Abstraction), Attrs: _t808, ValueArity: abstraction_with_arity234[1].(int64)} - return _t809 + _t1075 := &pb.Upsert{Name: relation_id403, Body: abstraction_with_arity404[0].(*pb.Abstraction), Attrs: _t1074, ValueArity: abstraction_with_arity404[1].(int64)} + result407 := _t1075 + p.recordSpan(span_start406) + return result407 } func (p *Parser) parse_abstraction_with_arity() []interface{} { + span_start410 := p.spanStart() p.consumeLiteral("(") - _t810 := p.parse_bindings() - bindings236 := _t810 - _t811 := p.parse_formula() - formula237 := _t811 + _t1076 := p.parse_bindings() + bindings408 := _t1076 + _t1077 := p.parse_formula() + formula409 := _t1077 p.consumeLiteral(")") - _t812 := &pb.Abstraction{Vars: listConcat(bindings236[0].([]*pb.Binding), bindings236[1].([]*pb.Binding)), Value: formula237} - return []interface{}{_t812, int64(len(bindings236[1].([]*pb.Binding)))} + _t1078 := &pb.Abstraction{Vars: listConcat(bindings408[0].([]*pb.Binding), bindings408[1].([]*pb.Binding)), Value: formula409} + result411 := []interface{}{_t1078, int64(len(bindings408[1].([]*pb.Binding)))} + p.recordSpan(span_start410) + return result411 } func (p *Parser) parse_break() *pb.Break { + span_start415 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("break") - _t813 := p.parse_relation_id() - relation_id238 := _t813 - _t814 := p.parse_abstraction() - abstraction239 := _t814 - var _t815 []*pb.Attribute + p.pushPath(1) + _t1079 := p.parse_relation_id() + relation_id412 := _t1079 + p.popPath() + p.pushPath(2) + _t1080 := p.parse_abstraction() + abstraction413 := _t1080 + p.popPath() + p.pushPath(3) + var _t1081 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t816 := p.parse_attrs() - _t815 = _t816 + _t1082 := p.parse_attrs() + _t1081 = _t1082 } - attrs240 := _t815 + attrs414 := _t1081 + p.popPath() p.consumeLiteral(")") - _t817 := attrs240 - if attrs240 == nil { - _t817 = []*pb.Attribute{} + _t1083 := attrs414 + if attrs414 == nil { + _t1083 = []*pb.Attribute{} } - _t818 := &pb.Break{Name: relation_id238, Body: abstraction239, Attrs: _t817} - return _t818 + _t1084 := &pb.Break{Name: relation_id412, Body: abstraction413, Attrs: _t1083} + result416 := _t1084 + p.recordSpan(span_start415) + return result416 } func (p *Parser) parse_monoid_def() *pb.MonoidDef { + span_start421 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("monoid") - _t819 := p.parse_monoid() - monoid241 := _t819 - _t820 := p.parse_relation_id() - relation_id242 := _t820 - _t821 := p.parse_abstraction_with_arity() - abstraction_with_arity243 := _t821 - var _t822 []*pb.Attribute + p.pushPath(1) + _t1085 := p.parse_monoid() + monoid417 := _t1085 + p.popPath() + p.pushPath(2) + _t1086 := p.parse_relation_id() + relation_id418 := _t1086 + p.popPath() + _t1087 := p.parse_abstraction_with_arity() + abstraction_with_arity419 := _t1087 + p.pushPath(4) + var _t1088 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t823 := p.parse_attrs() - _t822 = _t823 + _t1089 := p.parse_attrs() + _t1088 = _t1089 } - attrs244 := _t822 + attrs420 := _t1088 + p.popPath() p.consumeLiteral(")") - _t824 := attrs244 - if attrs244 == nil { - _t824 = []*pb.Attribute{} + _t1090 := attrs420 + if attrs420 == nil { + _t1090 = []*pb.Attribute{} } - _t825 := &pb.MonoidDef{Monoid: monoid241, Name: relation_id242, Body: abstraction_with_arity243[0].(*pb.Abstraction), Attrs: _t824, ValueArity: abstraction_with_arity243[1].(int64)} - return _t825 + _t1091 := &pb.MonoidDef{Monoid: monoid417, Name: relation_id418, Body: abstraction_with_arity419[0].(*pb.Abstraction), Attrs: _t1090, ValueArity: abstraction_with_arity419[1].(int64)} + result422 := _t1091 + p.recordSpan(span_start421) + return result422 } func (p *Parser) parse_monoid() *pb.Monoid { - var _t826 int64 + span_start428 := p.spanStart() + var _t1092 int64 if p.matchLookaheadLiteral("(", 0) { - var _t827 int64 + var _t1093 int64 if p.matchLookaheadLiteral("sum", 1) { - _t827 = 3 + _t1093 = 3 } else { - var _t828 int64 + var _t1094 int64 if p.matchLookaheadLiteral("or", 1) { - _t828 = 0 + _t1094 = 0 } else { - var _t829 int64 + var _t1095 int64 if p.matchLookaheadLiteral("min", 1) { - _t829 = 1 + _t1095 = 1 } else { - var _t830 int64 + var _t1096 int64 if p.matchLookaheadLiteral("max", 1) { - _t830 = 2 + _t1096 = 2 } else { - _t830 = -1 + _t1096 = -1 } - _t829 = _t830 + _t1095 = _t1096 } - _t828 = _t829 + _t1094 = _t1095 } - _t827 = _t828 + _t1093 = _t1094 } - _t826 = _t827 + _t1092 = _t1093 } else { - _t826 = -1 - } - prediction245 := _t826 - var _t831 *pb.Monoid - if prediction245 == 3 { - _t832 := p.parse_sum_monoid() - sum_monoid249 := _t832 - _t833 := &pb.Monoid{} - _t833.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid249} - _t831 = _t833 + _t1092 = -1 + } + prediction423 := _t1092 + var _t1097 *pb.Monoid + if prediction423 == 3 { + _t1098 := p.parse_sum_monoid() + sum_monoid427 := _t1098 + _t1099 := &pb.Monoid{} + _t1099.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid427} + _t1097 = _t1099 } else { - var _t834 *pb.Monoid - if prediction245 == 2 { - _t835 := p.parse_max_monoid() - max_monoid248 := _t835 - _t836 := &pb.Monoid{} - _t836.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid248} - _t834 = _t836 + var _t1100 *pb.Monoid + if prediction423 == 2 { + _t1101 := p.parse_max_monoid() + max_monoid426 := _t1101 + _t1102 := &pb.Monoid{} + _t1102.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid426} + _t1100 = _t1102 } else { - var _t837 *pb.Monoid - if prediction245 == 1 { - _t838 := p.parse_min_monoid() - min_monoid247 := _t838 - _t839 := &pb.Monoid{} - _t839.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid247} - _t837 = _t839 + var _t1103 *pb.Monoid + if prediction423 == 1 { + _t1104 := p.parse_min_monoid() + min_monoid425 := _t1104 + _t1105 := &pb.Monoid{} + _t1105.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid425} + _t1103 = _t1105 } else { - var _t840 *pb.Monoid - if prediction245 == 0 { - _t841 := p.parse_or_monoid() - or_monoid246 := _t841 - _t842 := &pb.Monoid{} - _t842.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid246} - _t840 = _t842 + var _t1106 *pb.Monoid + if prediction423 == 0 { + _t1107 := p.parse_or_monoid() + or_monoid424 := _t1107 + _t1108 := &pb.Monoid{} + _t1108.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid424} + _t1106 = _t1108 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in monoid", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t837 = _t840 + _t1103 = _t1106 } - _t834 = _t837 + _t1100 = _t1103 } - _t831 = _t834 + _t1097 = _t1100 } - return _t831 + result429 := _t1097 + p.recordSpan(span_start428) + return result429 } func (p *Parser) parse_or_monoid() *pb.OrMonoid { + span_start430 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("or") p.consumeLiteral(")") - _t843 := &pb.OrMonoid{} - return _t843 + _t1109 := &pb.OrMonoid{} + result431 := _t1109 + p.recordSpan(span_start430) + return result431 } func (p *Parser) parse_min_monoid() *pb.MinMonoid { + span_start433 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("min") - _t844 := p.parse_type() - type250 := _t844 + p.pushPath(1) + _t1110 := p.parse_type() + type432 := _t1110 + p.popPath() p.consumeLiteral(")") - _t845 := &pb.MinMonoid{Type: type250} - return _t845 + _t1111 := &pb.MinMonoid{Type: type432} + result434 := _t1111 + p.recordSpan(span_start433) + return result434 } func (p *Parser) parse_max_monoid() *pb.MaxMonoid { + span_start436 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("max") - _t846 := p.parse_type() - type251 := _t846 + p.pushPath(1) + _t1112 := p.parse_type() + type435 := _t1112 + p.popPath() p.consumeLiteral(")") - _t847 := &pb.MaxMonoid{Type: type251} - return _t847 + _t1113 := &pb.MaxMonoid{Type: type435} + result437 := _t1113 + p.recordSpan(span_start436) + return result437 } func (p *Parser) parse_sum_monoid() *pb.SumMonoid { + span_start439 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("sum") - _t848 := p.parse_type() - type252 := _t848 + p.pushPath(1) + _t1114 := p.parse_type() + type438 := _t1114 + p.popPath() p.consumeLiteral(")") - _t849 := &pb.SumMonoid{Type: type252} - return _t849 + _t1115 := &pb.SumMonoid{Type: type438} + result440 := _t1115 + p.recordSpan(span_start439) + return result440 } func (p *Parser) parse_monus_def() *pb.MonusDef { + span_start445 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("monus") - _t850 := p.parse_monoid() - monoid253 := _t850 - _t851 := p.parse_relation_id() - relation_id254 := _t851 - _t852 := p.parse_abstraction_with_arity() - abstraction_with_arity255 := _t852 - var _t853 []*pb.Attribute + p.pushPath(1) + _t1116 := p.parse_monoid() + monoid441 := _t1116 + p.popPath() + p.pushPath(2) + _t1117 := p.parse_relation_id() + relation_id442 := _t1117 + p.popPath() + _t1118 := p.parse_abstraction_with_arity() + abstraction_with_arity443 := _t1118 + p.pushPath(4) + var _t1119 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t854 := p.parse_attrs() - _t853 = _t854 + _t1120 := p.parse_attrs() + _t1119 = _t1120 } - attrs256 := _t853 + attrs444 := _t1119 + p.popPath() p.consumeLiteral(")") - _t855 := attrs256 - if attrs256 == nil { - _t855 = []*pb.Attribute{} + _t1121 := attrs444 + if attrs444 == nil { + _t1121 = []*pb.Attribute{} } - _t856 := &pb.MonusDef{Monoid: monoid253, Name: relation_id254, Body: abstraction_with_arity255[0].(*pb.Abstraction), Attrs: _t855, ValueArity: abstraction_with_arity255[1].(int64)} - return _t856 + _t1122 := &pb.MonusDef{Monoid: monoid441, Name: relation_id442, Body: abstraction_with_arity443[0].(*pb.Abstraction), Attrs: _t1121, ValueArity: abstraction_with_arity443[1].(int64)} + result446 := _t1122 + p.recordSpan(span_start445) + return result446 } func (p *Parser) parse_constraint() *pb.Constraint { + span_start451 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("functional_dependency") - _t857 := p.parse_relation_id() - relation_id257 := _t857 - _t858 := p.parse_abstraction() - abstraction258 := _t858 - _t859 := p.parse_functional_dependency_keys() - functional_dependency_keys259 := _t859 - _t860 := p.parse_functional_dependency_values() - functional_dependency_values260 := _t860 + p.pushPath(2) + _t1123 := p.parse_relation_id() + relation_id447 := _t1123 + p.popPath() + _t1124 := p.parse_abstraction() + abstraction448 := _t1124 + _t1125 := p.parse_functional_dependency_keys() + functional_dependency_keys449 := _t1125 + _t1126 := p.parse_functional_dependency_values() + functional_dependency_values450 := _t1126 p.consumeLiteral(")") - _t861 := &pb.FunctionalDependency{Guard: abstraction258, Keys: functional_dependency_keys259, Values: functional_dependency_values260} - _t862 := &pb.Constraint{Name: relation_id257} - _t862.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t861} - return _t862 + _t1127 := &pb.FunctionalDependency{Guard: abstraction448, Keys: functional_dependency_keys449, Values: functional_dependency_values450} + _t1128 := &pb.Constraint{Name: relation_id447} + _t1128.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t1127} + result452 := _t1128 + p.recordSpan(span_start451) + return result452 } func (p *Parser) parse_functional_dependency_keys() []*pb.Var { + span_start458 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("keys") - xs261 := []*pb.Var{} - cond262 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond262 { - _t863 := p.parse_var() - item263 := _t863 - xs261 = append(xs261, item263) - cond262 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars264 := xs261 + xs453 := []*pb.Var{} + cond454 := p.matchLookaheadTerminal("SYMBOL", 0) + idx456 := 0 + for cond454 { + p.pushPath(idx456) + _t1129 := p.parse_var() + item455 := _t1129 + p.popPath() + xs453 = append(xs453, item455) + idx456 = (idx456 + 1) + cond454 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars457 := xs453 p.consumeLiteral(")") - return vars264 + result459 := vars457 + p.recordSpan(span_start458) + return result459 } func (p *Parser) parse_functional_dependency_values() []*pb.Var { + span_start465 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("values") - xs265 := []*pb.Var{} - cond266 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond266 { - _t864 := p.parse_var() - item267 := _t864 - xs265 = append(xs265, item267) - cond266 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars268 := xs265 + xs460 := []*pb.Var{} + cond461 := p.matchLookaheadTerminal("SYMBOL", 0) + idx463 := 0 + for cond461 { + p.pushPath(idx463) + _t1130 := p.parse_var() + item462 := _t1130 + p.popPath() + xs460 = append(xs460, item462) + idx463 = (idx463 + 1) + cond461 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars464 := xs460 p.consumeLiteral(")") - return vars268 + result466 := vars464 + p.recordSpan(span_start465) + return result466 } func (p *Parser) parse_data() *pb.Data { - var _t865 int64 + span_start471 := p.spanStart() + var _t1131 int64 if p.matchLookaheadLiteral("(", 0) { - var _t866 int64 + var _t1132 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t866 = 0 + _t1132 = 0 } else { - var _t867 int64 + var _t1133 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t867 = 2 + _t1133 = 2 } else { - var _t868 int64 + var _t1134 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t868 = 1 + _t1134 = 1 } else { - _t868 = -1 + _t1134 = -1 } - _t867 = _t868 + _t1133 = _t1134 } - _t866 = _t867 + _t1132 = _t1133 } - _t865 = _t866 + _t1131 = _t1132 } else { - _t865 = -1 - } - prediction269 := _t865 - var _t869 *pb.Data - if prediction269 == 2 { - _t870 := p.parse_csv_data() - csv_data272 := _t870 - _t871 := &pb.Data{} - _t871.DataType = &pb.Data_CsvData{CsvData: csv_data272} - _t869 = _t871 + _t1131 = -1 + } + prediction467 := _t1131 + var _t1135 *pb.Data + if prediction467 == 2 { + _t1136 := p.parse_csv_data() + csv_data470 := _t1136 + _t1137 := &pb.Data{} + _t1137.DataType = &pb.Data_CsvData{CsvData: csv_data470} + _t1135 = _t1137 } else { - var _t872 *pb.Data - if prediction269 == 1 { - _t873 := p.parse_betree_relation() - betree_relation271 := _t873 - _t874 := &pb.Data{} - _t874.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation271} - _t872 = _t874 + var _t1138 *pb.Data + if prediction467 == 1 { + _t1139 := p.parse_betree_relation() + betree_relation469 := _t1139 + _t1140 := &pb.Data{} + _t1140.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation469} + _t1138 = _t1140 } else { - var _t875 *pb.Data - if prediction269 == 0 { - _t876 := p.parse_rel_edb() - rel_edb270 := _t876 - _t877 := &pb.Data{} - _t877.DataType = &pb.Data_RelEdb{RelEdb: rel_edb270} - _t875 = _t877 + var _t1141 *pb.Data + if prediction467 == 0 { + _t1142 := p.parse_rel_edb() + rel_edb468 := _t1142 + _t1143 := &pb.Data{} + _t1143.DataType = &pb.Data_RelEdb{RelEdb: rel_edb468} + _t1141 = _t1143 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in data", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t872 = _t875 + _t1138 = _t1141 } - _t869 = _t872 + _t1135 = _t1138 } - return _t869 + result472 := _t1135 + p.recordSpan(span_start471) + return result472 } func (p *Parser) parse_rel_edb() *pb.RelEDB { + span_start476 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("rel_edb") - _t878 := p.parse_relation_id() - relation_id273 := _t878 - _t879 := p.parse_rel_edb_path() - rel_edb_path274 := _t879 - _t880 := p.parse_rel_edb_types() - rel_edb_types275 := _t880 + p.pushPath(1) + _t1144 := p.parse_relation_id() + relation_id473 := _t1144 + p.popPath() + p.pushPath(2) + _t1145 := p.parse_rel_edb_path() + rel_edb_path474 := _t1145 + p.popPath() + p.pushPath(3) + _t1146 := p.parse_rel_edb_types() + rel_edb_types475 := _t1146 + p.popPath() p.consumeLiteral(")") - _t881 := &pb.RelEDB{TargetId: relation_id273, Path: rel_edb_path274, Types: rel_edb_types275} - return _t881 + _t1147 := &pb.RelEDB{TargetId: relation_id473, Path: rel_edb_path474, Types: rel_edb_types475} + result477 := _t1147 + p.recordSpan(span_start476) + return result477 } func (p *Parser) parse_rel_edb_path() []string { + span_start483 := p.spanStart() p.consumeLiteral("[") - xs276 := []string{} - cond277 := p.matchLookaheadTerminal("STRING", 0) - for cond277 { - item278 := p.consumeTerminal("STRING").Value.AsString() - xs276 = append(xs276, item278) - cond277 = p.matchLookaheadTerminal("STRING", 0) - } - strings279 := xs276 + xs478 := []string{} + cond479 := p.matchLookaheadTerminal("STRING", 0) + idx481 := 0 + for cond479 { + p.pushPath(idx481) + item480 := p.consumeTerminal("STRING").Value.AsString() + p.popPath() + xs478 = append(xs478, item480) + idx481 = (idx481 + 1) + cond479 = p.matchLookaheadTerminal("STRING", 0) + } + strings482 := xs478 p.consumeLiteral("]") - return strings279 + result484 := strings482 + p.recordSpan(span_start483) + return result484 } func (p *Parser) parse_rel_edb_types() []*pb.Type { + span_start490 := p.spanStart() p.consumeLiteral("[") - xs280 := []*pb.Type{} - cond281 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond281 { - _t882 := p.parse_type() - item282 := _t882 - xs280 = append(xs280, item282) - cond281 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types283 := xs280 + xs485 := []*pb.Type{} + cond486 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx488 := 0 + for cond486 { + p.pushPath(idx488) + _t1148 := p.parse_type() + item487 := _t1148 + p.popPath() + xs485 = append(xs485, item487) + idx488 = (idx488 + 1) + cond486 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types489 := xs485 p.consumeLiteral("]") - return types283 + result491 := types489 + p.recordSpan(span_start490) + return result491 } func (p *Parser) parse_betree_relation() *pb.BeTreeRelation { + span_start494 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("betree_relation") - _t883 := p.parse_relation_id() - relation_id284 := _t883 - _t884 := p.parse_betree_info() - betree_info285 := _t884 + p.pushPath(1) + _t1149 := p.parse_relation_id() + relation_id492 := _t1149 + p.popPath() + p.pushPath(2) + _t1150 := p.parse_betree_info() + betree_info493 := _t1150 + p.popPath() p.consumeLiteral(")") - _t885 := &pb.BeTreeRelation{Name: relation_id284, RelationInfo: betree_info285} - return _t885 + _t1151 := &pb.BeTreeRelation{Name: relation_id492, RelationInfo: betree_info493} + result495 := _t1151 + p.recordSpan(span_start494) + return result495 } func (p *Parser) parse_betree_info() *pb.BeTreeInfo { + span_start499 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("betree_info") - _t886 := p.parse_betree_info_key_types() - betree_info_key_types286 := _t886 - _t887 := p.parse_betree_info_value_types() - betree_info_value_types287 := _t887 - _t888 := p.parse_config_dict() - config_dict288 := _t888 + _t1152 := p.parse_betree_info_key_types() + betree_info_key_types496 := _t1152 + _t1153 := p.parse_betree_info_value_types() + betree_info_value_types497 := _t1153 + _t1154 := p.parse_config_dict() + config_dict498 := _t1154 p.consumeLiteral(")") - _t889 := p.construct_betree_info(betree_info_key_types286, betree_info_value_types287, config_dict288) - return _t889 + _t1155 := p.construct_betree_info(betree_info_key_types496, betree_info_value_types497, config_dict498) + result500 := _t1155 + p.recordSpan(span_start499) + return result500 } func (p *Parser) parse_betree_info_key_types() []*pb.Type { + span_start506 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("key_types") - xs289 := []*pb.Type{} - cond290 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond290 { - _t890 := p.parse_type() - item291 := _t890 - xs289 = append(xs289, item291) - cond290 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types292 := xs289 + xs501 := []*pb.Type{} + cond502 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx504 := 0 + for cond502 { + p.pushPath(idx504) + _t1156 := p.parse_type() + item503 := _t1156 + p.popPath() + xs501 = append(xs501, item503) + idx504 = (idx504 + 1) + cond502 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types505 := xs501 p.consumeLiteral(")") - return types292 + result507 := types505 + p.recordSpan(span_start506) + return result507 } func (p *Parser) parse_betree_info_value_types() []*pb.Type { + span_start513 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("value_types") - xs293 := []*pb.Type{} - cond294 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond294 { - _t891 := p.parse_type() - item295 := _t891 - xs293 = append(xs293, item295) - cond294 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types296 := xs293 + xs508 := []*pb.Type{} + cond509 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx511 := 0 + for cond509 { + p.pushPath(idx511) + _t1157 := p.parse_type() + item510 := _t1157 + p.popPath() + xs508 = append(xs508, item510) + idx511 = (idx511 + 1) + cond509 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types512 := xs508 p.consumeLiteral(")") - return types296 + result514 := types512 + p.recordSpan(span_start513) + return result514 } func (p *Parser) parse_csv_data() *pb.CSVData { + span_start519 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("csv_data") - _t892 := p.parse_csvlocator() - csvlocator297 := _t892 - _t893 := p.parse_csv_config() - csv_config298 := _t893 - _t894 := p.parse_csv_columns() - csv_columns299 := _t894 - _t895 := p.parse_csv_asof() - csv_asof300 := _t895 + p.pushPath(1) + _t1158 := p.parse_csvlocator() + csvlocator515 := _t1158 + p.popPath() + p.pushPath(2) + _t1159 := p.parse_csv_config() + csv_config516 := _t1159 + p.popPath() + p.pushPath(3) + _t1160 := p.parse_csv_columns() + csv_columns517 := _t1160 + p.popPath() + p.pushPath(4) + _t1161 := p.parse_csv_asof() + csv_asof518 := _t1161 + p.popPath() p.consumeLiteral(")") - _t896 := &pb.CSVData{Locator: csvlocator297, Config: csv_config298, Columns: csv_columns299, Asof: csv_asof300} - return _t896 + _t1162 := &pb.CSVData{Locator: csvlocator515, Config: csv_config516, Columns: csv_columns517, Asof: csv_asof518} + result520 := _t1162 + p.recordSpan(span_start519) + return result520 } func (p *Parser) parse_csvlocator() *pb.CSVLocator { + span_start523 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("csv_locator") - var _t897 []string + p.pushPath(1) + var _t1163 []string if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("paths", 1)) { - _t898 := p.parse_csv_locator_paths() - _t897 = _t898 + _t1164 := p.parse_csv_locator_paths() + _t1163 = _t1164 } - csv_locator_paths301 := _t897 - var _t899 *string + csv_locator_paths521 := _t1163 + p.popPath() + var _t1165 *string if p.matchLookaheadLiteral("(", 0) { - _t900 := p.parse_csv_locator_inline_data() - _t899 = ptr(_t900) + _t1166 := p.parse_csv_locator_inline_data() + _t1165 = ptr(_t1166) } - csv_locator_inline_data302 := _t899 + csv_locator_inline_data522 := _t1165 p.consumeLiteral(")") - _t901 := csv_locator_paths301 - if csv_locator_paths301 == nil { - _t901 = []string{} + _t1167 := csv_locator_paths521 + if csv_locator_paths521 == nil { + _t1167 = []string{} } - _t902 := &pb.CSVLocator{Paths: _t901, InlineData: []byte(deref(csv_locator_inline_data302, ""))} - return _t902 + _t1168 := &pb.CSVLocator{Paths: _t1167, InlineData: []byte(deref(csv_locator_inline_data522, ""))} + result524 := _t1168 + p.recordSpan(span_start523) + return result524 } func (p *Parser) parse_csv_locator_paths() []string { + span_start530 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("paths") - xs303 := []string{} - cond304 := p.matchLookaheadTerminal("STRING", 0) - for cond304 { - item305 := p.consumeTerminal("STRING").Value.AsString() - xs303 = append(xs303, item305) - cond304 = p.matchLookaheadTerminal("STRING", 0) - } - strings306 := xs303 + xs525 := []string{} + cond526 := p.matchLookaheadTerminal("STRING", 0) + idx528 := 0 + for cond526 { + p.pushPath(idx528) + item527 := p.consumeTerminal("STRING").Value.AsString() + p.popPath() + xs525 = append(xs525, item527) + idx528 = (idx528 + 1) + cond526 = p.matchLookaheadTerminal("STRING", 0) + } + strings529 := xs525 p.consumeLiteral(")") - return strings306 + result531 := strings529 + p.recordSpan(span_start530) + return result531 } func (p *Parser) parse_csv_locator_inline_data() string { + span_start533 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("inline_data") - string307 := p.consumeTerminal("STRING").Value.AsString() + string532 := p.consumeTerminal("STRING").Value.AsString() p.consumeLiteral(")") - return string307 + result534 := string532 + p.recordSpan(span_start533) + return result534 } func (p *Parser) parse_csv_config() *pb.CSVConfig { + span_start536 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("csv_config") - _t903 := p.parse_config_dict() - config_dict308 := _t903 + _t1169 := p.parse_config_dict() + config_dict535 := _t1169 p.consumeLiteral(")") - _t904 := p.construct_csv_config(config_dict308) - return _t904 + _t1170 := p.construct_csv_config(config_dict535) + result537 := _t1170 + p.recordSpan(span_start536) + return result537 } func (p *Parser) parse_csv_columns() []*pb.CSVColumn { + span_start543 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("columns") - xs309 := []*pb.CSVColumn{} - cond310 := p.matchLookaheadLiteral("(", 0) - for cond310 { - _t905 := p.parse_csv_column() - item311 := _t905 - xs309 = append(xs309, item311) - cond310 = p.matchLookaheadLiteral("(", 0) - } - csv_columns312 := xs309 + xs538 := []*pb.CSVColumn{} + cond539 := p.matchLookaheadLiteral("(", 0) + idx541 := 0 + for cond539 { + p.pushPath(idx541) + _t1171 := p.parse_csv_column() + item540 := _t1171 + p.popPath() + xs538 = append(xs538, item540) + idx541 = (idx541 + 1) + cond539 = p.matchLookaheadLiteral("(", 0) + } + csv_columns542 := xs538 p.consumeLiteral(")") - return csv_columns312 + result544 := csv_columns542 + p.recordSpan(span_start543) + return result544 } func (p *Parser) parse_csv_column() *pb.CSVColumn { + span_start552 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("column") - string313 := p.consumeTerminal("STRING").Value.AsString() - _t906 := p.parse_relation_id() - relation_id314 := _t906 + p.pushPath(1) + string545 := p.consumeTerminal("STRING").Value.AsString() + p.popPath() + p.pushPath(2) + _t1172 := p.parse_relation_id() + relation_id546 := _t1172 + p.popPath() p.consumeLiteral("[") - xs315 := []*pb.Type{} - cond316 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond316 { - _t907 := p.parse_type() - item317 := _t907 - xs315 = append(xs315, item317) - cond316 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types318 := xs315 + p.pushPath(3) + xs547 := []*pb.Type{} + cond548 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx550 := 0 + for cond548 { + p.pushPath(idx550) + _t1173 := p.parse_type() + item549 := _t1173 + p.popPath() + xs547 = append(xs547, item549) + idx550 = (idx550 + 1) + cond548 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + p.popPath() + types551 := xs547 p.consumeLiteral("]") p.consumeLiteral(")") - _t908 := &pb.CSVColumn{ColumnName: string313, TargetId: relation_id314, Types: types318} - return _t908 + _t1174 := &pb.CSVColumn{ColumnName: string545, TargetId: relation_id546, Types: types551} + result553 := _t1174 + p.recordSpan(span_start552) + return result553 } func (p *Parser) parse_csv_asof() string { + span_start555 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("asof") - string319 := p.consumeTerminal("STRING").Value.AsString() + string554 := p.consumeTerminal("STRING").Value.AsString() p.consumeLiteral(")") - return string319 + result556 := string554 + p.recordSpan(span_start555) + return result556 } func (p *Parser) parse_undefine() *pb.Undefine { + span_start558 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("undefine") - _t909 := p.parse_fragment_id() - fragment_id320 := _t909 + p.pushPath(1) + _t1175 := p.parse_fragment_id() + fragment_id557 := _t1175 + p.popPath() p.consumeLiteral(")") - _t910 := &pb.Undefine{FragmentId: fragment_id320} - return _t910 + _t1176 := &pb.Undefine{FragmentId: fragment_id557} + result559 := _t1176 + p.recordSpan(span_start558) + return result559 } func (p *Parser) parse_context() *pb.Context { + span_start565 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("context") - xs321 := []*pb.RelationId{} - cond322 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - for cond322 { - _t911 := p.parse_relation_id() - item323 := _t911 - xs321 = append(xs321, item323) - cond322 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - } - relation_ids324 := xs321 + p.pushPath(1) + xs560 := []*pb.RelationId{} + cond561 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx563 := 0 + for cond561 { + p.pushPath(idx563) + _t1177 := p.parse_relation_id() + item562 := _t1177 + p.popPath() + xs560 = append(xs560, item562) + idx563 = (idx563 + 1) + cond561 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + p.popPath() + relation_ids564 := xs560 p.consumeLiteral(")") - _t912 := &pb.Context{Relations: relation_ids324} - return _t912 + _t1178 := &pb.Context{Relations: relation_ids564} + result566 := _t1178 + p.recordSpan(span_start565) + return result566 } func (p *Parser) parse_epoch_reads() []*pb.Read { + span_start572 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("reads") - xs325 := []*pb.Read{} - cond326 := p.matchLookaheadLiteral("(", 0) - for cond326 { - _t913 := p.parse_read() - item327 := _t913 - xs325 = append(xs325, item327) - cond326 = p.matchLookaheadLiteral("(", 0) - } - reads328 := xs325 + xs567 := []*pb.Read{} + cond568 := p.matchLookaheadLiteral("(", 0) + idx570 := 0 + for cond568 { + p.pushPath(idx570) + _t1179 := p.parse_read() + item569 := _t1179 + p.popPath() + xs567 = append(xs567, item569) + idx570 = (idx570 + 1) + cond568 = p.matchLookaheadLiteral("(", 0) + } + reads571 := xs567 p.consumeLiteral(")") - return reads328 + result573 := reads571 + p.recordSpan(span_start572) + return result573 } func (p *Parser) parse_read() *pb.Read { - var _t914 int64 + span_start580 := p.spanStart() + var _t1180 int64 if p.matchLookaheadLiteral("(", 0) { - var _t915 int64 + var _t1181 int64 if p.matchLookaheadLiteral("what_if", 1) { - _t915 = 2 + _t1181 = 2 } else { - var _t916 int64 + var _t1182 int64 if p.matchLookaheadLiteral("output", 1) { - _t916 = 1 + _t1182 = 1 } else { - var _t917 int64 + var _t1183 int64 if p.matchLookaheadLiteral("export", 1) { - _t917 = 4 + _t1183 = 4 } else { - var _t918 int64 + var _t1184 int64 if p.matchLookaheadLiteral("demand", 1) { - _t918 = 0 + _t1184 = 0 } else { - var _t919 int64 + var _t1185 int64 if p.matchLookaheadLiteral("abort", 1) { - _t919 = 3 + _t1185 = 3 } else { - _t919 = -1 + _t1185 = -1 } - _t918 = _t919 + _t1184 = _t1185 } - _t917 = _t918 + _t1183 = _t1184 } - _t916 = _t917 + _t1182 = _t1183 } - _t915 = _t916 + _t1181 = _t1182 } - _t914 = _t915 + _t1180 = _t1181 } else { - _t914 = -1 - } - prediction329 := _t914 - var _t920 *pb.Read - if prediction329 == 4 { - _t921 := p.parse_export() - export334 := _t921 - _t922 := &pb.Read{} - _t922.ReadType = &pb.Read_Export{Export: export334} - _t920 = _t922 + _t1180 = -1 + } + prediction574 := _t1180 + var _t1186 *pb.Read + if prediction574 == 4 { + _t1187 := p.parse_export() + export579 := _t1187 + _t1188 := &pb.Read{} + _t1188.ReadType = &pb.Read_Export{Export: export579} + _t1186 = _t1188 } else { - var _t923 *pb.Read - if prediction329 == 3 { - _t924 := p.parse_abort() - abort333 := _t924 - _t925 := &pb.Read{} - _t925.ReadType = &pb.Read_Abort{Abort: abort333} - _t923 = _t925 + var _t1189 *pb.Read + if prediction574 == 3 { + _t1190 := p.parse_abort() + abort578 := _t1190 + _t1191 := &pb.Read{} + _t1191.ReadType = &pb.Read_Abort{Abort: abort578} + _t1189 = _t1191 } else { - var _t926 *pb.Read - if prediction329 == 2 { - _t927 := p.parse_what_if() - what_if332 := _t927 - _t928 := &pb.Read{} - _t928.ReadType = &pb.Read_WhatIf{WhatIf: what_if332} - _t926 = _t928 + var _t1192 *pb.Read + if prediction574 == 2 { + _t1193 := p.parse_what_if() + what_if577 := _t1193 + _t1194 := &pb.Read{} + _t1194.ReadType = &pb.Read_WhatIf{WhatIf: what_if577} + _t1192 = _t1194 } else { - var _t929 *pb.Read - if prediction329 == 1 { - _t930 := p.parse_output() - output331 := _t930 - _t931 := &pb.Read{} - _t931.ReadType = &pb.Read_Output{Output: output331} - _t929 = _t931 + var _t1195 *pb.Read + if prediction574 == 1 { + _t1196 := p.parse_output() + output576 := _t1196 + _t1197 := &pb.Read{} + _t1197.ReadType = &pb.Read_Output{Output: output576} + _t1195 = _t1197 } else { - var _t932 *pb.Read - if prediction329 == 0 { - _t933 := p.parse_demand() - demand330 := _t933 - _t934 := &pb.Read{} - _t934.ReadType = &pb.Read_Demand{Demand: demand330} - _t932 = _t934 + var _t1198 *pb.Read + if prediction574 == 0 { + _t1199 := p.parse_demand() + demand575 := _t1199 + _t1200 := &pb.Read{} + _t1200.ReadType = &pb.Read_Demand{Demand: demand575} + _t1198 = _t1200 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in read", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t929 = _t932 + _t1195 = _t1198 } - _t926 = _t929 + _t1192 = _t1195 } - _t923 = _t926 + _t1189 = _t1192 } - _t920 = _t923 + _t1186 = _t1189 } - return _t920 + result581 := _t1186 + p.recordSpan(span_start580) + return result581 } func (p *Parser) parse_demand() *pb.Demand { + span_start583 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("demand") - _t935 := p.parse_relation_id() - relation_id335 := _t935 + p.pushPath(1) + _t1201 := p.parse_relation_id() + relation_id582 := _t1201 + p.popPath() p.consumeLiteral(")") - _t936 := &pb.Demand{RelationId: relation_id335} - return _t936 + _t1202 := &pb.Demand{RelationId: relation_id582} + result584 := _t1202 + p.recordSpan(span_start583) + return result584 } func (p *Parser) parse_output() *pb.Output { + span_start587 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("output") - _t937 := p.parse_name() - name336 := _t937 - _t938 := p.parse_relation_id() - relation_id337 := _t938 + p.pushPath(1) + _t1203 := p.parse_name() + name585 := _t1203 + p.popPath() + p.pushPath(2) + _t1204 := p.parse_relation_id() + relation_id586 := _t1204 + p.popPath() p.consumeLiteral(")") - _t939 := &pb.Output{Name: name336, RelationId: relation_id337} - return _t939 + _t1205 := &pb.Output{Name: name585, RelationId: relation_id586} + result588 := _t1205 + p.recordSpan(span_start587) + return result588 } func (p *Parser) parse_what_if() *pb.WhatIf { + span_start591 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("what_if") - _t940 := p.parse_name() - name338 := _t940 - _t941 := p.parse_epoch() - epoch339 := _t941 + p.pushPath(1) + _t1206 := p.parse_name() + name589 := _t1206 + p.popPath() + p.pushPath(2) + _t1207 := p.parse_epoch() + epoch590 := _t1207 + p.popPath() p.consumeLiteral(")") - _t942 := &pb.WhatIf{Branch: name338, Epoch: epoch339} - return _t942 + _t1208 := &pb.WhatIf{Branch: name589, Epoch: epoch590} + result592 := _t1208 + p.recordSpan(span_start591) + return result592 } func (p *Parser) parse_abort() *pb.Abort { + span_start595 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("abort") - var _t943 *string + p.pushPath(1) + var _t1209 *string if (p.matchLookaheadLiteral(":", 0) && p.matchLookaheadTerminal("SYMBOL", 1)) { - _t944 := p.parse_name() - _t943 = ptr(_t944) - } - name340 := _t943 - _t945 := p.parse_relation_id() - relation_id341 := _t945 + _t1210 := p.parse_name() + _t1209 = ptr(_t1210) + } + name593 := _t1209 + p.popPath() + p.pushPath(2) + _t1211 := p.parse_relation_id() + relation_id594 := _t1211 + p.popPath() p.consumeLiteral(")") - _t946 := &pb.Abort{Name: deref(name340, "abort"), RelationId: relation_id341} - return _t946 + _t1212 := &pb.Abort{Name: deref(name593, "abort"), RelationId: relation_id594} + result596 := _t1212 + p.recordSpan(span_start595) + return result596 } func (p *Parser) parse_export() *pb.Export { + span_start598 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("export") - _t947 := p.parse_export_csv_config() - export_csv_config342 := _t947 + p.pushPath(1) + _t1213 := p.parse_export_csv_config() + export_csv_config597 := _t1213 + p.popPath() p.consumeLiteral(")") - _t948 := &pb.Export{} - _t948.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config342} - return _t948 + _t1214 := &pb.Export{} + _t1214.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config597} + result599 := _t1214 + p.recordSpan(span_start598) + return result599 } func (p *Parser) parse_export_csv_config() *pb.ExportCSVConfig { + span_start603 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("export_csv_config") - _t949 := p.parse_export_csv_path() - export_csv_path343 := _t949 - _t950 := p.parse_export_csv_columns() - export_csv_columns344 := _t950 - _t951 := p.parse_config_dict() - config_dict345 := _t951 + _t1215 := p.parse_export_csv_path() + export_csv_path600 := _t1215 + _t1216 := p.parse_export_csv_columns() + export_csv_columns601 := _t1216 + _t1217 := p.parse_config_dict() + config_dict602 := _t1217 p.consumeLiteral(")") - _t952 := p.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) - return _t952 + _t1218 := p.export_csv_config(export_csv_path600, export_csv_columns601, config_dict602) + result604 := _t1218 + p.recordSpan(span_start603) + return result604 } func (p *Parser) parse_export_csv_path() string { + span_start606 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("path") - string346 := p.consumeTerminal("STRING").Value.AsString() + string605 := p.consumeTerminal("STRING").Value.AsString() p.consumeLiteral(")") - return string346 + result607 := string605 + p.recordSpan(span_start606) + return result607 } func (p *Parser) parse_export_csv_columns() []*pb.ExportCSVColumn { + span_start613 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("columns") - xs347 := []*pb.ExportCSVColumn{} - cond348 := p.matchLookaheadLiteral("(", 0) - for cond348 { - _t953 := p.parse_export_csv_column() - item349 := _t953 - xs347 = append(xs347, item349) - cond348 = p.matchLookaheadLiteral("(", 0) - } - export_csv_columns350 := xs347 + xs608 := []*pb.ExportCSVColumn{} + cond609 := p.matchLookaheadLiteral("(", 0) + idx611 := 0 + for cond609 { + p.pushPath(idx611) + _t1219 := p.parse_export_csv_column() + item610 := _t1219 + p.popPath() + xs608 = append(xs608, item610) + idx611 = (idx611 + 1) + cond609 = p.matchLookaheadLiteral("(", 0) + } + export_csv_columns612 := xs608 p.consumeLiteral(")") - return export_csv_columns350 + result614 := export_csv_columns612 + p.recordSpan(span_start613) + return result614 } func (p *Parser) parse_export_csv_column() *pb.ExportCSVColumn { + span_start617 := p.spanStart() p.consumeLiteral("(") p.consumeLiteral("column") - string351 := p.consumeTerminal("STRING").Value.AsString() - _t954 := p.parse_relation_id() - relation_id352 := _t954 + p.pushPath(1) + string615 := p.consumeTerminal("STRING").Value.AsString() + p.popPath() + p.pushPath(2) + _t1220 := p.parse_relation_id() + relation_id616 := _t1220 + p.popPath() p.consumeLiteral(")") - _t955 := &pb.ExportCSVColumn{ColumnName: string351, ColumnData: relation_id352} - return _t955 + _t1221 := &pb.ExportCSVColumn{ColumnName: string615, ColumnData: relation_id616} + result618 := _t1221 + p.recordSpan(span_start617) + return result618 } -// Parse parses the input string and returns the result -func Parse(input string) (*pb.Transaction, error) { +// Parse parses the input string and returns the result and provenance map +func Parse(input string) (*pb.Transaction, map[string]Span, error) { defer func() { if r := recover(); r != nil { if pe, ok := r.(ParseError); ok { @@ -4126,15 +4868,15 @@ func Parse(input string) (*pb.Transaction, error) { }() lexer := NewLexer(input) - parser := NewParser(lexer.tokens) + parser := NewParser(lexer.tokens, input) result := parser.parse_transaction() // Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens) { remainingToken := parser.lookahead(0) if remainingToken.Type != "$" { - return nil, ParseError{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)} + return nil, nil, ParseError{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)} } } - return result, nil + return result, parser.Provenance, nil } diff --git a/go/test/parser_test.go b/go/test/parser_test.go index ee79f40a..8af81894 100644 --- a/go/test/parser_test.go +++ b/go/test/parser_test.go @@ -20,7 +20,7 @@ func TestBasicParsing(t *testing.T) { (writes) (reads))) ` - result, err := lqp.Parse(input) + result, _, err := lqp.Parse(input) if err != nil { t.Fatalf("Failed to parse basic transaction: %v", err) } @@ -66,7 +66,7 @@ func TestParseLQPFiles(t *testing.T) { } // Parse the LQP file - result, err := lqp.Parse(string(content)) + result, _, err := lqp.Parse(string(content)) if err != nil { t.Fatalf("Failed to parse LQP file %s: %v", entry.Name(), err) } diff --git a/julia/LQPParser/src/parser.jl b/julia/LQPParser/src/parser.jl index d2119ad0..4b3b1a07 100644 --- a/julia/LQPParser/src/parser.jl +++ b/julia/LQPParser/src/parser.jl @@ -48,13 +48,25 @@ end Base.showerror(io::IO, e::ParseError) = print(io, "ParseError: ", e.msg) +struct Location + line::Int + column::Int + offset::Int +end + +struct Span + start_::Location + end_::Location +end + struct Token type::String value::Any - pos::Int + start_pos::Int + end_pos::Int end -Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.pos, ")") +Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.start_pos, ")") mutable struct Lexer @@ -136,11 +148,11 @@ function tokenize!(lexer::Lexer) # Pick the longest match token_type, value, action, end_pos = candidates[argmax([c[4] for c in candidates])] - push!(lexer.tokens, Token(token_type, action(value), lexer.pos)) + push!(lexer.tokens, Token(token_type, action(value), lexer.pos, end_pos)) lexer.pos = end_pos end - push!(lexer.tokens, Token("\$", "", lexer.pos)) + push!(lexer.tokens, Token("\$", "", lexer.pos, lexer.pos)) return nothing end @@ -215,23 +227,37 @@ mutable struct Parser id_to_debuginfo::Dict{Vector{UInt8},Vector{Pair{Tuple{UInt64,UInt64},String}}} _current_fragment_id::Union{Nothing,Vector{UInt8}} _relation_id_to_name::Dict{Tuple{UInt64,UInt64},String} + provenance::Dict{Tuple{Vararg{Int}},Span} + _path::Vector{Int} + _line_starts::Vector{Int} - function Parser(tokens::Vector{Token}) - return new(tokens, 1, Dict(), nothing, Dict()) + function Parser(tokens::Vector{Token}, input::String) + line_starts = _compute_line_starts(input) + return new(tokens, 1, Dict(), nothing, Dict(), Dict(), Int[], line_starts) + end +end + +function _compute_line_starts(text::String)::Vector{Int} + starts = [0] + for (i, ch) in enumerate(text) + if ch == '\n' + push!(starts, i) + end end + return starts end function lookahead(parser::Parser, k::Int=0)::Token idx = parser.pos + k - return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1) + return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1, -1) end function consume_literal!(parser::Parser, expected::String) if !match_lookahead_literal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) + throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) end parser.pos += 1 return nothing @@ -241,7 +267,7 @@ end function consume_terminal!(parser::Parser, expected::String) if !match_lookahead_terminal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) + throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) end token = lookahead(parser, 0) parser.pos += 1 @@ -268,6 +294,35 @@ function match_lookahead_terminal(parser::Parser, terminal::String, k::Int)::Boo end +function push_path!(parser::Parser, n::Int) + push!(parser._path, n) + return nothing +end + +function pop_path!(parser::Parser) + pop!(parser._path) + return nothing +end + +function span_start(parser::Parser)::Int + return parser.tokens[parser.pos].start_pos +end + +function record_span!(parser::Parser, start_offset::Int) + end_offset = parser.tokens[parser.pos - 1].end_pos + start_loc = _make_location(parser, start_offset) + end_loc = _make_location(parser, end_offset) + parser.provenance[Tuple(parser._path)] = Span(start_loc, end_loc) + return nothing +end + +function _make_location(parser::Parser, offset::Int)::Location + # Binary search for the line containing offset + line = searchsortedlast(parser._line_starts, offset) + column = offset - parser._line_starts[line] + 1 + return Location(line, column, offset) +end + function start_fragment!(parser::Parser, fragment_id::Proto.FragmentId) parser._current_fragment_id = fragment_id.id return fragment_id @@ -425,63 +480,63 @@ end function construct_csv_config(parser::Parser, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.CSVConfig config = Dict(config_dict) - _t945 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) - header_row = _t945 - _t946 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) - skip = _t946 - _t947 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") - new_line = _t947 - _t948 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") - delimiter = _t948 - _t949 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") - quotechar = _t949 - _t950 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") - escapechar = _t950 - _t951 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") - comment = _t951 - _t952 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) - missing_strings = _t952 - _t953 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") - decimal_separator = _t953 - _t954 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") - encoding = _t954 - _t955 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") - compression = _t955 - _t956 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t956 + _t1211 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) + header_row = _t1211 + _t1212 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) + skip = _t1212 + _t1213 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") + new_line = _t1213 + _t1214 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") + delimiter = _t1214 + _t1215 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") + quotechar = _t1215 + _t1216 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") + escapechar = _t1216 + _t1217 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") + comment = _t1217 + _t1218 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) + missing_strings = _t1218 + _t1219 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") + decimal_separator = _t1219 + _t1220 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") + encoding = _t1220 + _t1221 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") + compression = _t1221 + _t1222 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1222 end function construct_betree_info(parser::Parser, key_types::Vector{Proto.var"#Type"}, value_types::Vector{Proto.var"#Type"}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.BeTreeInfo config = Dict(config_dict) - _t957 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) - epsilon = _t957 - _t958 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) - max_pivots = _t958 - _t959 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) - max_deltas = _t959 - _t960 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) - max_leaf = _t960 - _t961 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t961 - _t962 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) - root_pageid = _t962 - _t963 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) - inline_data = _t963 - _t964 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) - element_count = _t964 - _t965 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) - tree_height = _t965 - _t966 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) - relation_locator = _t966 - _t967 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t967 + _t1223 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) + epsilon = _t1223 + _t1224 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) + max_pivots = _t1224 + _t1225 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) + max_deltas = _t1225 + _t1226 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) + max_leaf = _t1226 + _t1227 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1227 + _t1228 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) + root_pageid = _t1228 + _t1229 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) + inline_data = _t1229 + _t1230 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) + element_count = _t1230 + _t1231 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) + tree_height = _t1231 + _t1232 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) + relation_locator = _t1232 + _t1233 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1233 end function default_configure(parser::Parser)::Proto.Configure - _t968 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t968 - _t969 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) - return _t969 + _t1234 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1234 + _t1235 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1235 end function construct_configure(parser::Parser, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.Configure @@ -503,62 +558,62 @@ function construct_configure(parser::Parser, config_dict::Vector{Tuple{String, P end end end - _t970 = Proto.IVMConfig(level=maintenance_level) - ivm_config = _t970 - _t971 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) - semantics_version = _t971 - _t972 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t972 + _t1236 = Proto.IVMConfig(level=maintenance_level) + ivm_config = _t1236 + _t1237 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) + semantics_version = _t1237 + _t1238 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1238 end function export_csv_config(parser::Parser, path::String, columns::Vector{Proto.ExportCSVColumn}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.ExportCSVConfig config = Dict(config_dict) - _t973 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) - partition_size = _t973 - _t974 = _extract_value_string(parser, get(config, "compression", nothing), "") - compression = _t974 - _t975 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) - syntax_header_row = _t975 - _t976 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") - syntax_missing_string = _t976 - _t977 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") - syntax_delim = _t977 - _t978 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") - syntax_quotechar = _t978 - _t979 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") - syntax_escapechar = _t979 - _t980 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t980 + _t1239 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) + partition_size = _t1239 + _t1240 = _extract_value_string(parser, get(config, "compression", nothing), "") + compression = _t1240 + _t1241 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) + syntax_header_row = _t1241 + _t1242 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") + syntax_missing_string = _t1242 + _t1243 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") + syntax_delim = _t1243 + _t1244 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") + syntax_quotechar = _t1244 + _t1245 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") + syntax_escapechar = _t1245 + _t1246 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1246 end function _make_value_int32(parser::Parser, v::Int32)::Proto.Value - _t981 = Proto.Value(value=OneOf(:int_value, Int64(v))) - return _t981 + _t1247 = Proto.Value(value=OneOf(:int_value, Int64(v))) + return _t1247 end function _make_value_int64(parser::Parser, v::Int64)::Proto.Value - _t982 = Proto.Value(value=OneOf(:int_value, v)) - return _t982 + _t1248 = Proto.Value(value=OneOf(:int_value, v)) + return _t1248 end function _make_value_float64(parser::Parser, v::Float64)::Proto.Value - _t983 = Proto.Value(value=OneOf(:float_value, v)) - return _t983 + _t1249 = Proto.Value(value=OneOf(:float_value, v)) + return _t1249 end function _make_value_string(parser::Parser, v::String)::Proto.Value - _t984 = Proto.Value(value=OneOf(:string_value, v)) - return _t984 + _t1250 = Proto.Value(value=OneOf(:string_value, v)) + return _t1250 end function _make_value_boolean(parser::Parser, v::Bool)::Proto.Value - _t985 = Proto.Value(value=OneOf(:boolean_value, v)) - return _t985 + _t1251 = Proto.Value(value=OneOf(:boolean_value, v)) + return _t1251 end function _make_value_uint128(parser::Parser, v::Proto.UInt128Value)::Proto.Value - _t986 = Proto.Value(value=OneOf(:uint128_value, v)) - return _t986 + _t1252 = Proto.Value(value=OneOf(:uint128_value, v)) + return _t1252 end function is_default_configure(parser::Parser, cfg::Proto.Configure)::Bool @@ -575,82 +630,82 @@ function deconstruct_configure(parser::Parser, msg::Proto.Configure)::Vector{Tup result = Tuple{String, Proto.Value}[] if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO - _t988 = _make_value_string(parser, "auto") - push!(result, ("ivm.maintenance_level", _t988,)) - _t987 = nothing + _t1254 = _make_value_string(parser, "auto") + push!(result, ("ivm.maintenance_level", _t1254,)) + _t1253 = nothing else if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_ALL - _t990 = _make_value_string(parser, "all") - push!(result, ("ivm.maintenance_level", _t990,)) - _t989 = nothing + _t1256 = _make_value_string(parser, "all") + push!(result, ("ivm.maintenance_level", _t1256,)) + _t1255 = nothing else if msg.ivm_config.level == Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t992 = _make_value_string(parser, "off") - push!(result, ("ivm.maintenance_level", _t992,)) - _t991 = nothing + _t1258 = _make_value_string(parser, "off") + push!(result, ("ivm.maintenance_level", _t1258,)) + _t1257 = nothing else - _t991 = nothing + _t1257 = nothing end - _t989 = _t991 + _t1255 = _t1257 end - _t987 = _t989 + _t1253 = _t1255 end - _t993 = _make_value_int64(parser, msg.semantics_version) - push!(result, ("semantics_version", _t993,)) + _t1259 = _make_value_int64(parser, msg.semantics_version) + push!(result, ("semantics_version", _t1259,)) return sort(result) end function deconstruct_csv_config(parser::Parser, msg::Proto.CSVConfig)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - _t994 = _make_value_int32(parser, msg.header_row) - push!(result, ("csv_header_row", _t994,)) - _t995 = _make_value_int64(parser, msg.skip) - push!(result, ("csv_skip", _t995,)) + _t1260 = _make_value_int32(parser, msg.header_row) + push!(result, ("csv_header_row", _t1260,)) + _t1261 = _make_value_int64(parser, msg.skip) + push!(result, ("csv_skip", _t1261,)) if msg.new_line != "" - _t997 = _make_value_string(parser, msg.new_line) - push!(result, ("csv_new_line", _t997,)) - _t996 = nothing + _t1263 = _make_value_string(parser, msg.new_line) + push!(result, ("csv_new_line", _t1263,)) + _t1262 = nothing else - _t996 = nothing - end - _t998 = _make_value_string(parser, msg.delimiter) - push!(result, ("csv_delimiter", _t998,)) - _t999 = _make_value_string(parser, msg.quotechar) - push!(result, ("csv_quotechar", _t999,)) - _t1000 = _make_value_string(parser, msg.escapechar) - push!(result, ("csv_escapechar", _t1000,)) + _t1262 = nothing + end + _t1264 = _make_value_string(parser, msg.delimiter) + push!(result, ("csv_delimiter", _t1264,)) + _t1265 = _make_value_string(parser, msg.quotechar) + push!(result, ("csv_quotechar", _t1265,)) + _t1266 = _make_value_string(parser, msg.escapechar) + push!(result, ("csv_escapechar", _t1266,)) if msg.comment != "" - _t1002 = _make_value_string(parser, msg.comment) - push!(result, ("csv_comment", _t1002,)) - _t1001 = nothing + _t1268 = _make_value_string(parser, msg.comment) + push!(result, ("csv_comment", _t1268,)) + _t1267 = nothing else - _t1001 = nothing + _t1267 = nothing end for missing_string in msg.missing_strings - _t1003 = _make_value_string(parser, missing_string) - push!(result, ("csv_missing_strings", _t1003,)) - end - _t1004 = _make_value_string(parser, msg.decimal_separator) - push!(result, ("csv_decimal_separator", _t1004,)) - _t1005 = _make_value_string(parser, msg.encoding) - push!(result, ("csv_encoding", _t1005,)) - _t1006 = _make_value_string(parser, msg.compression) - push!(result, ("csv_compression", _t1006,)) + _t1269 = _make_value_string(parser, missing_string) + push!(result, ("csv_missing_strings", _t1269,)) + end + _t1270 = _make_value_string(parser, msg.decimal_separator) + push!(result, ("csv_decimal_separator", _t1270,)) + _t1271 = _make_value_string(parser, msg.encoding) + push!(result, ("csv_encoding", _t1271,)) + _t1272 = _make_value_string(parser, msg.compression) + push!(result, ("csv_compression", _t1272,)) return sort(result) end function _maybe_push_float64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Float64})::Nothing if !isnothing(val) - _t1008 = _make_value_float64(parser, val) - push!(result, (key, _t1008,)) - _t1007 = nothing + _t1274 = _make_value_float64(parser, val) + push!(result, (key, _t1274,)) + _t1273 = nothing else - _t1007 = nothing + _t1273 = nothing end return nothing end @@ -658,11 +713,11 @@ end function _maybe_push_int64(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Int64})::Nothing if !isnothing(val) - _t1010 = _make_value_int64(parser, val) - push!(result, (key, _t1010,)) - _t1009 = nothing + _t1276 = _make_value_int64(parser, val) + push!(result, (key, _t1276,)) + _t1275 = nothing else - _t1009 = nothing + _t1275 = nothing end return nothing end @@ -670,11 +725,11 @@ end function _maybe_push_uint128(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Proto.UInt128Value})::Nothing if !isnothing(val) - _t1012 = _make_value_uint128(parser, val) - push!(result, (key, _t1012,)) - _t1011 = nothing + _t1278 = _make_value_uint128(parser, val) + push!(result, (key, _t1278,)) + _t1277 = nothing else - _t1011 = nothing + _t1277 = nothing end return nothing end @@ -682,43 +737,43 @@ end function _maybe_push_bytes_as_string(parser::Parser, result::Vector{Tuple{String, Proto.Value}}, key::String, val::Union{Nothing, Vector{UInt8}})::Nothing if !isnothing(val) - _t1014 = _make_value_string(parser, String(val)) - push!(result, (key, _t1014,)) - _t1013 = nothing + _t1280 = _make_value_string(parser, String(val)) + push!(result, (key, _t1280,)) + _t1279 = nothing else - _t1013 = nothing + _t1279 = nothing end return nothing end function deconstruct_betree_info_config(parser::Parser, msg::Proto.BeTreeInfo)::Vector{Tuple{String, Proto.Value}} result = Tuple{String, Proto.Value}[] - _t1015 = _make_value_float64(parser, msg.storage_config.epsilon) - push!(result, ("betree_config_epsilon", _t1015,)) - _t1016 = _make_value_int64(parser, msg.storage_config.max_pivots) - push!(result, ("betree_config_max_pivots", _t1016,)) - _t1017 = _make_value_int64(parser, msg.storage_config.max_deltas) - push!(result, ("betree_config_max_deltas", _t1017,)) - _t1018 = _make_value_int64(parser, msg.storage_config.max_leaf) - push!(result, ("betree_config_max_leaf", _t1018,)) + _t1281 = _make_value_float64(parser, msg.storage_config.epsilon) + push!(result, ("betree_config_epsilon", _t1281,)) + _t1282 = _make_value_int64(parser, msg.storage_config.max_pivots) + push!(result, ("betree_config_max_pivots", _t1282,)) + _t1283 = _make_value_int64(parser, msg.storage_config.max_deltas) + push!(result, ("betree_config_max_deltas", _t1283,)) + _t1284 = _make_value_int64(parser, msg.storage_config.max_leaf) + push!(result, ("betree_config_max_leaf", _t1284,)) if _has_proto_field(msg.relation_locator, Symbol("root_pageid")) - _t1020 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) - _t1019 = _t1020 + _t1286 = _maybe_push_uint128(parser, result, "betree_locator_root_pageid", _get_oneof_field(msg.relation_locator, :root_pageid)) + _t1285 = _t1286 else - _t1019 = nothing + _t1285 = nothing end if _has_proto_field(msg.relation_locator, Symbol("inline_data")) - _t1022 = _maybe_push_bytes_as_string(parser, result, "betree_locator_inline_data", _get_oneof_field(msg.relation_locator, :inline_data)) - _t1021 = _t1022 + _t1288 = _maybe_push_bytes_as_string(parser, result, "betree_locator_inline_data", _get_oneof_field(msg.relation_locator, :inline_data)) + _t1287 = _t1288 else - _t1021 = nothing + _t1287 = nothing end - _t1023 = _make_value_int64(parser, msg.relation_locator.element_count) - push!(result, ("betree_locator_element_count", _t1023,)) - _t1024 = _make_value_int64(parser, msg.relation_locator.tree_height) - push!(result, ("betree_locator_tree_height", _t1024,)) + _t1289 = _make_value_int64(parser, msg.relation_locator.element_count) + push!(result, ("betree_locator_element_count", _t1289,)) + _t1290 = _make_value_int64(parser, msg.relation_locator.tree_height) + push!(result, ("betree_locator_tree_height", _t1290,)) return sort(result) end @@ -726,59 +781,59 @@ function deconstruct_export_csv_config(parser::Parser, msg::Proto.ExportCSVConfi result = Tuple{String, Proto.Value}[] if !isnothing(msg.partition_size) - _t1026 = _make_value_int64(parser, msg.partition_size) - push!(result, ("partition_size", _t1026,)) - _t1025 = nothing + _t1292 = _make_value_int64(parser, msg.partition_size) + push!(result, ("partition_size", _t1292,)) + _t1291 = nothing else - _t1025 = nothing + _t1291 = nothing end if !isnothing(msg.compression) - _t1028 = _make_value_string(parser, msg.compression) - push!(result, ("compression", _t1028,)) - _t1027 = nothing + _t1294 = _make_value_string(parser, msg.compression) + push!(result, ("compression", _t1294,)) + _t1293 = nothing else - _t1027 = nothing + _t1293 = nothing end if !isnothing(msg.syntax_header_row) - _t1030 = _make_value_boolean(parser, msg.syntax_header_row) - push!(result, ("syntax_header_row", _t1030,)) - _t1029 = nothing + _t1296 = _make_value_boolean(parser, msg.syntax_header_row) + push!(result, ("syntax_header_row", _t1296,)) + _t1295 = nothing else - _t1029 = nothing + _t1295 = nothing end if !isnothing(msg.syntax_missing_string) - _t1032 = _make_value_string(parser, msg.syntax_missing_string) - push!(result, ("syntax_missing_string", _t1032,)) - _t1031 = nothing + _t1298 = _make_value_string(parser, msg.syntax_missing_string) + push!(result, ("syntax_missing_string", _t1298,)) + _t1297 = nothing else - _t1031 = nothing + _t1297 = nothing end if !isnothing(msg.syntax_delim) - _t1034 = _make_value_string(parser, msg.syntax_delim) - push!(result, ("syntax_delim", _t1034,)) - _t1033 = nothing + _t1300 = _make_value_string(parser, msg.syntax_delim) + push!(result, ("syntax_delim", _t1300,)) + _t1299 = nothing else - _t1033 = nothing + _t1299 = nothing end if !isnothing(msg.syntax_quotechar) - _t1036 = _make_value_string(parser, msg.syntax_quotechar) - push!(result, ("syntax_quotechar", _t1036,)) - _t1035 = nothing + _t1302 = _make_value_string(parser, msg.syntax_quotechar) + push!(result, ("syntax_quotechar", _t1302,)) + _t1301 = nothing else - _t1035 = nothing + _t1301 = nothing end if !isnothing(msg.syntax_escapechar) - _t1038 = _make_value_string(parser, msg.syntax_escapechar) - push!(result, ("syntax_escapechar", _t1038,)) - _t1037 = nothing + _t1304 = _make_value_string(parser, msg.syntax_escapechar) + push!(result, ("syntax_escapechar", _t1304,)) + _t1303 = nothing else - _t1037 = nothing + _t1303 = nothing end return sort(result) end @@ -813,2899 +868,3562 @@ end # --- Parse functions --- function parse_transaction(parser::Parser)::Proto.Transaction + span_start7 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "transaction") + push_path!(parser, 2) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "configure", 1)) - _t354 = parse_configure(parser) - _t353 = _t354 + _t620 = parse_configure(parser) + _t619 = _t620 else - _t353 = nothing + _t619 = nothing end - configure0 = _t353 + configure0 = _t619 + pop_path!(parser) + push_path!(parser, 3) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "sync", 1)) - _t356 = parse_sync(parser) - _t355 = _t356 + _t622 = parse_sync(parser) + _t621 = _t622 else - _t355 = nothing + _t621 = nothing end - sync1 = _t355 + sync1 = _t621 + pop_path!(parser) + push_path!(parser, 1) xs2 = Proto.Epoch[] cond3 = match_lookahead_literal(parser, "(", 0) + idx5 = 0 while cond3 - _t357 = parse_epoch(parser) - item4 = _t357 + push_path!(parser, idx5) + _t623 = parse_epoch(parser) + item4 = _t623 + pop_path!(parser) push!(xs2, item4) + idx5 = (idx5 + 1) cond3 = match_lookahead_literal(parser, "(", 0) end - epochs5 = xs2 + pop_path!(parser) + epochs6 = xs2 consume_literal!(parser, ")") - _t358 = default_configure(parser) - _t359 = Proto.Transaction(epochs=epochs5, configure=(!isnothing(configure0) ? configure0 : _t358), sync=sync1) - return _t359 + _t624 = default_configure(parser) + _t625 = Proto.Transaction(epochs=epochs6, configure=(!isnothing(configure0) ? configure0 : _t624), sync=sync1) + result8 = _t625 + record_span!(parser, span_start7) + return result8 end function parse_configure(parser::Parser)::Proto.Configure + span_start10 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "configure") - _t360 = parse_config_dict(parser) - config_dict6 = _t360 + _t626 = parse_config_dict(parser) + config_dict9 = _t626 consume_literal!(parser, ")") - _t361 = construct_configure(parser, config_dict6) - return _t361 + _t627 = construct_configure(parser, config_dict9) + result11 = _t627 + record_span!(parser, span_start10) + return result11 end function parse_config_dict(parser::Parser)::Vector{Tuple{String, Proto.Value}} + span_start17 = span_start(parser) consume_literal!(parser, "{") - xs7 = Tuple{String, Proto.Value}[] - cond8 = match_lookahead_literal(parser, ":", 0) - while cond8 - _t362 = parse_config_key_value(parser) - item9 = _t362 - push!(xs7, item9) - cond8 = match_lookahead_literal(parser, ":", 0) - end - config_key_values10 = xs7 + xs12 = Tuple{String, Proto.Value}[] + cond13 = match_lookahead_literal(parser, ":", 0) + idx15 = 0 + while cond13 + push_path!(parser, idx15) + _t628 = parse_config_key_value(parser) + item14 = _t628 + pop_path!(parser) + push!(xs12, item14) + idx15 = (idx15 + 1) + cond13 = match_lookahead_literal(parser, ":", 0) + end + config_key_values16 = xs12 consume_literal!(parser, "}") - return config_key_values10 + result18 = config_key_values16 + record_span!(parser, span_start17) + return result18 end function parse_config_key_value(parser::Parser)::Tuple{String, Proto.Value} + span_start21 = span_start(parser) consume_literal!(parser, ":") - symbol11 = consume_terminal!(parser, "SYMBOL") - _t363 = parse_value(parser) - value12 = _t363 - return (symbol11, value12,) + symbol19 = consume_terminal!(parser, "SYMBOL") + _t629 = parse_value(parser) + value20 = _t629 + result22 = (symbol19, value20,) + record_span!(parser, span_start21) + return result22 end function parse_value(parser::Parser)::Proto.Value + span_start33 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t364 = 9 + _t630 = 9 else if match_lookahead_literal(parser, "missing", 0) - _t365 = 8 + _t631 = 8 else if match_lookahead_literal(parser, "false", 0) - _t366 = 9 + _t632 = 9 else if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "datetime", 1) - _t368 = 1 + _t634 = 1 else if match_lookahead_literal(parser, "date", 1) - _t369 = 0 + _t635 = 0 else - _t369 = -1 + _t635 = -1 end - _t368 = _t369 + _t634 = _t635 end - _t367 = _t368 + _t633 = _t634 else if match_lookahead_terminal(parser, "UINT128", 0) - _t370 = 5 + _t636 = 5 else if match_lookahead_terminal(parser, "STRING", 0) - _t371 = 2 + _t637 = 2 else if match_lookahead_terminal(parser, "INT128", 0) - _t372 = 6 + _t638 = 6 else if match_lookahead_terminal(parser, "INT", 0) - _t373 = 3 + _t639 = 3 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t374 = 4 + _t640 = 4 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t375 = 7 + _t641 = 7 else - _t375 = -1 + _t641 = -1 end - _t374 = _t375 + _t640 = _t641 end - _t373 = _t374 + _t639 = _t640 end - _t372 = _t373 + _t638 = _t639 end - _t371 = _t372 + _t637 = _t638 end - _t370 = _t371 + _t636 = _t637 end - _t367 = _t370 + _t633 = _t636 end - _t366 = _t367 + _t632 = _t633 end - _t365 = _t366 + _t631 = _t632 end - _t364 = _t365 + _t630 = _t631 end - prediction13 = _t364 + prediction23 = _t630 - if prediction13 == 9 - _t377 = parse_boolean_value(parser) - boolean_value22 = _t377 - _t378 = Proto.Value(value=OneOf(:boolean_value, boolean_value22)) - _t376 = _t378 + if prediction23 == 9 + _t643 = parse_boolean_value(parser) + boolean_value32 = _t643 + _t644 = Proto.Value(value=OneOf(:boolean_value, boolean_value32)) + _t642 = _t644 else - if prediction13 == 8 + if prediction23 == 8 consume_literal!(parser, "missing") - _t380 = Proto.MissingValue() - _t381 = Proto.Value(value=OneOf(:missing_value, _t380)) - _t379 = _t381 + _t646 = Proto.MissingValue() + _t647 = Proto.Value(value=OneOf(:missing_value, _t646)) + _t645 = _t647 else - if prediction13 == 7 - decimal21 = consume_terminal!(parser, "DECIMAL") - _t383 = Proto.Value(value=OneOf(:decimal_value, decimal21)) - _t382 = _t383 + if prediction23 == 7 + decimal31 = consume_terminal!(parser, "DECIMAL") + _t649 = Proto.Value(value=OneOf(:decimal_value, decimal31)) + _t648 = _t649 else - if prediction13 == 6 - int12820 = consume_terminal!(parser, "INT128") - _t385 = Proto.Value(value=OneOf(:int128_value, int12820)) - _t384 = _t385 + if prediction23 == 6 + int12830 = consume_terminal!(parser, "INT128") + _t651 = Proto.Value(value=OneOf(:int128_value, int12830)) + _t650 = _t651 else - if prediction13 == 5 - uint12819 = consume_terminal!(parser, "UINT128") - _t387 = Proto.Value(value=OneOf(:uint128_value, uint12819)) - _t386 = _t387 + if prediction23 == 5 + uint12829 = consume_terminal!(parser, "UINT128") + _t653 = Proto.Value(value=OneOf(:uint128_value, uint12829)) + _t652 = _t653 else - if prediction13 == 4 - float18 = consume_terminal!(parser, "FLOAT") - _t389 = Proto.Value(value=OneOf(:float_value, float18)) - _t388 = _t389 + if prediction23 == 4 + float28 = consume_terminal!(parser, "FLOAT") + _t655 = Proto.Value(value=OneOf(:float_value, float28)) + _t654 = _t655 else - if prediction13 == 3 - int17 = consume_terminal!(parser, "INT") - _t391 = Proto.Value(value=OneOf(:int_value, int17)) - _t390 = _t391 + if prediction23 == 3 + int27 = consume_terminal!(parser, "INT") + _t657 = Proto.Value(value=OneOf(:int_value, int27)) + _t656 = _t657 else - if prediction13 == 2 - string16 = consume_terminal!(parser, "STRING") - _t393 = Proto.Value(value=OneOf(:string_value, string16)) - _t392 = _t393 + if prediction23 == 2 + string26 = consume_terminal!(parser, "STRING") + _t659 = Proto.Value(value=OneOf(:string_value, string26)) + _t658 = _t659 else - if prediction13 == 1 - _t395 = parse_datetime(parser) - datetime15 = _t395 - _t396 = Proto.Value(value=OneOf(:datetime_value, datetime15)) - _t394 = _t396 + if prediction23 == 1 + _t661 = parse_datetime(parser) + datetime25 = _t661 + _t662 = Proto.Value(value=OneOf(:datetime_value, datetime25)) + _t660 = _t662 else - if prediction13 == 0 - _t398 = parse_date(parser) - date14 = _t398 - _t399 = Proto.Value(value=OneOf(:date_value, date14)) - _t397 = _t399 + if prediction23 == 0 + _t664 = parse_date(parser) + date24 = _t664 + _t665 = Proto.Value(value=OneOf(:date_value, date24)) + _t663 = _t665 else throw(ParseError("Unexpected token in value" * ": " * string(lookahead(parser, 0)))) end - _t394 = _t397 + _t660 = _t663 end - _t392 = _t394 + _t658 = _t660 end - _t390 = _t392 + _t656 = _t658 end - _t388 = _t390 + _t654 = _t656 end - _t386 = _t388 + _t652 = _t654 end - _t384 = _t386 + _t650 = _t652 end - _t382 = _t384 + _t648 = _t650 end - _t379 = _t382 + _t645 = _t648 end - _t376 = _t379 + _t642 = _t645 end - return _t376 + result34 = _t642 + record_span!(parser, span_start33) + return result34 end function parse_date(parser::Parser)::Proto.DateValue + span_start38 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "date") - int23 = consume_terminal!(parser, "INT") - int_324 = consume_terminal!(parser, "INT") - int_425 = consume_terminal!(parser, "INT") + push_path!(parser, 1) + int35 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_336 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_437 = consume_terminal!(parser, "INT") + pop_path!(parser) consume_literal!(parser, ")") - _t400 = Proto.DateValue(year=Int32(int23), month=Int32(int_324), day=Int32(int_425)) - return _t400 + _t666 = Proto.DateValue(year=Int32(int35), month=Int32(int_336), day=Int32(int_437)) + result39 = _t666 + record_span!(parser, span_start38) + return result39 end function parse_datetime(parser::Parser)::Proto.DateTimeValue + span_start47 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "datetime") - int26 = consume_terminal!(parser, "INT") - int_327 = consume_terminal!(parser, "INT") - int_428 = consume_terminal!(parser, "INT") - int_529 = consume_terminal!(parser, "INT") - int_630 = consume_terminal!(parser, "INT") - int_731 = consume_terminal!(parser, "INT") + push_path!(parser, 1) + int40 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_341 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_442 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 4) + int_543 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 5) + int_644 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 6) + int_745 = consume_terminal!(parser, "INT") + pop_path!(parser) if match_lookahead_terminal(parser, "INT", 0) - _t401 = consume_terminal!(parser, "INT") + _t667 = consume_terminal!(parser, "INT") else - _t401 = nothing + _t667 = nothing end - int_832 = _t401 + int_846 = _t667 consume_literal!(parser, ")") - _t402 = Proto.DateTimeValue(year=Int32(int26), month=Int32(int_327), day=Int32(int_428), hour=Int32(int_529), minute=Int32(int_630), second=Int32(int_731), microsecond=Int32((!isnothing(int_832) ? int_832 : 0))) - return _t402 + _t668 = Proto.DateTimeValue(year=Int32(int40), month=Int32(int_341), day=Int32(int_442), hour=Int32(int_543), minute=Int32(int_644), second=Int32(int_745), microsecond=Int32((!isnothing(int_846) ? int_846 : 0))) + result48 = _t668 + record_span!(parser, span_start47) + return result48 end function parse_boolean_value(parser::Parser)::Bool + span_start50 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t403 = 0 + _t669 = 0 else if match_lookahead_literal(parser, "false", 0) - _t404 = 1 + _t670 = 1 else - _t404 = -1 + _t670 = -1 end - _t403 = _t404 + _t669 = _t670 end - prediction33 = _t403 + prediction49 = _t669 - if prediction33 == 1 + if prediction49 == 1 consume_literal!(parser, "false") - _t405 = false + _t671 = false else - if prediction33 == 0 + if prediction49 == 0 consume_literal!(parser, "true") - _t406 = true + _t672 = true else throw(ParseError("Unexpected token in boolean_value" * ": " * string(lookahead(parser, 0)))) end - _t405 = _t406 + _t671 = _t672 end - return _t405 + result51 = _t671 + record_span!(parser, span_start50) + return result51 end function parse_sync(parser::Parser)::Proto.Sync + span_start57 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sync") - xs34 = Proto.FragmentId[] - cond35 = match_lookahead_literal(parser, ":", 0) - while cond35 - _t407 = parse_fragment_id(parser) - item36 = _t407 - push!(xs34, item36) - cond35 = match_lookahead_literal(parser, ":", 0) + push_path!(parser, 1) + xs52 = Proto.FragmentId[] + cond53 = match_lookahead_literal(parser, ":", 0) + idx55 = 0 + while cond53 + push_path!(parser, idx55) + _t673 = parse_fragment_id(parser) + item54 = _t673 + pop_path!(parser) + push!(xs52, item54) + idx55 = (idx55 + 1) + cond53 = match_lookahead_literal(parser, ":", 0) end - fragment_ids37 = xs34 + pop_path!(parser) + fragment_ids56 = xs52 consume_literal!(parser, ")") - _t408 = Proto.Sync(fragments=fragment_ids37) - return _t408 + _t674 = Proto.Sync(fragments=fragment_ids56) + result58 = _t674 + record_span!(parser, span_start57) + return result58 end function parse_fragment_id(parser::Parser)::Proto.FragmentId + span_start60 = span_start(parser) consume_literal!(parser, ":") - symbol38 = consume_terminal!(parser, "SYMBOL") - return Proto.FragmentId(Vector{UInt8}(symbol38)) + symbol59 = consume_terminal!(parser, "SYMBOL") + result61 = Proto.FragmentId(Vector{UInt8}(symbol59)) + record_span!(parser, span_start60) + return result61 end function parse_epoch(parser::Parser)::Proto.Epoch + span_start64 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "epoch") + push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "writes", 1)) - _t410 = parse_epoch_writes(parser) - _t409 = _t410 + _t676 = parse_epoch_writes(parser) + _t675 = _t676 else - _t409 = nothing + _t675 = nothing end - epoch_writes39 = _t409 + epoch_writes62 = _t675 + pop_path!(parser) + push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t412 = parse_epoch_reads(parser) - _t411 = _t412 + _t678 = parse_epoch_reads(parser) + _t677 = _t678 else - _t411 = nothing + _t677 = nothing end - epoch_reads40 = _t411 + epoch_reads63 = _t677 + pop_path!(parser) consume_literal!(parser, ")") - _t413 = Proto.Epoch(writes=(!isnothing(epoch_writes39) ? epoch_writes39 : Proto.Write[]), reads=(!isnothing(epoch_reads40) ? epoch_reads40 : Proto.Read[])) - return _t413 + _t679 = Proto.Epoch(writes=(!isnothing(epoch_writes62) ? epoch_writes62 : Proto.Write[]), reads=(!isnothing(epoch_reads63) ? epoch_reads63 : Proto.Read[])) + result65 = _t679 + record_span!(parser, span_start64) + return result65 end function parse_epoch_writes(parser::Parser)::Vector{Proto.Write} + span_start71 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "writes") - xs41 = Proto.Write[] - cond42 = match_lookahead_literal(parser, "(", 0) - while cond42 - _t414 = parse_write(parser) - item43 = _t414 - push!(xs41, item43) - cond42 = match_lookahead_literal(parser, "(", 0) + xs66 = Proto.Write[] + cond67 = match_lookahead_literal(parser, "(", 0) + idx69 = 0 + while cond67 + push_path!(parser, idx69) + _t680 = parse_write(parser) + item68 = _t680 + pop_path!(parser) + push!(xs66, item68) + idx69 = (idx69 + 1) + cond67 = match_lookahead_literal(parser, "(", 0) end - writes44 = xs41 + writes70 = xs66 consume_literal!(parser, ")") - return writes44 + result72 = writes70 + record_span!(parser, span_start71) + return result72 end function parse_write(parser::Parser)::Proto.Write + span_start77 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "undefine", 1) - _t416 = 1 + _t682 = 1 else if match_lookahead_literal(parser, "define", 1) - _t417 = 0 + _t683 = 0 else if match_lookahead_literal(parser, "context", 1) - _t418 = 2 + _t684 = 2 else - _t418 = -1 + _t684 = -1 end - _t417 = _t418 + _t683 = _t684 end - _t416 = _t417 + _t682 = _t683 end - _t415 = _t416 + _t681 = _t682 else - _t415 = -1 + _t681 = -1 end - prediction45 = _t415 + prediction73 = _t681 - if prediction45 == 2 - _t420 = parse_context(parser) - context48 = _t420 - _t421 = Proto.Write(write_type=OneOf(:context, context48)) - _t419 = _t421 + if prediction73 == 2 + _t686 = parse_context(parser) + context76 = _t686 + _t687 = Proto.Write(write_type=OneOf(:context, context76)) + _t685 = _t687 else - if prediction45 == 1 - _t423 = parse_undefine(parser) - undefine47 = _t423 - _t424 = Proto.Write(write_type=OneOf(:undefine, undefine47)) - _t422 = _t424 + if prediction73 == 1 + _t689 = parse_undefine(parser) + undefine75 = _t689 + _t690 = Proto.Write(write_type=OneOf(:undefine, undefine75)) + _t688 = _t690 else - if prediction45 == 0 - _t426 = parse_define(parser) - define46 = _t426 - _t427 = Proto.Write(write_type=OneOf(:define, define46)) - _t425 = _t427 + if prediction73 == 0 + _t692 = parse_define(parser) + define74 = _t692 + _t693 = Proto.Write(write_type=OneOf(:define, define74)) + _t691 = _t693 else throw(ParseError("Unexpected token in write" * ": " * string(lookahead(parser, 0)))) end - _t422 = _t425 + _t688 = _t691 end - _t419 = _t422 + _t685 = _t688 end - return _t419 + result78 = _t685 + record_span!(parser, span_start77) + return result78 end function parse_define(parser::Parser)::Proto.Define + span_start80 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "define") - _t428 = parse_fragment(parser) - fragment49 = _t428 + push_path!(parser, 1) + _t694 = parse_fragment(parser) + fragment79 = _t694 + pop_path!(parser) consume_literal!(parser, ")") - _t429 = Proto.Define(fragment=fragment49) - return _t429 + _t695 = Proto.Define(fragment=fragment79) + result81 = _t695 + record_span!(parser, span_start80) + return result81 end function parse_fragment(parser::Parser)::Proto.Fragment + span_start88 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "fragment") - _t430 = parse_new_fragment_id(parser) - new_fragment_id50 = _t430 - xs51 = Proto.Declaration[] - cond52 = match_lookahead_literal(parser, "(", 0) - while cond52 - _t431 = parse_declaration(parser) - item53 = _t431 - push!(xs51, item53) - cond52 = match_lookahead_literal(parser, "(", 0) + _t696 = parse_new_fragment_id(parser) + new_fragment_id82 = _t696 + xs83 = Proto.Declaration[] + cond84 = match_lookahead_literal(parser, "(", 0) + idx86 = 0 + while cond84 + push_path!(parser, idx86) + _t697 = parse_declaration(parser) + item85 = _t697 + pop_path!(parser) + push!(xs83, item85) + idx86 = (idx86 + 1) + cond84 = match_lookahead_literal(parser, "(", 0) end - declarations54 = xs51 + declarations87 = xs83 consume_literal!(parser, ")") - return construct_fragment(parser, new_fragment_id50, declarations54) + result89 = construct_fragment(parser, new_fragment_id82, declarations87) + record_span!(parser, span_start88) + return result89 end function parse_new_fragment_id(parser::Parser)::Proto.FragmentId - _t432 = parse_fragment_id(parser) - fragment_id55 = _t432 - start_fragment!(parser, fragment_id55) - return fragment_id55 + span_start91 = span_start(parser) + _t698 = parse_fragment_id(parser) + fragment_id90 = _t698 + start_fragment!(parser, fragment_id90) + result92 = fragment_id90 + record_span!(parser, span_start91) + return result92 end function parse_declaration(parser::Parser)::Proto.Declaration + span_start98 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t434 = 3 + _t700 = 3 else if match_lookahead_literal(parser, "functional_dependency", 1) - _t435 = 2 + _t701 = 2 else if match_lookahead_literal(parser, "def", 1) - _t436 = 0 + _t702 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t437 = 3 + _t703 = 3 else if match_lookahead_literal(parser, "betree_relation", 1) - _t438 = 3 + _t704 = 3 else if match_lookahead_literal(parser, "algorithm", 1) - _t439 = 1 + _t705 = 1 else - _t439 = -1 + _t705 = -1 end - _t438 = _t439 + _t704 = _t705 end - _t437 = _t438 + _t703 = _t704 end - _t436 = _t437 + _t702 = _t703 end - _t435 = _t436 + _t701 = _t702 end - _t434 = _t435 + _t700 = _t701 end - _t433 = _t434 + _t699 = _t700 else - _t433 = -1 + _t699 = -1 end - prediction56 = _t433 + prediction93 = _t699 - if prediction56 == 3 - _t441 = parse_data(parser) - data60 = _t441 - _t442 = Proto.Declaration(declaration_type=OneOf(:data, data60)) - _t440 = _t442 + if prediction93 == 3 + _t707 = parse_data(parser) + data97 = _t707 + _t708 = Proto.Declaration(declaration_type=OneOf(:data, data97)) + _t706 = _t708 else - if prediction56 == 2 - _t444 = parse_constraint(parser) - constraint59 = _t444 - _t445 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint59)) - _t443 = _t445 + if prediction93 == 2 + _t710 = parse_constraint(parser) + constraint96 = _t710 + _t711 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint96)) + _t709 = _t711 else - if prediction56 == 1 - _t447 = parse_algorithm(parser) - algorithm58 = _t447 - _t448 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm58)) - _t446 = _t448 + if prediction93 == 1 + _t713 = parse_algorithm(parser) + algorithm95 = _t713 + _t714 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm95)) + _t712 = _t714 else - if prediction56 == 0 - _t450 = parse_def(parser) - def57 = _t450 - _t451 = Proto.Declaration(declaration_type=OneOf(:def, def57)) - _t449 = _t451 + if prediction93 == 0 + _t716 = parse_def(parser) + def94 = _t716 + _t717 = Proto.Declaration(declaration_type=OneOf(:def, def94)) + _t715 = _t717 else throw(ParseError("Unexpected token in declaration" * ": " * string(lookahead(parser, 0)))) end - _t446 = _t449 + _t712 = _t715 end - _t443 = _t446 + _t709 = _t712 end - _t440 = _t443 + _t706 = _t709 end - return _t440 + result99 = _t706 + record_span!(parser, span_start98) + return result99 end function parse_def(parser::Parser)::Proto.Def + span_start103 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "def") - _t452 = parse_relation_id(parser) - relation_id61 = _t452 - _t453 = parse_abstraction(parser) - abstraction62 = _t453 + push_path!(parser, 1) + _t718 = parse_relation_id(parser) + relation_id100 = _t718 + pop_path!(parser) + push_path!(parser, 2) + _t719 = parse_abstraction(parser) + abstraction101 = _t719 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t455 = parse_attrs(parser) - _t454 = _t455 + _t721 = parse_attrs(parser) + _t720 = _t721 else - _t454 = nothing + _t720 = nothing end - attrs63 = _t454 + attrs102 = _t720 + pop_path!(parser) consume_literal!(parser, ")") - _t456 = Proto.Def(name=relation_id61, body=abstraction62, attrs=(!isnothing(attrs63) ? attrs63 : Proto.Attribute[])) - return _t456 + _t722 = Proto.Def(name=relation_id100, body=abstraction101, attrs=(!isnothing(attrs102) ? attrs102 : Proto.Attribute[])) + result104 = _t722 + record_span!(parser, span_start103) + return result104 end function parse_relation_id(parser::Parser)::Proto.RelationId + span_start108 = span_start(parser) if match_lookahead_literal(parser, ":", 0) - _t457 = 0 + _t723 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t458 = 1 + _t724 = 1 else - _t458 = -1 + _t724 = -1 end - _t457 = _t458 + _t723 = _t724 end - prediction64 = _t457 + prediction105 = _t723 - if prediction64 == 1 - uint12866 = consume_terminal!(parser, "UINT128") - _t459 = Proto.RelationId(uint12866.low, uint12866.high) + if prediction105 == 1 + uint128107 = consume_terminal!(parser, "UINT128") + _t725 = Proto.RelationId(uint128107.low, uint128107.high) else - if prediction64 == 0 + if prediction105 == 0 consume_literal!(parser, ":") - symbol65 = consume_terminal!(parser, "SYMBOL") - _t460 = relation_id_from_string(parser, symbol65) + symbol106 = consume_terminal!(parser, "SYMBOL") + _t726 = relation_id_from_string(parser, symbol106) else throw(ParseError("Unexpected token in relation_id" * ": " * string(lookahead(parser, 0)))) end - _t459 = _t460 + _t725 = _t726 end - return _t459 + result109 = _t725 + record_span!(parser, span_start108) + return result109 end function parse_abstraction(parser::Parser)::Proto.Abstraction + span_start112 = span_start(parser) consume_literal!(parser, "(") - _t461 = parse_bindings(parser) - bindings67 = _t461 - _t462 = parse_formula(parser) - formula68 = _t462 + _t727 = parse_bindings(parser) + bindings110 = _t727 + push_path!(parser, 2) + _t728 = parse_formula(parser) + formula111 = _t728 + pop_path!(parser) consume_literal!(parser, ")") - _t463 = Proto.Abstraction(vars=vcat(bindings67[1], !isnothing(bindings67[2]) ? bindings67[2] : []), value=formula68) - return _t463 + _t729 = Proto.Abstraction(vars=vcat(bindings110[1], !isnothing(bindings110[2]) ? bindings110[2] : []), value=formula111) + result113 = _t729 + record_span!(parser, span_start112) + return result113 end function parse_bindings(parser::Parser)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} + span_start120 = span_start(parser) consume_literal!(parser, "[") - xs69 = Proto.Binding[] - cond70 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond70 - _t464 = parse_binding(parser) - item71 = _t464 - push!(xs69, item71) - cond70 = match_lookahead_terminal(parser, "SYMBOL", 0) - end - bindings72 = xs69 + xs114 = Proto.Binding[] + cond115 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx117 = 0 + while cond115 + push_path!(parser, idx117) + _t730 = parse_binding(parser) + item116 = _t730 + pop_path!(parser) + push!(xs114, item116) + idx117 = (idx117 + 1) + cond115 = match_lookahead_terminal(parser, "SYMBOL", 0) + end + bindings118 = xs114 if match_lookahead_literal(parser, "|", 0) - _t466 = parse_value_bindings(parser) - _t465 = _t466 + _t732 = parse_value_bindings(parser) + _t731 = _t732 else - _t465 = nothing + _t731 = nothing end - value_bindings73 = _t465 + value_bindings119 = _t731 consume_literal!(parser, "]") - return (bindings72, (!isnothing(value_bindings73) ? value_bindings73 : Proto.Binding[]),) + result121 = (bindings118, (!isnothing(value_bindings119) ? value_bindings119 : Proto.Binding[]),) + record_span!(parser, span_start120) + return result121 end function parse_binding(parser::Parser)::Proto.Binding - symbol74 = consume_terminal!(parser, "SYMBOL") + span_start124 = span_start(parser) + symbol122 = consume_terminal!(parser, "SYMBOL") consume_literal!(parser, "::") - _t467 = parse_type(parser) - type75 = _t467 - _t468 = Proto.Var(name=symbol74) - _t469 = Proto.Binding(var=_t468, var"#type"=type75) - return _t469 + push_path!(parser, 2) + _t733 = parse_type(parser) + type123 = _t733 + pop_path!(parser) + _t734 = Proto.Var(name=symbol122) + _t735 = Proto.Binding(var=_t734, var"#type"=type123) + result125 = _t735 + record_span!(parser, span_start124) + return result125 end function parse_type(parser::Parser)::Proto.var"#Type" + span_start138 = span_start(parser) if match_lookahead_literal(parser, "UNKNOWN", 0) - _t470 = 0 + _t736 = 0 else if match_lookahead_literal(parser, "UINT128", 0) - _t471 = 4 + _t737 = 4 else if match_lookahead_literal(parser, "STRING", 0) - _t472 = 1 + _t738 = 1 else if match_lookahead_literal(parser, "MISSING", 0) - _t473 = 8 + _t739 = 8 else if match_lookahead_literal(parser, "INT128", 0) - _t474 = 5 + _t740 = 5 else if match_lookahead_literal(parser, "INT", 0) - _t475 = 2 + _t741 = 2 else if match_lookahead_literal(parser, "FLOAT", 0) - _t476 = 3 + _t742 = 3 else if match_lookahead_literal(parser, "DATETIME", 0) - _t477 = 7 + _t743 = 7 else if match_lookahead_literal(parser, "DATE", 0) - _t478 = 6 + _t744 = 6 else if match_lookahead_literal(parser, "BOOLEAN", 0) - _t479 = 10 + _t745 = 10 else if match_lookahead_literal(parser, "(", 0) - _t480 = 9 + _t746 = 9 else - _t480 = -1 + _t746 = -1 end - _t479 = _t480 + _t745 = _t746 end - _t478 = _t479 + _t744 = _t745 end - _t477 = _t478 + _t743 = _t744 end - _t476 = _t477 + _t742 = _t743 end - _t475 = _t476 + _t741 = _t742 end - _t474 = _t475 + _t740 = _t741 end - _t473 = _t474 + _t739 = _t740 end - _t472 = _t473 + _t738 = _t739 end - _t471 = _t472 + _t737 = _t738 end - _t470 = _t471 + _t736 = _t737 end - prediction76 = _t470 + prediction126 = _t736 - if prediction76 == 10 - _t482 = parse_boolean_type(parser) - boolean_type87 = _t482 - _t483 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type87)) - _t481 = _t483 + if prediction126 == 10 + _t748 = parse_boolean_type(parser) + boolean_type137 = _t748 + _t749 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type137)) + _t747 = _t749 else - if prediction76 == 9 - _t485 = parse_decimal_type(parser) - decimal_type86 = _t485 - _t486 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type86)) - _t484 = _t486 + if prediction126 == 9 + _t751 = parse_decimal_type(parser) + decimal_type136 = _t751 + _t752 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type136)) + _t750 = _t752 else - if prediction76 == 8 - _t488 = parse_missing_type(parser) - missing_type85 = _t488 - _t489 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type85)) - _t487 = _t489 + if prediction126 == 8 + _t754 = parse_missing_type(parser) + missing_type135 = _t754 + _t755 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type135)) + _t753 = _t755 else - if prediction76 == 7 - _t491 = parse_datetime_type(parser) - datetime_type84 = _t491 - _t492 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type84)) - _t490 = _t492 + if prediction126 == 7 + _t757 = parse_datetime_type(parser) + datetime_type134 = _t757 + _t758 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type134)) + _t756 = _t758 else - if prediction76 == 6 - _t494 = parse_date_type(parser) - date_type83 = _t494 - _t495 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type83)) - _t493 = _t495 + if prediction126 == 6 + _t760 = parse_date_type(parser) + date_type133 = _t760 + _t761 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type133)) + _t759 = _t761 else - if prediction76 == 5 - _t497 = parse_int128_type(parser) - int128_type82 = _t497 - _t498 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type82)) - _t496 = _t498 + if prediction126 == 5 + _t763 = parse_int128_type(parser) + int128_type132 = _t763 + _t764 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type132)) + _t762 = _t764 else - if prediction76 == 4 - _t500 = parse_uint128_type(parser) - uint128_type81 = _t500 - _t501 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type81)) - _t499 = _t501 + if prediction126 == 4 + _t766 = parse_uint128_type(parser) + uint128_type131 = _t766 + _t767 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type131)) + _t765 = _t767 else - if prediction76 == 3 - _t503 = parse_float_type(parser) - float_type80 = _t503 - _t504 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type80)) - _t502 = _t504 + if prediction126 == 3 + _t769 = parse_float_type(parser) + float_type130 = _t769 + _t770 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type130)) + _t768 = _t770 else - if prediction76 == 2 - _t506 = parse_int_type(parser) - int_type79 = _t506 - _t507 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type79)) - _t505 = _t507 + if prediction126 == 2 + _t772 = parse_int_type(parser) + int_type129 = _t772 + _t773 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type129)) + _t771 = _t773 else - if prediction76 == 1 - _t509 = parse_string_type(parser) - string_type78 = _t509 - _t510 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type78)) - _t508 = _t510 + if prediction126 == 1 + _t775 = parse_string_type(parser) + string_type128 = _t775 + _t776 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type128)) + _t774 = _t776 else - if prediction76 == 0 - _t512 = parse_unspecified_type(parser) - unspecified_type77 = _t512 - _t513 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type77)) - _t511 = _t513 + if prediction126 == 0 + _t778 = parse_unspecified_type(parser) + unspecified_type127 = _t778 + _t779 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type127)) + _t777 = _t779 else throw(ParseError("Unexpected token in type" * ": " * string(lookahead(parser, 0)))) end - _t508 = _t511 + _t774 = _t777 end - _t505 = _t508 + _t771 = _t774 end - _t502 = _t505 + _t768 = _t771 end - _t499 = _t502 + _t765 = _t768 end - _t496 = _t499 + _t762 = _t765 end - _t493 = _t496 + _t759 = _t762 end - _t490 = _t493 + _t756 = _t759 end - _t487 = _t490 + _t753 = _t756 end - _t484 = _t487 + _t750 = _t753 end - _t481 = _t484 + _t747 = _t750 end - return _t481 + result139 = _t747 + record_span!(parser, span_start138) + return result139 end function parse_unspecified_type(parser::Parser)::Proto.UnspecifiedType + span_start140 = span_start(parser) consume_literal!(parser, "UNKNOWN") - _t514 = Proto.UnspecifiedType() - return _t514 + _t780 = Proto.UnspecifiedType() + result141 = _t780 + record_span!(parser, span_start140) + return result141 end function parse_string_type(parser::Parser)::Proto.StringType + span_start142 = span_start(parser) consume_literal!(parser, "STRING") - _t515 = Proto.StringType() - return _t515 + _t781 = Proto.StringType() + result143 = _t781 + record_span!(parser, span_start142) + return result143 end function parse_int_type(parser::Parser)::Proto.IntType + span_start144 = span_start(parser) consume_literal!(parser, "INT") - _t516 = Proto.IntType() - return _t516 + _t782 = Proto.IntType() + result145 = _t782 + record_span!(parser, span_start144) + return result145 end function parse_float_type(parser::Parser)::Proto.FloatType + span_start146 = span_start(parser) consume_literal!(parser, "FLOAT") - _t517 = Proto.FloatType() - return _t517 + _t783 = Proto.FloatType() + result147 = _t783 + record_span!(parser, span_start146) + return result147 end function parse_uint128_type(parser::Parser)::Proto.UInt128Type + span_start148 = span_start(parser) consume_literal!(parser, "UINT128") - _t518 = Proto.UInt128Type() - return _t518 + _t784 = Proto.UInt128Type() + result149 = _t784 + record_span!(parser, span_start148) + return result149 end function parse_int128_type(parser::Parser)::Proto.Int128Type + span_start150 = span_start(parser) consume_literal!(parser, "INT128") - _t519 = Proto.Int128Type() - return _t519 + _t785 = Proto.Int128Type() + result151 = _t785 + record_span!(parser, span_start150) + return result151 end function parse_date_type(parser::Parser)::Proto.DateType + span_start152 = span_start(parser) consume_literal!(parser, "DATE") - _t520 = Proto.DateType() - return _t520 + _t786 = Proto.DateType() + result153 = _t786 + record_span!(parser, span_start152) + return result153 end function parse_datetime_type(parser::Parser)::Proto.DateTimeType + span_start154 = span_start(parser) consume_literal!(parser, "DATETIME") - _t521 = Proto.DateTimeType() - return _t521 + _t787 = Proto.DateTimeType() + result155 = _t787 + record_span!(parser, span_start154) + return result155 end function parse_missing_type(parser::Parser)::Proto.MissingType + span_start156 = span_start(parser) consume_literal!(parser, "MISSING") - _t522 = Proto.MissingType() - return _t522 + _t788 = Proto.MissingType() + result157 = _t788 + record_span!(parser, span_start156) + return result157 end function parse_decimal_type(parser::Parser)::Proto.DecimalType + span_start160 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "DECIMAL") - int88 = consume_terminal!(parser, "INT") - int_389 = consume_terminal!(parser, "INT") + push_path!(parser, 1) + int158 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3159 = consume_terminal!(parser, "INT") + pop_path!(parser) consume_literal!(parser, ")") - _t523 = Proto.DecimalType(precision=Int32(int88), scale=Int32(int_389)) - return _t523 + _t789 = Proto.DecimalType(precision=Int32(int158), scale=Int32(int_3159)) + result161 = _t789 + record_span!(parser, span_start160) + return result161 end function parse_boolean_type(parser::Parser)::Proto.BooleanType + span_start162 = span_start(parser) consume_literal!(parser, "BOOLEAN") - _t524 = Proto.BooleanType() - return _t524 + _t790 = Proto.BooleanType() + result163 = _t790 + record_span!(parser, span_start162) + return result163 end function parse_value_bindings(parser::Parser)::Vector{Proto.Binding} + span_start169 = span_start(parser) consume_literal!(parser, "|") - xs90 = Proto.Binding[] - cond91 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond91 - _t525 = parse_binding(parser) - item92 = _t525 - push!(xs90, item92) - cond91 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs164 = Proto.Binding[] + cond165 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx167 = 0 + while cond165 + push_path!(parser, idx167) + _t791 = parse_binding(parser) + item166 = _t791 + pop_path!(parser) + push!(xs164, item166) + idx167 = (idx167 + 1) + cond165 = match_lookahead_terminal(parser, "SYMBOL", 0) end - bindings93 = xs90 - return bindings93 + bindings168 = xs164 + result170 = bindings168 + record_span!(parser, span_start169) + return result170 end function parse_formula(parser::Parser)::Proto.Formula + span_start185 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "true", 1) - _t527 = 0 + _t793 = 0 else if match_lookahead_literal(parser, "relatom", 1) - _t528 = 11 + _t794 = 11 else if match_lookahead_literal(parser, "reduce", 1) - _t529 = 3 + _t795 = 3 else if match_lookahead_literal(parser, "primitive", 1) - _t530 = 10 + _t796 = 10 else if match_lookahead_literal(parser, "pragma", 1) - _t531 = 9 + _t797 = 9 else if match_lookahead_literal(parser, "or", 1) - _t532 = 5 + _t798 = 5 else if match_lookahead_literal(parser, "not", 1) - _t533 = 6 + _t799 = 6 else if match_lookahead_literal(parser, "ffi", 1) - _t534 = 7 + _t800 = 7 else if match_lookahead_literal(parser, "false", 1) - _t535 = 1 + _t801 = 1 else if match_lookahead_literal(parser, "exists", 1) - _t536 = 2 + _t802 = 2 else if match_lookahead_literal(parser, "cast", 1) - _t537 = 12 + _t803 = 12 else if match_lookahead_literal(parser, "atom", 1) - _t538 = 8 + _t804 = 8 else if match_lookahead_literal(parser, "and", 1) - _t539 = 4 + _t805 = 4 else if match_lookahead_literal(parser, ">=", 1) - _t540 = 10 + _t806 = 10 else if match_lookahead_literal(parser, ">", 1) - _t541 = 10 + _t807 = 10 else if match_lookahead_literal(parser, "=", 1) - _t542 = 10 + _t808 = 10 else if match_lookahead_literal(parser, "<=", 1) - _t543 = 10 + _t809 = 10 else if match_lookahead_literal(parser, "<", 1) - _t544 = 10 + _t810 = 10 else if match_lookahead_literal(parser, "/", 1) - _t545 = 10 + _t811 = 10 else if match_lookahead_literal(parser, "-", 1) - _t546 = 10 + _t812 = 10 else if match_lookahead_literal(parser, "+", 1) - _t547 = 10 + _t813 = 10 else if match_lookahead_literal(parser, "*", 1) - _t548 = 10 + _t814 = 10 else - _t548 = -1 + _t814 = -1 end - _t547 = _t548 + _t813 = _t814 end - _t546 = _t547 + _t812 = _t813 end - _t545 = _t546 + _t811 = _t812 end - _t544 = _t545 + _t810 = _t811 end - _t543 = _t544 + _t809 = _t810 end - _t542 = _t543 + _t808 = _t809 end - _t541 = _t542 + _t807 = _t808 end - _t540 = _t541 + _t806 = _t807 end - _t539 = _t540 + _t805 = _t806 end - _t538 = _t539 + _t804 = _t805 end - _t537 = _t538 + _t803 = _t804 end - _t536 = _t537 + _t802 = _t803 end - _t535 = _t536 + _t801 = _t802 end - _t534 = _t535 + _t800 = _t801 end - _t533 = _t534 + _t799 = _t800 end - _t532 = _t533 + _t798 = _t799 end - _t531 = _t532 + _t797 = _t798 end - _t530 = _t531 + _t796 = _t797 end - _t529 = _t530 + _t795 = _t796 end - _t528 = _t529 + _t794 = _t795 end - _t527 = _t528 + _t793 = _t794 end - _t526 = _t527 + _t792 = _t793 else - _t526 = -1 + _t792 = -1 end - prediction94 = _t526 + prediction171 = _t792 - if prediction94 == 12 - _t550 = parse_cast(parser) - cast107 = _t550 - _t551 = Proto.Formula(formula_type=OneOf(:cast, cast107)) - _t549 = _t551 + if prediction171 == 12 + _t816 = parse_cast(parser) + cast184 = _t816 + _t817 = Proto.Formula(formula_type=OneOf(:cast, cast184)) + _t815 = _t817 else - if prediction94 == 11 - _t553 = parse_rel_atom(parser) - rel_atom106 = _t553 - _t554 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom106)) - _t552 = _t554 + if prediction171 == 11 + _t819 = parse_rel_atom(parser) + rel_atom183 = _t819 + _t820 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom183)) + _t818 = _t820 else - if prediction94 == 10 - _t556 = parse_primitive(parser) - primitive105 = _t556 - _t557 = Proto.Formula(formula_type=OneOf(:primitive, primitive105)) - _t555 = _t557 + if prediction171 == 10 + _t822 = parse_primitive(parser) + primitive182 = _t822 + _t823 = Proto.Formula(formula_type=OneOf(:primitive, primitive182)) + _t821 = _t823 else - if prediction94 == 9 - _t559 = parse_pragma(parser) - pragma104 = _t559 - _t560 = Proto.Formula(formula_type=OneOf(:pragma, pragma104)) - _t558 = _t560 + if prediction171 == 9 + _t825 = parse_pragma(parser) + pragma181 = _t825 + _t826 = Proto.Formula(formula_type=OneOf(:pragma, pragma181)) + _t824 = _t826 else - if prediction94 == 8 - _t562 = parse_atom(parser) - atom103 = _t562 - _t563 = Proto.Formula(formula_type=OneOf(:atom, atom103)) - _t561 = _t563 + if prediction171 == 8 + _t828 = parse_atom(parser) + atom180 = _t828 + _t829 = Proto.Formula(formula_type=OneOf(:atom, atom180)) + _t827 = _t829 else - if prediction94 == 7 - _t565 = parse_ffi(parser) - ffi102 = _t565 - _t566 = Proto.Formula(formula_type=OneOf(:ffi, ffi102)) - _t564 = _t566 + if prediction171 == 7 + _t831 = parse_ffi(parser) + ffi179 = _t831 + _t832 = Proto.Formula(formula_type=OneOf(:ffi, ffi179)) + _t830 = _t832 else - if prediction94 == 6 - _t568 = parse_not(parser) - not101 = _t568 - _t569 = Proto.Formula(formula_type=OneOf(:not, not101)) - _t567 = _t569 + if prediction171 == 6 + _t834 = parse_not(parser) + not178 = _t834 + _t835 = Proto.Formula(formula_type=OneOf(:not, not178)) + _t833 = _t835 else - if prediction94 == 5 - _t571 = parse_disjunction(parser) - disjunction100 = _t571 - _t572 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction100)) - _t570 = _t572 + if prediction171 == 5 + _t837 = parse_disjunction(parser) + disjunction177 = _t837 + _t838 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction177)) + _t836 = _t838 else - if prediction94 == 4 - _t574 = parse_conjunction(parser) - conjunction99 = _t574 - _t575 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction99)) - _t573 = _t575 + if prediction171 == 4 + _t840 = parse_conjunction(parser) + conjunction176 = _t840 + _t841 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction176)) + _t839 = _t841 else - if prediction94 == 3 - _t577 = parse_reduce(parser) - reduce98 = _t577 - _t578 = Proto.Formula(formula_type=OneOf(:reduce, reduce98)) - _t576 = _t578 + if prediction171 == 3 + _t843 = parse_reduce(parser) + reduce175 = _t843 + _t844 = Proto.Formula(formula_type=OneOf(:reduce, reduce175)) + _t842 = _t844 else - if prediction94 == 2 - _t580 = parse_exists(parser) - exists97 = _t580 - _t581 = Proto.Formula(formula_type=OneOf(:exists, exists97)) - _t579 = _t581 + if prediction171 == 2 + _t846 = parse_exists(parser) + exists174 = _t846 + _t847 = Proto.Formula(formula_type=OneOf(:exists, exists174)) + _t845 = _t847 else - if prediction94 == 1 - _t583 = parse_false(parser) - false96 = _t583 - _t584 = Proto.Formula(formula_type=OneOf(:disjunction, false96)) - _t582 = _t584 + if prediction171 == 1 + _t849 = parse_false(parser) + false173 = _t849 + _t850 = Proto.Formula(formula_type=OneOf(:disjunction, false173)) + _t848 = _t850 else - if prediction94 == 0 - _t586 = parse_true(parser) - true95 = _t586 - _t587 = Proto.Formula(formula_type=OneOf(:conjunction, true95)) - _t585 = _t587 + if prediction171 == 0 + _t852 = parse_true(parser) + true172 = _t852 + _t853 = Proto.Formula(formula_type=OneOf(:conjunction, true172)) + _t851 = _t853 else throw(ParseError("Unexpected token in formula" * ": " * string(lookahead(parser, 0)))) end - _t582 = _t585 + _t848 = _t851 end - _t579 = _t582 + _t845 = _t848 end - _t576 = _t579 + _t842 = _t845 end - _t573 = _t576 + _t839 = _t842 end - _t570 = _t573 + _t836 = _t839 end - _t567 = _t570 + _t833 = _t836 end - _t564 = _t567 + _t830 = _t833 end - _t561 = _t564 + _t827 = _t830 end - _t558 = _t561 + _t824 = _t827 end - _t555 = _t558 + _t821 = _t824 end - _t552 = _t555 + _t818 = _t821 end - _t549 = _t552 + _t815 = _t818 end - return _t549 + result186 = _t815 + record_span!(parser, span_start185) + return result186 end function parse_true(parser::Parser)::Proto.Conjunction + span_start187 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "true") consume_literal!(parser, ")") - _t588 = Proto.Conjunction(args=Proto.Formula[]) - return _t588 + _t854 = Proto.Conjunction(args=Proto.Formula[]) + result188 = _t854 + record_span!(parser, span_start187) + return result188 end function parse_false(parser::Parser)::Proto.Disjunction + span_start189 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "false") consume_literal!(parser, ")") - _t589 = Proto.Disjunction(args=Proto.Formula[]) - return _t589 + _t855 = Proto.Disjunction(args=Proto.Formula[]) + result190 = _t855 + record_span!(parser, span_start189) + return result190 end function parse_exists(parser::Parser)::Proto.Exists + span_start193 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "exists") - _t590 = parse_bindings(parser) - bindings108 = _t590 - _t591 = parse_formula(parser) - formula109 = _t591 + _t856 = parse_bindings(parser) + bindings191 = _t856 + _t857 = parse_formula(parser) + formula192 = _t857 consume_literal!(parser, ")") - _t592 = Proto.Abstraction(vars=vcat(bindings108[1], !isnothing(bindings108[2]) ? bindings108[2] : []), value=formula109) - _t593 = Proto.Exists(body=_t592) - return _t593 + _t858 = Proto.Abstraction(vars=vcat(bindings191[1], !isnothing(bindings191[2]) ? bindings191[2] : []), value=formula192) + _t859 = Proto.Exists(body=_t858) + result194 = _t859 + record_span!(parser, span_start193) + return result194 end function parse_reduce(parser::Parser)::Proto.Reduce + span_start198 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reduce") - _t594 = parse_abstraction(parser) - abstraction110 = _t594 - _t595 = parse_abstraction(parser) - abstraction_3111 = _t595 - _t596 = parse_terms(parser) - terms112 = _t596 + push_path!(parser, 1) + _t860 = parse_abstraction(parser) + abstraction195 = _t860 + pop_path!(parser) + push_path!(parser, 2) + _t861 = parse_abstraction(parser) + abstraction_3196 = _t861 + pop_path!(parser) + push_path!(parser, 3) + _t862 = parse_terms(parser) + terms197 = _t862 + pop_path!(parser) consume_literal!(parser, ")") - _t597 = Proto.Reduce(op=abstraction110, body=abstraction_3111, terms=terms112) - return _t597 + _t863 = Proto.Reduce(op=abstraction195, body=abstraction_3196, terms=terms197) + result199 = _t863 + record_span!(parser, span_start198) + return result199 end function parse_terms(parser::Parser)::Vector{Proto.Term} + span_start205 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "terms") - xs113 = Proto.Term[] - cond114 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond114 - _t598 = parse_term(parser) - item115 = _t598 - push!(xs113, item115) - cond114 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + xs200 = Proto.Term[] + cond201 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx203 = 0 + while cond201 + push_path!(parser, idx203) + _t864 = parse_term(parser) + item202 = _t864 + pop_path!(parser) + push!(xs200, item202) + idx203 = (idx203 + 1) + cond201 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms116 = xs113 + terms204 = xs200 consume_literal!(parser, ")") - return terms116 + result206 = terms204 + record_span!(parser, span_start205) + return result206 end function parse_term(parser::Parser)::Proto.Term + span_start210 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t599 = 1 + _t865 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t600 = 1 + _t866 = 1 else if match_lookahead_literal(parser, "false", 0) - _t601 = 1 + _t867 = 1 else if match_lookahead_literal(parser, "(", 0) - _t602 = 1 + _t868 = 1 else if match_lookahead_terminal(parser, "UINT128", 0) - _t603 = 1 + _t869 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t604 = 0 + _t870 = 0 else if match_lookahead_terminal(parser, "STRING", 0) - _t605 = 1 + _t871 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t606 = 1 + _t872 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t607 = 1 + _t873 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t608 = 1 + _t874 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t609 = 1 + _t875 = 1 else - _t609 = -1 + _t875 = -1 end - _t608 = _t609 + _t874 = _t875 end - _t607 = _t608 + _t873 = _t874 end - _t606 = _t607 + _t872 = _t873 end - _t605 = _t606 + _t871 = _t872 end - _t604 = _t605 + _t870 = _t871 end - _t603 = _t604 + _t869 = _t870 end - _t602 = _t603 + _t868 = _t869 end - _t601 = _t602 + _t867 = _t868 end - _t600 = _t601 + _t866 = _t867 end - _t599 = _t600 + _t865 = _t866 end - prediction117 = _t599 + prediction207 = _t865 - if prediction117 == 1 - _t611 = parse_constant(parser) - constant119 = _t611 - _t612 = Proto.Term(term_type=OneOf(:constant, constant119)) - _t610 = _t612 + if prediction207 == 1 + _t877 = parse_constant(parser) + constant209 = _t877 + _t878 = Proto.Term(term_type=OneOf(:constant, constant209)) + _t876 = _t878 else - if prediction117 == 0 - _t614 = parse_var(parser) - var118 = _t614 - _t615 = Proto.Term(term_type=OneOf(:var, var118)) - _t613 = _t615 + if prediction207 == 0 + _t880 = parse_var(parser) + var208 = _t880 + _t881 = Proto.Term(term_type=OneOf(:var, var208)) + _t879 = _t881 else throw(ParseError("Unexpected token in term" * ": " * string(lookahead(parser, 0)))) end - _t610 = _t613 + _t876 = _t879 end - return _t610 + result211 = _t876 + record_span!(parser, span_start210) + return result211 end function parse_var(parser::Parser)::Proto.Var - symbol120 = consume_terminal!(parser, "SYMBOL") - _t616 = Proto.Var(name=symbol120) - return _t616 + span_start213 = span_start(parser) + symbol212 = consume_terminal!(parser, "SYMBOL") + _t882 = Proto.Var(name=symbol212) + result214 = _t882 + record_span!(parser, span_start213) + return result214 end function parse_constant(parser::Parser)::Proto.Value - _t617 = parse_value(parser) - value121 = _t617 - return value121 + span_start216 = span_start(parser) + _t883 = parse_value(parser) + value215 = _t883 + result217 = value215 + record_span!(parser, span_start216) + return result217 end function parse_conjunction(parser::Parser)::Proto.Conjunction + span_start223 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "and") - xs122 = Proto.Formula[] - cond123 = match_lookahead_literal(parser, "(", 0) - while cond123 - _t618 = parse_formula(parser) - item124 = _t618 - push!(xs122, item124) - cond123 = match_lookahead_literal(parser, "(", 0) + push_path!(parser, 1) + xs218 = Proto.Formula[] + cond219 = match_lookahead_literal(parser, "(", 0) + idx221 = 0 + while cond219 + push_path!(parser, idx221) + _t884 = parse_formula(parser) + item220 = _t884 + pop_path!(parser) + push!(xs218, item220) + idx221 = (idx221 + 1) + cond219 = match_lookahead_literal(parser, "(", 0) end - formulas125 = xs122 + pop_path!(parser) + formulas222 = xs218 consume_literal!(parser, ")") - _t619 = Proto.Conjunction(args=formulas125) - return _t619 + _t885 = Proto.Conjunction(args=formulas222) + result224 = _t885 + record_span!(parser, span_start223) + return result224 end function parse_disjunction(parser::Parser)::Proto.Disjunction + span_start230 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") - xs126 = Proto.Formula[] - cond127 = match_lookahead_literal(parser, "(", 0) - while cond127 - _t620 = parse_formula(parser) - item128 = _t620 - push!(xs126, item128) - cond127 = match_lookahead_literal(parser, "(", 0) + push_path!(parser, 1) + xs225 = Proto.Formula[] + cond226 = match_lookahead_literal(parser, "(", 0) + idx228 = 0 + while cond226 + push_path!(parser, idx228) + _t886 = parse_formula(parser) + item227 = _t886 + pop_path!(parser) + push!(xs225, item227) + idx228 = (idx228 + 1) + cond226 = match_lookahead_literal(parser, "(", 0) end - formulas129 = xs126 + pop_path!(parser) + formulas229 = xs225 consume_literal!(parser, ")") - _t621 = Proto.Disjunction(args=formulas129) - return _t621 + _t887 = Proto.Disjunction(args=formulas229) + result231 = _t887 + record_span!(parser, span_start230) + return result231 end function parse_not(parser::Parser)::Proto.Not + span_start233 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "not") - _t622 = parse_formula(parser) - formula130 = _t622 + push_path!(parser, 1) + _t888 = parse_formula(parser) + formula232 = _t888 + pop_path!(parser) consume_literal!(parser, ")") - _t623 = Proto.Not(arg=formula130) - return _t623 + _t889 = Proto.Not(arg=formula232) + result234 = _t889 + record_span!(parser, span_start233) + return result234 end function parse_ffi(parser::Parser)::Proto.FFI + span_start238 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "ffi") - _t624 = parse_name(parser) - name131 = _t624 - _t625 = parse_ffi_args(parser) - ffi_args132 = _t625 - _t626 = parse_terms(parser) - terms133 = _t626 + push_path!(parser, 1) + _t890 = parse_name(parser) + name235 = _t890 + pop_path!(parser) + push_path!(parser, 2) + _t891 = parse_ffi_args(parser) + ffi_args236 = _t891 + pop_path!(parser) + push_path!(parser, 3) + _t892 = parse_terms(parser) + terms237 = _t892 + pop_path!(parser) consume_literal!(parser, ")") - _t627 = Proto.FFI(name=name131, args=ffi_args132, terms=terms133) - return _t627 + _t893 = Proto.FFI(name=name235, args=ffi_args236, terms=terms237) + result239 = _t893 + record_span!(parser, span_start238) + return result239 end function parse_name(parser::Parser)::String + span_start241 = span_start(parser) consume_literal!(parser, ":") - symbol134 = consume_terminal!(parser, "SYMBOL") - return symbol134 + symbol240 = consume_terminal!(parser, "SYMBOL") + result242 = symbol240 + record_span!(parser, span_start241) + return result242 end function parse_ffi_args(parser::Parser)::Vector{Proto.Abstraction} + span_start248 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "args") - xs135 = Proto.Abstraction[] - cond136 = match_lookahead_literal(parser, "(", 0) - while cond136 - _t628 = parse_abstraction(parser) - item137 = _t628 - push!(xs135, item137) - cond136 = match_lookahead_literal(parser, "(", 0) + xs243 = Proto.Abstraction[] + cond244 = match_lookahead_literal(parser, "(", 0) + idx246 = 0 + while cond244 + push_path!(parser, idx246) + _t894 = parse_abstraction(parser) + item245 = _t894 + pop_path!(parser) + push!(xs243, item245) + idx246 = (idx246 + 1) + cond244 = match_lookahead_literal(parser, "(", 0) end - abstractions138 = xs135 + abstractions247 = xs243 consume_literal!(parser, ")") - return abstractions138 + result249 = abstractions247 + record_span!(parser, span_start248) + return result249 end function parse_atom(parser::Parser)::Proto.Atom + span_start256 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "atom") - _t629 = parse_relation_id(parser) - relation_id139 = _t629 - xs140 = Proto.Term[] - cond141 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond141 - _t630 = parse_term(parser) - item142 = _t630 - push!(xs140, item142) - cond141 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + _t895 = parse_relation_id(parser) + relation_id250 = _t895 + pop_path!(parser) + push_path!(parser, 2) + xs251 = Proto.Term[] + cond252 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx254 = 0 + while cond252 + push_path!(parser, idx254) + _t896 = parse_term(parser) + item253 = _t896 + pop_path!(parser) + push!(xs251, item253) + idx254 = (idx254 + 1) + cond252 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms143 = xs140 + pop_path!(parser) + terms255 = xs251 consume_literal!(parser, ")") - _t631 = Proto.Atom(name=relation_id139, terms=terms143) - return _t631 + _t897 = Proto.Atom(name=relation_id250, terms=terms255) + result257 = _t897 + record_span!(parser, span_start256) + return result257 end function parse_pragma(parser::Parser)::Proto.Pragma + span_start264 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "pragma") - _t632 = parse_name(parser) - name144 = _t632 - xs145 = Proto.Term[] - cond146 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond146 - _t633 = parse_term(parser) - item147 = _t633 - push!(xs145, item147) - cond146 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + _t898 = parse_name(parser) + name258 = _t898 + pop_path!(parser) + push_path!(parser, 2) + xs259 = Proto.Term[] + cond260 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx262 = 0 + while cond260 + push_path!(parser, idx262) + _t899 = parse_term(parser) + item261 = _t899 + pop_path!(parser) + push!(xs259, item261) + idx262 = (idx262 + 1) + cond260 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms148 = xs145 + pop_path!(parser) + terms263 = xs259 consume_literal!(parser, ")") - _t634 = Proto.Pragma(name=name144, terms=terms148) - return _t634 + _t900 = Proto.Pragma(name=name258, terms=terms263) + result265 = _t900 + record_span!(parser, span_start264) + return result265 end function parse_primitive(parser::Parser)::Proto.Primitive + span_start282 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "primitive", 1) - _t636 = 9 + _t902 = 9 else if match_lookahead_literal(parser, ">=", 1) - _t637 = 4 + _t903 = 4 else if match_lookahead_literal(parser, ">", 1) - _t638 = 3 + _t904 = 3 else if match_lookahead_literal(parser, "=", 1) - _t639 = 0 + _t905 = 0 else if match_lookahead_literal(parser, "<=", 1) - _t640 = 2 + _t906 = 2 else if match_lookahead_literal(parser, "<", 1) - _t641 = 1 + _t907 = 1 else if match_lookahead_literal(parser, "/", 1) - _t642 = 8 + _t908 = 8 else if match_lookahead_literal(parser, "-", 1) - _t643 = 6 + _t909 = 6 else if match_lookahead_literal(parser, "+", 1) - _t644 = 5 + _t910 = 5 else if match_lookahead_literal(parser, "*", 1) - _t645 = 7 + _t911 = 7 else - _t645 = -1 + _t911 = -1 end - _t644 = _t645 + _t910 = _t911 end - _t643 = _t644 + _t909 = _t910 end - _t642 = _t643 + _t908 = _t909 end - _t641 = _t642 + _t907 = _t908 end - _t640 = _t641 + _t906 = _t907 end - _t639 = _t640 + _t905 = _t906 end - _t638 = _t639 + _t904 = _t905 end - _t637 = _t638 + _t903 = _t904 end - _t636 = _t637 + _t902 = _t903 end - _t635 = _t636 + _t901 = _t902 else - _t635 = -1 + _t901 = -1 end - prediction149 = _t635 + prediction266 = _t901 - if prediction149 == 9 + if prediction266 == 9 consume_literal!(parser, "(") consume_literal!(parser, "primitive") - _t647 = parse_name(parser) - name159 = _t647 - xs160 = Proto.RelTerm[] - cond161 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond161 - _t648 = parse_rel_term(parser) - item162 = _t648 - push!(xs160, item162) - cond161 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + _t913 = parse_name(parser) + name276 = _t913 + pop_path!(parser) + push_path!(parser, 2) + xs277 = Proto.RelTerm[] + cond278 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx280 = 0 + while cond278 + push_path!(parser, idx280) + _t914 = parse_rel_term(parser) + item279 = _t914 + pop_path!(parser) + push!(xs277, item279) + idx280 = (idx280 + 1) + cond278 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - rel_terms163 = xs160 + pop_path!(parser) + rel_terms281 = xs277 consume_literal!(parser, ")") - _t649 = Proto.Primitive(name=name159, terms=rel_terms163) - _t646 = _t649 + _t915 = Proto.Primitive(name=name276, terms=rel_terms281) + _t912 = _t915 else - if prediction149 == 8 - _t651 = parse_divide(parser) - divide158 = _t651 - _t650 = divide158 + if prediction266 == 8 + _t917 = parse_divide(parser) + divide275 = _t917 + _t916 = divide275 else - if prediction149 == 7 - _t653 = parse_multiply(parser) - multiply157 = _t653 - _t652 = multiply157 + if prediction266 == 7 + _t919 = parse_multiply(parser) + multiply274 = _t919 + _t918 = multiply274 else - if prediction149 == 6 - _t655 = parse_minus(parser) - minus156 = _t655 - _t654 = minus156 + if prediction266 == 6 + _t921 = parse_minus(parser) + minus273 = _t921 + _t920 = minus273 else - if prediction149 == 5 - _t657 = parse_add(parser) - add155 = _t657 - _t656 = add155 + if prediction266 == 5 + _t923 = parse_add(parser) + add272 = _t923 + _t922 = add272 else - if prediction149 == 4 - _t659 = parse_gt_eq(parser) - gt_eq154 = _t659 - _t658 = gt_eq154 + if prediction266 == 4 + _t925 = parse_gt_eq(parser) + gt_eq271 = _t925 + _t924 = gt_eq271 else - if prediction149 == 3 - _t661 = parse_gt(parser) - gt153 = _t661 - _t660 = gt153 + if prediction266 == 3 + _t927 = parse_gt(parser) + gt270 = _t927 + _t926 = gt270 else - if prediction149 == 2 - _t663 = parse_lt_eq(parser) - lt_eq152 = _t663 - _t662 = lt_eq152 + if prediction266 == 2 + _t929 = parse_lt_eq(parser) + lt_eq269 = _t929 + _t928 = lt_eq269 else - if prediction149 == 1 - _t665 = parse_lt(parser) - lt151 = _t665 - _t664 = lt151 + if prediction266 == 1 + _t931 = parse_lt(parser) + lt268 = _t931 + _t930 = lt268 else - if prediction149 == 0 - _t667 = parse_eq(parser) - eq150 = _t667 - _t666 = eq150 + if prediction266 == 0 + _t933 = parse_eq(parser) + eq267 = _t933 + _t932 = eq267 else throw(ParseError("Unexpected token in primitive" * ": " * string(lookahead(parser, 0)))) end - _t664 = _t666 + _t930 = _t932 end - _t662 = _t664 + _t928 = _t930 end - _t660 = _t662 + _t926 = _t928 end - _t658 = _t660 + _t924 = _t926 end - _t656 = _t658 + _t922 = _t924 end - _t654 = _t656 + _t920 = _t922 end - _t652 = _t654 + _t918 = _t920 end - _t650 = _t652 + _t916 = _t918 end - _t646 = _t650 + _t912 = _t916 end - return _t646 + result283 = _t912 + record_span!(parser, span_start282) + return result283 end function parse_eq(parser::Parser)::Proto.Primitive + span_start286 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "=") - _t668 = parse_term(parser) - term164 = _t668 - _t669 = parse_term(parser) - term_3165 = _t669 + _t934 = parse_term(parser) + term284 = _t934 + _t935 = parse_term(parser) + term_3285 = _t935 consume_literal!(parser, ")") - _t670 = Proto.RelTerm(rel_term_type=OneOf(:term, term164)) - _t671 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3165)) - _t672 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t670, _t671]) - return _t672 + _t936 = Proto.RelTerm(rel_term_type=OneOf(:term, term284)) + _t937 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3285)) + _t938 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t936, _t937]) + result287 = _t938 + record_span!(parser, span_start286) + return result287 end function parse_lt(parser::Parser)::Proto.Primitive + span_start290 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<") - _t673 = parse_term(parser) - term166 = _t673 - _t674 = parse_term(parser) - term_3167 = _t674 + _t939 = parse_term(parser) + term288 = _t939 + _t940 = parse_term(parser) + term_3289 = _t940 consume_literal!(parser, ")") - _t675 = Proto.RelTerm(rel_term_type=OneOf(:term, term166)) - _t676 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3167)) - _t677 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t675, _t676]) - return _t677 + _t941 = Proto.RelTerm(rel_term_type=OneOf(:term, term288)) + _t942 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3289)) + _t943 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t941, _t942]) + result291 = _t943 + record_span!(parser, span_start290) + return result291 end function parse_lt_eq(parser::Parser)::Proto.Primitive + span_start294 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<=") - _t678 = parse_term(parser) - term168 = _t678 - _t679 = parse_term(parser) - term_3169 = _t679 + _t944 = parse_term(parser) + term292 = _t944 + _t945 = parse_term(parser) + term_3293 = _t945 consume_literal!(parser, ")") - _t680 = Proto.RelTerm(rel_term_type=OneOf(:term, term168)) - _t681 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3169)) - _t682 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t680, _t681]) - return _t682 + _t946 = Proto.RelTerm(rel_term_type=OneOf(:term, term292)) + _t947 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3293)) + _t948 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t946, _t947]) + result295 = _t948 + record_span!(parser, span_start294) + return result295 end function parse_gt(parser::Parser)::Proto.Primitive + span_start298 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">") - _t683 = parse_term(parser) - term170 = _t683 - _t684 = parse_term(parser) - term_3171 = _t684 + _t949 = parse_term(parser) + term296 = _t949 + _t950 = parse_term(parser) + term_3297 = _t950 consume_literal!(parser, ")") - _t685 = Proto.RelTerm(rel_term_type=OneOf(:term, term170)) - _t686 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3171)) - _t687 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t685, _t686]) - return _t687 + _t951 = Proto.RelTerm(rel_term_type=OneOf(:term, term296)) + _t952 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3297)) + _t953 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t951, _t952]) + result299 = _t953 + record_span!(parser, span_start298) + return result299 end function parse_gt_eq(parser::Parser)::Proto.Primitive + span_start302 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">=") - _t688 = parse_term(parser) - term172 = _t688 - _t689 = parse_term(parser) - term_3173 = _t689 + _t954 = parse_term(parser) + term300 = _t954 + _t955 = parse_term(parser) + term_3301 = _t955 consume_literal!(parser, ")") - _t690 = Proto.RelTerm(rel_term_type=OneOf(:term, term172)) - _t691 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3173)) - _t692 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t690, _t691]) - return _t692 + _t956 = Proto.RelTerm(rel_term_type=OneOf(:term, term300)) + _t957 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3301)) + _t958 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t956, _t957]) + result303 = _t958 + record_span!(parser, span_start302) + return result303 end function parse_add(parser::Parser)::Proto.Primitive + span_start307 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "+") - _t693 = parse_term(parser) - term174 = _t693 - _t694 = parse_term(parser) - term_3175 = _t694 - _t695 = parse_term(parser) - term_4176 = _t695 + _t959 = parse_term(parser) + term304 = _t959 + _t960 = parse_term(parser) + term_3305 = _t960 + _t961 = parse_term(parser) + term_4306 = _t961 consume_literal!(parser, ")") - _t696 = Proto.RelTerm(rel_term_type=OneOf(:term, term174)) - _t697 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3175)) - _t698 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4176)) - _t699 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t696, _t697, _t698]) - return _t699 + _t962 = Proto.RelTerm(rel_term_type=OneOf(:term, term304)) + _t963 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3305)) + _t964 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4306)) + _t965 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t962, _t963, _t964]) + result308 = _t965 + record_span!(parser, span_start307) + return result308 end function parse_minus(parser::Parser)::Proto.Primitive + span_start312 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "-") - _t700 = parse_term(parser) - term177 = _t700 - _t701 = parse_term(parser) - term_3178 = _t701 - _t702 = parse_term(parser) - term_4179 = _t702 + _t966 = parse_term(parser) + term309 = _t966 + _t967 = parse_term(parser) + term_3310 = _t967 + _t968 = parse_term(parser) + term_4311 = _t968 consume_literal!(parser, ")") - _t703 = Proto.RelTerm(rel_term_type=OneOf(:term, term177)) - _t704 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3178)) - _t705 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4179)) - _t706 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t703, _t704, _t705]) - return _t706 + _t969 = Proto.RelTerm(rel_term_type=OneOf(:term, term309)) + _t970 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3310)) + _t971 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4311)) + _t972 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t969, _t970, _t971]) + result313 = _t972 + record_span!(parser, span_start312) + return result313 end function parse_multiply(parser::Parser)::Proto.Primitive + span_start317 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "*") - _t707 = parse_term(parser) - term180 = _t707 - _t708 = parse_term(parser) - term_3181 = _t708 - _t709 = parse_term(parser) - term_4182 = _t709 + _t973 = parse_term(parser) + term314 = _t973 + _t974 = parse_term(parser) + term_3315 = _t974 + _t975 = parse_term(parser) + term_4316 = _t975 consume_literal!(parser, ")") - _t710 = Proto.RelTerm(rel_term_type=OneOf(:term, term180)) - _t711 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3181)) - _t712 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4182)) - _t713 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t710, _t711, _t712]) - return _t713 + _t976 = Proto.RelTerm(rel_term_type=OneOf(:term, term314)) + _t977 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3315)) + _t978 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4316)) + _t979 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t976, _t977, _t978]) + result318 = _t979 + record_span!(parser, span_start317) + return result318 end function parse_divide(parser::Parser)::Proto.Primitive + span_start322 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "/") - _t714 = parse_term(parser) - term183 = _t714 - _t715 = parse_term(parser) - term_3184 = _t715 - _t716 = parse_term(parser) - term_4185 = _t716 + _t980 = parse_term(parser) + term319 = _t980 + _t981 = parse_term(parser) + term_3320 = _t981 + _t982 = parse_term(parser) + term_4321 = _t982 consume_literal!(parser, ")") - _t717 = Proto.RelTerm(rel_term_type=OneOf(:term, term183)) - _t718 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3184)) - _t719 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4185)) - _t720 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t717, _t718, _t719]) - return _t720 + _t983 = Proto.RelTerm(rel_term_type=OneOf(:term, term319)) + _t984 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3320)) + _t985 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4321)) + _t986 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t983, _t984, _t985]) + result323 = _t986 + record_span!(parser, span_start322) + return result323 end function parse_rel_term(parser::Parser)::Proto.RelTerm + span_start327 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t721 = 1 + _t987 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t722 = 1 + _t988 = 1 else if match_lookahead_literal(parser, "false", 0) - _t723 = 1 + _t989 = 1 else if match_lookahead_literal(parser, "(", 0) - _t724 = 1 + _t990 = 1 else if match_lookahead_literal(parser, "#", 0) - _t725 = 0 + _t991 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t726 = 1 + _t992 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t727 = 1 + _t993 = 1 else if match_lookahead_terminal(parser, "STRING", 0) - _t728 = 1 + _t994 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t729 = 1 + _t995 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t730 = 1 + _t996 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t731 = 1 + _t997 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t732 = 1 + _t998 = 1 else - _t732 = -1 + _t998 = -1 end - _t731 = _t732 + _t997 = _t998 end - _t730 = _t731 + _t996 = _t997 end - _t729 = _t730 + _t995 = _t996 end - _t728 = _t729 + _t994 = _t995 end - _t727 = _t728 + _t993 = _t994 end - _t726 = _t727 + _t992 = _t993 end - _t725 = _t726 + _t991 = _t992 end - _t724 = _t725 + _t990 = _t991 end - _t723 = _t724 + _t989 = _t990 end - _t722 = _t723 + _t988 = _t989 end - _t721 = _t722 + _t987 = _t988 end - prediction186 = _t721 + prediction324 = _t987 - if prediction186 == 1 - _t734 = parse_term(parser) - term188 = _t734 - _t735 = Proto.RelTerm(rel_term_type=OneOf(:term, term188)) - _t733 = _t735 + if prediction324 == 1 + _t1000 = parse_term(parser) + term326 = _t1000 + _t1001 = Proto.RelTerm(rel_term_type=OneOf(:term, term326)) + _t999 = _t1001 else - if prediction186 == 0 - _t737 = parse_specialized_value(parser) - specialized_value187 = _t737 - _t738 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value187)) - _t736 = _t738 + if prediction324 == 0 + _t1003 = parse_specialized_value(parser) + specialized_value325 = _t1003 + _t1004 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value325)) + _t1002 = _t1004 else throw(ParseError("Unexpected token in rel_term" * ": " * string(lookahead(parser, 0)))) end - _t733 = _t736 + _t999 = _t1002 end - return _t733 + result328 = _t999 + record_span!(parser, span_start327) + return result328 end function parse_specialized_value(parser::Parser)::Proto.Value + span_start330 = span_start(parser) consume_literal!(parser, "#") - _t739 = parse_value(parser) - value189 = _t739 - return value189 + _t1005 = parse_value(parser) + value329 = _t1005 + result331 = value329 + record_span!(parser, span_start330) + return result331 end function parse_rel_atom(parser::Parser)::Proto.RelAtom + span_start338 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "relatom") - _t740 = parse_name(parser) - name190 = _t740 - xs191 = Proto.RelTerm[] - cond192 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond192 - _t741 = parse_rel_term(parser) - item193 = _t741 - push!(xs191, item193) - cond192 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 3) + _t1006 = parse_name(parser) + name332 = _t1006 + pop_path!(parser) + push_path!(parser, 2) + xs333 = Proto.RelTerm[] + cond334 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx336 = 0 + while cond334 + push_path!(parser, idx336) + _t1007 = parse_rel_term(parser) + item335 = _t1007 + pop_path!(parser) + push!(xs333, item335) + idx336 = (idx336 + 1) + cond334 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - rel_terms194 = xs191 + pop_path!(parser) + rel_terms337 = xs333 consume_literal!(parser, ")") - _t742 = Proto.RelAtom(name=name190, terms=rel_terms194) - return _t742 + _t1008 = Proto.RelAtom(name=name332, terms=rel_terms337) + result339 = _t1008 + record_span!(parser, span_start338) + return result339 end function parse_cast(parser::Parser)::Proto.Cast + span_start342 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "cast") - _t743 = parse_term(parser) - term195 = _t743 - _t744 = parse_term(parser) - term_3196 = _t744 + push_path!(parser, 2) + _t1009 = parse_term(parser) + term340 = _t1009 + pop_path!(parser) + push_path!(parser, 3) + _t1010 = parse_term(parser) + term_3341 = _t1010 + pop_path!(parser) consume_literal!(parser, ")") - _t745 = Proto.Cast(input=term195, result=term_3196) - return _t745 + _t1011 = Proto.Cast(input=term340, result=term_3341) + result343 = _t1011 + record_span!(parser, span_start342) + return result343 end function parse_attrs(parser::Parser)::Vector{Proto.Attribute} + span_start349 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attrs") - xs197 = Proto.Attribute[] - cond198 = match_lookahead_literal(parser, "(", 0) - while cond198 - _t746 = parse_attribute(parser) - item199 = _t746 - push!(xs197, item199) - cond198 = match_lookahead_literal(parser, "(", 0) + xs344 = Proto.Attribute[] + cond345 = match_lookahead_literal(parser, "(", 0) + idx347 = 0 + while cond345 + push_path!(parser, idx347) + _t1012 = parse_attribute(parser) + item346 = _t1012 + pop_path!(parser) + push!(xs344, item346) + idx347 = (idx347 + 1) + cond345 = match_lookahead_literal(parser, "(", 0) end - attributes200 = xs197 + attributes348 = xs344 consume_literal!(parser, ")") - return attributes200 + result350 = attributes348 + record_span!(parser, span_start349) + return result350 end function parse_attribute(parser::Parser)::Proto.Attribute + span_start357 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attribute") - _t747 = parse_name(parser) - name201 = _t747 - xs202 = Proto.Value[] - cond203 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond203 - _t748 = parse_value(parser) - item204 = _t748 - push!(xs202, item204) - cond203 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + _t1013 = parse_name(parser) + name351 = _t1013 + pop_path!(parser) + push_path!(parser, 2) + xs352 = Proto.Value[] + cond353 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx355 = 0 + while cond353 + push_path!(parser, idx355) + _t1014 = parse_value(parser) + item354 = _t1014 + pop_path!(parser) + push!(xs352, item354) + idx355 = (idx355 + 1) + cond353 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - values205 = xs202 + pop_path!(parser) + values356 = xs352 consume_literal!(parser, ")") - _t749 = Proto.Attribute(name=name201, args=values205) - return _t749 + _t1015 = Proto.Attribute(name=name351, args=values356) + result358 = _t1015 + record_span!(parser, span_start357) + return result358 end function parse_algorithm(parser::Parser)::Proto.Algorithm + span_start365 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "algorithm") - xs206 = Proto.RelationId[] - cond207 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond207 - _t750 = parse_relation_id(parser) - item208 = _t750 - push!(xs206, item208) - cond207 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + xs359 = Proto.RelationId[] + cond360 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx362 = 0 + while cond360 + push_path!(parser, idx362) + _t1016 = parse_relation_id(parser) + item361 = _t1016 + pop_path!(parser) + push!(xs359, item361) + idx362 = (idx362 + 1) + cond360 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) end - relation_ids209 = xs206 - _t751 = parse_script(parser) - script210 = _t751 + pop_path!(parser) + relation_ids363 = xs359 + push_path!(parser, 2) + _t1017 = parse_script(parser) + script364 = _t1017 + pop_path!(parser) consume_literal!(parser, ")") - _t752 = Proto.Algorithm(var"#global"=relation_ids209, body=script210) - return _t752 + _t1018 = Proto.Algorithm(var"#global"=relation_ids363, body=script364) + result366 = _t1018 + record_span!(parser, span_start365) + return result366 end function parse_script(parser::Parser)::Proto.Script + span_start372 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "script") - xs211 = Proto.Construct[] - cond212 = match_lookahead_literal(parser, "(", 0) - while cond212 - _t753 = parse_construct(parser) - item213 = _t753 - push!(xs211, item213) - cond212 = match_lookahead_literal(parser, "(", 0) + push_path!(parser, 1) + xs367 = Proto.Construct[] + cond368 = match_lookahead_literal(parser, "(", 0) + idx370 = 0 + while cond368 + push_path!(parser, idx370) + _t1019 = parse_construct(parser) + item369 = _t1019 + pop_path!(parser) + push!(xs367, item369) + idx370 = (idx370 + 1) + cond368 = match_lookahead_literal(parser, "(", 0) end - constructs214 = xs211 + pop_path!(parser) + constructs371 = xs367 consume_literal!(parser, ")") - _t754 = Proto.Script(constructs=constructs214) - return _t754 + _t1020 = Proto.Script(constructs=constructs371) + result373 = _t1020 + record_span!(parser, span_start372) + return result373 end function parse_construct(parser::Parser)::Proto.Construct + span_start377 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t756 = 1 + _t1022 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t757 = 1 + _t1023 = 1 else if match_lookahead_literal(parser, "monoid", 1) - _t758 = 1 + _t1024 = 1 else if match_lookahead_literal(parser, "loop", 1) - _t759 = 0 + _t1025 = 0 else if match_lookahead_literal(parser, "break", 1) - _t760 = 1 + _t1026 = 1 else if match_lookahead_literal(parser, "assign", 1) - _t761 = 1 + _t1027 = 1 else - _t761 = -1 + _t1027 = -1 end - _t760 = _t761 + _t1026 = _t1027 end - _t759 = _t760 + _t1025 = _t1026 end - _t758 = _t759 + _t1024 = _t1025 end - _t757 = _t758 + _t1023 = _t1024 end - _t756 = _t757 + _t1022 = _t1023 end - _t755 = _t756 + _t1021 = _t1022 else - _t755 = -1 + _t1021 = -1 end - prediction215 = _t755 + prediction374 = _t1021 - if prediction215 == 1 - _t763 = parse_instruction(parser) - instruction217 = _t763 - _t764 = Proto.Construct(construct_type=OneOf(:instruction, instruction217)) - _t762 = _t764 + if prediction374 == 1 + _t1029 = parse_instruction(parser) + instruction376 = _t1029 + _t1030 = Proto.Construct(construct_type=OneOf(:instruction, instruction376)) + _t1028 = _t1030 else - if prediction215 == 0 - _t766 = parse_loop(parser) - loop216 = _t766 - _t767 = Proto.Construct(construct_type=OneOf(:loop, loop216)) - _t765 = _t767 + if prediction374 == 0 + _t1032 = parse_loop(parser) + loop375 = _t1032 + _t1033 = Proto.Construct(construct_type=OneOf(:loop, loop375)) + _t1031 = _t1033 else throw(ParseError("Unexpected token in construct" * ": " * string(lookahead(parser, 0)))) end - _t762 = _t765 + _t1028 = _t1031 end - return _t762 + result378 = _t1028 + record_span!(parser, span_start377) + return result378 end function parse_loop(parser::Parser)::Proto.Loop + span_start381 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "loop") - _t768 = parse_init(parser) - init218 = _t768 - _t769 = parse_script(parser) - script219 = _t769 + push_path!(parser, 1) + _t1034 = parse_init(parser) + init379 = _t1034 + pop_path!(parser) + push_path!(parser, 2) + _t1035 = parse_script(parser) + script380 = _t1035 + pop_path!(parser) consume_literal!(parser, ")") - _t770 = Proto.Loop(init=init218, body=script219) - return _t770 + _t1036 = Proto.Loop(init=init379, body=script380) + result382 = _t1036 + record_span!(parser, span_start381) + return result382 end function parse_init(parser::Parser)::Vector{Proto.Instruction} + span_start388 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "init") - xs220 = Proto.Instruction[] - cond221 = match_lookahead_literal(parser, "(", 0) - while cond221 - _t771 = parse_instruction(parser) - item222 = _t771 - push!(xs220, item222) - cond221 = match_lookahead_literal(parser, "(", 0) + xs383 = Proto.Instruction[] + cond384 = match_lookahead_literal(parser, "(", 0) + idx386 = 0 + while cond384 + push_path!(parser, idx386) + _t1037 = parse_instruction(parser) + item385 = _t1037 + pop_path!(parser) + push!(xs383, item385) + idx386 = (idx386 + 1) + cond384 = match_lookahead_literal(parser, "(", 0) end - instructions223 = xs220 + instructions387 = xs383 consume_literal!(parser, ")") - return instructions223 + result389 = instructions387 + record_span!(parser, span_start388) + return result389 end function parse_instruction(parser::Parser)::Proto.Instruction + span_start396 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t773 = 1 + _t1039 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t774 = 4 + _t1040 = 4 else if match_lookahead_literal(parser, "monoid", 1) - _t775 = 3 + _t1041 = 3 else if match_lookahead_literal(parser, "break", 1) - _t776 = 2 + _t1042 = 2 else if match_lookahead_literal(parser, "assign", 1) - _t777 = 0 + _t1043 = 0 else - _t777 = -1 + _t1043 = -1 end - _t776 = _t777 + _t1042 = _t1043 end - _t775 = _t776 + _t1041 = _t1042 end - _t774 = _t775 + _t1040 = _t1041 end - _t773 = _t774 + _t1039 = _t1040 end - _t772 = _t773 + _t1038 = _t1039 else - _t772 = -1 + _t1038 = -1 end - prediction224 = _t772 + prediction390 = _t1038 - if prediction224 == 4 - _t779 = parse_monus_def(parser) - monus_def229 = _t779 - _t780 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def229)) - _t778 = _t780 + if prediction390 == 4 + _t1045 = parse_monus_def(parser) + monus_def395 = _t1045 + _t1046 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def395)) + _t1044 = _t1046 else - if prediction224 == 3 - _t782 = parse_monoid_def(parser) - monoid_def228 = _t782 - _t783 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def228)) - _t781 = _t783 + if prediction390 == 3 + _t1048 = parse_monoid_def(parser) + monoid_def394 = _t1048 + _t1049 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def394)) + _t1047 = _t1049 else - if prediction224 == 2 - _t785 = parse_break(parser) - break227 = _t785 - _t786 = Proto.Instruction(instr_type=OneOf(:var"#break", break227)) - _t784 = _t786 + if prediction390 == 2 + _t1051 = parse_break(parser) + break393 = _t1051 + _t1052 = Proto.Instruction(instr_type=OneOf(:var"#break", break393)) + _t1050 = _t1052 else - if prediction224 == 1 - _t788 = parse_upsert(parser) - upsert226 = _t788 - _t789 = Proto.Instruction(instr_type=OneOf(:upsert, upsert226)) - _t787 = _t789 + if prediction390 == 1 + _t1054 = parse_upsert(parser) + upsert392 = _t1054 + _t1055 = Proto.Instruction(instr_type=OneOf(:upsert, upsert392)) + _t1053 = _t1055 else - if prediction224 == 0 - _t791 = parse_assign(parser) - assign225 = _t791 - _t792 = Proto.Instruction(instr_type=OneOf(:assign, assign225)) - _t790 = _t792 + if prediction390 == 0 + _t1057 = parse_assign(parser) + assign391 = _t1057 + _t1058 = Proto.Instruction(instr_type=OneOf(:assign, assign391)) + _t1056 = _t1058 else throw(ParseError("Unexpected token in instruction" * ": " * string(lookahead(parser, 0)))) end - _t787 = _t790 + _t1053 = _t1056 end - _t784 = _t787 + _t1050 = _t1053 end - _t781 = _t784 + _t1047 = _t1050 end - _t778 = _t781 + _t1044 = _t1047 end - return _t778 + result397 = _t1044 + record_span!(parser, span_start396) + return result397 end function parse_assign(parser::Parser)::Proto.Assign + span_start401 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "assign") - _t793 = parse_relation_id(parser) - relation_id230 = _t793 - _t794 = parse_abstraction(parser) - abstraction231 = _t794 + push_path!(parser, 1) + _t1059 = parse_relation_id(parser) + relation_id398 = _t1059 + pop_path!(parser) + push_path!(parser, 2) + _t1060 = parse_abstraction(parser) + abstraction399 = _t1060 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t796 = parse_attrs(parser) - _t795 = _t796 + _t1062 = parse_attrs(parser) + _t1061 = _t1062 else - _t795 = nothing + _t1061 = nothing end - attrs232 = _t795 + attrs400 = _t1061 + pop_path!(parser) consume_literal!(parser, ")") - _t797 = Proto.Assign(name=relation_id230, body=abstraction231, attrs=(!isnothing(attrs232) ? attrs232 : Proto.Attribute[])) - return _t797 + _t1063 = Proto.Assign(name=relation_id398, body=abstraction399, attrs=(!isnothing(attrs400) ? attrs400 : Proto.Attribute[])) + result402 = _t1063 + record_span!(parser, span_start401) + return result402 end function parse_upsert(parser::Parser)::Proto.Upsert + span_start406 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "upsert") - _t798 = parse_relation_id(parser) - relation_id233 = _t798 - _t799 = parse_abstraction_with_arity(parser) - abstraction_with_arity234 = _t799 + push_path!(parser, 1) + _t1064 = parse_relation_id(parser) + relation_id403 = _t1064 + pop_path!(parser) + _t1065 = parse_abstraction_with_arity(parser) + abstraction_with_arity404 = _t1065 + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t801 = parse_attrs(parser) - _t800 = _t801 + _t1067 = parse_attrs(parser) + _t1066 = _t1067 else - _t800 = nothing + _t1066 = nothing end - attrs235 = _t800 + attrs405 = _t1066 + pop_path!(parser) consume_literal!(parser, ")") - _t802 = Proto.Upsert(name=relation_id233, body=abstraction_with_arity234[1], attrs=(!isnothing(attrs235) ? attrs235 : Proto.Attribute[]), value_arity=abstraction_with_arity234[2]) - return _t802 + _t1068 = Proto.Upsert(name=relation_id403, body=abstraction_with_arity404[1], attrs=(!isnothing(attrs405) ? attrs405 : Proto.Attribute[]), value_arity=abstraction_with_arity404[2]) + result407 = _t1068 + record_span!(parser, span_start406) + return result407 end function parse_abstraction_with_arity(parser::Parser)::Tuple{Proto.Abstraction, Int64} + span_start410 = span_start(parser) consume_literal!(parser, "(") - _t803 = parse_bindings(parser) - bindings236 = _t803 - _t804 = parse_formula(parser) - formula237 = _t804 + _t1069 = parse_bindings(parser) + bindings408 = _t1069 + _t1070 = parse_formula(parser) + formula409 = _t1070 consume_literal!(parser, ")") - _t805 = Proto.Abstraction(vars=vcat(bindings236[1], !isnothing(bindings236[2]) ? bindings236[2] : []), value=formula237) - return (_t805, length(bindings236[2]),) + _t1071 = Proto.Abstraction(vars=vcat(bindings408[1], !isnothing(bindings408[2]) ? bindings408[2] : []), value=formula409) + result411 = (_t1071, length(bindings408[2]),) + record_span!(parser, span_start410) + return result411 end function parse_break(parser::Parser)::Proto.Break + span_start415 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "break") - _t806 = parse_relation_id(parser) - relation_id238 = _t806 - _t807 = parse_abstraction(parser) - abstraction239 = _t807 + push_path!(parser, 1) + _t1072 = parse_relation_id(parser) + relation_id412 = _t1072 + pop_path!(parser) + push_path!(parser, 2) + _t1073 = parse_abstraction(parser) + abstraction413 = _t1073 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t809 = parse_attrs(parser) - _t808 = _t809 + _t1075 = parse_attrs(parser) + _t1074 = _t1075 else - _t808 = nothing + _t1074 = nothing end - attrs240 = _t808 + attrs414 = _t1074 + pop_path!(parser) consume_literal!(parser, ")") - _t810 = Proto.Break(name=relation_id238, body=abstraction239, attrs=(!isnothing(attrs240) ? attrs240 : Proto.Attribute[])) - return _t810 + _t1076 = Proto.Break(name=relation_id412, body=abstraction413, attrs=(!isnothing(attrs414) ? attrs414 : Proto.Attribute[])) + result416 = _t1076 + record_span!(parser, span_start415) + return result416 end function parse_monoid_def(parser::Parser)::Proto.MonoidDef + span_start421 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monoid") - _t811 = parse_monoid(parser) - monoid241 = _t811 - _t812 = parse_relation_id(parser) - relation_id242 = _t812 - _t813 = parse_abstraction_with_arity(parser) - abstraction_with_arity243 = _t813 + push_path!(parser, 1) + _t1077 = parse_monoid(parser) + monoid417 = _t1077 + pop_path!(parser) + push_path!(parser, 2) + _t1078 = parse_relation_id(parser) + relation_id418 = _t1078 + pop_path!(parser) + _t1079 = parse_abstraction_with_arity(parser) + abstraction_with_arity419 = _t1079 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t815 = parse_attrs(parser) - _t814 = _t815 + _t1081 = parse_attrs(parser) + _t1080 = _t1081 else - _t814 = nothing + _t1080 = nothing end - attrs244 = _t814 + attrs420 = _t1080 + pop_path!(parser) consume_literal!(parser, ")") - _t816 = Proto.MonoidDef(monoid=monoid241, name=relation_id242, body=abstraction_with_arity243[1], attrs=(!isnothing(attrs244) ? attrs244 : Proto.Attribute[]), value_arity=abstraction_with_arity243[2]) - return _t816 + _t1082 = Proto.MonoidDef(monoid=monoid417, name=relation_id418, body=abstraction_with_arity419[1], attrs=(!isnothing(attrs420) ? attrs420 : Proto.Attribute[]), value_arity=abstraction_with_arity419[2]) + result422 = _t1082 + record_span!(parser, span_start421) + return result422 end function parse_monoid(parser::Parser)::Proto.Monoid + span_start428 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "sum", 1) - _t818 = 3 + _t1084 = 3 else if match_lookahead_literal(parser, "or", 1) - _t819 = 0 + _t1085 = 0 else if match_lookahead_literal(parser, "min", 1) - _t820 = 1 + _t1086 = 1 else if match_lookahead_literal(parser, "max", 1) - _t821 = 2 + _t1087 = 2 else - _t821 = -1 + _t1087 = -1 end - _t820 = _t821 + _t1086 = _t1087 end - _t819 = _t820 + _t1085 = _t1086 end - _t818 = _t819 + _t1084 = _t1085 end - _t817 = _t818 + _t1083 = _t1084 else - _t817 = -1 + _t1083 = -1 end - prediction245 = _t817 + prediction423 = _t1083 - if prediction245 == 3 - _t823 = parse_sum_monoid(parser) - sum_monoid249 = _t823 - _t824 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid249)) - _t822 = _t824 + if prediction423 == 3 + _t1089 = parse_sum_monoid(parser) + sum_monoid427 = _t1089 + _t1090 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid427)) + _t1088 = _t1090 else - if prediction245 == 2 - _t826 = parse_max_monoid(parser) - max_monoid248 = _t826 - _t827 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid248)) - _t825 = _t827 + if prediction423 == 2 + _t1092 = parse_max_monoid(parser) + max_monoid426 = _t1092 + _t1093 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid426)) + _t1091 = _t1093 else - if prediction245 == 1 - _t829 = parse_min_monoid(parser) - min_monoid247 = _t829 - _t830 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid247)) - _t828 = _t830 + if prediction423 == 1 + _t1095 = parse_min_monoid(parser) + min_monoid425 = _t1095 + _t1096 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid425)) + _t1094 = _t1096 else - if prediction245 == 0 - _t832 = parse_or_monoid(parser) - or_monoid246 = _t832 - _t833 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid246)) - _t831 = _t833 + if prediction423 == 0 + _t1098 = parse_or_monoid(parser) + or_monoid424 = _t1098 + _t1099 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid424)) + _t1097 = _t1099 else throw(ParseError("Unexpected token in monoid" * ": " * string(lookahead(parser, 0)))) end - _t828 = _t831 + _t1094 = _t1097 end - _t825 = _t828 + _t1091 = _t1094 end - _t822 = _t825 + _t1088 = _t1091 end - return _t822 + result429 = _t1088 + record_span!(parser, span_start428) + return result429 end function parse_or_monoid(parser::Parser)::Proto.OrMonoid + span_start430 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") consume_literal!(parser, ")") - _t834 = Proto.OrMonoid() - return _t834 + _t1100 = Proto.OrMonoid() + result431 = _t1100 + record_span!(parser, span_start430) + return result431 end function parse_min_monoid(parser::Parser)::Proto.MinMonoid + span_start433 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "min") - _t835 = parse_type(parser) - type250 = _t835 + push_path!(parser, 1) + _t1101 = parse_type(parser) + type432 = _t1101 + pop_path!(parser) consume_literal!(parser, ")") - _t836 = Proto.MinMonoid(var"#type"=type250) - return _t836 + _t1102 = Proto.MinMonoid(var"#type"=type432) + result434 = _t1102 + record_span!(parser, span_start433) + return result434 end function parse_max_monoid(parser::Parser)::Proto.MaxMonoid + span_start436 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "max") - _t837 = parse_type(parser) - type251 = _t837 + push_path!(parser, 1) + _t1103 = parse_type(parser) + type435 = _t1103 + pop_path!(parser) consume_literal!(parser, ")") - _t838 = Proto.MaxMonoid(var"#type"=type251) - return _t838 + _t1104 = Proto.MaxMonoid(var"#type"=type435) + result437 = _t1104 + record_span!(parser, span_start436) + return result437 end function parse_sum_monoid(parser::Parser)::Proto.SumMonoid + span_start439 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sum") - _t839 = parse_type(parser) - type252 = _t839 + push_path!(parser, 1) + _t1105 = parse_type(parser) + type438 = _t1105 + pop_path!(parser) consume_literal!(parser, ")") - _t840 = Proto.SumMonoid(var"#type"=type252) - return _t840 + _t1106 = Proto.SumMonoid(var"#type"=type438) + result440 = _t1106 + record_span!(parser, span_start439) + return result440 end function parse_monus_def(parser::Parser)::Proto.MonusDef + span_start445 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monus") - _t841 = parse_monoid(parser) - monoid253 = _t841 - _t842 = parse_relation_id(parser) - relation_id254 = _t842 - _t843 = parse_abstraction_with_arity(parser) - abstraction_with_arity255 = _t843 + push_path!(parser, 1) + _t1107 = parse_monoid(parser) + monoid441 = _t1107 + pop_path!(parser) + push_path!(parser, 2) + _t1108 = parse_relation_id(parser) + relation_id442 = _t1108 + pop_path!(parser) + _t1109 = parse_abstraction_with_arity(parser) + abstraction_with_arity443 = _t1109 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t845 = parse_attrs(parser) - _t844 = _t845 + _t1111 = parse_attrs(parser) + _t1110 = _t1111 else - _t844 = nothing + _t1110 = nothing end - attrs256 = _t844 + attrs444 = _t1110 + pop_path!(parser) consume_literal!(parser, ")") - _t846 = Proto.MonusDef(monoid=monoid253, name=relation_id254, body=abstraction_with_arity255[1], attrs=(!isnothing(attrs256) ? attrs256 : Proto.Attribute[]), value_arity=abstraction_with_arity255[2]) - return _t846 + _t1112 = Proto.MonusDef(monoid=monoid441, name=relation_id442, body=abstraction_with_arity443[1], attrs=(!isnothing(attrs444) ? attrs444 : Proto.Attribute[]), value_arity=abstraction_with_arity443[2]) + result446 = _t1112 + record_span!(parser, span_start445) + return result446 end function parse_constraint(parser::Parser)::Proto.Constraint + span_start451 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "functional_dependency") - _t847 = parse_relation_id(parser) - relation_id257 = _t847 - _t848 = parse_abstraction(parser) - abstraction258 = _t848 - _t849 = parse_functional_dependency_keys(parser) - functional_dependency_keys259 = _t849 - _t850 = parse_functional_dependency_values(parser) - functional_dependency_values260 = _t850 + push_path!(parser, 2) + _t1113 = parse_relation_id(parser) + relation_id447 = _t1113 + pop_path!(parser) + _t1114 = parse_abstraction(parser) + abstraction448 = _t1114 + _t1115 = parse_functional_dependency_keys(parser) + functional_dependency_keys449 = _t1115 + _t1116 = parse_functional_dependency_values(parser) + functional_dependency_values450 = _t1116 consume_literal!(parser, ")") - _t851 = Proto.FunctionalDependency(guard=abstraction258, keys=functional_dependency_keys259, values=functional_dependency_values260) - _t852 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t851), name=relation_id257) - return _t852 + _t1117 = Proto.FunctionalDependency(guard=abstraction448, keys=functional_dependency_keys449, values=functional_dependency_values450) + _t1118 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t1117), name=relation_id447) + result452 = _t1118 + record_span!(parser, span_start451) + return result452 end function parse_functional_dependency_keys(parser::Parser)::Vector{Proto.Var} + span_start458 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "keys") - xs261 = Proto.Var[] - cond262 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond262 - _t853 = parse_var(parser) - item263 = _t853 - push!(xs261, item263) - cond262 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs453 = Proto.Var[] + cond454 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx456 = 0 + while cond454 + push_path!(parser, idx456) + _t1119 = parse_var(parser) + item455 = _t1119 + pop_path!(parser) + push!(xs453, item455) + idx456 = (idx456 + 1) + cond454 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars264 = xs261 + vars457 = xs453 consume_literal!(parser, ")") - return vars264 + result459 = vars457 + record_span!(parser, span_start458) + return result459 end function parse_functional_dependency_values(parser::Parser)::Vector{Proto.Var} + span_start465 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "values") - xs265 = Proto.Var[] - cond266 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond266 - _t854 = parse_var(parser) - item267 = _t854 - push!(xs265, item267) - cond266 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs460 = Proto.Var[] + cond461 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx463 = 0 + while cond461 + push_path!(parser, idx463) + _t1120 = parse_var(parser) + item462 = _t1120 + pop_path!(parser) + push!(xs460, item462) + idx463 = (idx463 + 1) + cond461 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars268 = xs265 + vars464 = xs460 consume_literal!(parser, ")") - return vars268 + result466 = vars464 + record_span!(parser, span_start465) + return result466 end function parse_data(parser::Parser)::Proto.Data + span_start471 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t856 = 0 + _t1122 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t857 = 2 + _t1123 = 2 else if match_lookahead_literal(parser, "betree_relation", 1) - _t858 = 1 + _t1124 = 1 else - _t858 = -1 + _t1124 = -1 end - _t857 = _t858 + _t1123 = _t1124 end - _t856 = _t857 + _t1122 = _t1123 end - _t855 = _t856 + _t1121 = _t1122 else - _t855 = -1 + _t1121 = -1 end - prediction269 = _t855 + prediction467 = _t1121 - if prediction269 == 2 - _t860 = parse_csv_data(parser) - csv_data272 = _t860 - _t861 = Proto.Data(data_type=OneOf(:csv_data, csv_data272)) - _t859 = _t861 + if prediction467 == 2 + _t1126 = parse_csv_data(parser) + csv_data470 = _t1126 + _t1127 = Proto.Data(data_type=OneOf(:csv_data, csv_data470)) + _t1125 = _t1127 else - if prediction269 == 1 - _t863 = parse_betree_relation(parser) - betree_relation271 = _t863 - _t864 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation271)) - _t862 = _t864 + if prediction467 == 1 + _t1129 = parse_betree_relation(parser) + betree_relation469 = _t1129 + _t1130 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation469)) + _t1128 = _t1130 else - if prediction269 == 0 - _t866 = parse_rel_edb(parser) - rel_edb270 = _t866 - _t867 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb270)) - _t865 = _t867 + if prediction467 == 0 + _t1132 = parse_rel_edb(parser) + rel_edb468 = _t1132 + _t1133 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb468)) + _t1131 = _t1133 else throw(ParseError("Unexpected token in data" * ": " * string(lookahead(parser, 0)))) end - _t862 = _t865 + _t1128 = _t1131 end - _t859 = _t862 + _t1125 = _t1128 end - return _t859 + result472 = _t1125 + record_span!(parser, span_start471) + return result472 end function parse_rel_edb(parser::Parser)::Proto.RelEDB + span_start476 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "rel_edb") - _t868 = parse_relation_id(parser) - relation_id273 = _t868 - _t869 = parse_rel_edb_path(parser) - rel_edb_path274 = _t869 - _t870 = parse_rel_edb_types(parser) - rel_edb_types275 = _t870 + push_path!(parser, 1) + _t1134 = parse_relation_id(parser) + relation_id473 = _t1134 + pop_path!(parser) + push_path!(parser, 2) + _t1135 = parse_rel_edb_path(parser) + rel_edb_path474 = _t1135 + pop_path!(parser) + push_path!(parser, 3) + _t1136 = parse_rel_edb_types(parser) + rel_edb_types475 = _t1136 + pop_path!(parser) consume_literal!(parser, ")") - _t871 = Proto.RelEDB(target_id=relation_id273, path=rel_edb_path274, types=rel_edb_types275) - return _t871 + _t1137 = Proto.RelEDB(target_id=relation_id473, path=rel_edb_path474, types=rel_edb_types475) + result477 = _t1137 + record_span!(parser, span_start476) + return result477 end function parse_rel_edb_path(parser::Parser)::Vector{String} + span_start483 = span_start(parser) consume_literal!(parser, "[") - xs276 = String[] - cond277 = match_lookahead_terminal(parser, "STRING", 0) - while cond277 - item278 = consume_terminal!(parser, "STRING") - push!(xs276, item278) - cond277 = match_lookahead_terminal(parser, "STRING", 0) - end - strings279 = xs276 + xs478 = String[] + cond479 = match_lookahead_terminal(parser, "STRING", 0) + idx481 = 0 + while cond479 + push_path!(parser, idx481) + item480 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push!(xs478, item480) + idx481 = (idx481 + 1) + cond479 = match_lookahead_terminal(parser, "STRING", 0) + end + strings482 = xs478 consume_literal!(parser, "]") - return strings279 + result484 = strings482 + record_span!(parser, span_start483) + return result484 end function parse_rel_edb_types(parser::Parser)::Vector{Proto.var"#Type"} + span_start490 = span_start(parser) consume_literal!(parser, "[") - xs280 = Proto.var"#Type"[] - cond281 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond281 - _t872 = parse_type(parser) - item282 = _t872 - push!(xs280, item282) - cond281 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - end - types283 = xs280 + xs485 = Proto.var"#Type"[] + cond486 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx488 = 0 + while cond486 + push_path!(parser, idx488) + _t1138 = parse_type(parser) + item487 = _t1138 + pop_path!(parser) + push!(xs485, item487) + idx488 = (idx488 + 1) + cond486 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + end + types489 = xs485 consume_literal!(parser, "]") - return types283 + result491 = types489 + record_span!(parser, span_start490) + return result491 end function parse_betree_relation(parser::Parser)::Proto.BeTreeRelation + span_start494 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_relation") - _t873 = parse_relation_id(parser) - relation_id284 = _t873 - _t874 = parse_betree_info(parser) - betree_info285 = _t874 + push_path!(parser, 1) + _t1139 = parse_relation_id(parser) + relation_id492 = _t1139 + pop_path!(parser) + push_path!(parser, 2) + _t1140 = parse_betree_info(parser) + betree_info493 = _t1140 + pop_path!(parser) consume_literal!(parser, ")") - _t875 = Proto.BeTreeRelation(name=relation_id284, relation_info=betree_info285) - return _t875 + _t1141 = Proto.BeTreeRelation(name=relation_id492, relation_info=betree_info493) + result495 = _t1141 + record_span!(parser, span_start494) + return result495 end function parse_betree_info(parser::Parser)::Proto.BeTreeInfo + span_start499 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_info") - _t876 = parse_betree_info_key_types(parser) - betree_info_key_types286 = _t876 - _t877 = parse_betree_info_value_types(parser) - betree_info_value_types287 = _t877 - _t878 = parse_config_dict(parser) - config_dict288 = _t878 + _t1142 = parse_betree_info_key_types(parser) + betree_info_key_types496 = _t1142 + _t1143 = parse_betree_info_value_types(parser) + betree_info_value_types497 = _t1143 + _t1144 = parse_config_dict(parser) + config_dict498 = _t1144 consume_literal!(parser, ")") - _t879 = construct_betree_info(parser, betree_info_key_types286, betree_info_value_types287, config_dict288) - return _t879 + _t1145 = construct_betree_info(parser, betree_info_key_types496, betree_info_value_types497, config_dict498) + result500 = _t1145 + record_span!(parser, span_start499) + return result500 end function parse_betree_info_key_types(parser::Parser)::Vector{Proto.var"#Type"} + span_start506 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "key_types") - xs289 = Proto.var"#Type"[] - cond290 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond290 - _t880 = parse_type(parser) - item291 = _t880 - push!(xs289, item291) - cond290 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs501 = Proto.var"#Type"[] + cond502 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx504 = 0 + while cond502 + push_path!(parser, idx504) + _t1146 = parse_type(parser) + item503 = _t1146 + pop_path!(parser) + push!(xs501, item503) + idx504 = (idx504 + 1) + cond502 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types292 = xs289 + types505 = xs501 consume_literal!(parser, ")") - return types292 + result507 = types505 + record_span!(parser, span_start506) + return result507 end function parse_betree_info_value_types(parser::Parser)::Vector{Proto.var"#Type"} + span_start513 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "value_types") - xs293 = Proto.var"#Type"[] - cond294 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond294 - _t881 = parse_type(parser) - item295 = _t881 - push!(xs293, item295) - cond294 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs508 = Proto.var"#Type"[] + cond509 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx511 = 0 + while cond509 + push_path!(parser, idx511) + _t1147 = parse_type(parser) + item510 = _t1147 + pop_path!(parser) + push!(xs508, item510) + idx511 = (idx511 + 1) + cond509 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types296 = xs293 + types512 = xs508 consume_literal!(parser, ")") - return types296 + result514 = types512 + record_span!(parser, span_start513) + return result514 end function parse_csv_data(parser::Parser)::Proto.CSVData + span_start519 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_data") - _t882 = parse_csvlocator(parser) - csvlocator297 = _t882 - _t883 = parse_csv_config(parser) - csv_config298 = _t883 - _t884 = parse_csv_columns(parser) - csv_columns299 = _t884 - _t885 = parse_csv_asof(parser) - csv_asof300 = _t885 + push_path!(parser, 1) + _t1148 = parse_csvlocator(parser) + csvlocator515 = _t1148 + pop_path!(parser) + push_path!(parser, 2) + _t1149 = parse_csv_config(parser) + csv_config516 = _t1149 + pop_path!(parser) + push_path!(parser, 3) + _t1150 = parse_csv_columns(parser) + csv_columns517 = _t1150 + pop_path!(parser) + push_path!(parser, 4) + _t1151 = parse_csv_asof(parser) + csv_asof518 = _t1151 + pop_path!(parser) consume_literal!(parser, ")") - _t886 = Proto.CSVData(locator=csvlocator297, config=csv_config298, columns=csv_columns299, asof=csv_asof300) - return _t886 + _t1152 = Proto.CSVData(locator=csvlocator515, config=csv_config516, columns=csv_columns517, asof=csv_asof518) + result520 = _t1152 + record_span!(parser, span_start519) + return result520 end function parse_csvlocator(parser::Parser)::Proto.CSVLocator + span_start523 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_locator") + push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "paths", 1)) - _t888 = parse_csv_locator_paths(parser) - _t887 = _t888 + _t1154 = parse_csv_locator_paths(parser) + _t1153 = _t1154 else - _t887 = nothing + _t1153 = nothing end - csv_locator_paths301 = _t887 + csv_locator_paths521 = _t1153 + pop_path!(parser) if match_lookahead_literal(parser, "(", 0) - _t890 = parse_csv_locator_inline_data(parser) - _t889 = _t890 + _t1156 = parse_csv_locator_inline_data(parser) + _t1155 = _t1156 else - _t889 = nothing + _t1155 = nothing end - csv_locator_inline_data302 = _t889 + csv_locator_inline_data522 = _t1155 consume_literal!(parser, ")") - _t891 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths301) ? csv_locator_paths301 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data302) ? csv_locator_inline_data302 : ""))) - return _t891 + _t1157 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths521) ? csv_locator_paths521 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data522) ? csv_locator_inline_data522 : ""))) + result524 = _t1157 + record_span!(parser, span_start523) + return result524 end function parse_csv_locator_paths(parser::Parser)::Vector{String} + span_start530 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "paths") - xs303 = String[] - cond304 = match_lookahead_terminal(parser, "STRING", 0) - while cond304 - item305 = consume_terminal!(parser, "STRING") - push!(xs303, item305) - cond304 = match_lookahead_terminal(parser, "STRING", 0) + xs525 = String[] + cond526 = match_lookahead_terminal(parser, "STRING", 0) + idx528 = 0 + while cond526 + push_path!(parser, idx528) + item527 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push!(xs525, item527) + idx528 = (idx528 + 1) + cond526 = match_lookahead_terminal(parser, "STRING", 0) end - strings306 = xs303 + strings529 = xs525 consume_literal!(parser, ")") - return strings306 + result531 = strings529 + record_span!(parser, span_start530) + return result531 end function parse_csv_locator_inline_data(parser::Parser)::String + span_start533 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "inline_data") - string307 = consume_terminal!(parser, "STRING") + string532 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string307 + result534 = string532 + record_span!(parser, span_start533) + return result534 end function parse_csv_config(parser::Parser)::Proto.CSVConfig + span_start536 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_config") - _t892 = parse_config_dict(parser) - config_dict308 = _t892 + _t1158 = parse_config_dict(parser) + config_dict535 = _t1158 consume_literal!(parser, ")") - _t893 = construct_csv_config(parser, config_dict308) - return _t893 + _t1159 = construct_csv_config(parser, config_dict535) + result537 = _t1159 + record_span!(parser, span_start536) + return result537 end function parse_csv_columns(parser::Parser)::Vector{Proto.CSVColumn} + span_start543 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs309 = Proto.CSVColumn[] - cond310 = match_lookahead_literal(parser, "(", 0) - while cond310 - _t894 = parse_csv_column(parser) - item311 = _t894 - push!(xs309, item311) - cond310 = match_lookahead_literal(parser, "(", 0) + xs538 = Proto.CSVColumn[] + cond539 = match_lookahead_literal(parser, "(", 0) + idx541 = 0 + while cond539 + push_path!(parser, idx541) + _t1160 = parse_csv_column(parser) + item540 = _t1160 + pop_path!(parser) + push!(xs538, item540) + idx541 = (idx541 + 1) + cond539 = match_lookahead_literal(parser, "(", 0) end - csv_columns312 = xs309 + csv_columns542 = xs538 consume_literal!(parser, ")") - return csv_columns312 + result544 = csv_columns542 + record_span!(parser, span_start543) + return result544 end function parse_csv_column(parser::Parser)::Proto.CSVColumn + span_start552 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") - string313 = consume_terminal!(parser, "STRING") - _t895 = parse_relation_id(parser) - relation_id314 = _t895 + push_path!(parser, 1) + string545 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1161 = parse_relation_id(parser) + relation_id546 = _t1161 + pop_path!(parser) consume_literal!(parser, "[") - xs315 = Proto.var"#Type"[] - cond316 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond316 - _t896 = parse_type(parser) - item317 = _t896 - push!(xs315, item317) - cond316 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - end - types318 = xs315 + push_path!(parser, 3) + xs547 = Proto.var"#Type"[] + cond548 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx550 = 0 + while cond548 + push_path!(parser, idx550) + _t1162 = parse_type(parser) + item549 = _t1162 + pop_path!(parser) + push!(xs547, item549) + idx550 = (idx550 + 1) + cond548 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + end + pop_path!(parser) + types551 = xs547 consume_literal!(parser, "]") consume_literal!(parser, ")") - _t897 = Proto.CSVColumn(column_name=string313, target_id=relation_id314, types=types318) - return _t897 + _t1163 = Proto.CSVColumn(column_name=string545, target_id=relation_id546, types=types551) + result553 = _t1163 + record_span!(parser, span_start552) + return result553 end function parse_csv_asof(parser::Parser)::String + span_start555 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "asof") - string319 = consume_terminal!(parser, "STRING") + string554 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string319 + result556 = string554 + record_span!(parser, span_start555) + return result556 end function parse_undefine(parser::Parser)::Proto.Undefine + span_start558 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "undefine") - _t898 = parse_fragment_id(parser) - fragment_id320 = _t898 + push_path!(parser, 1) + _t1164 = parse_fragment_id(parser) + fragment_id557 = _t1164 + pop_path!(parser) consume_literal!(parser, ")") - _t899 = Proto.Undefine(fragment_id=fragment_id320) - return _t899 + _t1165 = Proto.Undefine(fragment_id=fragment_id557) + result559 = _t1165 + record_span!(parser, span_start558) + return result559 end function parse_context(parser::Parser)::Proto.Context + span_start565 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "context") - xs321 = Proto.RelationId[] - cond322 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond322 - _t900 = parse_relation_id(parser) - item323 = _t900 - push!(xs321, item323) - cond322 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + xs560 = Proto.RelationId[] + cond561 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx563 = 0 + while cond561 + push_path!(parser, idx563) + _t1166 = parse_relation_id(parser) + item562 = _t1166 + pop_path!(parser) + push!(xs560, item562) + idx563 = (idx563 + 1) + cond561 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) end - relation_ids324 = xs321 + pop_path!(parser) + relation_ids564 = xs560 consume_literal!(parser, ")") - _t901 = Proto.Context(relations=relation_ids324) - return _t901 + _t1167 = Proto.Context(relations=relation_ids564) + result566 = _t1167 + record_span!(parser, span_start565) + return result566 end function parse_epoch_reads(parser::Parser)::Vector{Proto.Read} + span_start572 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reads") - xs325 = Proto.Read[] - cond326 = match_lookahead_literal(parser, "(", 0) - while cond326 - _t902 = parse_read(parser) - item327 = _t902 - push!(xs325, item327) - cond326 = match_lookahead_literal(parser, "(", 0) + xs567 = Proto.Read[] + cond568 = match_lookahead_literal(parser, "(", 0) + idx570 = 0 + while cond568 + push_path!(parser, idx570) + _t1168 = parse_read(parser) + item569 = _t1168 + pop_path!(parser) + push!(xs567, item569) + idx570 = (idx570 + 1) + cond568 = match_lookahead_literal(parser, "(", 0) end - reads328 = xs325 + reads571 = xs567 consume_literal!(parser, ")") - return reads328 + result573 = reads571 + record_span!(parser, span_start572) + return result573 end function parse_read(parser::Parser)::Proto.Read + span_start580 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "what_if", 1) - _t904 = 2 + _t1170 = 2 else if match_lookahead_literal(parser, "output", 1) - _t905 = 1 + _t1171 = 1 else if match_lookahead_literal(parser, "export", 1) - _t906 = 4 + _t1172 = 4 else if match_lookahead_literal(parser, "demand", 1) - _t907 = 0 + _t1173 = 0 else if match_lookahead_literal(parser, "abort", 1) - _t908 = 3 + _t1174 = 3 else - _t908 = -1 + _t1174 = -1 end - _t907 = _t908 + _t1173 = _t1174 end - _t906 = _t907 + _t1172 = _t1173 end - _t905 = _t906 + _t1171 = _t1172 end - _t904 = _t905 + _t1170 = _t1171 end - _t903 = _t904 + _t1169 = _t1170 else - _t903 = -1 + _t1169 = -1 end - prediction329 = _t903 + prediction574 = _t1169 - if prediction329 == 4 - _t910 = parse_export(parser) - export334 = _t910 - _t911 = Proto.Read(read_type=OneOf(:var"#export", export334)) - _t909 = _t911 + if prediction574 == 4 + _t1176 = parse_export(parser) + export579 = _t1176 + _t1177 = Proto.Read(read_type=OneOf(:var"#export", export579)) + _t1175 = _t1177 else - if prediction329 == 3 - _t913 = parse_abort(parser) - abort333 = _t913 - _t914 = Proto.Read(read_type=OneOf(:abort, abort333)) - _t912 = _t914 + if prediction574 == 3 + _t1179 = parse_abort(parser) + abort578 = _t1179 + _t1180 = Proto.Read(read_type=OneOf(:abort, abort578)) + _t1178 = _t1180 else - if prediction329 == 2 - _t916 = parse_what_if(parser) - what_if332 = _t916 - _t917 = Proto.Read(read_type=OneOf(:what_if, what_if332)) - _t915 = _t917 + if prediction574 == 2 + _t1182 = parse_what_if(parser) + what_if577 = _t1182 + _t1183 = Proto.Read(read_type=OneOf(:what_if, what_if577)) + _t1181 = _t1183 else - if prediction329 == 1 - _t919 = parse_output(parser) - output331 = _t919 - _t920 = Proto.Read(read_type=OneOf(:output, output331)) - _t918 = _t920 + if prediction574 == 1 + _t1185 = parse_output(parser) + output576 = _t1185 + _t1186 = Proto.Read(read_type=OneOf(:output, output576)) + _t1184 = _t1186 else - if prediction329 == 0 - _t922 = parse_demand(parser) - demand330 = _t922 - _t923 = Proto.Read(read_type=OneOf(:demand, demand330)) - _t921 = _t923 + if prediction574 == 0 + _t1188 = parse_demand(parser) + demand575 = _t1188 + _t1189 = Proto.Read(read_type=OneOf(:demand, demand575)) + _t1187 = _t1189 else throw(ParseError("Unexpected token in read" * ": " * string(lookahead(parser, 0)))) end - _t918 = _t921 + _t1184 = _t1187 end - _t915 = _t918 + _t1181 = _t1184 end - _t912 = _t915 + _t1178 = _t1181 end - _t909 = _t912 + _t1175 = _t1178 end - return _t909 + result581 = _t1175 + record_span!(parser, span_start580) + return result581 end function parse_demand(parser::Parser)::Proto.Demand + span_start583 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "demand") - _t924 = parse_relation_id(parser) - relation_id335 = _t924 + push_path!(parser, 1) + _t1190 = parse_relation_id(parser) + relation_id582 = _t1190 + pop_path!(parser) consume_literal!(parser, ")") - _t925 = Proto.Demand(relation_id=relation_id335) - return _t925 + _t1191 = Proto.Demand(relation_id=relation_id582) + result584 = _t1191 + record_span!(parser, span_start583) + return result584 end function parse_output(parser::Parser)::Proto.Output + span_start587 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "output") - _t926 = parse_name(parser) - name336 = _t926 - _t927 = parse_relation_id(parser) - relation_id337 = _t927 + push_path!(parser, 1) + _t1192 = parse_name(parser) + name585 = _t1192 + pop_path!(parser) + push_path!(parser, 2) + _t1193 = parse_relation_id(parser) + relation_id586 = _t1193 + pop_path!(parser) consume_literal!(parser, ")") - _t928 = Proto.Output(name=name336, relation_id=relation_id337) - return _t928 + _t1194 = Proto.Output(name=name585, relation_id=relation_id586) + result588 = _t1194 + record_span!(parser, span_start587) + return result588 end function parse_what_if(parser::Parser)::Proto.WhatIf + span_start591 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "what_if") - _t929 = parse_name(parser) - name338 = _t929 - _t930 = parse_epoch(parser) - epoch339 = _t930 + push_path!(parser, 1) + _t1195 = parse_name(parser) + name589 = _t1195 + pop_path!(parser) + push_path!(parser, 2) + _t1196 = parse_epoch(parser) + epoch590 = _t1196 + pop_path!(parser) consume_literal!(parser, ")") - _t931 = Proto.WhatIf(branch=name338, epoch=epoch339) - return _t931 + _t1197 = Proto.WhatIf(branch=name589, epoch=epoch590) + result592 = _t1197 + record_span!(parser, span_start591) + return result592 end function parse_abort(parser::Parser)::Proto.Abort + span_start595 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "abort") + push_path!(parser, 1) if (match_lookahead_literal(parser, ":", 0) && match_lookahead_terminal(parser, "SYMBOL", 1)) - _t933 = parse_name(parser) - _t932 = _t933 + _t1199 = parse_name(parser) + _t1198 = _t1199 else - _t932 = nothing + _t1198 = nothing end - name340 = _t932 - _t934 = parse_relation_id(parser) - relation_id341 = _t934 + name593 = _t1198 + pop_path!(parser) + push_path!(parser, 2) + _t1200 = parse_relation_id(parser) + relation_id594 = _t1200 + pop_path!(parser) consume_literal!(parser, ")") - _t935 = Proto.Abort(name=(!isnothing(name340) ? name340 : "abort"), relation_id=relation_id341) - return _t935 + _t1201 = Proto.Abort(name=(!isnothing(name593) ? name593 : "abort"), relation_id=relation_id594) + result596 = _t1201 + record_span!(parser, span_start595) + return result596 end function parse_export(parser::Parser)::Proto.Export + span_start598 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export") - _t936 = parse_export_csv_config(parser) - export_csv_config342 = _t936 + push_path!(parser, 1) + _t1202 = parse_export_csv_config(parser) + export_csv_config597 = _t1202 + pop_path!(parser) consume_literal!(parser, ")") - _t937 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config342)) - return _t937 + _t1203 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config597)) + result599 = _t1203 + record_span!(parser, span_start598) + return result599 end function parse_export_csv_config(parser::Parser)::Proto.ExportCSVConfig + span_start603 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export_csv_config") - _t938 = parse_export_csv_path(parser) - export_csv_path343 = _t938 - _t939 = parse_export_csv_columns(parser) - export_csv_columns344 = _t939 - _t940 = parse_config_dict(parser) - config_dict345 = _t940 + _t1204 = parse_export_csv_path(parser) + export_csv_path600 = _t1204 + _t1205 = parse_export_csv_columns(parser) + export_csv_columns601 = _t1205 + _t1206 = parse_config_dict(parser) + config_dict602 = _t1206 consume_literal!(parser, ")") - _t941 = export_csv_config(parser, export_csv_path343, export_csv_columns344, config_dict345) - return _t941 + _t1207 = export_csv_config(parser, export_csv_path600, export_csv_columns601, config_dict602) + result604 = _t1207 + record_span!(parser, span_start603) + return result604 end function parse_export_csv_path(parser::Parser)::String + span_start606 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "path") - string346 = consume_terminal!(parser, "STRING") + string605 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string346 + result607 = string605 + record_span!(parser, span_start606) + return result607 end function parse_export_csv_columns(parser::Parser)::Vector{Proto.ExportCSVColumn} + span_start613 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs347 = Proto.ExportCSVColumn[] - cond348 = match_lookahead_literal(parser, "(", 0) - while cond348 - _t942 = parse_export_csv_column(parser) - item349 = _t942 - push!(xs347, item349) - cond348 = match_lookahead_literal(parser, "(", 0) + xs608 = Proto.ExportCSVColumn[] + cond609 = match_lookahead_literal(parser, "(", 0) + idx611 = 0 + while cond609 + push_path!(parser, idx611) + _t1208 = parse_export_csv_column(parser) + item610 = _t1208 + pop_path!(parser) + push!(xs608, item610) + idx611 = (idx611 + 1) + cond609 = match_lookahead_literal(parser, "(", 0) end - export_csv_columns350 = xs347 + export_csv_columns612 = xs608 consume_literal!(parser, ")") - return export_csv_columns350 + result614 = export_csv_columns612 + record_span!(parser, span_start613) + return result614 end function parse_export_csv_column(parser::Parser)::Proto.ExportCSVColumn + span_start617 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") - string351 = consume_terminal!(parser, "STRING") - _t943 = parse_relation_id(parser) - relation_id352 = _t943 + push_path!(parser, 1) + string615 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1209 = parse_relation_id(parser) + relation_id616 = _t1209 + pop_path!(parser) consume_literal!(parser, ")") - _t944 = Proto.ExportCSVColumn(column_name=string351, column_data=relation_id352) - return _t944 + _t1210 = Proto.ExportCSVColumn(column_name=string615, column_data=relation_id616) + result618 = _t1210 + record_span!(parser, span_start617) + return result618 end function parse(input::String) lexer = Lexer(input) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input) result = parse_transaction(parser) # Check for unconsumed tokens (except EOF) if parser.pos <= length(parser.tokens) @@ -3714,5 +4432,5 @@ function parse(input::String) throw(ParseError("Unexpected token at end of input: $remaining_token")) end end - return result + return result, parser.provenance end diff --git a/julia/LQPParser/test/runtests.jl b/julia/LQPParser/test/runtests.jl index b48042f7..7788b8e6 100644 --- a/julia/LQPParser/test/runtests.jl +++ b/julia/LQPParser/test/runtests.jl @@ -34,7 +34,7 @@ end (reads))) """ - result = parse(input) + result, provenance = parse(input) @test result !== nothing @test typeof(result) == Proto.Transaction @test length(result.epochs) == 1 @@ -54,7 +54,7 @@ end # Parse the LQP file content = read(lqp_path, String) - result = parse(content) + result, _ = parse(content) @test result !== nothing @test typeof(result) == Proto.Transaction diff --git a/python-tools/src/lqp/cli.py b/python-tools/src/lqp/cli.py index e8a1f56f..3b53032f 100644 --- a/python-tools/src/lqp/cli.py +++ b/python-tools/src/lqp/cli.py @@ -25,9 +25,9 @@ def parse_lqp_to_proto(filename, use_generated=False, validate=True): if use_generated: from lqp.gen.parser import parse from lqp.proto_validator import validate_proto - lqp_proto = parse(lqp_text) + lqp_proto, provenance = parse(lqp_text) if validate: - validate_proto(lqp_proto) + validate_proto(lqp_proto, provenance) else: lqp = parse_lqp(filename, lqp_text) if validate and isinstance(lqp, ir.Transaction): diff --git a/python-tools/src/lqp/gen/parser.py b/python-tools/src/lqp/gen/parser.py index 8a2cbf55..33050592 100644 --- a/python-tools/src/lqp/gen/parser.py +++ b/python-tools/src/lqp/gen/parser.py @@ -10,10 +10,12 @@ """ import ast +import bisect import hashlib import re from collections.abc import Sequence -from typing import List, Optional, Any, Tuple, Callable +from dataclasses import dataclass +from typing import Dict, List, Optional, Any, Tuple, Callable from decimal import Decimal from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -24,15 +26,31 @@ class ParseError(Exception): pass +@dataclass(frozen=True) +class Location: + """Source location with 1-based line and column.""" + line: int + column: int + offset: int + + +@dataclass(frozen=True) +class Span: + """Source span from start to end location.""" + start: Location + end: Location + + class Token: """Token representation.""" - def __init__(self, type: str, value: str, pos: int): + def __init__(self, type: str, value: str, start_pos: int, end_pos: int): self.type = type self.value = value - self.pos = pos + self.start_pos = start_pos + self.end_pos = end_pos def __repr__(self) -> str: - return f"Token({self.type}, {self.value!r}, {self.pos})" + return f"Token({self.type}, {self.value!r}, {self.start_pos})" class Lexer: @@ -102,10 +120,10 @@ def _tokenize(self) -> None: # Pick the longest match token_type, value, action, end_pos = max(candidates, key=lambda x: x[3]) - self.tokens.append(Token(token_type, action(value), self.pos)) + self.tokens.append(Token(token_type, action(value), self.pos, end_pos)) self.pos = end_pos - self.tokens.append(Token('$', '', self.pos)) + self.tokens.append(Token('$', '', self.pos, self.pos)) @staticmethod def scan_symbol(s: str) -> str: @@ -179,32 +197,45 @@ def scan_decimal(d: str) -> Any: return logic_pb2.DecimalValue(precision=precision, scale=scale, value=value) +def _compute_line_starts(text: str) -> List[int]: + """Compute byte offsets where each line begins.""" + starts = [0] + for i, ch in enumerate(text): + if ch == '\n': + starts.append(i + 1) + return starts + + class Parser: """LL(k) recursive-descent parser with backtracking.""" - def __init__(self, tokens: List[Token]): + def __init__(self, tokens: List[Token], input_str: str): self.tokens = tokens self.pos = 0 self.id_to_debuginfo = {} self._current_fragment_id: bytes | None = None self._relation_id_to_name = {} + self.provenance: Dict[Tuple[int, ...], Span] = {} + self._path: List[int] = [] + self._input_str = input_str + self._line_starts = _compute_line_starts(input_str) def lookahead(self, k: int = 0) -> Token: """Get lookahead token at offset k.""" idx = self.pos + k - return self.tokens[idx] if idx < len(self.tokens) else Token('$', '', -1) + return self.tokens[idx] if idx < len(self.tokens) else Token('$', '', -1, -1) def consume_literal(self, expected: str) -> None: """Consume a literal token.""" if not self.match_lookahead_literal(expected, 0): token = self.lookahead(0) - raise ParseError(f'Expected literal {expected!r} but got {token.type}=`{token.value!r}` at position {token.pos}') + raise ParseError(f'Expected literal {expected!r} but got {token.type}=`{token.value!r}` at position {token.start_pos}') self.pos += 1 def consume_terminal(self, expected: str) -> Any: """Consume a terminal token and return parsed value.""" if not self.match_lookahead_terminal(expected, 0): token = self.lookahead(0) - raise ParseError(f'Expected terminal {expected} but got {token.type}=`{token.value!r}` at position {token.pos}') + raise ParseError(f'Expected terminal {expected} but got {token.type}=`{token.value!r}` at position {token.start_pos}') token = self.lookahead(0) self.pos += 1 return token.value @@ -227,6 +258,25 @@ def match_lookahead_terminal(self, terminal: str, k: int) -> bool: token = self.lookahead(k) return token.type == terminal + def _push_path(self, n: int) -> None: + self._path.append(n) + + def _pop_path(self) -> None: + self._path.pop() + + def _span_start(self) -> int: + return self.tokens[self.pos].start_pos + + def _record_span(self, start_offset: int) -> None: + end_offset = self.tokens[self.pos - 1].end_pos + span = Span(self._make_location(start_offset), self._make_location(end_offset)) + self.provenance[tuple(self._path)] = span + + def _make_location(self, offset: int) -> Location: + line = bisect.bisect_right(self._line_starts, offset) + column = offset - self._line_starts[line - 1] + 1 + return Location(line, column, offset) + def start_fragment(self, fragment_id: fragments_pb2.FragmentId) -> fragments_pb2.FragmentId: """Set current fragment ID for debug info tracking.""" self._current_fragment_id = fragment_id.id @@ -282,10 +332,10 @@ def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) - if value is not None: assert value is not None - _t945 = value.HasField('int_value') + _t1211 = value.HasField('int_value') else: - _t945 = False - if _t945: + _t1211 = False + if _t1211: assert value is not None return int(value.int_value) return int(default) @@ -294,10 +344,10 @@ def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) - if value is not None: assert value is not None - _t946 = value.HasField('int_value') + _t1212 = value.HasField('int_value') else: - _t946 = False - if _t946: + _t1212 = False + if _t1212: assert value is not None return value.int_value return default @@ -306,10 +356,10 @@ def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: floa if value is not None: assert value is not None - _t947 = value.HasField('float_value') + _t1213 = value.HasField('float_value') else: - _t947 = False - if _t947: + _t1213 = False + if _t1213: assert value is not None return value.float_value return default @@ -318,10 +368,10 @@ def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) if value is not None: assert value is not None - _t948 = value.HasField('string_value') + _t1214 = value.HasField('string_value') else: - _t948 = False - if _t948: + _t1214 = False + if _t1214: assert value is not None return value.string_value return default @@ -330,10 +380,10 @@ def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool if value is not None: assert value is not None - _t949 = value.HasField('boolean_value') + _t1215 = value.HasField('boolean_value') else: - _t949 = False - if _t949: + _t1215 = False + if _t1215: assert value is not None return value.boolean_value return default @@ -342,10 +392,10 @@ def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) if value is not None: assert value is not None - _t950 = value.HasField('string_value') + _t1216 = value.HasField('string_value') else: - _t950 = False - if _t950: + _t1216 = False + if _t1216: assert value is not None return value.string_value.encode() return default @@ -354,10 +404,10 @@ def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logi if value is not None: assert value is not None - _t951 = value.HasField('uint128_value') + _t1217 = value.HasField('uint128_value') else: - _t951 = False - if _t951: + _t1217 = False + if _t1217: assert value is not None return value.uint128_value return default @@ -366,10 +416,10 @@ def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: if value is not None: assert value is not None - _t952 = value.HasField('string_value') + _t1218 = value.HasField('string_value') else: - _t952 = False - if _t952: + _t1218 = False + if _t1218: assert value is not None return [value.string_value] return default @@ -378,10 +428,10 @@ def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional if value is not None: assert value is not None - _t953 = value.HasField('int_value') + _t1219 = value.HasField('int_value') else: - _t953 = False - if _t953: + _t1219 = False + if _t1219: assert value is not None return value.int_value return None @@ -390,10 +440,10 @@ def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Option if value is not None: assert value is not None - _t954 = value.HasField('float_value') + _t1220 = value.HasField('float_value') else: - _t954 = False - if _t954: + _t1220 = False + if _t1220: assert value is not None return value.float_value return None @@ -402,10 +452,10 @@ def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optiona if value is not None: assert value is not None - _t955 = value.HasField('string_value') + _t1221 = value.HasField('string_value') else: - _t955 = False - if _t955: + _t1221 = False + if _t1221: assert value is not None return value.string_value return None @@ -414,10 +464,10 @@ def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional if value is not None: assert value is not None - _t956 = value.HasField('string_value') + _t1222 = value.HasField('string_value') else: - _t956 = False - if _t956: + _t1222 = False + if _t1222: assert value is not None return value.string_value.encode() return None @@ -426,10 +476,10 @@ def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Option if value is not None: assert value is not None - _t957 = value.HasField('uint128_value') + _t1223 = value.HasField('uint128_value') else: - _t957 = False - if _t957: + _t1223 = False + if _t1223: assert value is not None return value.uint128_value return None @@ -438,71 +488,71 @@ def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Op if value is not None: assert value is not None - _t958 = value.HasField('string_value') + _t1224 = value.HasField('string_value') else: - _t958 = False - if _t958: + _t1224 = False + if _t1224: assert value is not None return [value.string_value] return None def construct_csv_config(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t959 = self._extract_value_int32(config.get('csv_header_row'), 1) - header_row = _t959 - _t960 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t960 - _t961 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t961 - _t962 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t962 - _t963 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t963 - _t964 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t964 - _t965 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t965 - _t966 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t966 - _t967 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t967 - _t968 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t968 - _t969 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t969 - _t970 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t970 + _t1225 = self._extract_value_int32(config.get('csv_header_row'), 1) + header_row = _t1225 + _t1226 = self._extract_value_int64(config.get('csv_skip'), 0) + skip = _t1226 + _t1227 = self._extract_value_string(config.get('csv_new_line'), '') + new_line = _t1227 + _t1228 = self._extract_value_string(config.get('csv_delimiter'), ',') + delimiter = _t1228 + _t1229 = self._extract_value_string(config.get('csv_quotechar'), '"') + quotechar = _t1229 + _t1230 = self._extract_value_string(config.get('csv_escapechar'), '"') + escapechar = _t1230 + _t1231 = self._extract_value_string(config.get('csv_comment'), '') + comment = _t1231 + _t1232 = self._extract_value_string_list(config.get('csv_missing_strings'), []) + missing_strings = _t1232 + _t1233 = self._extract_value_string(config.get('csv_decimal_separator'), '.') + decimal_separator = _t1233 + _t1234 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') + encoding = _t1234 + _t1235 = self._extract_value_string(config.get('csv_compression'), 'auto') + compression = _t1235 + _t1236 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1236 def construct_betree_info(self, key_types: Sequence[logic_pb2.Type], value_types: Sequence[logic_pb2.Type], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t971 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t971 - _t972 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t972 - _t973 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t973 - _t974 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t974 - _t975 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t975 - _t976 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t976 - _t977 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t977 - _t978 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t978 - _t979 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t979 - _t980 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t980 - _t981 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t981 + _t1237 = self._try_extract_value_float64(config.get('betree_config_epsilon')) + epsilon = _t1237 + _t1238 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) + max_pivots = _t1238 + _t1239 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) + max_deltas = _t1239 + _t1240 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) + max_leaf = _t1240 + _t1241 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1241 + _t1242 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) + root_pageid = _t1242 + _t1243 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) + inline_data = _t1243 + _t1244 = self._try_extract_value_int64(config.get('betree_locator_element_count')) + element_count = _t1244 + _t1245 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) + tree_height = _t1245 + _t1246 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1246 + _t1247 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1247 def default_configure(self) -> transactions_pb2.Configure: - _t982 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t982 - _t983 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t983 + _t1248 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1248 + _t1249 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1249 def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -519,55 +569,55 @@ def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]] maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t984 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t984 - _t985 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t985 - _t986 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t986 + _t1250 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1250 + _t1251 = self._extract_value_int64(config.get('semantics_version'), 0) + semantics_version = _t1251 + _t1252 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1252 def export_csv_config(self, path: str, columns: Sequence[transactions_pb2.ExportCSVColumn], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t987 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t987 - _t988 = self._extract_value_string(config.get('compression'), '') - compression = _t988 - _t989 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t989 - _t990 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t990 - _t991 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t991 - _t992 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t992 - _t993 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t993 - _t994 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t994 + _t1253 = self._extract_value_int64(config.get('partition_size'), 0) + partition_size = _t1253 + _t1254 = self._extract_value_string(config.get('compression'), '') + compression = _t1254 + _t1255 = self._extract_value_boolean(config.get('syntax_header_row'), True) + syntax_header_row = _t1255 + _t1256 = self._extract_value_string(config.get('syntax_missing_string'), '') + syntax_missing_string = _t1256 + _t1257 = self._extract_value_string(config.get('syntax_delim'), ',') + syntax_delim = _t1257 + _t1258 = self._extract_value_string(config.get('syntax_quotechar'), '"') + syntax_quotechar = _t1258 + _t1259 = self._extract_value_string(config.get('syntax_escapechar'), '\\') + syntax_escapechar = _t1259 + _t1260 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1260 def _make_value_int32(self, v: int) -> logic_pb2.Value: - _t995 = logic_pb2.Value(int_value=int(v)) - return _t995 + _t1261 = logic_pb2.Value(int_value=int(v)) + return _t1261 def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t996 = logic_pb2.Value(int_value=v) - return _t996 + _t1262 = logic_pb2.Value(int_value=v) + return _t1262 def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t997 = logic_pb2.Value(float_value=v) - return _t997 + _t1263 = logic_pb2.Value(float_value=v) + return _t1263 def _make_value_string(self, v: str) -> logic_pb2.Value: - _t998 = logic_pb2.Value(string_value=v) - return _t998 + _t1264 = logic_pb2.Value(string_value=v) + return _t1264 def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t999 = logic_pb2.Value(boolean_value=v) - return _t999 + _t1265 = logic_pb2.Value(boolean_value=v) + return _t1265 def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1000 = logic_pb2.Value(uint128_value=v) - return _t1000 + _t1266 = logic_pb2.Value(uint128_value=v) + return _t1266 def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: if cfg.semantics_version != 0: @@ -580,136 +630,136 @@ def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[s result = [] if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1002 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1002,)) - _t1001 = None + _t1268 = self._make_value_string('auto') + result.append(('ivm.maintenance_level', _t1268,)) + _t1267 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1004 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1004,)) - _t1003 = None + _t1270 = self._make_value_string('all') + result.append(('ivm.maintenance_level', _t1270,)) + _t1269 = None else: if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1006 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1006,)) - _t1005 = None + _t1272 = self._make_value_string('off') + result.append(('ivm.maintenance_level', _t1272,)) + _t1271 = None else: - _t1005 = None - _t1003 = _t1005 - _t1001 = _t1003 - _t1007 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1007,)) + _t1271 = None + _t1269 = _t1271 + _t1267 = _t1269 + _t1273 = self._make_value_int64(msg.semantics_version) + result.append(('semantics_version', _t1273,)) return sorted(result) def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1008 = self._make_value_int32(msg.header_row) - result.append(('csv_header_row', _t1008,)) - _t1009 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1009,)) + _t1274 = self._make_value_int32(msg.header_row) + result.append(('csv_header_row', _t1274,)) + _t1275 = self._make_value_int64(msg.skip) + result.append(('csv_skip', _t1275,)) if msg.new_line != '': - _t1011 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1011,)) - _t1010 = None - else: - _t1010 = None - _t1012 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1012,)) - _t1013 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1013,)) - _t1014 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1014,)) + _t1277 = self._make_value_string(msg.new_line) + result.append(('csv_new_line', _t1277,)) + _t1276 = None + else: + _t1276 = None + _t1278 = self._make_value_string(msg.delimiter) + result.append(('csv_delimiter', _t1278,)) + _t1279 = self._make_value_string(msg.quotechar) + result.append(('csv_quotechar', _t1279,)) + _t1280 = self._make_value_string(msg.escapechar) + result.append(('csv_escapechar', _t1280,)) if msg.comment != '': - _t1016 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1016,)) - _t1015 = None + _t1282 = self._make_value_string(msg.comment) + result.append(('csv_comment', _t1282,)) + _t1281 = None else: - _t1015 = None + _t1281 = None for missing_string in msg.missing_strings: - _t1017 = self._make_value_string(missing_string) - result.append(('csv_missing_strings', _t1017,)) - _t1018 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1018,)) - _t1019 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1019,)) - _t1020 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1020,)) + _t1283 = self._make_value_string(missing_string) + result.append(('csv_missing_strings', _t1283,)) + _t1284 = self._make_value_string(msg.decimal_separator) + result.append(('csv_decimal_separator', _t1284,)) + _t1285 = self._make_value_string(msg.encoding) + result.append(('csv_encoding', _t1285,)) + _t1286 = self._make_value_string(msg.compression) + result.append(('csv_compression', _t1286,)) return sorted(result) def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: if val is not None: assert val is not None - _t1022 = self._make_value_float64(val) - result.append((key, _t1022,)) - _t1021 = None + _t1288 = self._make_value_float64(val) + result.append((key, _t1288,)) + _t1287 = None else: - _t1021 = None + _t1287 = None return None def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: if val is not None: assert val is not None - _t1024 = self._make_value_int64(val) - result.append((key, _t1024,)) - _t1023 = None + _t1290 = self._make_value_int64(val) + result.append((key, _t1290,)) + _t1289 = None else: - _t1023 = None + _t1289 = None return None def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: if val is not None: assert val is not None - _t1026 = self._make_value_uint128(val) - result.append((key, _t1026,)) - _t1025 = None + _t1292 = self._make_value_uint128(val) + result.append((key, _t1292,)) + _t1291 = None else: - _t1025 = None + _t1291 = None return None def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: if val is not None: assert val is not None - _t1028 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1028,)) - _t1027 = None + _t1294 = self._make_value_string(val.decode('utf-8')) + result.append((key, _t1294,)) + _t1293 = None else: - _t1027 = None + _t1293 = None return None def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: result = [] - _t1029 = self._make_value_float64(msg.storage_config.epsilon) - result.append(('betree_config_epsilon', _t1029,)) - _t1030 = self._make_value_int64(msg.storage_config.max_pivots) - result.append(('betree_config_max_pivots', _t1030,)) - _t1031 = self._make_value_int64(msg.storage_config.max_deltas) - result.append(('betree_config_max_deltas', _t1031,)) - _t1032 = self._make_value_int64(msg.storage_config.max_leaf) - result.append(('betree_config_max_leaf', _t1032,)) + _t1295 = self._make_value_float64(msg.storage_config.epsilon) + result.append(('betree_config_epsilon', _t1295,)) + _t1296 = self._make_value_int64(msg.storage_config.max_pivots) + result.append(('betree_config_max_pivots', _t1296,)) + _t1297 = self._make_value_int64(msg.storage_config.max_deltas) + result.append(('betree_config_max_deltas', _t1297,)) + _t1298 = self._make_value_int64(msg.storage_config.max_leaf) + result.append(('betree_config_max_leaf', _t1298,)) if msg.relation_locator.HasField('root_pageid'): - _t1034 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1033 = _t1034 + _t1300 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) + _t1299 = _t1300 else: - _t1033 = None + _t1299 = None if msg.relation_locator.HasField('inline_data'): - _t1036 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1035 = _t1036 - else: - _t1035 = None - _t1037 = self._make_value_int64(msg.relation_locator.element_count) - result.append(('betree_locator_element_count', _t1037,)) - _t1038 = self._make_value_int64(msg.relation_locator.tree_height) - result.append(('betree_locator_tree_height', _t1038,)) + _t1302 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) + _t1301 = _t1302 + else: + _t1301 = None + _t1303 = self._make_value_int64(msg.relation_locator.element_count) + result.append(('betree_locator_element_count', _t1303,)) + _t1304 = self._make_value_int64(msg.relation_locator.tree_height) + result.append(('betree_locator_tree_height', _t1304,)) return sorted(result) def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: @@ -717,59 +767,59 @@ def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) - if msg.partition_size is not None: assert msg.partition_size is not None - _t1040 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1040,)) - _t1039 = None + _t1306 = self._make_value_int64(msg.partition_size) + result.append(('partition_size', _t1306,)) + _t1305 = None else: - _t1039 = None + _t1305 = None if msg.compression is not None: assert msg.compression is not None - _t1042 = self._make_value_string(msg.compression) - result.append(('compression', _t1042,)) - _t1041 = None + _t1308 = self._make_value_string(msg.compression) + result.append(('compression', _t1308,)) + _t1307 = None else: - _t1041 = None + _t1307 = None if msg.syntax_header_row is not None: assert msg.syntax_header_row is not None - _t1044 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1044,)) - _t1043 = None + _t1310 = self._make_value_boolean(msg.syntax_header_row) + result.append(('syntax_header_row', _t1310,)) + _t1309 = None else: - _t1043 = None + _t1309 = None if msg.syntax_missing_string is not None: assert msg.syntax_missing_string is not None - _t1046 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1046,)) - _t1045 = None + _t1312 = self._make_value_string(msg.syntax_missing_string) + result.append(('syntax_missing_string', _t1312,)) + _t1311 = None else: - _t1045 = None + _t1311 = None if msg.syntax_delim is not None: assert msg.syntax_delim is not None - _t1048 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1048,)) - _t1047 = None + _t1314 = self._make_value_string(msg.syntax_delim) + result.append(('syntax_delim', _t1314,)) + _t1313 = None else: - _t1047 = None + _t1313 = None if msg.syntax_quotechar is not None: assert msg.syntax_quotechar is not None - _t1050 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1050,)) - _t1049 = None + _t1316 = self._make_value_string(msg.syntax_quotechar) + result.append(('syntax_quotechar', _t1316,)) + _t1315 = None else: - _t1049 = None + _t1315 = None if msg.syntax_escapechar is not None: assert msg.syntax_escapechar is not None - _t1052 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1052,)) - _t1051 = None + _t1318 = self._make_value_string(msg.syntax_escapechar) + result.append(('syntax_escapechar', _t1318,)) + _t1317 = None else: - _t1051 = None + _t1317 = None return sorted(result) def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: @@ -796,2543 +846,3206 @@ def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arit # --- Parse methods --- def parse_transaction(self) -> transactions_pb2.Transaction: + span_start7 = self._span_start() self.consume_literal('(') self.consume_literal('transaction') + self._push_path(2) if (self.match_lookahead_literal('(', 0) and self.match_lookahead_literal('configure', 1)): - _t354 = self.parse_configure() - _t353 = _t354 + _t620 = self.parse_configure() + _t619 = _t620 else: - _t353 = None - configure0 = _t353 + _t619 = None + configure0 = _t619 + self._pop_path() + self._push_path(3) if (self.match_lookahead_literal('(', 0) and self.match_lookahead_literal('sync', 1)): - _t356 = self.parse_sync() - _t355 = _t356 + _t622 = self.parse_sync() + _t621 = _t622 else: - _t355 = None - sync1 = _t355 + _t621 = None + sync1 = _t621 + self._pop_path() + self._push_path(1) xs2 = [] cond3 = self.match_lookahead_literal('(', 0) + idx5 = 0 while cond3: - _t357 = self.parse_epoch() - item4 = _t357 + self._push_path(idx5) + _t623 = self.parse_epoch() + item4 = _t623 + self._pop_path() xs2.append(item4) + idx5 = (idx5 + 1) cond3 = self.match_lookahead_literal('(', 0) - epochs5 = xs2 + self._pop_path() + epochs6 = xs2 self.consume_literal(')') - _t358 = self.default_configure() - _t359 = transactions_pb2.Transaction(epochs=epochs5, configure=(configure0 if configure0 is not None else _t358), sync=sync1) - return _t359 + _t624 = self.default_configure() + _t625 = transactions_pb2.Transaction(epochs=epochs6, configure=(configure0 if configure0 is not None else _t624), sync=sync1) + result8 = _t625 + self._record_span(span_start7) + return result8 def parse_configure(self) -> transactions_pb2.Configure: + span_start10 = self._span_start() self.consume_literal('(') self.consume_literal('configure') - _t360 = self.parse_config_dict() - config_dict6 = _t360 + _t626 = self.parse_config_dict() + config_dict9 = _t626 self.consume_literal(')') - _t361 = self.construct_configure(config_dict6) - return _t361 + _t627 = self.construct_configure(config_dict9) + result11 = _t627 + self._record_span(span_start10) + return result11 def parse_config_dict(self) -> Sequence[tuple[str, logic_pb2.Value]]: + span_start17 = self._span_start() self.consume_literal('{') - xs7 = [] - cond8 = self.match_lookahead_literal(':', 0) - while cond8: - _t362 = self.parse_config_key_value() - item9 = _t362 - xs7.append(item9) - cond8 = self.match_lookahead_literal(':', 0) - config_key_values10 = xs7 + xs12 = [] + cond13 = self.match_lookahead_literal(':', 0) + idx15 = 0 + while cond13: + self._push_path(idx15) + _t628 = self.parse_config_key_value() + item14 = _t628 + self._pop_path() + xs12.append(item14) + idx15 = (idx15 + 1) + cond13 = self.match_lookahead_literal(':', 0) + config_key_values16 = xs12 self.consume_literal('}') - return config_key_values10 + result18 = config_key_values16 + self._record_span(span_start17) + return result18 def parse_config_key_value(self) -> tuple[str, logic_pb2.Value]: + span_start21 = self._span_start() self.consume_literal(':') - symbol11 = self.consume_terminal('SYMBOL') - _t363 = self.parse_value() - value12 = _t363 - return (symbol11, value12,) + symbol19 = self.consume_terminal('SYMBOL') + _t629 = self.parse_value() + value20 = _t629 + result22 = (symbol19, value20,) + self._record_span(span_start21) + return result22 def parse_value(self) -> logic_pb2.Value: + span_start33 = self._span_start() if self.match_lookahead_literal('true', 0): - _t364 = 9 + _t630 = 9 else: if self.match_lookahead_literal('missing', 0): - _t365 = 8 + _t631 = 8 else: if self.match_lookahead_literal('false', 0): - _t366 = 9 + _t632 = 9 else: if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('datetime', 1): - _t368 = 1 + _t634 = 1 else: if self.match_lookahead_literal('date', 1): - _t369 = 0 + _t635 = 0 else: - _t369 = -1 - _t368 = _t369 - _t367 = _t368 + _t635 = -1 + _t634 = _t635 + _t633 = _t634 else: if self.match_lookahead_terminal('UINT128', 0): - _t370 = 5 + _t636 = 5 else: if self.match_lookahead_terminal('STRING', 0): - _t371 = 2 + _t637 = 2 else: if self.match_lookahead_terminal('INT128', 0): - _t372 = 6 + _t638 = 6 else: if self.match_lookahead_terminal('INT', 0): - _t373 = 3 + _t639 = 3 else: if self.match_lookahead_terminal('FLOAT', 0): - _t374 = 4 + _t640 = 4 else: if self.match_lookahead_terminal('DECIMAL', 0): - _t375 = 7 + _t641 = 7 else: - _t375 = -1 - _t374 = _t375 - _t373 = _t374 - _t372 = _t373 - _t371 = _t372 - _t370 = _t371 - _t367 = _t370 - _t366 = _t367 - _t365 = _t366 - _t364 = _t365 - prediction13 = _t364 - - if prediction13 == 9: - _t377 = self.parse_boolean_value() - boolean_value22 = _t377 - _t378 = logic_pb2.Value(boolean_value=boolean_value22) - _t376 = _t378 + _t641 = -1 + _t640 = _t641 + _t639 = _t640 + _t638 = _t639 + _t637 = _t638 + _t636 = _t637 + _t633 = _t636 + _t632 = _t633 + _t631 = _t632 + _t630 = _t631 + prediction23 = _t630 + + if prediction23 == 9: + _t643 = self.parse_boolean_value() + boolean_value32 = _t643 + _t644 = logic_pb2.Value(boolean_value=boolean_value32) + _t642 = _t644 else: - if prediction13 == 8: + if prediction23 == 8: self.consume_literal('missing') - _t380 = logic_pb2.MissingValue() - _t381 = logic_pb2.Value(missing_value=_t380) - _t379 = _t381 + _t646 = logic_pb2.MissingValue() + _t647 = logic_pb2.Value(missing_value=_t646) + _t645 = _t647 else: - if prediction13 == 7: - decimal21 = self.consume_terminal('DECIMAL') - _t383 = logic_pb2.Value(decimal_value=decimal21) - _t382 = _t383 + if prediction23 == 7: + decimal31 = self.consume_terminal('DECIMAL') + _t649 = logic_pb2.Value(decimal_value=decimal31) + _t648 = _t649 else: - if prediction13 == 6: - int12820 = self.consume_terminal('INT128') - _t385 = logic_pb2.Value(int128_value=int12820) - _t384 = _t385 + if prediction23 == 6: + int12830 = self.consume_terminal('INT128') + _t651 = logic_pb2.Value(int128_value=int12830) + _t650 = _t651 else: - if prediction13 == 5: - uint12819 = self.consume_terminal('UINT128') - _t387 = logic_pb2.Value(uint128_value=uint12819) - _t386 = _t387 + if prediction23 == 5: + uint12829 = self.consume_terminal('UINT128') + _t653 = logic_pb2.Value(uint128_value=uint12829) + _t652 = _t653 else: - if prediction13 == 4: - float18 = self.consume_terminal('FLOAT') - _t389 = logic_pb2.Value(float_value=float18) - _t388 = _t389 + if prediction23 == 4: + float28 = self.consume_terminal('FLOAT') + _t655 = logic_pb2.Value(float_value=float28) + _t654 = _t655 else: - if prediction13 == 3: - int17 = self.consume_terminal('INT') - _t391 = logic_pb2.Value(int_value=int17) - _t390 = _t391 + if prediction23 == 3: + int27 = self.consume_terminal('INT') + _t657 = logic_pb2.Value(int_value=int27) + _t656 = _t657 else: - if prediction13 == 2: - string16 = self.consume_terminal('STRING') - _t393 = logic_pb2.Value(string_value=string16) - _t392 = _t393 + if prediction23 == 2: + string26 = self.consume_terminal('STRING') + _t659 = logic_pb2.Value(string_value=string26) + _t658 = _t659 else: - if prediction13 == 1: - _t395 = self.parse_datetime() - datetime15 = _t395 - _t396 = logic_pb2.Value(datetime_value=datetime15) - _t394 = _t396 + if prediction23 == 1: + _t661 = self.parse_datetime() + datetime25 = _t661 + _t662 = logic_pb2.Value(datetime_value=datetime25) + _t660 = _t662 else: - if prediction13 == 0: - _t398 = self.parse_date() - date14 = _t398 - _t399 = logic_pb2.Value(date_value=date14) - _t397 = _t399 + if prediction23 == 0: + _t664 = self.parse_date() + date24 = _t664 + _t665 = logic_pb2.Value(date_value=date24) + _t663 = _t665 else: raise ParseError(f"{'Unexpected token in value'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t394 = _t397 - _t392 = _t394 - _t390 = _t392 - _t388 = _t390 - _t386 = _t388 - _t384 = _t386 - _t382 = _t384 - _t379 = _t382 - _t376 = _t379 - return _t376 + _t660 = _t663 + _t658 = _t660 + _t656 = _t658 + _t654 = _t656 + _t652 = _t654 + _t650 = _t652 + _t648 = _t650 + _t645 = _t648 + _t642 = _t645 + result34 = _t642 + self._record_span(span_start33) + return result34 def parse_date(self) -> logic_pb2.DateValue: + span_start38 = self._span_start() self.consume_literal('(') self.consume_literal('date') - int23 = self.consume_terminal('INT') - int_324 = self.consume_terminal('INT') - int_425 = self.consume_terminal('INT') - self.consume_literal(')') - _t400 = logic_pb2.DateValue(year=int(int23), month=int(int_324), day=int(int_425)) - return _t400 + self._push_path(1) + int35 = self.consume_terminal('INT') + self._pop_path() + self._push_path(2) + int_336 = self.consume_terminal('INT') + self._pop_path() + self._push_path(3) + int_437 = self.consume_terminal('INT') + self._pop_path() + self.consume_literal(')') + _t666 = logic_pb2.DateValue(year=int(int35), month=int(int_336), day=int(int_437)) + result39 = _t666 + self._record_span(span_start38) + return result39 def parse_datetime(self) -> logic_pb2.DateTimeValue: + span_start47 = self._span_start() self.consume_literal('(') self.consume_literal('datetime') - int26 = self.consume_terminal('INT') - int_327 = self.consume_terminal('INT') - int_428 = self.consume_terminal('INT') - int_529 = self.consume_terminal('INT') - int_630 = self.consume_terminal('INT') - int_731 = self.consume_terminal('INT') + self._push_path(1) + int40 = self.consume_terminal('INT') + self._pop_path() + self._push_path(2) + int_341 = self.consume_terminal('INT') + self._pop_path() + self._push_path(3) + int_442 = self.consume_terminal('INT') + self._pop_path() + self._push_path(4) + int_543 = self.consume_terminal('INT') + self._pop_path() + self._push_path(5) + int_644 = self.consume_terminal('INT') + self._pop_path() + self._push_path(6) + int_745 = self.consume_terminal('INT') + self._pop_path() if self.match_lookahead_terminal('INT', 0): - _t401 = self.consume_terminal('INT') + _t667 = self.consume_terminal('INT') else: - _t401 = None - int_832 = _t401 + _t667 = None + int_846 = _t667 self.consume_literal(')') - _t402 = logic_pb2.DateTimeValue(year=int(int26), month=int(int_327), day=int(int_428), hour=int(int_529), minute=int(int_630), second=int(int_731), microsecond=int((int_832 if int_832 is not None else 0))) - return _t402 + _t668 = logic_pb2.DateTimeValue(year=int(int40), month=int(int_341), day=int(int_442), hour=int(int_543), minute=int(int_644), second=int(int_745), microsecond=int((int_846 if int_846 is not None else 0))) + result48 = _t668 + self._record_span(span_start47) + return result48 def parse_boolean_value(self) -> bool: + span_start50 = self._span_start() if self.match_lookahead_literal('true', 0): - _t403 = 0 + _t669 = 0 else: if self.match_lookahead_literal('false', 0): - _t404 = 1 + _t670 = 1 else: - _t404 = -1 - _t403 = _t404 - prediction33 = _t403 + _t670 = -1 + _t669 = _t670 + prediction49 = _t669 - if prediction33 == 1: + if prediction49 == 1: self.consume_literal('false') - _t405 = False + _t671 = False else: - if prediction33 == 0: + if prediction49 == 0: self.consume_literal('true') - _t406 = True + _t672 = True else: raise ParseError(f"{'Unexpected token in boolean_value'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t405 = _t406 - return _t405 + _t671 = _t672 + result51 = _t671 + self._record_span(span_start50) + return result51 def parse_sync(self) -> transactions_pb2.Sync: + span_start57 = self._span_start() self.consume_literal('(') self.consume_literal('sync') - xs34 = [] - cond35 = self.match_lookahead_literal(':', 0) - while cond35: - _t407 = self.parse_fragment_id() - item36 = _t407 - xs34.append(item36) - cond35 = self.match_lookahead_literal(':', 0) - fragment_ids37 = xs34 - self.consume_literal(')') - _t408 = transactions_pb2.Sync(fragments=fragment_ids37) - return _t408 + self._push_path(1) + xs52 = [] + cond53 = self.match_lookahead_literal(':', 0) + idx55 = 0 + while cond53: + self._push_path(idx55) + _t673 = self.parse_fragment_id() + item54 = _t673 + self._pop_path() + xs52.append(item54) + idx55 = (idx55 + 1) + cond53 = self.match_lookahead_literal(':', 0) + self._pop_path() + fragment_ids56 = xs52 + self.consume_literal(')') + _t674 = transactions_pb2.Sync(fragments=fragment_ids56) + result58 = _t674 + self._record_span(span_start57) + return result58 def parse_fragment_id(self) -> fragments_pb2.FragmentId: + span_start60 = self._span_start() self.consume_literal(':') - symbol38 = self.consume_terminal('SYMBOL') - return fragments_pb2.FragmentId(id=symbol38.encode()) + symbol59 = self.consume_terminal('SYMBOL') + result61 = fragments_pb2.FragmentId(id=symbol59.encode()) + self._record_span(span_start60) + return result61 def parse_epoch(self) -> transactions_pb2.Epoch: + span_start64 = self._span_start() self.consume_literal('(') self.consume_literal('epoch') + self._push_path(1) if (self.match_lookahead_literal('(', 0) and self.match_lookahead_literal('writes', 1)): - _t410 = self.parse_epoch_writes() - _t409 = _t410 + _t676 = self.parse_epoch_writes() + _t675 = _t676 else: - _t409 = None - epoch_writes39 = _t409 + _t675 = None + epoch_writes62 = _t675 + self._pop_path() + self._push_path(2) if self.match_lookahead_literal('(', 0): - _t412 = self.parse_epoch_reads() - _t411 = _t412 + _t678 = self.parse_epoch_reads() + _t677 = _t678 else: - _t411 = None - epoch_reads40 = _t411 + _t677 = None + epoch_reads63 = _t677 + self._pop_path() self.consume_literal(')') - _t413 = transactions_pb2.Epoch(writes=(epoch_writes39 if epoch_writes39 is not None else []), reads=(epoch_reads40 if epoch_reads40 is not None else [])) - return _t413 + _t679 = transactions_pb2.Epoch(writes=(epoch_writes62 if epoch_writes62 is not None else []), reads=(epoch_reads63 if epoch_reads63 is not None else [])) + result65 = _t679 + self._record_span(span_start64) + return result65 def parse_epoch_writes(self) -> Sequence[transactions_pb2.Write]: + span_start71 = self._span_start() self.consume_literal('(') self.consume_literal('writes') - xs41 = [] - cond42 = self.match_lookahead_literal('(', 0) - while cond42: - _t414 = self.parse_write() - item43 = _t414 - xs41.append(item43) - cond42 = self.match_lookahead_literal('(', 0) - writes44 = xs41 - self.consume_literal(')') - return writes44 + xs66 = [] + cond67 = self.match_lookahead_literal('(', 0) + idx69 = 0 + while cond67: + self._push_path(idx69) + _t680 = self.parse_write() + item68 = _t680 + self._pop_path() + xs66.append(item68) + idx69 = (idx69 + 1) + cond67 = self.match_lookahead_literal('(', 0) + writes70 = xs66 + self.consume_literal(')') + result72 = writes70 + self._record_span(span_start71) + return result72 def parse_write(self) -> transactions_pb2.Write: + span_start77 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('undefine', 1): - _t416 = 1 + _t682 = 1 else: if self.match_lookahead_literal('define', 1): - _t417 = 0 + _t683 = 0 else: if self.match_lookahead_literal('context', 1): - _t418 = 2 + _t684 = 2 else: - _t418 = -1 - _t417 = _t418 - _t416 = _t417 - _t415 = _t416 + _t684 = -1 + _t683 = _t684 + _t682 = _t683 + _t681 = _t682 else: - _t415 = -1 - prediction45 = _t415 + _t681 = -1 + prediction73 = _t681 - if prediction45 == 2: - _t420 = self.parse_context() - context48 = _t420 - _t421 = transactions_pb2.Write(context=context48) - _t419 = _t421 + if prediction73 == 2: + _t686 = self.parse_context() + context76 = _t686 + _t687 = transactions_pb2.Write(context=context76) + _t685 = _t687 else: - if prediction45 == 1: - _t423 = self.parse_undefine() - undefine47 = _t423 - _t424 = transactions_pb2.Write(undefine=undefine47) - _t422 = _t424 + if prediction73 == 1: + _t689 = self.parse_undefine() + undefine75 = _t689 + _t690 = transactions_pb2.Write(undefine=undefine75) + _t688 = _t690 else: - if prediction45 == 0: - _t426 = self.parse_define() - define46 = _t426 - _t427 = transactions_pb2.Write(define=define46) - _t425 = _t427 + if prediction73 == 0: + _t692 = self.parse_define() + define74 = _t692 + _t693 = transactions_pb2.Write(define=define74) + _t691 = _t693 else: raise ParseError(f"{'Unexpected token in write'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t422 = _t425 - _t419 = _t422 - return _t419 + _t688 = _t691 + _t685 = _t688 + result78 = _t685 + self._record_span(span_start77) + return result78 def parse_define(self) -> transactions_pb2.Define: + span_start80 = self._span_start() self.consume_literal('(') self.consume_literal('define') - _t428 = self.parse_fragment() - fragment49 = _t428 + self._push_path(1) + _t694 = self.parse_fragment() + fragment79 = _t694 + self._pop_path() self.consume_literal(')') - _t429 = transactions_pb2.Define(fragment=fragment49) - return _t429 + _t695 = transactions_pb2.Define(fragment=fragment79) + result81 = _t695 + self._record_span(span_start80) + return result81 def parse_fragment(self) -> fragments_pb2.Fragment: + span_start88 = self._span_start() self.consume_literal('(') self.consume_literal('fragment') - _t430 = self.parse_new_fragment_id() - new_fragment_id50 = _t430 - xs51 = [] - cond52 = self.match_lookahead_literal('(', 0) - while cond52: - _t431 = self.parse_declaration() - item53 = _t431 - xs51.append(item53) - cond52 = self.match_lookahead_literal('(', 0) - declarations54 = xs51 - self.consume_literal(')') - return self.construct_fragment(new_fragment_id50, declarations54) + _t696 = self.parse_new_fragment_id() + new_fragment_id82 = _t696 + xs83 = [] + cond84 = self.match_lookahead_literal('(', 0) + idx86 = 0 + while cond84: + self._push_path(idx86) + _t697 = self.parse_declaration() + item85 = _t697 + self._pop_path() + xs83.append(item85) + idx86 = (idx86 + 1) + cond84 = self.match_lookahead_literal('(', 0) + declarations87 = xs83 + self.consume_literal(')') + result89 = self.construct_fragment(new_fragment_id82, declarations87) + self._record_span(span_start88) + return result89 def parse_new_fragment_id(self) -> fragments_pb2.FragmentId: - _t432 = self.parse_fragment_id() - fragment_id55 = _t432 - self.start_fragment(fragment_id55) - return fragment_id55 + span_start91 = self._span_start() + _t698 = self.parse_fragment_id() + fragment_id90 = _t698 + self.start_fragment(fragment_id90) + result92 = fragment_id90 + self._record_span(span_start91) + return result92 def parse_declaration(self) -> logic_pb2.Declaration: + span_start98 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('rel_edb', 1): - _t434 = 3 + _t700 = 3 else: if self.match_lookahead_literal('functional_dependency', 1): - _t435 = 2 + _t701 = 2 else: if self.match_lookahead_literal('def', 1): - _t436 = 0 + _t702 = 0 else: if self.match_lookahead_literal('csv_data', 1): - _t437 = 3 + _t703 = 3 else: if self.match_lookahead_literal('betree_relation', 1): - _t438 = 3 + _t704 = 3 else: if self.match_lookahead_literal('algorithm', 1): - _t439 = 1 + _t705 = 1 else: - _t439 = -1 - _t438 = _t439 - _t437 = _t438 - _t436 = _t437 - _t435 = _t436 - _t434 = _t435 - _t433 = _t434 - else: - _t433 = -1 - prediction56 = _t433 - - if prediction56 == 3: - _t441 = self.parse_data() - data60 = _t441 - _t442 = logic_pb2.Declaration(data=data60) - _t440 = _t442 + _t705 = -1 + _t704 = _t705 + _t703 = _t704 + _t702 = _t703 + _t701 = _t702 + _t700 = _t701 + _t699 = _t700 + else: + _t699 = -1 + prediction93 = _t699 + + if prediction93 == 3: + _t707 = self.parse_data() + data97 = _t707 + _t708 = logic_pb2.Declaration(data=data97) + _t706 = _t708 else: - if prediction56 == 2: - _t444 = self.parse_constraint() - constraint59 = _t444 - _t445 = logic_pb2.Declaration(constraint=constraint59) - _t443 = _t445 + if prediction93 == 2: + _t710 = self.parse_constraint() + constraint96 = _t710 + _t711 = logic_pb2.Declaration(constraint=constraint96) + _t709 = _t711 else: - if prediction56 == 1: - _t447 = self.parse_algorithm() - algorithm58 = _t447 - _t448 = logic_pb2.Declaration(algorithm=algorithm58) - _t446 = _t448 + if prediction93 == 1: + _t713 = self.parse_algorithm() + algorithm95 = _t713 + _t714 = logic_pb2.Declaration(algorithm=algorithm95) + _t712 = _t714 else: - if prediction56 == 0: - _t450 = self.parse_def() - def57 = _t450 - _t451 = logic_pb2.Declaration() - getattr(_t451, 'def').CopyFrom(def57) - _t449 = _t451 + if prediction93 == 0: + _t716 = self.parse_def() + def94 = _t716 + _t717 = logic_pb2.Declaration() + getattr(_t717, 'def').CopyFrom(def94) + _t715 = _t717 else: raise ParseError(f"{'Unexpected token in declaration'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t446 = _t449 - _t443 = _t446 - _t440 = _t443 - return _t440 + _t712 = _t715 + _t709 = _t712 + _t706 = _t709 + result99 = _t706 + self._record_span(span_start98) + return result99 def parse_def(self) -> logic_pb2.Def: + span_start103 = self._span_start() self.consume_literal('(') self.consume_literal('def') - _t452 = self.parse_relation_id() - relation_id61 = _t452 - _t453 = self.parse_abstraction() - abstraction62 = _t453 + self._push_path(1) + _t718 = self.parse_relation_id() + relation_id100 = _t718 + self._pop_path() + self._push_path(2) + _t719 = self.parse_abstraction() + abstraction101 = _t719 + self._pop_path() + self._push_path(3) if self.match_lookahead_literal('(', 0): - _t455 = self.parse_attrs() - _t454 = _t455 + _t721 = self.parse_attrs() + _t720 = _t721 else: - _t454 = None - attrs63 = _t454 + _t720 = None + attrs102 = _t720 + self._pop_path() self.consume_literal(')') - _t456 = logic_pb2.Def(name=relation_id61, body=abstraction62, attrs=(attrs63 if attrs63 is not None else [])) - return _t456 + _t722 = logic_pb2.Def(name=relation_id100, body=abstraction101, attrs=(attrs102 if attrs102 is not None else [])) + result104 = _t722 + self._record_span(span_start103) + return result104 def parse_relation_id(self) -> logic_pb2.RelationId: + span_start108 = self._span_start() if self.match_lookahead_literal(':', 0): - _t457 = 0 + _t723 = 0 else: if self.match_lookahead_terminal('UINT128', 0): - _t458 = 1 + _t724 = 1 else: - _t458 = -1 - _t457 = _t458 - prediction64 = _t457 + _t724 = -1 + _t723 = _t724 + prediction105 = _t723 - if prediction64 == 1: - uint12866 = self.consume_terminal('UINT128') - _t459 = logic_pb2.RelationId(id_low=uint12866.low, id_high=uint12866.high) + if prediction105 == 1: + uint128107 = self.consume_terminal('UINT128') + _t725 = logic_pb2.RelationId(id_low=uint128107.low, id_high=uint128107.high) else: - if prediction64 == 0: + if prediction105 == 0: self.consume_literal(':') - symbol65 = self.consume_terminal('SYMBOL') - _t460 = self.relation_id_from_string(symbol65) + symbol106 = self.consume_terminal('SYMBOL') + _t726 = self.relation_id_from_string(symbol106) else: raise ParseError(f"{'Unexpected token in relation_id'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t459 = _t460 - return _t459 + _t725 = _t726 + result109 = _t725 + self._record_span(span_start108) + return result109 def parse_abstraction(self) -> logic_pb2.Abstraction: + span_start112 = self._span_start() self.consume_literal('(') - _t461 = self.parse_bindings() - bindings67 = _t461 - _t462 = self.parse_formula() - formula68 = _t462 + _t727 = self.parse_bindings() + bindings110 = _t727 + self._push_path(2) + _t728 = self.parse_formula() + formula111 = _t728 + self._pop_path() self.consume_literal(')') - _t463 = logic_pb2.Abstraction(vars=(list(bindings67[0]) + list(bindings67[1] if bindings67[1] is not None else [])), value=formula68) - return _t463 + _t729 = logic_pb2.Abstraction(vars=(list(bindings110[0]) + list(bindings110[1] if bindings110[1] is not None else [])), value=formula111) + result113 = _t729 + self._record_span(span_start112) + return result113 def parse_bindings(self) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: + span_start120 = self._span_start() self.consume_literal('[') - xs69 = [] - cond70 = self.match_lookahead_terminal('SYMBOL', 0) - while cond70: - _t464 = self.parse_binding() - item71 = _t464 - xs69.append(item71) - cond70 = self.match_lookahead_terminal('SYMBOL', 0) - bindings72 = xs69 + xs114 = [] + cond115 = self.match_lookahead_terminal('SYMBOL', 0) + idx117 = 0 + while cond115: + self._push_path(idx117) + _t730 = self.parse_binding() + item116 = _t730 + self._pop_path() + xs114.append(item116) + idx117 = (idx117 + 1) + cond115 = self.match_lookahead_terminal('SYMBOL', 0) + bindings118 = xs114 if self.match_lookahead_literal('|', 0): - _t466 = self.parse_value_bindings() - _t465 = _t466 + _t732 = self.parse_value_bindings() + _t731 = _t732 else: - _t465 = None - value_bindings73 = _t465 + _t731 = None + value_bindings119 = _t731 self.consume_literal(']') - return (bindings72, (value_bindings73 if value_bindings73 is not None else []),) + result121 = (bindings118, (value_bindings119 if value_bindings119 is not None else []),) + self._record_span(span_start120) + return result121 def parse_binding(self) -> logic_pb2.Binding: - symbol74 = self.consume_terminal('SYMBOL') + span_start124 = self._span_start() + symbol122 = self.consume_terminal('SYMBOL') self.consume_literal('::') - _t467 = self.parse_type() - type75 = _t467 - _t468 = logic_pb2.Var(name=symbol74) - _t469 = logic_pb2.Binding(var=_t468, type=type75) - return _t469 + self._push_path(2) + _t733 = self.parse_type() + type123 = _t733 + self._pop_path() + _t734 = logic_pb2.Var(name=symbol122) + _t735 = logic_pb2.Binding(var=_t734, type=type123) + result125 = _t735 + self._record_span(span_start124) + return result125 def parse_type(self) -> logic_pb2.Type: + span_start138 = self._span_start() if self.match_lookahead_literal('UNKNOWN', 0): - _t470 = 0 + _t736 = 0 else: if self.match_lookahead_literal('UINT128', 0): - _t471 = 4 + _t737 = 4 else: if self.match_lookahead_literal('STRING', 0): - _t472 = 1 + _t738 = 1 else: if self.match_lookahead_literal('MISSING', 0): - _t473 = 8 + _t739 = 8 else: if self.match_lookahead_literal('INT128', 0): - _t474 = 5 + _t740 = 5 else: if self.match_lookahead_literal('INT', 0): - _t475 = 2 + _t741 = 2 else: if self.match_lookahead_literal('FLOAT', 0): - _t476 = 3 + _t742 = 3 else: if self.match_lookahead_literal('DATETIME', 0): - _t477 = 7 + _t743 = 7 else: if self.match_lookahead_literal('DATE', 0): - _t478 = 6 + _t744 = 6 else: if self.match_lookahead_literal('BOOLEAN', 0): - _t479 = 10 + _t745 = 10 else: if self.match_lookahead_literal('(', 0): - _t480 = 9 + _t746 = 9 else: - _t480 = -1 - _t479 = _t480 - _t478 = _t479 - _t477 = _t478 - _t476 = _t477 - _t475 = _t476 - _t474 = _t475 - _t473 = _t474 - _t472 = _t473 - _t471 = _t472 - _t470 = _t471 - prediction76 = _t470 - - if prediction76 == 10: - _t482 = self.parse_boolean_type() - boolean_type87 = _t482 - _t483 = logic_pb2.Type(boolean_type=boolean_type87) - _t481 = _t483 + _t746 = -1 + _t745 = _t746 + _t744 = _t745 + _t743 = _t744 + _t742 = _t743 + _t741 = _t742 + _t740 = _t741 + _t739 = _t740 + _t738 = _t739 + _t737 = _t738 + _t736 = _t737 + prediction126 = _t736 + + if prediction126 == 10: + _t748 = self.parse_boolean_type() + boolean_type137 = _t748 + _t749 = logic_pb2.Type(boolean_type=boolean_type137) + _t747 = _t749 else: - if prediction76 == 9: - _t485 = self.parse_decimal_type() - decimal_type86 = _t485 - _t486 = logic_pb2.Type(decimal_type=decimal_type86) - _t484 = _t486 + if prediction126 == 9: + _t751 = self.parse_decimal_type() + decimal_type136 = _t751 + _t752 = logic_pb2.Type(decimal_type=decimal_type136) + _t750 = _t752 else: - if prediction76 == 8: - _t488 = self.parse_missing_type() - missing_type85 = _t488 - _t489 = logic_pb2.Type(missing_type=missing_type85) - _t487 = _t489 + if prediction126 == 8: + _t754 = self.parse_missing_type() + missing_type135 = _t754 + _t755 = logic_pb2.Type(missing_type=missing_type135) + _t753 = _t755 else: - if prediction76 == 7: - _t491 = self.parse_datetime_type() - datetime_type84 = _t491 - _t492 = logic_pb2.Type(datetime_type=datetime_type84) - _t490 = _t492 + if prediction126 == 7: + _t757 = self.parse_datetime_type() + datetime_type134 = _t757 + _t758 = logic_pb2.Type(datetime_type=datetime_type134) + _t756 = _t758 else: - if prediction76 == 6: - _t494 = self.parse_date_type() - date_type83 = _t494 - _t495 = logic_pb2.Type(date_type=date_type83) - _t493 = _t495 + if prediction126 == 6: + _t760 = self.parse_date_type() + date_type133 = _t760 + _t761 = logic_pb2.Type(date_type=date_type133) + _t759 = _t761 else: - if prediction76 == 5: - _t497 = self.parse_int128_type() - int128_type82 = _t497 - _t498 = logic_pb2.Type(int128_type=int128_type82) - _t496 = _t498 + if prediction126 == 5: + _t763 = self.parse_int128_type() + int128_type132 = _t763 + _t764 = logic_pb2.Type(int128_type=int128_type132) + _t762 = _t764 else: - if prediction76 == 4: - _t500 = self.parse_uint128_type() - uint128_type81 = _t500 - _t501 = logic_pb2.Type(uint128_type=uint128_type81) - _t499 = _t501 + if prediction126 == 4: + _t766 = self.parse_uint128_type() + uint128_type131 = _t766 + _t767 = logic_pb2.Type(uint128_type=uint128_type131) + _t765 = _t767 else: - if prediction76 == 3: - _t503 = self.parse_float_type() - float_type80 = _t503 - _t504 = logic_pb2.Type(float_type=float_type80) - _t502 = _t504 + if prediction126 == 3: + _t769 = self.parse_float_type() + float_type130 = _t769 + _t770 = logic_pb2.Type(float_type=float_type130) + _t768 = _t770 else: - if prediction76 == 2: - _t506 = self.parse_int_type() - int_type79 = _t506 - _t507 = logic_pb2.Type(int_type=int_type79) - _t505 = _t507 + if prediction126 == 2: + _t772 = self.parse_int_type() + int_type129 = _t772 + _t773 = logic_pb2.Type(int_type=int_type129) + _t771 = _t773 else: - if prediction76 == 1: - _t509 = self.parse_string_type() - string_type78 = _t509 - _t510 = logic_pb2.Type(string_type=string_type78) - _t508 = _t510 + if prediction126 == 1: + _t775 = self.parse_string_type() + string_type128 = _t775 + _t776 = logic_pb2.Type(string_type=string_type128) + _t774 = _t776 else: - if prediction76 == 0: - _t512 = self.parse_unspecified_type() - unspecified_type77 = _t512 - _t513 = logic_pb2.Type(unspecified_type=unspecified_type77) - _t511 = _t513 + if prediction126 == 0: + _t778 = self.parse_unspecified_type() + unspecified_type127 = _t778 + _t779 = logic_pb2.Type(unspecified_type=unspecified_type127) + _t777 = _t779 else: raise ParseError(f"{'Unexpected token in type'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t508 = _t511 - _t505 = _t508 - _t502 = _t505 - _t499 = _t502 - _t496 = _t499 - _t493 = _t496 - _t490 = _t493 - _t487 = _t490 - _t484 = _t487 - _t481 = _t484 - return _t481 + _t774 = _t777 + _t771 = _t774 + _t768 = _t771 + _t765 = _t768 + _t762 = _t765 + _t759 = _t762 + _t756 = _t759 + _t753 = _t756 + _t750 = _t753 + _t747 = _t750 + result139 = _t747 + self._record_span(span_start138) + return result139 def parse_unspecified_type(self) -> logic_pb2.UnspecifiedType: + span_start140 = self._span_start() self.consume_literal('UNKNOWN') - _t514 = logic_pb2.UnspecifiedType() - return _t514 + _t780 = logic_pb2.UnspecifiedType() + result141 = _t780 + self._record_span(span_start140) + return result141 def parse_string_type(self) -> logic_pb2.StringType: + span_start142 = self._span_start() self.consume_literal('STRING') - _t515 = logic_pb2.StringType() - return _t515 + _t781 = logic_pb2.StringType() + result143 = _t781 + self._record_span(span_start142) + return result143 def parse_int_type(self) -> logic_pb2.IntType: + span_start144 = self._span_start() self.consume_literal('INT') - _t516 = logic_pb2.IntType() - return _t516 + _t782 = logic_pb2.IntType() + result145 = _t782 + self._record_span(span_start144) + return result145 def parse_float_type(self) -> logic_pb2.FloatType: + span_start146 = self._span_start() self.consume_literal('FLOAT') - _t517 = logic_pb2.FloatType() - return _t517 + _t783 = logic_pb2.FloatType() + result147 = _t783 + self._record_span(span_start146) + return result147 def parse_uint128_type(self) -> logic_pb2.UInt128Type: + span_start148 = self._span_start() self.consume_literal('UINT128') - _t518 = logic_pb2.UInt128Type() - return _t518 + _t784 = logic_pb2.UInt128Type() + result149 = _t784 + self._record_span(span_start148) + return result149 def parse_int128_type(self) -> logic_pb2.Int128Type: + span_start150 = self._span_start() self.consume_literal('INT128') - _t519 = logic_pb2.Int128Type() - return _t519 + _t785 = logic_pb2.Int128Type() + result151 = _t785 + self._record_span(span_start150) + return result151 def parse_date_type(self) -> logic_pb2.DateType: + span_start152 = self._span_start() self.consume_literal('DATE') - _t520 = logic_pb2.DateType() - return _t520 + _t786 = logic_pb2.DateType() + result153 = _t786 + self._record_span(span_start152) + return result153 def parse_datetime_type(self) -> logic_pb2.DateTimeType: + span_start154 = self._span_start() self.consume_literal('DATETIME') - _t521 = logic_pb2.DateTimeType() - return _t521 + _t787 = logic_pb2.DateTimeType() + result155 = _t787 + self._record_span(span_start154) + return result155 def parse_missing_type(self) -> logic_pb2.MissingType: + span_start156 = self._span_start() self.consume_literal('MISSING') - _t522 = logic_pb2.MissingType() - return _t522 + _t788 = logic_pb2.MissingType() + result157 = _t788 + self._record_span(span_start156) + return result157 def parse_decimal_type(self) -> logic_pb2.DecimalType: + span_start160 = self._span_start() self.consume_literal('(') self.consume_literal('DECIMAL') - int88 = self.consume_terminal('INT') - int_389 = self.consume_terminal('INT') - self.consume_literal(')') - _t523 = logic_pb2.DecimalType(precision=int(int88), scale=int(int_389)) - return _t523 + self._push_path(1) + int158 = self.consume_terminal('INT') + self._pop_path() + self._push_path(2) + int_3159 = self.consume_terminal('INT') + self._pop_path() + self.consume_literal(')') + _t789 = logic_pb2.DecimalType(precision=int(int158), scale=int(int_3159)) + result161 = _t789 + self._record_span(span_start160) + return result161 def parse_boolean_type(self) -> logic_pb2.BooleanType: + span_start162 = self._span_start() self.consume_literal('BOOLEAN') - _t524 = logic_pb2.BooleanType() - return _t524 + _t790 = logic_pb2.BooleanType() + result163 = _t790 + self._record_span(span_start162) + return result163 def parse_value_bindings(self) -> Sequence[logic_pb2.Binding]: + span_start169 = self._span_start() self.consume_literal('|') - xs90 = [] - cond91 = self.match_lookahead_terminal('SYMBOL', 0) - while cond91: - _t525 = self.parse_binding() - item92 = _t525 - xs90.append(item92) - cond91 = self.match_lookahead_terminal('SYMBOL', 0) - bindings93 = xs90 - return bindings93 + xs164 = [] + cond165 = self.match_lookahead_terminal('SYMBOL', 0) + idx167 = 0 + while cond165: + self._push_path(idx167) + _t791 = self.parse_binding() + item166 = _t791 + self._pop_path() + xs164.append(item166) + idx167 = (idx167 + 1) + cond165 = self.match_lookahead_terminal('SYMBOL', 0) + bindings168 = xs164 + result170 = bindings168 + self._record_span(span_start169) + return result170 def parse_formula(self) -> logic_pb2.Formula: + span_start185 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('true', 1): - _t527 = 0 + _t793 = 0 else: if self.match_lookahead_literal('relatom', 1): - _t528 = 11 + _t794 = 11 else: if self.match_lookahead_literal('reduce', 1): - _t529 = 3 + _t795 = 3 else: if self.match_lookahead_literal('primitive', 1): - _t530 = 10 + _t796 = 10 else: if self.match_lookahead_literal('pragma', 1): - _t531 = 9 + _t797 = 9 else: if self.match_lookahead_literal('or', 1): - _t532 = 5 + _t798 = 5 else: if self.match_lookahead_literal('not', 1): - _t533 = 6 + _t799 = 6 else: if self.match_lookahead_literal('ffi', 1): - _t534 = 7 + _t800 = 7 else: if self.match_lookahead_literal('false', 1): - _t535 = 1 + _t801 = 1 else: if self.match_lookahead_literal('exists', 1): - _t536 = 2 + _t802 = 2 else: if self.match_lookahead_literal('cast', 1): - _t537 = 12 + _t803 = 12 else: if self.match_lookahead_literal('atom', 1): - _t538 = 8 + _t804 = 8 else: if self.match_lookahead_literal('and', 1): - _t539 = 4 + _t805 = 4 else: if self.match_lookahead_literal('>=', 1): - _t540 = 10 + _t806 = 10 else: if self.match_lookahead_literal('>', 1): - _t541 = 10 + _t807 = 10 else: if self.match_lookahead_literal('=', 1): - _t542 = 10 + _t808 = 10 else: if self.match_lookahead_literal('<=', 1): - _t543 = 10 + _t809 = 10 else: if self.match_lookahead_literal('<', 1): - _t544 = 10 + _t810 = 10 else: if self.match_lookahead_literal('/', 1): - _t545 = 10 + _t811 = 10 else: if self.match_lookahead_literal('-', 1): - _t546 = 10 + _t812 = 10 else: if self.match_lookahead_literal('+', 1): - _t547 = 10 + _t813 = 10 else: if self.match_lookahead_literal('*', 1): - _t548 = 10 + _t814 = 10 else: - _t548 = -1 - _t547 = _t548 - _t546 = _t547 - _t545 = _t546 - _t544 = _t545 - _t543 = _t544 - _t542 = _t543 - _t541 = _t542 - _t540 = _t541 - _t539 = _t540 - _t538 = _t539 - _t537 = _t538 - _t536 = _t537 - _t535 = _t536 - _t534 = _t535 - _t533 = _t534 - _t532 = _t533 - _t531 = _t532 - _t530 = _t531 - _t529 = _t530 - _t528 = _t529 - _t527 = _t528 - _t526 = _t527 - else: - _t526 = -1 - prediction94 = _t526 - - if prediction94 == 12: - _t550 = self.parse_cast() - cast107 = _t550 - _t551 = logic_pb2.Formula(cast=cast107) - _t549 = _t551 + _t814 = -1 + _t813 = _t814 + _t812 = _t813 + _t811 = _t812 + _t810 = _t811 + _t809 = _t810 + _t808 = _t809 + _t807 = _t808 + _t806 = _t807 + _t805 = _t806 + _t804 = _t805 + _t803 = _t804 + _t802 = _t803 + _t801 = _t802 + _t800 = _t801 + _t799 = _t800 + _t798 = _t799 + _t797 = _t798 + _t796 = _t797 + _t795 = _t796 + _t794 = _t795 + _t793 = _t794 + _t792 = _t793 + else: + _t792 = -1 + prediction171 = _t792 + + if prediction171 == 12: + _t816 = self.parse_cast() + cast184 = _t816 + _t817 = logic_pb2.Formula(cast=cast184) + _t815 = _t817 else: - if prediction94 == 11: - _t553 = self.parse_rel_atom() - rel_atom106 = _t553 - _t554 = logic_pb2.Formula(rel_atom=rel_atom106) - _t552 = _t554 + if prediction171 == 11: + _t819 = self.parse_rel_atom() + rel_atom183 = _t819 + _t820 = logic_pb2.Formula(rel_atom=rel_atom183) + _t818 = _t820 else: - if prediction94 == 10: - _t556 = self.parse_primitive() - primitive105 = _t556 - _t557 = logic_pb2.Formula(primitive=primitive105) - _t555 = _t557 + if prediction171 == 10: + _t822 = self.parse_primitive() + primitive182 = _t822 + _t823 = logic_pb2.Formula(primitive=primitive182) + _t821 = _t823 else: - if prediction94 == 9: - _t559 = self.parse_pragma() - pragma104 = _t559 - _t560 = logic_pb2.Formula(pragma=pragma104) - _t558 = _t560 + if prediction171 == 9: + _t825 = self.parse_pragma() + pragma181 = _t825 + _t826 = logic_pb2.Formula(pragma=pragma181) + _t824 = _t826 else: - if prediction94 == 8: - _t562 = self.parse_atom() - atom103 = _t562 - _t563 = logic_pb2.Formula(atom=atom103) - _t561 = _t563 + if prediction171 == 8: + _t828 = self.parse_atom() + atom180 = _t828 + _t829 = logic_pb2.Formula(atom=atom180) + _t827 = _t829 else: - if prediction94 == 7: - _t565 = self.parse_ffi() - ffi102 = _t565 - _t566 = logic_pb2.Formula(ffi=ffi102) - _t564 = _t566 + if prediction171 == 7: + _t831 = self.parse_ffi() + ffi179 = _t831 + _t832 = logic_pb2.Formula(ffi=ffi179) + _t830 = _t832 else: - if prediction94 == 6: - _t568 = self.parse_not() - not101 = _t568 - _t569 = logic_pb2.Formula() - getattr(_t569, 'not').CopyFrom(not101) - _t567 = _t569 + if prediction171 == 6: + _t834 = self.parse_not() + not178 = _t834 + _t835 = logic_pb2.Formula() + getattr(_t835, 'not').CopyFrom(not178) + _t833 = _t835 else: - if prediction94 == 5: - _t571 = self.parse_disjunction() - disjunction100 = _t571 - _t572 = logic_pb2.Formula(disjunction=disjunction100) - _t570 = _t572 + if prediction171 == 5: + _t837 = self.parse_disjunction() + disjunction177 = _t837 + _t838 = logic_pb2.Formula(disjunction=disjunction177) + _t836 = _t838 else: - if prediction94 == 4: - _t574 = self.parse_conjunction() - conjunction99 = _t574 - _t575 = logic_pb2.Formula(conjunction=conjunction99) - _t573 = _t575 + if prediction171 == 4: + _t840 = self.parse_conjunction() + conjunction176 = _t840 + _t841 = logic_pb2.Formula(conjunction=conjunction176) + _t839 = _t841 else: - if prediction94 == 3: - _t577 = self.parse_reduce() - reduce98 = _t577 - _t578 = logic_pb2.Formula(reduce=reduce98) - _t576 = _t578 + if prediction171 == 3: + _t843 = self.parse_reduce() + reduce175 = _t843 + _t844 = logic_pb2.Formula(reduce=reduce175) + _t842 = _t844 else: - if prediction94 == 2: - _t580 = self.parse_exists() - exists97 = _t580 - _t581 = logic_pb2.Formula(exists=exists97) - _t579 = _t581 + if prediction171 == 2: + _t846 = self.parse_exists() + exists174 = _t846 + _t847 = logic_pb2.Formula(exists=exists174) + _t845 = _t847 else: - if prediction94 == 1: - _t583 = self.parse_false() - false96 = _t583 - _t584 = logic_pb2.Formula(disjunction=false96) - _t582 = _t584 + if prediction171 == 1: + _t849 = self.parse_false() + false173 = _t849 + _t850 = logic_pb2.Formula(disjunction=false173) + _t848 = _t850 else: - if prediction94 == 0: - _t586 = self.parse_true() - true95 = _t586 - _t587 = logic_pb2.Formula(conjunction=true95) - _t585 = _t587 + if prediction171 == 0: + _t852 = self.parse_true() + true172 = _t852 + _t853 = logic_pb2.Formula(conjunction=true172) + _t851 = _t853 else: raise ParseError(f"{'Unexpected token in formula'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t582 = _t585 - _t579 = _t582 - _t576 = _t579 - _t573 = _t576 - _t570 = _t573 - _t567 = _t570 - _t564 = _t567 - _t561 = _t564 - _t558 = _t561 - _t555 = _t558 - _t552 = _t555 - _t549 = _t552 - return _t549 + _t848 = _t851 + _t845 = _t848 + _t842 = _t845 + _t839 = _t842 + _t836 = _t839 + _t833 = _t836 + _t830 = _t833 + _t827 = _t830 + _t824 = _t827 + _t821 = _t824 + _t818 = _t821 + _t815 = _t818 + result186 = _t815 + self._record_span(span_start185) + return result186 def parse_true(self) -> logic_pb2.Conjunction: + span_start187 = self._span_start() self.consume_literal('(') self.consume_literal('true') self.consume_literal(')') - _t588 = logic_pb2.Conjunction(args=[]) - return _t588 + _t854 = logic_pb2.Conjunction(args=[]) + result188 = _t854 + self._record_span(span_start187) + return result188 def parse_false(self) -> logic_pb2.Disjunction: + span_start189 = self._span_start() self.consume_literal('(') self.consume_literal('false') self.consume_literal(')') - _t589 = logic_pb2.Disjunction(args=[]) - return _t589 + _t855 = logic_pb2.Disjunction(args=[]) + result190 = _t855 + self._record_span(span_start189) + return result190 def parse_exists(self) -> logic_pb2.Exists: + span_start193 = self._span_start() self.consume_literal('(') self.consume_literal('exists') - _t590 = self.parse_bindings() - bindings108 = _t590 - _t591 = self.parse_formula() - formula109 = _t591 + _t856 = self.parse_bindings() + bindings191 = _t856 + _t857 = self.parse_formula() + formula192 = _t857 self.consume_literal(')') - _t592 = logic_pb2.Abstraction(vars=(list(bindings108[0]) + list(bindings108[1] if bindings108[1] is not None else [])), value=formula109) - _t593 = logic_pb2.Exists(body=_t592) - return _t593 + _t858 = logic_pb2.Abstraction(vars=(list(bindings191[0]) + list(bindings191[1] if bindings191[1] is not None else [])), value=formula192) + _t859 = logic_pb2.Exists(body=_t858) + result194 = _t859 + self._record_span(span_start193) + return result194 def parse_reduce(self) -> logic_pb2.Reduce: + span_start198 = self._span_start() self.consume_literal('(') self.consume_literal('reduce') - _t594 = self.parse_abstraction() - abstraction110 = _t594 - _t595 = self.parse_abstraction() - abstraction_3111 = _t595 - _t596 = self.parse_terms() - terms112 = _t596 - self.consume_literal(')') - _t597 = logic_pb2.Reduce(op=abstraction110, body=abstraction_3111, terms=terms112) - return _t597 + self._push_path(1) + _t860 = self.parse_abstraction() + abstraction195 = _t860 + self._pop_path() + self._push_path(2) + _t861 = self.parse_abstraction() + abstraction_3196 = _t861 + self._pop_path() + self._push_path(3) + _t862 = self.parse_terms() + terms197 = _t862 + self._pop_path() + self.consume_literal(')') + _t863 = logic_pb2.Reduce(op=abstraction195, body=abstraction_3196, terms=terms197) + result199 = _t863 + self._record_span(span_start198) + return result199 def parse_terms(self) -> Sequence[logic_pb2.Term]: + span_start205 = self._span_start() self.consume_literal('(') self.consume_literal('terms') - xs113 = [] - cond114 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond114: - _t598 = self.parse_term() - item115 = _t598 - xs113.append(item115) - cond114 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - terms116 = xs113 - self.consume_literal(')') - return terms116 + xs200 = [] + cond201 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx203 = 0 + while cond201: + self._push_path(idx203) + _t864 = self.parse_term() + item202 = _t864 + self._pop_path() + xs200.append(item202) + idx203 = (idx203 + 1) + cond201 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + terms204 = xs200 + self.consume_literal(')') + result206 = terms204 + self._record_span(span_start205) + return result206 def parse_term(self) -> logic_pb2.Term: + span_start210 = self._span_start() if self.match_lookahead_literal('true', 0): - _t599 = 1 + _t865 = 1 else: if self.match_lookahead_literal('missing', 0): - _t600 = 1 + _t866 = 1 else: if self.match_lookahead_literal('false', 0): - _t601 = 1 + _t867 = 1 else: if self.match_lookahead_literal('(', 0): - _t602 = 1 + _t868 = 1 else: if self.match_lookahead_terminal('UINT128', 0): - _t603 = 1 + _t869 = 1 else: if self.match_lookahead_terminal('SYMBOL', 0): - _t604 = 0 + _t870 = 0 else: if self.match_lookahead_terminal('STRING', 0): - _t605 = 1 + _t871 = 1 else: if self.match_lookahead_terminal('INT128', 0): - _t606 = 1 + _t872 = 1 else: if self.match_lookahead_terminal('INT', 0): - _t607 = 1 + _t873 = 1 else: if self.match_lookahead_terminal('FLOAT', 0): - _t608 = 1 + _t874 = 1 else: if self.match_lookahead_terminal('DECIMAL', 0): - _t609 = 1 + _t875 = 1 else: - _t609 = -1 - _t608 = _t609 - _t607 = _t608 - _t606 = _t607 - _t605 = _t606 - _t604 = _t605 - _t603 = _t604 - _t602 = _t603 - _t601 = _t602 - _t600 = _t601 - _t599 = _t600 - prediction117 = _t599 - - if prediction117 == 1: - _t611 = self.parse_constant() - constant119 = _t611 - _t612 = logic_pb2.Term(constant=constant119) - _t610 = _t612 + _t875 = -1 + _t874 = _t875 + _t873 = _t874 + _t872 = _t873 + _t871 = _t872 + _t870 = _t871 + _t869 = _t870 + _t868 = _t869 + _t867 = _t868 + _t866 = _t867 + _t865 = _t866 + prediction207 = _t865 + + if prediction207 == 1: + _t877 = self.parse_constant() + constant209 = _t877 + _t878 = logic_pb2.Term(constant=constant209) + _t876 = _t878 else: - if prediction117 == 0: - _t614 = self.parse_var() - var118 = _t614 - _t615 = logic_pb2.Term(var=var118) - _t613 = _t615 + if prediction207 == 0: + _t880 = self.parse_var() + var208 = _t880 + _t881 = logic_pb2.Term(var=var208) + _t879 = _t881 else: raise ParseError(f"{'Unexpected token in term'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t610 = _t613 - return _t610 + _t876 = _t879 + result211 = _t876 + self._record_span(span_start210) + return result211 def parse_var(self) -> logic_pb2.Var: - symbol120 = self.consume_terminal('SYMBOL') - _t616 = logic_pb2.Var(name=symbol120) - return _t616 + span_start213 = self._span_start() + symbol212 = self.consume_terminal('SYMBOL') + _t882 = logic_pb2.Var(name=symbol212) + result214 = _t882 + self._record_span(span_start213) + return result214 def parse_constant(self) -> logic_pb2.Value: - _t617 = self.parse_value() - value121 = _t617 - return value121 + span_start216 = self._span_start() + _t883 = self.parse_value() + value215 = _t883 + result217 = value215 + self._record_span(span_start216) + return result217 def parse_conjunction(self) -> logic_pb2.Conjunction: + span_start223 = self._span_start() self.consume_literal('(') self.consume_literal('and') - xs122 = [] - cond123 = self.match_lookahead_literal('(', 0) - while cond123: - _t618 = self.parse_formula() - item124 = _t618 - xs122.append(item124) - cond123 = self.match_lookahead_literal('(', 0) - formulas125 = xs122 - self.consume_literal(')') - _t619 = logic_pb2.Conjunction(args=formulas125) - return _t619 + self._push_path(1) + xs218 = [] + cond219 = self.match_lookahead_literal('(', 0) + idx221 = 0 + while cond219: + self._push_path(idx221) + _t884 = self.parse_formula() + item220 = _t884 + self._pop_path() + xs218.append(item220) + idx221 = (idx221 + 1) + cond219 = self.match_lookahead_literal('(', 0) + self._pop_path() + formulas222 = xs218 + self.consume_literal(')') + _t885 = logic_pb2.Conjunction(args=formulas222) + result224 = _t885 + self._record_span(span_start223) + return result224 def parse_disjunction(self) -> logic_pb2.Disjunction: + span_start230 = self._span_start() self.consume_literal('(') self.consume_literal('or') - xs126 = [] - cond127 = self.match_lookahead_literal('(', 0) - while cond127: - _t620 = self.parse_formula() - item128 = _t620 - xs126.append(item128) - cond127 = self.match_lookahead_literal('(', 0) - formulas129 = xs126 - self.consume_literal(')') - _t621 = logic_pb2.Disjunction(args=formulas129) - return _t621 + self._push_path(1) + xs225 = [] + cond226 = self.match_lookahead_literal('(', 0) + idx228 = 0 + while cond226: + self._push_path(idx228) + _t886 = self.parse_formula() + item227 = _t886 + self._pop_path() + xs225.append(item227) + idx228 = (idx228 + 1) + cond226 = self.match_lookahead_literal('(', 0) + self._pop_path() + formulas229 = xs225 + self.consume_literal(')') + _t887 = logic_pb2.Disjunction(args=formulas229) + result231 = _t887 + self._record_span(span_start230) + return result231 def parse_not(self) -> logic_pb2.Not: + span_start233 = self._span_start() self.consume_literal('(') self.consume_literal('not') - _t622 = self.parse_formula() - formula130 = _t622 + self._push_path(1) + _t888 = self.parse_formula() + formula232 = _t888 + self._pop_path() self.consume_literal(')') - _t623 = logic_pb2.Not(arg=formula130) - return _t623 + _t889 = logic_pb2.Not(arg=formula232) + result234 = _t889 + self._record_span(span_start233) + return result234 def parse_ffi(self) -> logic_pb2.FFI: + span_start238 = self._span_start() self.consume_literal('(') self.consume_literal('ffi') - _t624 = self.parse_name() - name131 = _t624 - _t625 = self.parse_ffi_args() - ffi_args132 = _t625 - _t626 = self.parse_terms() - terms133 = _t626 - self.consume_literal(')') - _t627 = logic_pb2.FFI(name=name131, args=ffi_args132, terms=terms133) - return _t627 + self._push_path(1) + _t890 = self.parse_name() + name235 = _t890 + self._pop_path() + self._push_path(2) + _t891 = self.parse_ffi_args() + ffi_args236 = _t891 + self._pop_path() + self._push_path(3) + _t892 = self.parse_terms() + terms237 = _t892 + self._pop_path() + self.consume_literal(')') + _t893 = logic_pb2.FFI(name=name235, args=ffi_args236, terms=terms237) + result239 = _t893 + self._record_span(span_start238) + return result239 def parse_name(self) -> str: + span_start241 = self._span_start() self.consume_literal(':') - symbol134 = self.consume_terminal('SYMBOL') - return symbol134 + symbol240 = self.consume_terminal('SYMBOL') + result242 = symbol240 + self._record_span(span_start241) + return result242 def parse_ffi_args(self) -> Sequence[logic_pb2.Abstraction]: + span_start248 = self._span_start() self.consume_literal('(') self.consume_literal('args') - xs135 = [] - cond136 = self.match_lookahead_literal('(', 0) - while cond136: - _t628 = self.parse_abstraction() - item137 = _t628 - xs135.append(item137) - cond136 = self.match_lookahead_literal('(', 0) - abstractions138 = xs135 - self.consume_literal(')') - return abstractions138 + xs243 = [] + cond244 = self.match_lookahead_literal('(', 0) + idx246 = 0 + while cond244: + self._push_path(idx246) + _t894 = self.parse_abstraction() + item245 = _t894 + self._pop_path() + xs243.append(item245) + idx246 = (idx246 + 1) + cond244 = self.match_lookahead_literal('(', 0) + abstractions247 = xs243 + self.consume_literal(')') + result249 = abstractions247 + self._record_span(span_start248) + return result249 def parse_atom(self) -> logic_pb2.Atom: + span_start256 = self._span_start() self.consume_literal('(') self.consume_literal('atom') - _t629 = self.parse_relation_id() - relation_id139 = _t629 - xs140 = [] - cond141 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond141: - _t630 = self.parse_term() - item142 = _t630 - xs140.append(item142) - cond141 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - terms143 = xs140 - self.consume_literal(')') - _t631 = logic_pb2.Atom(name=relation_id139, terms=terms143) - return _t631 + self._push_path(1) + _t895 = self.parse_relation_id() + relation_id250 = _t895 + self._pop_path() + self._push_path(2) + xs251 = [] + cond252 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx254 = 0 + while cond252: + self._push_path(idx254) + _t896 = self.parse_term() + item253 = _t896 + self._pop_path() + xs251.append(item253) + idx254 = (idx254 + 1) + cond252 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + terms255 = xs251 + self.consume_literal(')') + _t897 = logic_pb2.Atom(name=relation_id250, terms=terms255) + result257 = _t897 + self._record_span(span_start256) + return result257 def parse_pragma(self) -> logic_pb2.Pragma: + span_start264 = self._span_start() self.consume_literal('(') self.consume_literal('pragma') - _t632 = self.parse_name() - name144 = _t632 - xs145 = [] - cond146 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond146: - _t633 = self.parse_term() - item147 = _t633 - xs145.append(item147) - cond146 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - terms148 = xs145 - self.consume_literal(')') - _t634 = logic_pb2.Pragma(name=name144, terms=terms148) - return _t634 + self._push_path(1) + _t898 = self.parse_name() + name258 = _t898 + self._pop_path() + self._push_path(2) + xs259 = [] + cond260 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx262 = 0 + while cond260: + self._push_path(idx262) + _t899 = self.parse_term() + item261 = _t899 + self._pop_path() + xs259.append(item261) + idx262 = (idx262 + 1) + cond260 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + terms263 = xs259 + self.consume_literal(')') + _t900 = logic_pb2.Pragma(name=name258, terms=terms263) + result265 = _t900 + self._record_span(span_start264) + return result265 def parse_primitive(self) -> logic_pb2.Primitive: + span_start282 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('primitive', 1): - _t636 = 9 + _t902 = 9 else: if self.match_lookahead_literal('>=', 1): - _t637 = 4 + _t903 = 4 else: if self.match_lookahead_literal('>', 1): - _t638 = 3 + _t904 = 3 else: if self.match_lookahead_literal('=', 1): - _t639 = 0 + _t905 = 0 else: if self.match_lookahead_literal('<=', 1): - _t640 = 2 + _t906 = 2 else: if self.match_lookahead_literal('<', 1): - _t641 = 1 + _t907 = 1 else: if self.match_lookahead_literal('/', 1): - _t642 = 8 + _t908 = 8 else: if self.match_lookahead_literal('-', 1): - _t643 = 6 + _t909 = 6 else: if self.match_lookahead_literal('+', 1): - _t644 = 5 + _t910 = 5 else: if self.match_lookahead_literal('*', 1): - _t645 = 7 + _t911 = 7 else: - _t645 = -1 - _t644 = _t645 - _t643 = _t644 - _t642 = _t643 - _t641 = _t642 - _t640 = _t641 - _t639 = _t640 - _t638 = _t639 - _t637 = _t638 - _t636 = _t637 - _t635 = _t636 - else: - _t635 = -1 - prediction149 = _t635 - - if prediction149 == 9: + _t911 = -1 + _t910 = _t911 + _t909 = _t910 + _t908 = _t909 + _t907 = _t908 + _t906 = _t907 + _t905 = _t906 + _t904 = _t905 + _t903 = _t904 + _t902 = _t903 + _t901 = _t902 + else: + _t901 = -1 + prediction266 = _t901 + + if prediction266 == 9: self.consume_literal('(') self.consume_literal('primitive') - _t647 = self.parse_name() - name159 = _t647 - xs160 = [] - cond161 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond161: - _t648 = self.parse_rel_term() - item162 = _t648 - xs160.append(item162) - cond161 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - rel_terms163 = xs160 + self._push_path(1) + _t913 = self.parse_name() + name276 = _t913 + self._pop_path() + self._push_path(2) + xs277 = [] + cond278 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx280 = 0 + while cond278: + self._push_path(idx280) + _t914 = self.parse_rel_term() + item279 = _t914 + self._pop_path() + xs277.append(item279) + idx280 = (idx280 + 1) + cond278 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + rel_terms281 = xs277 self.consume_literal(')') - _t649 = logic_pb2.Primitive(name=name159, terms=rel_terms163) - _t646 = _t649 + _t915 = logic_pb2.Primitive(name=name276, terms=rel_terms281) + _t912 = _t915 else: - if prediction149 == 8: - _t651 = self.parse_divide() - divide158 = _t651 - _t650 = divide158 + if prediction266 == 8: + _t917 = self.parse_divide() + divide275 = _t917 + _t916 = divide275 else: - if prediction149 == 7: - _t653 = self.parse_multiply() - multiply157 = _t653 - _t652 = multiply157 + if prediction266 == 7: + _t919 = self.parse_multiply() + multiply274 = _t919 + _t918 = multiply274 else: - if prediction149 == 6: - _t655 = self.parse_minus() - minus156 = _t655 - _t654 = minus156 + if prediction266 == 6: + _t921 = self.parse_minus() + minus273 = _t921 + _t920 = minus273 else: - if prediction149 == 5: - _t657 = self.parse_add() - add155 = _t657 - _t656 = add155 + if prediction266 == 5: + _t923 = self.parse_add() + add272 = _t923 + _t922 = add272 else: - if prediction149 == 4: - _t659 = self.parse_gt_eq() - gt_eq154 = _t659 - _t658 = gt_eq154 + if prediction266 == 4: + _t925 = self.parse_gt_eq() + gt_eq271 = _t925 + _t924 = gt_eq271 else: - if prediction149 == 3: - _t661 = self.parse_gt() - gt153 = _t661 - _t660 = gt153 + if prediction266 == 3: + _t927 = self.parse_gt() + gt270 = _t927 + _t926 = gt270 else: - if prediction149 == 2: - _t663 = self.parse_lt_eq() - lt_eq152 = _t663 - _t662 = lt_eq152 + if prediction266 == 2: + _t929 = self.parse_lt_eq() + lt_eq269 = _t929 + _t928 = lt_eq269 else: - if prediction149 == 1: - _t665 = self.parse_lt() - lt151 = _t665 - _t664 = lt151 + if prediction266 == 1: + _t931 = self.parse_lt() + lt268 = _t931 + _t930 = lt268 else: - if prediction149 == 0: - _t667 = self.parse_eq() - eq150 = _t667 - _t666 = eq150 + if prediction266 == 0: + _t933 = self.parse_eq() + eq267 = _t933 + _t932 = eq267 else: raise ParseError(f"{'Unexpected token in primitive'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t664 = _t666 - _t662 = _t664 - _t660 = _t662 - _t658 = _t660 - _t656 = _t658 - _t654 = _t656 - _t652 = _t654 - _t650 = _t652 - _t646 = _t650 - return _t646 + _t930 = _t932 + _t928 = _t930 + _t926 = _t928 + _t924 = _t926 + _t922 = _t924 + _t920 = _t922 + _t918 = _t920 + _t916 = _t918 + _t912 = _t916 + result283 = _t912 + self._record_span(span_start282) + return result283 def parse_eq(self) -> logic_pb2.Primitive: + span_start286 = self._span_start() self.consume_literal('(') self.consume_literal('=') - _t668 = self.parse_term() - term164 = _t668 - _t669 = self.parse_term() - term_3165 = _t669 - self.consume_literal(')') - _t670 = logic_pb2.RelTerm(term=term164) - _t671 = logic_pb2.RelTerm(term=term_3165) - _t672 = logic_pb2.Primitive(name='rel_primitive_eq', terms=[_t670, _t671]) - return _t672 + _t934 = self.parse_term() + term284 = _t934 + _t935 = self.parse_term() + term_3285 = _t935 + self.consume_literal(')') + _t936 = logic_pb2.RelTerm(term=term284) + _t937 = logic_pb2.RelTerm(term=term_3285) + _t938 = logic_pb2.Primitive(name='rel_primitive_eq', terms=[_t936, _t937]) + result287 = _t938 + self._record_span(span_start286) + return result287 def parse_lt(self) -> logic_pb2.Primitive: + span_start290 = self._span_start() self.consume_literal('(') self.consume_literal('<') - _t673 = self.parse_term() - term166 = _t673 - _t674 = self.parse_term() - term_3167 = _t674 - self.consume_literal(')') - _t675 = logic_pb2.RelTerm(term=term166) - _t676 = logic_pb2.RelTerm(term=term_3167) - _t677 = logic_pb2.Primitive(name='rel_primitive_lt_monotype', terms=[_t675, _t676]) - return _t677 + _t939 = self.parse_term() + term288 = _t939 + _t940 = self.parse_term() + term_3289 = _t940 + self.consume_literal(')') + _t941 = logic_pb2.RelTerm(term=term288) + _t942 = logic_pb2.RelTerm(term=term_3289) + _t943 = logic_pb2.Primitive(name='rel_primitive_lt_monotype', terms=[_t941, _t942]) + result291 = _t943 + self._record_span(span_start290) + return result291 def parse_lt_eq(self) -> logic_pb2.Primitive: + span_start294 = self._span_start() self.consume_literal('(') self.consume_literal('<=') - _t678 = self.parse_term() - term168 = _t678 - _t679 = self.parse_term() - term_3169 = _t679 - self.consume_literal(')') - _t680 = logic_pb2.RelTerm(term=term168) - _t681 = logic_pb2.RelTerm(term=term_3169) - _t682 = logic_pb2.Primitive(name='rel_primitive_lt_eq_monotype', terms=[_t680, _t681]) - return _t682 + _t944 = self.parse_term() + term292 = _t944 + _t945 = self.parse_term() + term_3293 = _t945 + self.consume_literal(')') + _t946 = logic_pb2.RelTerm(term=term292) + _t947 = logic_pb2.RelTerm(term=term_3293) + _t948 = logic_pb2.Primitive(name='rel_primitive_lt_eq_monotype', terms=[_t946, _t947]) + result295 = _t948 + self._record_span(span_start294) + return result295 def parse_gt(self) -> logic_pb2.Primitive: + span_start298 = self._span_start() self.consume_literal('(') self.consume_literal('>') - _t683 = self.parse_term() - term170 = _t683 - _t684 = self.parse_term() - term_3171 = _t684 - self.consume_literal(')') - _t685 = logic_pb2.RelTerm(term=term170) - _t686 = logic_pb2.RelTerm(term=term_3171) - _t687 = logic_pb2.Primitive(name='rel_primitive_gt_monotype', terms=[_t685, _t686]) - return _t687 + _t949 = self.parse_term() + term296 = _t949 + _t950 = self.parse_term() + term_3297 = _t950 + self.consume_literal(')') + _t951 = logic_pb2.RelTerm(term=term296) + _t952 = logic_pb2.RelTerm(term=term_3297) + _t953 = logic_pb2.Primitive(name='rel_primitive_gt_monotype', terms=[_t951, _t952]) + result299 = _t953 + self._record_span(span_start298) + return result299 def parse_gt_eq(self) -> logic_pb2.Primitive: + span_start302 = self._span_start() self.consume_literal('(') self.consume_literal('>=') - _t688 = self.parse_term() - term172 = _t688 - _t689 = self.parse_term() - term_3173 = _t689 - self.consume_literal(')') - _t690 = logic_pb2.RelTerm(term=term172) - _t691 = logic_pb2.RelTerm(term=term_3173) - _t692 = logic_pb2.Primitive(name='rel_primitive_gt_eq_monotype', terms=[_t690, _t691]) - return _t692 + _t954 = self.parse_term() + term300 = _t954 + _t955 = self.parse_term() + term_3301 = _t955 + self.consume_literal(')') + _t956 = logic_pb2.RelTerm(term=term300) + _t957 = logic_pb2.RelTerm(term=term_3301) + _t958 = logic_pb2.Primitive(name='rel_primitive_gt_eq_monotype', terms=[_t956, _t957]) + result303 = _t958 + self._record_span(span_start302) + return result303 def parse_add(self) -> logic_pb2.Primitive: + span_start307 = self._span_start() self.consume_literal('(') self.consume_literal('+') - _t693 = self.parse_term() - term174 = _t693 - _t694 = self.parse_term() - term_3175 = _t694 - _t695 = self.parse_term() - term_4176 = _t695 - self.consume_literal(')') - _t696 = logic_pb2.RelTerm(term=term174) - _t697 = logic_pb2.RelTerm(term=term_3175) - _t698 = logic_pb2.RelTerm(term=term_4176) - _t699 = logic_pb2.Primitive(name='rel_primitive_add_monotype', terms=[_t696, _t697, _t698]) - return _t699 + _t959 = self.parse_term() + term304 = _t959 + _t960 = self.parse_term() + term_3305 = _t960 + _t961 = self.parse_term() + term_4306 = _t961 + self.consume_literal(')') + _t962 = logic_pb2.RelTerm(term=term304) + _t963 = logic_pb2.RelTerm(term=term_3305) + _t964 = logic_pb2.RelTerm(term=term_4306) + _t965 = logic_pb2.Primitive(name='rel_primitive_add_monotype', terms=[_t962, _t963, _t964]) + result308 = _t965 + self._record_span(span_start307) + return result308 def parse_minus(self) -> logic_pb2.Primitive: + span_start312 = self._span_start() self.consume_literal('(') self.consume_literal('-') - _t700 = self.parse_term() - term177 = _t700 - _t701 = self.parse_term() - term_3178 = _t701 - _t702 = self.parse_term() - term_4179 = _t702 - self.consume_literal(')') - _t703 = logic_pb2.RelTerm(term=term177) - _t704 = logic_pb2.RelTerm(term=term_3178) - _t705 = logic_pb2.RelTerm(term=term_4179) - _t706 = logic_pb2.Primitive(name='rel_primitive_subtract_monotype', terms=[_t703, _t704, _t705]) - return _t706 + _t966 = self.parse_term() + term309 = _t966 + _t967 = self.parse_term() + term_3310 = _t967 + _t968 = self.parse_term() + term_4311 = _t968 + self.consume_literal(')') + _t969 = logic_pb2.RelTerm(term=term309) + _t970 = logic_pb2.RelTerm(term=term_3310) + _t971 = logic_pb2.RelTerm(term=term_4311) + _t972 = logic_pb2.Primitive(name='rel_primitive_subtract_monotype', terms=[_t969, _t970, _t971]) + result313 = _t972 + self._record_span(span_start312) + return result313 def parse_multiply(self) -> logic_pb2.Primitive: + span_start317 = self._span_start() self.consume_literal('(') self.consume_literal('*') - _t707 = self.parse_term() - term180 = _t707 - _t708 = self.parse_term() - term_3181 = _t708 - _t709 = self.parse_term() - term_4182 = _t709 - self.consume_literal(')') - _t710 = logic_pb2.RelTerm(term=term180) - _t711 = logic_pb2.RelTerm(term=term_3181) - _t712 = logic_pb2.RelTerm(term=term_4182) - _t713 = logic_pb2.Primitive(name='rel_primitive_multiply_monotype', terms=[_t710, _t711, _t712]) - return _t713 + _t973 = self.parse_term() + term314 = _t973 + _t974 = self.parse_term() + term_3315 = _t974 + _t975 = self.parse_term() + term_4316 = _t975 + self.consume_literal(')') + _t976 = logic_pb2.RelTerm(term=term314) + _t977 = logic_pb2.RelTerm(term=term_3315) + _t978 = logic_pb2.RelTerm(term=term_4316) + _t979 = logic_pb2.Primitive(name='rel_primitive_multiply_monotype', terms=[_t976, _t977, _t978]) + result318 = _t979 + self._record_span(span_start317) + return result318 def parse_divide(self) -> logic_pb2.Primitive: + span_start322 = self._span_start() self.consume_literal('(') self.consume_literal('/') - _t714 = self.parse_term() - term183 = _t714 - _t715 = self.parse_term() - term_3184 = _t715 - _t716 = self.parse_term() - term_4185 = _t716 - self.consume_literal(')') - _t717 = logic_pb2.RelTerm(term=term183) - _t718 = logic_pb2.RelTerm(term=term_3184) - _t719 = logic_pb2.RelTerm(term=term_4185) - _t720 = logic_pb2.Primitive(name='rel_primitive_divide_monotype', terms=[_t717, _t718, _t719]) - return _t720 + _t980 = self.parse_term() + term319 = _t980 + _t981 = self.parse_term() + term_3320 = _t981 + _t982 = self.parse_term() + term_4321 = _t982 + self.consume_literal(')') + _t983 = logic_pb2.RelTerm(term=term319) + _t984 = logic_pb2.RelTerm(term=term_3320) + _t985 = logic_pb2.RelTerm(term=term_4321) + _t986 = logic_pb2.Primitive(name='rel_primitive_divide_monotype', terms=[_t983, _t984, _t985]) + result323 = _t986 + self._record_span(span_start322) + return result323 def parse_rel_term(self) -> logic_pb2.RelTerm: + span_start327 = self._span_start() if self.match_lookahead_literal('true', 0): - _t721 = 1 + _t987 = 1 else: if self.match_lookahead_literal('missing', 0): - _t722 = 1 + _t988 = 1 else: if self.match_lookahead_literal('false', 0): - _t723 = 1 + _t989 = 1 else: if self.match_lookahead_literal('(', 0): - _t724 = 1 + _t990 = 1 else: if self.match_lookahead_literal('#', 0): - _t725 = 0 + _t991 = 0 else: if self.match_lookahead_terminal('UINT128', 0): - _t726 = 1 + _t992 = 1 else: if self.match_lookahead_terminal('SYMBOL', 0): - _t727 = 1 + _t993 = 1 else: if self.match_lookahead_terminal('STRING', 0): - _t728 = 1 + _t994 = 1 else: if self.match_lookahead_terminal('INT128', 0): - _t729 = 1 + _t995 = 1 else: if self.match_lookahead_terminal('INT', 0): - _t730 = 1 + _t996 = 1 else: if self.match_lookahead_terminal('FLOAT', 0): - _t731 = 1 + _t997 = 1 else: if self.match_lookahead_terminal('DECIMAL', 0): - _t732 = 1 + _t998 = 1 else: - _t732 = -1 - _t731 = _t732 - _t730 = _t731 - _t729 = _t730 - _t728 = _t729 - _t727 = _t728 - _t726 = _t727 - _t725 = _t726 - _t724 = _t725 - _t723 = _t724 - _t722 = _t723 - _t721 = _t722 - prediction186 = _t721 - - if prediction186 == 1: - _t734 = self.parse_term() - term188 = _t734 - _t735 = logic_pb2.RelTerm(term=term188) - _t733 = _t735 + _t998 = -1 + _t997 = _t998 + _t996 = _t997 + _t995 = _t996 + _t994 = _t995 + _t993 = _t994 + _t992 = _t993 + _t991 = _t992 + _t990 = _t991 + _t989 = _t990 + _t988 = _t989 + _t987 = _t988 + prediction324 = _t987 + + if prediction324 == 1: + _t1000 = self.parse_term() + term326 = _t1000 + _t1001 = logic_pb2.RelTerm(term=term326) + _t999 = _t1001 else: - if prediction186 == 0: - _t737 = self.parse_specialized_value() - specialized_value187 = _t737 - _t738 = logic_pb2.RelTerm(specialized_value=specialized_value187) - _t736 = _t738 + if prediction324 == 0: + _t1003 = self.parse_specialized_value() + specialized_value325 = _t1003 + _t1004 = logic_pb2.RelTerm(specialized_value=specialized_value325) + _t1002 = _t1004 else: raise ParseError(f"{'Unexpected token in rel_term'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t733 = _t736 - return _t733 + _t999 = _t1002 + result328 = _t999 + self._record_span(span_start327) + return result328 def parse_specialized_value(self) -> logic_pb2.Value: + span_start330 = self._span_start() self.consume_literal('#') - _t739 = self.parse_value() - value189 = _t739 - return value189 + _t1005 = self.parse_value() + value329 = _t1005 + result331 = value329 + self._record_span(span_start330) + return result331 def parse_rel_atom(self) -> logic_pb2.RelAtom: + span_start338 = self._span_start() self.consume_literal('(') self.consume_literal('relatom') - _t740 = self.parse_name() - name190 = _t740 - xs191 = [] - cond192 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond192: - _t741 = self.parse_rel_term() - item193 = _t741 - xs191.append(item193) - cond192 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) - rel_terms194 = xs191 - self.consume_literal(')') - _t742 = logic_pb2.RelAtom(name=name190, terms=rel_terms194) - return _t742 + self._push_path(3) + _t1006 = self.parse_name() + name332 = _t1006 + self._pop_path() + self._push_path(2) + xs333 = [] + cond334 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx336 = 0 + while cond334: + self._push_path(idx336) + _t1007 = self.parse_rel_term() + item335 = _t1007 + self._pop_path() + xs333.append(item335) + idx336 = (idx336 + 1) + cond334 = (((((((((((self.match_lookahead_literal('#', 0) or self.match_lookahead_literal('(', 0)) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('SYMBOL', 0)) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + rel_terms337 = xs333 + self.consume_literal(')') + _t1008 = logic_pb2.RelAtom(name=name332, terms=rel_terms337) + result339 = _t1008 + self._record_span(span_start338) + return result339 def parse_cast(self) -> logic_pb2.Cast: + span_start342 = self._span_start() self.consume_literal('(') self.consume_literal('cast') - _t743 = self.parse_term() - term195 = _t743 - _t744 = self.parse_term() - term_3196 = _t744 - self.consume_literal(')') - _t745 = logic_pb2.Cast(input=term195, result=term_3196) - return _t745 + self._push_path(2) + _t1009 = self.parse_term() + term340 = _t1009 + self._pop_path() + self._push_path(3) + _t1010 = self.parse_term() + term_3341 = _t1010 + self._pop_path() + self.consume_literal(')') + _t1011 = logic_pb2.Cast(input=term340, result=term_3341) + result343 = _t1011 + self._record_span(span_start342) + return result343 def parse_attrs(self) -> Sequence[logic_pb2.Attribute]: + span_start349 = self._span_start() self.consume_literal('(') self.consume_literal('attrs') - xs197 = [] - cond198 = self.match_lookahead_literal('(', 0) - while cond198: - _t746 = self.parse_attribute() - item199 = _t746 - xs197.append(item199) - cond198 = self.match_lookahead_literal('(', 0) - attributes200 = xs197 - self.consume_literal(')') - return attributes200 + xs344 = [] + cond345 = self.match_lookahead_literal('(', 0) + idx347 = 0 + while cond345: + self._push_path(idx347) + _t1012 = self.parse_attribute() + item346 = _t1012 + self._pop_path() + xs344.append(item346) + idx347 = (idx347 + 1) + cond345 = self.match_lookahead_literal('(', 0) + attributes348 = xs344 + self.consume_literal(')') + result350 = attributes348 + self._record_span(span_start349) + return result350 def parse_attribute(self) -> logic_pb2.Attribute: + span_start357 = self._span_start() self.consume_literal('(') self.consume_literal('attribute') - _t747 = self.parse_name() - name201 = _t747 - xs202 = [] - cond203 = (((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('UINT128', 0)) - while cond203: - _t748 = self.parse_value() - item204 = _t748 - xs202.append(item204) - cond203 = (((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('UINT128', 0)) - values205 = xs202 - self.consume_literal(')') - _t749 = logic_pb2.Attribute(name=name201, args=values205) - return _t749 + self._push_path(1) + _t1013 = self.parse_name() + name351 = _t1013 + self._pop_path() + self._push_path(2) + xs352 = [] + cond353 = (((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('UINT128', 0)) + idx355 = 0 + while cond353: + self._push_path(idx355) + _t1014 = self.parse_value() + item354 = _t1014 + self._pop_path() + xs352.append(item354) + idx355 = (idx355 + 1) + cond353 = (((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('false', 0)) or self.match_lookahead_literal('missing', 0)) or self.match_lookahead_literal('true', 0)) or self.match_lookahead_terminal('DECIMAL', 0)) or self.match_lookahead_terminal('FLOAT', 0)) or self.match_lookahead_terminal('INT', 0)) or self.match_lookahead_terminal('INT128', 0)) or self.match_lookahead_terminal('STRING', 0)) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + values356 = xs352 + self.consume_literal(')') + _t1015 = logic_pb2.Attribute(name=name351, args=values356) + result358 = _t1015 + self._record_span(span_start357) + return result358 def parse_algorithm(self) -> logic_pb2.Algorithm: + span_start365 = self._span_start() self.consume_literal('(') self.consume_literal('algorithm') - xs206 = [] - cond207 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) - while cond207: - _t750 = self.parse_relation_id() - item208 = _t750 - xs206.append(item208) - cond207 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) - relation_ids209 = xs206 - _t751 = self.parse_script() - script210 = _t751 - self.consume_literal(')') - _t752 = logic_pb2.Algorithm(body=script210) - getattr(_t752, 'global').extend(relation_ids209) - return _t752 + self._push_path(1) + xs359 = [] + cond360 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) + idx362 = 0 + while cond360: + self._push_path(idx362) + _t1016 = self.parse_relation_id() + item361 = _t1016 + self._pop_path() + xs359.append(item361) + idx362 = (idx362 + 1) + cond360 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + relation_ids363 = xs359 + self._push_path(2) + _t1017 = self.parse_script() + script364 = _t1017 + self._pop_path() + self.consume_literal(')') + _t1018 = logic_pb2.Algorithm(body=script364) + getattr(_t1018, 'global').extend(relation_ids363) + result366 = _t1018 + self._record_span(span_start365) + return result366 def parse_script(self) -> logic_pb2.Script: + span_start372 = self._span_start() self.consume_literal('(') self.consume_literal('script') - xs211 = [] - cond212 = self.match_lookahead_literal('(', 0) - while cond212: - _t753 = self.parse_construct() - item213 = _t753 - xs211.append(item213) - cond212 = self.match_lookahead_literal('(', 0) - constructs214 = xs211 - self.consume_literal(')') - _t754 = logic_pb2.Script(constructs=constructs214) - return _t754 + self._push_path(1) + xs367 = [] + cond368 = self.match_lookahead_literal('(', 0) + idx370 = 0 + while cond368: + self._push_path(idx370) + _t1019 = self.parse_construct() + item369 = _t1019 + self._pop_path() + xs367.append(item369) + idx370 = (idx370 + 1) + cond368 = self.match_lookahead_literal('(', 0) + self._pop_path() + constructs371 = xs367 + self.consume_literal(')') + _t1020 = logic_pb2.Script(constructs=constructs371) + result373 = _t1020 + self._record_span(span_start372) + return result373 def parse_construct(self) -> logic_pb2.Construct: + span_start377 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('upsert', 1): - _t756 = 1 + _t1022 = 1 else: if self.match_lookahead_literal('monus', 1): - _t757 = 1 + _t1023 = 1 else: if self.match_lookahead_literal('monoid', 1): - _t758 = 1 + _t1024 = 1 else: if self.match_lookahead_literal('loop', 1): - _t759 = 0 + _t1025 = 0 else: if self.match_lookahead_literal('break', 1): - _t760 = 1 + _t1026 = 1 else: if self.match_lookahead_literal('assign', 1): - _t761 = 1 + _t1027 = 1 else: - _t761 = -1 - _t760 = _t761 - _t759 = _t760 - _t758 = _t759 - _t757 = _t758 - _t756 = _t757 - _t755 = _t756 - else: - _t755 = -1 - prediction215 = _t755 - - if prediction215 == 1: - _t763 = self.parse_instruction() - instruction217 = _t763 - _t764 = logic_pb2.Construct(instruction=instruction217) - _t762 = _t764 + _t1027 = -1 + _t1026 = _t1027 + _t1025 = _t1026 + _t1024 = _t1025 + _t1023 = _t1024 + _t1022 = _t1023 + _t1021 = _t1022 + else: + _t1021 = -1 + prediction374 = _t1021 + + if prediction374 == 1: + _t1029 = self.parse_instruction() + instruction376 = _t1029 + _t1030 = logic_pb2.Construct(instruction=instruction376) + _t1028 = _t1030 else: - if prediction215 == 0: - _t766 = self.parse_loop() - loop216 = _t766 - _t767 = logic_pb2.Construct(loop=loop216) - _t765 = _t767 + if prediction374 == 0: + _t1032 = self.parse_loop() + loop375 = _t1032 + _t1033 = logic_pb2.Construct(loop=loop375) + _t1031 = _t1033 else: raise ParseError(f"{'Unexpected token in construct'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t762 = _t765 - return _t762 + _t1028 = _t1031 + result378 = _t1028 + self._record_span(span_start377) + return result378 def parse_loop(self) -> logic_pb2.Loop: + span_start381 = self._span_start() self.consume_literal('(') self.consume_literal('loop') - _t768 = self.parse_init() - init218 = _t768 - _t769 = self.parse_script() - script219 = _t769 - self.consume_literal(')') - _t770 = logic_pb2.Loop(init=init218, body=script219) - return _t770 + self._push_path(1) + _t1034 = self.parse_init() + init379 = _t1034 + self._pop_path() + self._push_path(2) + _t1035 = self.parse_script() + script380 = _t1035 + self._pop_path() + self.consume_literal(')') + _t1036 = logic_pb2.Loop(init=init379, body=script380) + result382 = _t1036 + self._record_span(span_start381) + return result382 def parse_init(self) -> Sequence[logic_pb2.Instruction]: + span_start388 = self._span_start() self.consume_literal('(') self.consume_literal('init') - xs220 = [] - cond221 = self.match_lookahead_literal('(', 0) - while cond221: - _t771 = self.parse_instruction() - item222 = _t771 - xs220.append(item222) - cond221 = self.match_lookahead_literal('(', 0) - instructions223 = xs220 - self.consume_literal(')') - return instructions223 + xs383 = [] + cond384 = self.match_lookahead_literal('(', 0) + idx386 = 0 + while cond384: + self._push_path(idx386) + _t1037 = self.parse_instruction() + item385 = _t1037 + self._pop_path() + xs383.append(item385) + idx386 = (idx386 + 1) + cond384 = self.match_lookahead_literal('(', 0) + instructions387 = xs383 + self.consume_literal(')') + result389 = instructions387 + self._record_span(span_start388) + return result389 def parse_instruction(self) -> logic_pb2.Instruction: + span_start396 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('upsert', 1): - _t773 = 1 + _t1039 = 1 else: if self.match_lookahead_literal('monus', 1): - _t774 = 4 + _t1040 = 4 else: if self.match_lookahead_literal('monoid', 1): - _t775 = 3 + _t1041 = 3 else: if self.match_lookahead_literal('break', 1): - _t776 = 2 + _t1042 = 2 else: if self.match_lookahead_literal('assign', 1): - _t777 = 0 + _t1043 = 0 else: - _t777 = -1 - _t776 = _t777 - _t775 = _t776 - _t774 = _t775 - _t773 = _t774 - _t772 = _t773 - else: - _t772 = -1 - prediction224 = _t772 - - if prediction224 == 4: - _t779 = self.parse_monus_def() - monus_def229 = _t779 - _t780 = logic_pb2.Instruction(monus_def=monus_def229) - _t778 = _t780 + _t1043 = -1 + _t1042 = _t1043 + _t1041 = _t1042 + _t1040 = _t1041 + _t1039 = _t1040 + _t1038 = _t1039 + else: + _t1038 = -1 + prediction390 = _t1038 + + if prediction390 == 4: + _t1045 = self.parse_monus_def() + monus_def395 = _t1045 + _t1046 = logic_pb2.Instruction(monus_def=monus_def395) + _t1044 = _t1046 else: - if prediction224 == 3: - _t782 = self.parse_monoid_def() - monoid_def228 = _t782 - _t783 = logic_pb2.Instruction(monoid_def=monoid_def228) - _t781 = _t783 + if prediction390 == 3: + _t1048 = self.parse_monoid_def() + monoid_def394 = _t1048 + _t1049 = logic_pb2.Instruction(monoid_def=monoid_def394) + _t1047 = _t1049 else: - if prediction224 == 2: - _t785 = self.parse_break() - break227 = _t785 - _t786 = logic_pb2.Instruction() - getattr(_t786, 'break').CopyFrom(break227) - _t784 = _t786 + if prediction390 == 2: + _t1051 = self.parse_break() + break393 = _t1051 + _t1052 = logic_pb2.Instruction() + getattr(_t1052, 'break').CopyFrom(break393) + _t1050 = _t1052 else: - if prediction224 == 1: - _t788 = self.parse_upsert() - upsert226 = _t788 - _t789 = logic_pb2.Instruction(upsert=upsert226) - _t787 = _t789 + if prediction390 == 1: + _t1054 = self.parse_upsert() + upsert392 = _t1054 + _t1055 = logic_pb2.Instruction(upsert=upsert392) + _t1053 = _t1055 else: - if prediction224 == 0: - _t791 = self.parse_assign() - assign225 = _t791 - _t792 = logic_pb2.Instruction(assign=assign225) - _t790 = _t792 + if prediction390 == 0: + _t1057 = self.parse_assign() + assign391 = _t1057 + _t1058 = logic_pb2.Instruction(assign=assign391) + _t1056 = _t1058 else: raise ParseError(f"{'Unexpected token in instruction'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t787 = _t790 - _t784 = _t787 - _t781 = _t784 - _t778 = _t781 - return _t778 + _t1053 = _t1056 + _t1050 = _t1053 + _t1047 = _t1050 + _t1044 = _t1047 + result397 = _t1044 + self._record_span(span_start396) + return result397 def parse_assign(self) -> logic_pb2.Assign: + span_start401 = self._span_start() self.consume_literal('(') self.consume_literal('assign') - _t793 = self.parse_relation_id() - relation_id230 = _t793 - _t794 = self.parse_abstraction() - abstraction231 = _t794 + self._push_path(1) + _t1059 = self.parse_relation_id() + relation_id398 = _t1059 + self._pop_path() + self._push_path(2) + _t1060 = self.parse_abstraction() + abstraction399 = _t1060 + self._pop_path() + self._push_path(3) if self.match_lookahead_literal('(', 0): - _t796 = self.parse_attrs() - _t795 = _t796 + _t1062 = self.parse_attrs() + _t1061 = _t1062 else: - _t795 = None - attrs232 = _t795 + _t1061 = None + attrs400 = _t1061 + self._pop_path() self.consume_literal(')') - _t797 = logic_pb2.Assign(name=relation_id230, body=abstraction231, attrs=(attrs232 if attrs232 is not None else [])) - return _t797 + _t1063 = logic_pb2.Assign(name=relation_id398, body=abstraction399, attrs=(attrs400 if attrs400 is not None else [])) + result402 = _t1063 + self._record_span(span_start401) + return result402 def parse_upsert(self) -> logic_pb2.Upsert: + span_start406 = self._span_start() self.consume_literal('(') self.consume_literal('upsert') - _t798 = self.parse_relation_id() - relation_id233 = _t798 - _t799 = self.parse_abstraction_with_arity() - abstraction_with_arity234 = _t799 + self._push_path(1) + _t1064 = self.parse_relation_id() + relation_id403 = _t1064 + self._pop_path() + _t1065 = self.parse_abstraction_with_arity() + abstraction_with_arity404 = _t1065 + self._push_path(3) if self.match_lookahead_literal('(', 0): - _t801 = self.parse_attrs() - _t800 = _t801 + _t1067 = self.parse_attrs() + _t1066 = _t1067 else: - _t800 = None - attrs235 = _t800 + _t1066 = None + attrs405 = _t1066 + self._pop_path() self.consume_literal(')') - _t802 = logic_pb2.Upsert(name=relation_id233, body=abstraction_with_arity234[0], attrs=(attrs235 if attrs235 is not None else []), value_arity=abstraction_with_arity234[1]) - return _t802 + _t1068 = logic_pb2.Upsert(name=relation_id403, body=abstraction_with_arity404[0], attrs=(attrs405 if attrs405 is not None else []), value_arity=abstraction_with_arity404[1]) + result407 = _t1068 + self._record_span(span_start406) + return result407 def parse_abstraction_with_arity(self) -> tuple[logic_pb2.Abstraction, int]: + span_start410 = self._span_start() self.consume_literal('(') - _t803 = self.parse_bindings() - bindings236 = _t803 - _t804 = self.parse_formula() - formula237 = _t804 + _t1069 = self.parse_bindings() + bindings408 = _t1069 + _t1070 = self.parse_formula() + formula409 = _t1070 self.consume_literal(')') - _t805 = logic_pb2.Abstraction(vars=(list(bindings236[0]) + list(bindings236[1] if bindings236[1] is not None else [])), value=formula237) - return (_t805, len(bindings236[1]),) + _t1071 = logic_pb2.Abstraction(vars=(list(bindings408[0]) + list(bindings408[1] if bindings408[1] is not None else [])), value=formula409) + result411 = (_t1071, len(bindings408[1]),) + self._record_span(span_start410) + return result411 def parse_break(self) -> logic_pb2.Break: + span_start415 = self._span_start() self.consume_literal('(') self.consume_literal('break') - _t806 = self.parse_relation_id() - relation_id238 = _t806 - _t807 = self.parse_abstraction() - abstraction239 = _t807 + self._push_path(1) + _t1072 = self.parse_relation_id() + relation_id412 = _t1072 + self._pop_path() + self._push_path(2) + _t1073 = self.parse_abstraction() + abstraction413 = _t1073 + self._pop_path() + self._push_path(3) if self.match_lookahead_literal('(', 0): - _t809 = self.parse_attrs() - _t808 = _t809 + _t1075 = self.parse_attrs() + _t1074 = _t1075 else: - _t808 = None - attrs240 = _t808 + _t1074 = None + attrs414 = _t1074 + self._pop_path() self.consume_literal(')') - _t810 = logic_pb2.Break(name=relation_id238, body=abstraction239, attrs=(attrs240 if attrs240 is not None else [])) - return _t810 + _t1076 = logic_pb2.Break(name=relation_id412, body=abstraction413, attrs=(attrs414 if attrs414 is not None else [])) + result416 = _t1076 + self._record_span(span_start415) + return result416 def parse_monoid_def(self) -> logic_pb2.MonoidDef: + span_start421 = self._span_start() self.consume_literal('(') self.consume_literal('monoid') - _t811 = self.parse_monoid() - monoid241 = _t811 - _t812 = self.parse_relation_id() - relation_id242 = _t812 - _t813 = self.parse_abstraction_with_arity() - abstraction_with_arity243 = _t813 + self._push_path(1) + _t1077 = self.parse_monoid() + monoid417 = _t1077 + self._pop_path() + self._push_path(2) + _t1078 = self.parse_relation_id() + relation_id418 = _t1078 + self._pop_path() + _t1079 = self.parse_abstraction_with_arity() + abstraction_with_arity419 = _t1079 + self._push_path(4) if self.match_lookahead_literal('(', 0): - _t815 = self.parse_attrs() - _t814 = _t815 + _t1081 = self.parse_attrs() + _t1080 = _t1081 else: - _t814 = None - attrs244 = _t814 + _t1080 = None + attrs420 = _t1080 + self._pop_path() self.consume_literal(')') - _t816 = logic_pb2.MonoidDef(monoid=monoid241, name=relation_id242, body=abstraction_with_arity243[0], attrs=(attrs244 if attrs244 is not None else []), value_arity=abstraction_with_arity243[1]) - return _t816 + _t1082 = logic_pb2.MonoidDef(monoid=monoid417, name=relation_id418, body=abstraction_with_arity419[0], attrs=(attrs420 if attrs420 is not None else []), value_arity=abstraction_with_arity419[1]) + result422 = _t1082 + self._record_span(span_start421) + return result422 def parse_monoid(self) -> logic_pb2.Monoid: + span_start428 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('sum', 1): - _t818 = 3 + _t1084 = 3 else: if self.match_lookahead_literal('or', 1): - _t819 = 0 + _t1085 = 0 else: if self.match_lookahead_literal('min', 1): - _t820 = 1 + _t1086 = 1 else: if self.match_lookahead_literal('max', 1): - _t821 = 2 + _t1087 = 2 else: - _t821 = -1 - _t820 = _t821 - _t819 = _t820 - _t818 = _t819 - _t817 = _t818 + _t1087 = -1 + _t1086 = _t1087 + _t1085 = _t1086 + _t1084 = _t1085 + _t1083 = _t1084 else: - _t817 = -1 - prediction245 = _t817 + _t1083 = -1 + prediction423 = _t1083 - if prediction245 == 3: - _t823 = self.parse_sum_monoid() - sum_monoid249 = _t823 - _t824 = logic_pb2.Monoid(sum_monoid=sum_monoid249) - _t822 = _t824 + if prediction423 == 3: + _t1089 = self.parse_sum_monoid() + sum_monoid427 = _t1089 + _t1090 = logic_pb2.Monoid(sum_monoid=sum_monoid427) + _t1088 = _t1090 else: - if prediction245 == 2: - _t826 = self.parse_max_monoid() - max_monoid248 = _t826 - _t827 = logic_pb2.Monoid(max_monoid=max_monoid248) - _t825 = _t827 + if prediction423 == 2: + _t1092 = self.parse_max_monoid() + max_monoid426 = _t1092 + _t1093 = logic_pb2.Monoid(max_monoid=max_monoid426) + _t1091 = _t1093 else: - if prediction245 == 1: - _t829 = self.parse_min_monoid() - min_monoid247 = _t829 - _t830 = logic_pb2.Monoid(min_monoid=min_monoid247) - _t828 = _t830 + if prediction423 == 1: + _t1095 = self.parse_min_monoid() + min_monoid425 = _t1095 + _t1096 = logic_pb2.Monoid(min_monoid=min_monoid425) + _t1094 = _t1096 else: - if prediction245 == 0: - _t832 = self.parse_or_monoid() - or_monoid246 = _t832 - _t833 = logic_pb2.Monoid(or_monoid=or_monoid246) - _t831 = _t833 + if prediction423 == 0: + _t1098 = self.parse_or_monoid() + or_monoid424 = _t1098 + _t1099 = logic_pb2.Monoid(or_monoid=or_monoid424) + _t1097 = _t1099 else: raise ParseError(f"{'Unexpected token in monoid'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t828 = _t831 - _t825 = _t828 - _t822 = _t825 - return _t822 + _t1094 = _t1097 + _t1091 = _t1094 + _t1088 = _t1091 + result429 = _t1088 + self._record_span(span_start428) + return result429 def parse_or_monoid(self) -> logic_pb2.OrMonoid: + span_start430 = self._span_start() self.consume_literal('(') self.consume_literal('or') self.consume_literal(')') - _t834 = logic_pb2.OrMonoid() - return _t834 + _t1100 = logic_pb2.OrMonoid() + result431 = _t1100 + self._record_span(span_start430) + return result431 def parse_min_monoid(self) -> logic_pb2.MinMonoid: + span_start433 = self._span_start() self.consume_literal('(') self.consume_literal('min') - _t835 = self.parse_type() - type250 = _t835 + self._push_path(1) + _t1101 = self.parse_type() + type432 = _t1101 + self._pop_path() self.consume_literal(')') - _t836 = logic_pb2.MinMonoid(type=type250) - return _t836 + _t1102 = logic_pb2.MinMonoid(type=type432) + result434 = _t1102 + self._record_span(span_start433) + return result434 def parse_max_monoid(self) -> logic_pb2.MaxMonoid: + span_start436 = self._span_start() self.consume_literal('(') self.consume_literal('max') - _t837 = self.parse_type() - type251 = _t837 + self._push_path(1) + _t1103 = self.parse_type() + type435 = _t1103 + self._pop_path() self.consume_literal(')') - _t838 = logic_pb2.MaxMonoid(type=type251) - return _t838 + _t1104 = logic_pb2.MaxMonoid(type=type435) + result437 = _t1104 + self._record_span(span_start436) + return result437 def parse_sum_monoid(self) -> logic_pb2.SumMonoid: + span_start439 = self._span_start() self.consume_literal('(') self.consume_literal('sum') - _t839 = self.parse_type() - type252 = _t839 + self._push_path(1) + _t1105 = self.parse_type() + type438 = _t1105 + self._pop_path() self.consume_literal(')') - _t840 = logic_pb2.SumMonoid(type=type252) - return _t840 + _t1106 = logic_pb2.SumMonoid(type=type438) + result440 = _t1106 + self._record_span(span_start439) + return result440 def parse_monus_def(self) -> logic_pb2.MonusDef: + span_start445 = self._span_start() self.consume_literal('(') self.consume_literal('monus') - _t841 = self.parse_monoid() - monoid253 = _t841 - _t842 = self.parse_relation_id() - relation_id254 = _t842 - _t843 = self.parse_abstraction_with_arity() - abstraction_with_arity255 = _t843 + self._push_path(1) + _t1107 = self.parse_monoid() + monoid441 = _t1107 + self._pop_path() + self._push_path(2) + _t1108 = self.parse_relation_id() + relation_id442 = _t1108 + self._pop_path() + _t1109 = self.parse_abstraction_with_arity() + abstraction_with_arity443 = _t1109 + self._push_path(4) if self.match_lookahead_literal('(', 0): - _t845 = self.parse_attrs() - _t844 = _t845 + _t1111 = self.parse_attrs() + _t1110 = _t1111 else: - _t844 = None - attrs256 = _t844 + _t1110 = None + attrs444 = _t1110 + self._pop_path() self.consume_literal(')') - _t846 = logic_pb2.MonusDef(monoid=monoid253, name=relation_id254, body=abstraction_with_arity255[0], attrs=(attrs256 if attrs256 is not None else []), value_arity=abstraction_with_arity255[1]) - return _t846 + _t1112 = logic_pb2.MonusDef(monoid=monoid441, name=relation_id442, body=abstraction_with_arity443[0], attrs=(attrs444 if attrs444 is not None else []), value_arity=abstraction_with_arity443[1]) + result446 = _t1112 + self._record_span(span_start445) + return result446 def parse_constraint(self) -> logic_pb2.Constraint: + span_start451 = self._span_start() self.consume_literal('(') self.consume_literal('functional_dependency') - _t847 = self.parse_relation_id() - relation_id257 = _t847 - _t848 = self.parse_abstraction() - abstraction258 = _t848 - _t849 = self.parse_functional_dependency_keys() - functional_dependency_keys259 = _t849 - _t850 = self.parse_functional_dependency_values() - functional_dependency_values260 = _t850 - self.consume_literal(')') - _t851 = logic_pb2.FunctionalDependency(guard=abstraction258, keys=functional_dependency_keys259, values=functional_dependency_values260) - _t852 = logic_pb2.Constraint(name=relation_id257, functional_dependency=_t851) - return _t852 + self._push_path(2) + _t1113 = self.parse_relation_id() + relation_id447 = _t1113 + self._pop_path() + _t1114 = self.parse_abstraction() + abstraction448 = _t1114 + _t1115 = self.parse_functional_dependency_keys() + functional_dependency_keys449 = _t1115 + _t1116 = self.parse_functional_dependency_values() + functional_dependency_values450 = _t1116 + self.consume_literal(')') + _t1117 = logic_pb2.FunctionalDependency(guard=abstraction448, keys=functional_dependency_keys449, values=functional_dependency_values450) + _t1118 = logic_pb2.Constraint(name=relation_id447, functional_dependency=_t1117) + result452 = _t1118 + self._record_span(span_start451) + return result452 def parse_functional_dependency_keys(self) -> Sequence[logic_pb2.Var]: + span_start458 = self._span_start() self.consume_literal('(') self.consume_literal('keys') - xs261 = [] - cond262 = self.match_lookahead_terminal('SYMBOL', 0) - while cond262: - _t853 = self.parse_var() - item263 = _t853 - xs261.append(item263) - cond262 = self.match_lookahead_terminal('SYMBOL', 0) - vars264 = xs261 - self.consume_literal(')') - return vars264 + xs453 = [] + cond454 = self.match_lookahead_terminal('SYMBOL', 0) + idx456 = 0 + while cond454: + self._push_path(idx456) + _t1119 = self.parse_var() + item455 = _t1119 + self._pop_path() + xs453.append(item455) + idx456 = (idx456 + 1) + cond454 = self.match_lookahead_terminal('SYMBOL', 0) + vars457 = xs453 + self.consume_literal(')') + result459 = vars457 + self._record_span(span_start458) + return result459 def parse_functional_dependency_values(self) -> Sequence[logic_pb2.Var]: + span_start465 = self._span_start() self.consume_literal('(') self.consume_literal('values') - xs265 = [] - cond266 = self.match_lookahead_terminal('SYMBOL', 0) - while cond266: - _t854 = self.parse_var() - item267 = _t854 - xs265.append(item267) - cond266 = self.match_lookahead_terminal('SYMBOL', 0) - vars268 = xs265 - self.consume_literal(')') - return vars268 + xs460 = [] + cond461 = self.match_lookahead_terminal('SYMBOL', 0) + idx463 = 0 + while cond461: + self._push_path(idx463) + _t1120 = self.parse_var() + item462 = _t1120 + self._pop_path() + xs460.append(item462) + idx463 = (idx463 + 1) + cond461 = self.match_lookahead_terminal('SYMBOL', 0) + vars464 = xs460 + self.consume_literal(')') + result466 = vars464 + self._record_span(span_start465) + return result466 def parse_data(self) -> logic_pb2.Data: + span_start471 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('rel_edb', 1): - _t856 = 0 + _t1122 = 0 else: if self.match_lookahead_literal('csv_data', 1): - _t857 = 2 + _t1123 = 2 else: if self.match_lookahead_literal('betree_relation', 1): - _t858 = 1 + _t1124 = 1 else: - _t858 = -1 - _t857 = _t858 - _t856 = _t857 - _t855 = _t856 + _t1124 = -1 + _t1123 = _t1124 + _t1122 = _t1123 + _t1121 = _t1122 else: - _t855 = -1 - prediction269 = _t855 + _t1121 = -1 + prediction467 = _t1121 - if prediction269 == 2: - _t860 = self.parse_csv_data() - csv_data272 = _t860 - _t861 = logic_pb2.Data(csv_data=csv_data272) - _t859 = _t861 + if prediction467 == 2: + _t1126 = self.parse_csv_data() + csv_data470 = _t1126 + _t1127 = logic_pb2.Data(csv_data=csv_data470) + _t1125 = _t1127 else: - if prediction269 == 1: - _t863 = self.parse_betree_relation() - betree_relation271 = _t863 - _t864 = logic_pb2.Data(betree_relation=betree_relation271) - _t862 = _t864 + if prediction467 == 1: + _t1129 = self.parse_betree_relation() + betree_relation469 = _t1129 + _t1130 = logic_pb2.Data(betree_relation=betree_relation469) + _t1128 = _t1130 else: - if prediction269 == 0: - _t866 = self.parse_rel_edb() - rel_edb270 = _t866 - _t867 = logic_pb2.Data(rel_edb=rel_edb270) - _t865 = _t867 + if prediction467 == 0: + _t1132 = self.parse_rel_edb() + rel_edb468 = _t1132 + _t1133 = logic_pb2.Data(rel_edb=rel_edb468) + _t1131 = _t1133 else: raise ParseError(f"{'Unexpected token in data'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t862 = _t865 - _t859 = _t862 - return _t859 + _t1128 = _t1131 + _t1125 = _t1128 + result472 = _t1125 + self._record_span(span_start471) + return result472 def parse_rel_edb(self) -> logic_pb2.RelEDB: + span_start476 = self._span_start() self.consume_literal('(') self.consume_literal('rel_edb') - _t868 = self.parse_relation_id() - relation_id273 = _t868 - _t869 = self.parse_rel_edb_path() - rel_edb_path274 = _t869 - _t870 = self.parse_rel_edb_types() - rel_edb_types275 = _t870 - self.consume_literal(')') - _t871 = logic_pb2.RelEDB(target_id=relation_id273, path=rel_edb_path274, types=rel_edb_types275) - return _t871 + self._push_path(1) + _t1134 = self.parse_relation_id() + relation_id473 = _t1134 + self._pop_path() + self._push_path(2) + _t1135 = self.parse_rel_edb_path() + rel_edb_path474 = _t1135 + self._pop_path() + self._push_path(3) + _t1136 = self.parse_rel_edb_types() + rel_edb_types475 = _t1136 + self._pop_path() + self.consume_literal(')') + _t1137 = logic_pb2.RelEDB(target_id=relation_id473, path=rel_edb_path474, types=rel_edb_types475) + result477 = _t1137 + self._record_span(span_start476) + return result477 def parse_rel_edb_path(self) -> Sequence[str]: + span_start483 = self._span_start() self.consume_literal('[') - xs276 = [] - cond277 = self.match_lookahead_terminal('STRING', 0) - while cond277: - item278 = self.consume_terminal('STRING') - xs276.append(item278) - cond277 = self.match_lookahead_terminal('STRING', 0) - strings279 = xs276 + xs478 = [] + cond479 = self.match_lookahead_terminal('STRING', 0) + idx481 = 0 + while cond479: + self._push_path(idx481) + item480 = self.consume_terminal('STRING') + self._pop_path() + xs478.append(item480) + idx481 = (idx481 + 1) + cond479 = self.match_lookahead_terminal('STRING', 0) + strings482 = xs478 self.consume_literal(']') - return strings279 + result484 = strings482 + self._record_span(span_start483) + return result484 def parse_rel_edb_types(self) -> Sequence[logic_pb2.Type]: + span_start490 = self._span_start() self.consume_literal('[') - xs280 = [] - cond281 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - while cond281: - _t872 = self.parse_type() - item282 = _t872 - xs280.append(item282) - cond281 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - types283 = xs280 + xs485 = [] + cond486 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + idx488 = 0 + while cond486: + self._push_path(idx488) + _t1138 = self.parse_type() + item487 = _t1138 + self._pop_path() + xs485.append(item487) + idx488 = (idx488 + 1) + cond486 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + types489 = xs485 self.consume_literal(']') - return types283 + result491 = types489 + self._record_span(span_start490) + return result491 def parse_betree_relation(self) -> logic_pb2.BeTreeRelation: + span_start494 = self._span_start() self.consume_literal('(') self.consume_literal('betree_relation') - _t873 = self.parse_relation_id() - relation_id284 = _t873 - _t874 = self.parse_betree_info() - betree_info285 = _t874 - self.consume_literal(')') - _t875 = logic_pb2.BeTreeRelation(name=relation_id284, relation_info=betree_info285) - return _t875 + self._push_path(1) + _t1139 = self.parse_relation_id() + relation_id492 = _t1139 + self._pop_path() + self._push_path(2) + _t1140 = self.parse_betree_info() + betree_info493 = _t1140 + self._pop_path() + self.consume_literal(')') + _t1141 = logic_pb2.BeTreeRelation(name=relation_id492, relation_info=betree_info493) + result495 = _t1141 + self._record_span(span_start494) + return result495 def parse_betree_info(self) -> logic_pb2.BeTreeInfo: + span_start499 = self._span_start() self.consume_literal('(') self.consume_literal('betree_info') - _t876 = self.parse_betree_info_key_types() - betree_info_key_types286 = _t876 - _t877 = self.parse_betree_info_value_types() - betree_info_value_types287 = _t877 - _t878 = self.parse_config_dict() - config_dict288 = _t878 - self.consume_literal(')') - _t879 = self.construct_betree_info(betree_info_key_types286, betree_info_value_types287, config_dict288) - return _t879 + _t1142 = self.parse_betree_info_key_types() + betree_info_key_types496 = _t1142 + _t1143 = self.parse_betree_info_value_types() + betree_info_value_types497 = _t1143 + _t1144 = self.parse_config_dict() + config_dict498 = _t1144 + self.consume_literal(')') + _t1145 = self.construct_betree_info(betree_info_key_types496, betree_info_value_types497, config_dict498) + result500 = _t1145 + self._record_span(span_start499) + return result500 def parse_betree_info_key_types(self) -> Sequence[logic_pb2.Type]: + span_start506 = self._span_start() self.consume_literal('(') self.consume_literal('key_types') - xs289 = [] - cond290 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - while cond290: - _t880 = self.parse_type() - item291 = _t880 - xs289.append(item291) - cond290 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - types292 = xs289 - self.consume_literal(')') - return types292 + xs501 = [] + cond502 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + idx504 = 0 + while cond502: + self._push_path(idx504) + _t1146 = self.parse_type() + item503 = _t1146 + self._pop_path() + xs501.append(item503) + idx504 = (idx504 + 1) + cond502 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + types505 = xs501 + self.consume_literal(')') + result507 = types505 + self._record_span(span_start506) + return result507 def parse_betree_info_value_types(self) -> Sequence[logic_pb2.Type]: + span_start513 = self._span_start() self.consume_literal('(') self.consume_literal('value_types') - xs293 = [] - cond294 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - while cond294: - _t881 = self.parse_type() - item295 = _t881 - xs293.append(item295) - cond294 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - types296 = xs293 - self.consume_literal(')') - return types296 + xs508 = [] + cond509 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + idx511 = 0 + while cond509: + self._push_path(idx511) + _t1147 = self.parse_type() + item510 = _t1147 + self._pop_path() + xs508.append(item510) + idx511 = (idx511 + 1) + cond509 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + types512 = xs508 + self.consume_literal(')') + result514 = types512 + self._record_span(span_start513) + return result514 def parse_csv_data(self) -> logic_pb2.CSVData: + span_start519 = self._span_start() self.consume_literal('(') self.consume_literal('csv_data') - _t882 = self.parse_csvlocator() - csvlocator297 = _t882 - _t883 = self.parse_csv_config() - csv_config298 = _t883 - _t884 = self.parse_csv_columns() - csv_columns299 = _t884 - _t885 = self.parse_csv_asof() - csv_asof300 = _t885 - self.consume_literal(')') - _t886 = logic_pb2.CSVData(locator=csvlocator297, config=csv_config298, columns=csv_columns299, asof=csv_asof300) - return _t886 + self._push_path(1) + _t1148 = self.parse_csvlocator() + csvlocator515 = _t1148 + self._pop_path() + self._push_path(2) + _t1149 = self.parse_csv_config() + csv_config516 = _t1149 + self._pop_path() + self._push_path(3) + _t1150 = self.parse_csv_columns() + csv_columns517 = _t1150 + self._pop_path() + self._push_path(4) + _t1151 = self.parse_csv_asof() + csv_asof518 = _t1151 + self._pop_path() + self.consume_literal(')') + _t1152 = logic_pb2.CSVData(locator=csvlocator515, config=csv_config516, columns=csv_columns517, asof=csv_asof518) + result520 = _t1152 + self._record_span(span_start519) + return result520 def parse_csvlocator(self) -> logic_pb2.CSVLocator: + span_start523 = self._span_start() self.consume_literal('(') self.consume_literal('csv_locator') + self._push_path(1) if (self.match_lookahead_literal('(', 0) and self.match_lookahead_literal('paths', 1)): - _t888 = self.parse_csv_locator_paths() - _t887 = _t888 + _t1154 = self.parse_csv_locator_paths() + _t1153 = _t1154 else: - _t887 = None - csv_locator_paths301 = _t887 + _t1153 = None + csv_locator_paths521 = _t1153 + self._pop_path() if self.match_lookahead_literal('(', 0): - _t890 = self.parse_csv_locator_inline_data() - _t889 = _t890 + _t1156 = self.parse_csv_locator_inline_data() + _t1155 = _t1156 else: - _t889 = None - csv_locator_inline_data302 = _t889 + _t1155 = None + csv_locator_inline_data522 = _t1155 self.consume_literal(')') - _t891 = logic_pb2.CSVLocator(paths=(csv_locator_paths301 if csv_locator_paths301 is not None else []), inline_data=(csv_locator_inline_data302 if csv_locator_inline_data302 is not None else '').encode()) - return _t891 + _t1157 = logic_pb2.CSVLocator(paths=(csv_locator_paths521 if csv_locator_paths521 is not None else []), inline_data=(csv_locator_inline_data522 if csv_locator_inline_data522 is not None else '').encode()) + result524 = _t1157 + self._record_span(span_start523) + return result524 def parse_csv_locator_paths(self) -> Sequence[str]: + span_start530 = self._span_start() self.consume_literal('(') self.consume_literal('paths') - xs303 = [] - cond304 = self.match_lookahead_terminal('STRING', 0) - while cond304: - item305 = self.consume_terminal('STRING') - xs303.append(item305) - cond304 = self.match_lookahead_terminal('STRING', 0) - strings306 = xs303 - self.consume_literal(')') - return strings306 + xs525 = [] + cond526 = self.match_lookahead_terminal('STRING', 0) + idx528 = 0 + while cond526: + self._push_path(idx528) + item527 = self.consume_terminal('STRING') + self._pop_path() + xs525.append(item527) + idx528 = (idx528 + 1) + cond526 = self.match_lookahead_terminal('STRING', 0) + strings529 = xs525 + self.consume_literal(')') + result531 = strings529 + self._record_span(span_start530) + return result531 def parse_csv_locator_inline_data(self) -> str: + span_start533 = self._span_start() self.consume_literal('(') self.consume_literal('inline_data') - string307 = self.consume_terminal('STRING') + string532 = self.consume_terminal('STRING') self.consume_literal(')') - return string307 + result534 = string532 + self._record_span(span_start533) + return result534 def parse_csv_config(self) -> logic_pb2.CSVConfig: + span_start536 = self._span_start() self.consume_literal('(') self.consume_literal('csv_config') - _t892 = self.parse_config_dict() - config_dict308 = _t892 + _t1158 = self.parse_config_dict() + config_dict535 = _t1158 self.consume_literal(')') - _t893 = self.construct_csv_config(config_dict308) - return _t893 + _t1159 = self.construct_csv_config(config_dict535) + result537 = _t1159 + self._record_span(span_start536) + return result537 def parse_csv_columns(self) -> Sequence[logic_pb2.CSVColumn]: + span_start543 = self._span_start() self.consume_literal('(') self.consume_literal('columns') - xs309 = [] - cond310 = self.match_lookahead_literal('(', 0) - while cond310: - _t894 = self.parse_csv_column() - item311 = _t894 - xs309.append(item311) - cond310 = self.match_lookahead_literal('(', 0) - csv_columns312 = xs309 - self.consume_literal(')') - return csv_columns312 + xs538 = [] + cond539 = self.match_lookahead_literal('(', 0) + idx541 = 0 + while cond539: + self._push_path(idx541) + _t1160 = self.parse_csv_column() + item540 = _t1160 + self._pop_path() + xs538.append(item540) + idx541 = (idx541 + 1) + cond539 = self.match_lookahead_literal('(', 0) + csv_columns542 = xs538 + self.consume_literal(')') + result544 = csv_columns542 + self._record_span(span_start543) + return result544 def parse_csv_column(self) -> logic_pb2.CSVColumn: + span_start552 = self._span_start() self.consume_literal('(') self.consume_literal('column') - string313 = self.consume_terminal('STRING') - _t895 = self.parse_relation_id() - relation_id314 = _t895 + self._push_path(1) + string545 = self.consume_terminal('STRING') + self._pop_path() + self._push_path(2) + _t1161 = self.parse_relation_id() + relation_id546 = _t1161 + self._pop_path() self.consume_literal('[') - xs315 = [] - cond316 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - while cond316: - _t896 = self.parse_type() - item317 = _t896 - xs315.append(item317) - cond316 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) - types318 = xs315 + self._push_path(3) + xs547 = [] + cond548 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + idx550 = 0 + while cond548: + self._push_path(idx550) + _t1162 = self.parse_type() + item549 = _t1162 + self._pop_path() + xs547.append(item549) + idx550 = (idx550 + 1) + cond548 = ((((((((((self.match_lookahead_literal('(', 0) or self.match_lookahead_literal('BOOLEAN', 0)) or self.match_lookahead_literal('DATE', 0)) or self.match_lookahead_literal('DATETIME', 0)) or self.match_lookahead_literal('FLOAT', 0)) or self.match_lookahead_literal('INT', 0)) or self.match_lookahead_literal('INT128', 0)) or self.match_lookahead_literal('MISSING', 0)) or self.match_lookahead_literal('STRING', 0)) or self.match_lookahead_literal('UINT128', 0)) or self.match_lookahead_literal('UNKNOWN', 0)) + self._pop_path() + types551 = xs547 self.consume_literal(']') self.consume_literal(')') - _t897 = logic_pb2.CSVColumn(column_name=string313, target_id=relation_id314, types=types318) - return _t897 + _t1163 = logic_pb2.CSVColumn(column_name=string545, target_id=relation_id546, types=types551) + result553 = _t1163 + self._record_span(span_start552) + return result553 def parse_csv_asof(self) -> str: + span_start555 = self._span_start() self.consume_literal('(') self.consume_literal('asof') - string319 = self.consume_terminal('STRING') + string554 = self.consume_terminal('STRING') self.consume_literal(')') - return string319 + result556 = string554 + self._record_span(span_start555) + return result556 def parse_undefine(self) -> transactions_pb2.Undefine: + span_start558 = self._span_start() self.consume_literal('(') self.consume_literal('undefine') - _t898 = self.parse_fragment_id() - fragment_id320 = _t898 + self._push_path(1) + _t1164 = self.parse_fragment_id() + fragment_id557 = _t1164 + self._pop_path() self.consume_literal(')') - _t899 = transactions_pb2.Undefine(fragment_id=fragment_id320) - return _t899 + _t1165 = transactions_pb2.Undefine(fragment_id=fragment_id557) + result559 = _t1165 + self._record_span(span_start558) + return result559 def parse_context(self) -> transactions_pb2.Context: + span_start565 = self._span_start() self.consume_literal('(') self.consume_literal('context') - xs321 = [] - cond322 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) - while cond322: - _t900 = self.parse_relation_id() - item323 = _t900 - xs321.append(item323) - cond322 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) - relation_ids324 = xs321 - self.consume_literal(')') - _t901 = transactions_pb2.Context(relations=relation_ids324) - return _t901 + self._push_path(1) + xs560 = [] + cond561 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) + idx563 = 0 + while cond561: + self._push_path(idx563) + _t1166 = self.parse_relation_id() + item562 = _t1166 + self._pop_path() + xs560.append(item562) + idx563 = (idx563 + 1) + cond561 = (self.match_lookahead_literal(':', 0) or self.match_lookahead_terminal('UINT128', 0)) + self._pop_path() + relation_ids564 = xs560 + self.consume_literal(')') + _t1167 = transactions_pb2.Context(relations=relation_ids564) + result566 = _t1167 + self._record_span(span_start565) + return result566 def parse_epoch_reads(self) -> Sequence[transactions_pb2.Read]: + span_start572 = self._span_start() self.consume_literal('(') self.consume_literal('reads') - xs325 = [] - cond326 = self.match_lookahead_literal('(', 0) - while cond326: - _t902 = self.parse_read() - item327 = _t902 - xs325.append(item327) - cond326 = self.match_lookahead_literal('(', 0) - reads328 = xs325 - self.consume_literal(')') - return reads328 + xs567 = [] + cond568 = self.match_lookahead_literal('(', 0) + idx570 = 0 + while cond568: + self._push_path(idx570) + _t1168 = self.parse_read() + item569 = _t1168 + self._pop_path() + xs567.append(item569) + idx570 = (idx570 + 1) + cond568 = self.match_lookahead_literal('(', 0) + reads571 = xs567 + self.consume_literal(')') + result573 = reads571 + self._record_span(span_start572) + return result573 def parse_read(self) -> transactions_pb2.Read: + span_start580 = self._span_start() if self.match_lookahead_literal('(', 0): if self.match_lookahead_literal('what_if', 1): - _t904 = 2 + _t1170 = 2 else: if self.match_lookahead_literal('output', 1): - _t905 = 1 + _t1171 = 1 else: if self.match_lookahead_literal('export', 1): - _t906 = 4 + _t1172 = 4 else: if self.match_lookahead_literal('demand', 1): - _t907 = 0 + _t1173 = 0 else: if self.match_lookahead_literal('abort', 1): - _t908 = 3 + _t1174 = 3 else: - _t908 = -1 - _t907 = _t908 - _t906 = _t907 - _t905 = _t906 - _t904 = _t905 - _t903 = _t904 - else: - _t903 = -1 - prediction329 = _t903 - - if prediction329 == 4: - _t910 = self.parse_export() - export334 = _t910 - _t911 = transactions_pb2.Read(export=export334) - _t909 = _t911 + _t1174 = -1 + _t1173 = _t1174 + _t1172 = _t1173 + _t1171 = _t1172 + _t1170 = _t1171 + _t1169 = _t1170 + else: + _t1169 = -1 + prediction574 = _t1169 + + if prediction574 == 4: + _t1176 = self.parse_export() + export579 = _t1176 + _t1177 = transactions_pb2.Read(export=export579) + _t1175 = _t1177 else: - if prediction329 == 3: - _t913 = self.parse_abort() - abort333 = _t913 - _t914 = transactions_pb2.Read(abort=abort333) - _t912 = _t914 + if prediction574 == 3: + _t1179 = self.parse_abort() + abort578 = _t1179 + _t1180 = transactions_pb2.Read(abort=abort578) + _t1178 = _t1180 else: - if prediction329 == 2: - _t916 = self.parse_what_if() - what_if332 = _t916 - _t917 = transactions_pb2.Read(what_if=what_if332) - _t915 = _t917 + if prediction574 == 2: + _t1182 = self.parse_what_if() + what_if577 = _t1182 + _t1183 = transactions_pb2.Read(what_if=what_if577) + _t1181 = _t1183 else: - if prediction329 == 1: - _t919 = self.parse_output() - output331 = _t919 - _t920 = transactions_pb2.Read(output=output331) - _t918 = _t920 + if prediction574 == 1: + _t1185 = self.parse_output() + output576 = _t1185 + _t1186 = transactions_pb2.Read(output=output576) + _t1184 = _t1186 else: - if prediction329 == 0: - _t922 = self.parse_demand() - demand330 = _t922 - _t923 = transactions_pb2.Read(demand=demand330) - _t921 = _t923 + if prediction574 == 0: + _t1188 = self.parse_demand() + demand575 = _t1188 + _t1189 = transactions_pb2.Read(demand=demand575) + _t1187 = _t1189 else: raise ParseError(f"{'Unexpected token in read'}: {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t918 = _t921 - _t915 = _t918 - _t912 = _t915 - _t909 = _t912 - return _t909 + _t1184 = _t1187 + _t1181 = _t1184 + _t1178 = _t1181 + _t1175 = _t1178 + result581 = _t1175 + self._record_span(span_start580) + return result581 def parse_demand(self) -> transactions_pb2.Demand: + span_start583 = self._span_start() self.consume_literal('(') self.consume_literal('demand') - _t924 = self.parse_relation_id() - relation_id335 = _t924 + self._push_path(1) + _t1190 = self.parse_relation_id() + relation_id582 = _t1190 + self._pop_path() self.consume_literal(')') - _t925 = transactions_pb2.Demand(relation_id=relation_id335) - return _t925 + _t1191 = transactions_pb2.Demand(relation_id=relation_id582) + result584 = _t1191 + self._record_span(span_start583) + return result584 def parse_output(self) -> transactions_pb2.Output: + span_start587 = self._span_start() self.consume_literal('(') self.consume_literal('output') - _t926 = self.parse_name() - name336 = _t926 - _t927 = self.parse_relation_id() - relation_id337 = _t927 - self.consume_literal(')') - _t928 = transactions_pb2.Output(name=name336, relation_id=relation_id337) - return _t928 + self._push_path(1) + _t1192 = self.parse_name() + name585 = _t1192 + self._pop_path() + self._push_path(2) + _t1193 = self.parse_relation_id() + relation_id586 = _t1193 + self._pop_path() + self.consume_literal(')') + _t1194 = transactions_pb2.Output(name=name585, relation_id=relation_id586) + result588 = _t1194 + self._record_span(span_start587) + return result588 def parse_what_if(self) -> transactions_pb2.WhatIf: + span_start591 = self._span_start() self.consume_literal('(') self.consume_literal('what_if') - _t929 = self.parse_name() - name338 = _t929 - _t930 = self.parse_epoch() - epoch339 = _t930 - self.consume_literal(')') - _t931 = transactions_pb2.WhatIf(branch=name338, epoch=epoch339) - return _t931 + self._push_path(1) + _t1195 = self.parse_name() + name589 = _t1195 + self._pop_path() + self._push_path(2) + _t1196 = self.parse_epoch() + epoch590 = _t1196 + self._pop_path() + self.consume_literal(')') + _t1197 = transactions_pb2.WhatIf(branch=name589, epoch=epoch590) + result592 = _t1197 + self._record_span(span_start591) + return result592 def parse_abort(self) -> transactions_pb2.Abort: + span_start595 = self._span_start() self.consume_literal('(') self.consume_literal('abort') + self._push_path(1) if (self.match_lookahead_literal(':', 0) and self.match_lookahead_terminal('SYMBOL', 1)): - _t933 = self.parse_name() - _t932 = _t933 - else: - _t932 = None - name340 = _t932 - _t934 = self.parse_relation_id() - relation_id341 = _t934 - self.consume_literal(')') - _t935 = transactions_pb2.Abort(name=(name340 if name340 is not None else 'abort'), relation_id=relation_id341) - return _t935 + _t1199 = self.parse_name() + _t1198 = _t1199 + else: + _t1198 = None + name593 = _t1198 + self._pop_path() + self._push_path(2) + _t1200 = self.parse_relation_id() + relation_id594 = _t1200 + self._pop_path() + self.consume_literal(')') + _t1201 = transactions_pb2.Abort(name=(name593 if name593 is not None else 'abort'), relation_id=relation_id594) + result596 = _t1201 + self._record_span(span_start595) + return result596 def parse_export(self) -> transactions_pb2.Export: + span_start598 = self._span_start() self.consume_literal('(') self.consume_literal('export') - _t936 = self.parse_export_csv_config() - export_csv_config342 = _t936 + self._push_path(1) + _t1202 = self.parse_export_csv_config() + export_csv_config597 = _t1202 + self._pop_path() self.consume_literal(')') - _t937 = transactions_pb2.Export(csv_config=export_csv_config342) - return _t937 + _t1203 = transactions_pb2.Export(csv_config=export_csv_config597) + result599 = _t1203 + self._record_span(span_start598) + return result599 def parse_export_csv_config(self) -> transactions_pb2.ExportCSVConfig: + span_start603 = self._span_start() self.consume_literal('(') self.consume_literal('export_csv_config') - _t938 = self.parse_export_csv_path() - export_csv_path343 = _t938 - _t939 = self.parse_export_csv_columns() - export_csv_columns344 = _t939 - _t940 = self.parse_config_dict() - config_dict345 = _t940 - self.consume_literal(')') - _t941 = self.export_csv_config(export_csv_path343, export_csv_columns344, config_dict345) - return _t941 + _t1204 = self.parse_export_csv_path() + export_csv_path600 = _t1204 + _t1205 = self.parse_export_csv_columns() + export_csv_columns601 = _t1205 + _t1206 = self.parse_config_dict() + config_dict602 = _t1206 + self.consume_literal(')') + _t1207 = self.export_csv_config(export_csv_path600, export_csv_columns601, config_dict602) + result604 = _t1207 + self._record_span(span_start603) + return result604 def parse_export_csv_path(self) -> str: + span_start606 = self._span_start() self.consume_literal('(') self.consume_literal('path') - string346 = self.consume_terminal('STRING') + string605 = self.consume_terminal('STRING') self.consume_literal(')') - return string346 + result607 = string605 + self._record_span(span_start606) + return result607 def parse_export_csv_columns(self) -> Sequence[transactions_pb2.ExportCSVColumn]: + span_start613 = self._span_start() self.consume_literal('(') self.consume_literal('columns') - xs347 = [] - cond348 = self.match_lookahead_literal('(', 0) - while cond348: - _t942 = self.parse_export_csv_column() - item349 = _t942 - xs347.append(item349) - cond348 = self.match_lookahead_literal('(', 0) - export_csv_columns350 = xs347 - self.consume_literal(')') - return export_csv_columns350 + xs608 = [] + cond609 = self.match_lookahead_literal('(', 0) + idx611 = 0 + while cond609: + self._push_path(idx611) + _t1208 = self.parse_export_csv_column() + item610 = _t1208 + self._pop_path() + xs608.append(item610) + idx611 = (idx611 + 1) + cond609 = self.match_lookahead_literal('(', 0) + export_csv_columns612 = xs608 + self.consume_literal(')') + result614 = export_csv_columns612 + self._record_span(span_start613) + return result614 def parse_export_csv_column(self) -> transactions_pb2.ExportCSVColumn: + span_start617 = self._span_start() self.consume_literal('(') self.consume_literal('column') - string351 = self.consume_terminal('STRING') - _t943 = self.parse_relation_id() - relation_id352 = _t943 - self.consume_literal(')') - _t944 = transactions_pb2.ExportCSVColumn(column_name=string351, column_data=relation_id352) - return _t944 - - -def parse(input_str: str) -> Any: - """Parse input string and return parse tree.""" + self._push_path(1) + string615 = self.consume_terminal('STRING') + self._pop_path() + self._push_path(2) + _t1209 = self.parse_relation_id() + relation_id616 = _t1209 + self._pop_path() + self.consume_literal(')') + _t1210 = transactions_pb2.ExportCSVColumn(column_name=string615, column_data=relation_id616) + result618 = _t1210 + self._record_span(span_start617) + return result618 + + +def parse(input_str: str) -> Tuple[Any, Dict[Tuple[int, ...], Span]]: + """Parse input string and return (parse tree, provenance map).""" lexer = Lexer(input_str) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input_str) result = parser.parse_transaction() # Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens): remaining_token = parser.lookahead(0) if remaining_token.type != '$': raise ParseError(f"Unexpected token at end of input: {remaining_token}") - return result + return result, parser.provenance diff --git a/python-tools/src/lqp/proto_validator.py b/python-tools/src/lqp/proto_validator.py index 8b5cd7bd..c331f53e 100644 --- a/python-tools/src/lqp/proto_validator.py +++ b/python-tools/src/lqp/proto_validator.py @@ -203,11 +203,36 @@ def unwrap_data(data: logic_pb2.Data) -> Optional[Message]: "Data": unwrap_data, } +_WRAPPER_ONEOF_NAMES = { + "Declaration": "declaration_type", + "Instruction": "instr_type", + "Formula": "formula_type", + "Construct": "construct_type", + "Write": "write_type", + "Read": "read_type", + "Constraint": "constraint_type", + "Data": "data_type", +} + class ProtoVisitor: - def __init__(self): + def __init__(self, provenance=None): self.original_names: Dict[Tuple[int, int], str] = {} self._visit_cache: Dict[str, Any] = {} + self.provenance = provenance or {} + self._path: List[int] = [] + + def _format_location(self, msg: str) -> str: + path = tuple(self._path) + while path: + span = self.provenance.get(path) + if span is not None: + return f"{msg} at :{span.start.line}:{span.start.column}" + path = path[:-1] + span = self.provenance.get(()) + if span is not None: + return f"{msg} at :{span.start.line}:{span.start.column}" + return msg def get_original_name(self, rid: logic_pb2.RelationId) -> str: key = relation_id_key(rid) @@ -231,7 +256,14 @@ def visit(self, node: Message, *args: Any) -> None: if unwrapper is not None: inner = unwrapper(cast(Any, node)) if inner is not None: + oneof_name = _WRAPPER_ONEOF_NAMES[type_name] + which = node.WhichOneof(oneof_name) + assert which is not None + descriptor = cast(Descriptor, node.DESCRIPTOR) + field_desc = descriptor.fields_by_name[which] + self._path.append(field_desc.number) self.visit(inner, *args) + self._path.pop() return return self._resolve_visitor(type_name)(node, *args) @@ -241,19 +273,25 @@ def generic_visit(self, node: Message, *args: Any) -> None: for field_desc in descriptor.fields: value = getattr(node, field_desc.name) if field_desc.label == FieldDescriptor.LABEL_REPEATED: - for item in value: + self._path.append(field_desc.number) + for i, item in enumerate(value): if isinstance(item, Message): + self._path.append(i) self.visit(item, *args) + self._path.pop() + self._path.pop() elif field_desc.message_type is not None and node.HasField(field_desc.name): if isinstance(value, Message): + self._path.append(field_desc.number) self.visit(value, *args) + self._path.pop() # --- Validation visitors --- class UnusedVariableVisitor(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.scopes: List[Tuple[Set[str], Set[str]]] = [] self.visit(txn) @@ -266,7 +304,7 @@ def _mark_var_used(self, var_name: str): if var_name in declared: used.add(var_name) return - raise ValidationError(f"Undeclared variable used: '{var_name}'") + raise ValidationError(self._format_location(f"Undeclared variable used: '{var_name}'")) def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): self.scopes.append((set(), set())) @@ -279,7 +317,7 @@ def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): for var_name in unused: if var_name.startswith("_"): continue - raise ValidationError(f"Unused variable declared: '{var_name}'") + raise ValidationError(self._format_location(f"Unused variable declared: '{var_name}'")) def visit_Var(self, node: logic_pb2.Var, *args: Any): self._mark_var_used(node.name) @@ -289,8 +327,8 @@ def visit_FunctionalDependency(self, node: logic_pb2.FunctionalDependency, *args class ShadowedVariableFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.visit(txn) def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): @@ -298,14 +336,14 @@ def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): for binding in node.vars: name = binding.var.name if name in in_scope_names: - raise ValidationError(f"Shadowed variable: '{name}'") + raise ValidationError(self._format_location(f"Shadowed variable: '{name}'")) new_scope = in_scope_names | {b.var.name for b in node.vars} self.visit(node.value, new_scope) class DuplicateRelationIdFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.seen_ids: Dict[Tuple[int, int], Tuple[int, Optional[bytes]]] = {} self.curr_epoch: int = 0 self.curr_fragment: Optional[bytes] = None @@ -320,14 +358,14 @@ def _check_relation_id(self, rid: logic_pb2.RelationId): seen_epoch, seen_frag = self.seen_ids[key] if self.curr_fragment != seen_frag: original_name = self.get_original_name(rid) - raise ValidationError( + raise ValidationError(self._format_location( f"Duplicate declaration across fragments: '{original_name}'" - ) + )) elif self.curr_epoch == seen_epoch: original_name = self.get_original_name(rid) - raise ValidationError( + raise ValidationError(self._format_location( f"Duplicate declaration within fragment in epoch: '{original_name}'" - ) + )) self.seen_ids[key] = (self.curr_epoch, self.curr_fragment) def visit_Fragment(self, node: fragments_pb2.Fragment, *args: Any): @@ -344,16 +382,16 @@ def visit_Algorithm(self, node: logic_pb2.Algorithm, *args: Any): key = relation_id_key(rid) if key in self.seen_ids: original_name = self.get_original_name(rid) - raise ValidationError( + raise ValidationError(self._format_location( f"Duplicate declaration: '{original_name}'" - ) + )) else: self.seen_ids[key] = (self.curr_epoch, self.curr_fragment) class DuplicateFragmentDefinitionFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.seen_ids: Set[bytes] = set() self.visit(txn) @@ -365,9 +403,9 @@ def visit_Define(self, node: transactions_pb2.Define, *args: Any): frag_id = node.fragment.id.id if frag_id in self.seen_ids: id_str = frag_id.decode("utf-8") - raise ValidationError( + raise ValidationError(self._format_location( f"Duplicate fragment within an epoch: '{id_str}'" - ) + )) else: self.seen_ids.add(frag_id) @@ -419,8 +457,8 @@ class State: relation_types: Dict[Tuple[int, int], List[str]] var_types: Dict[str, str] - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) global_defs = AtomTypeChecker.collect_global_defs(txn) relation_types = {} for _, node in global_defs: @@ -483,10 +521,10 @@ def visit_Atom(self, node: logic_pb2.Atom, *args: Any): relation_arity = len(relation_type_sig) if atom_arity != relation_arity: original_name = self.get_original_name(node.name) - raise ValidationError( + raise ValidationError(self._format_location( f"Incorrect arity for '{original_name}' atom: " f"expected {relation_arity} term{'' if relation_arity == 1 else 's'}, got {atom_arity}" - ) + )) for i, (term, expected_type) in enumerate(zip(node.terms, relation_type_sig)): which = term.WhichOneof("term_type") @@ -501,15 +539,15 @@ def visit_Atom(self, node: logic_pb2.Atom, *args: Any): if term_type != expected_type: original_name = self.get_original_name(node.name) pretty_term = proto_term_str(term) - raise ValidationError( + raise ValidationError(self._format_location( f"Incorrect type for '{original_name}' atom at index {i} ('{pretty_term}'): " f"expected {expected_type} term, got {term_type}" - ) + )) class LoopyBadBreakFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.visit(txn) def visit_Loop(self, node: logic_pb2.Loop, *args: Any): @@ -517,14 +555,14 @@ def visit_Loop(self, node: logic_pb2.Loop, *args: Any): if instr_wrapper.HasField("break"): brk = getattr(instr_wrapper, "break") original_name = self.get_original_name(brk.name) - raise ValidationError( + raise ValidationError(self._format_location( f"Break rule found outside of body: '{original_name}'" - ) + )) class LoopyBadGlobalFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.globals: Set[Tuple[int, int]] = set() self.init: Set[Tuple[int, int]] = set() self.visit(txn) @@ -567,23 +605,23 @@ def visit_Loop(self, node: logic_pb2.Loop, *args: Any): key = relation_id_key(actual.name) if key in self.globals and key not in self.init: original_name = self.get_original_name(actual.name) - raise ValidationError( + raise ValidationError(self._format_location( f"Global rule found in body: '{original_name}'" - ) + )) class LoopyUpdatesShouldBeAtoms(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.visit(txn) def _check_atom_body(self, node: _InstructionLike, instr_type_name: str): formula = node.body.value which = formula.WhichOneof("formula_type") if which != "atom": - raise ValidationError( + raise ValidationError(self._format_location( f"{instr_type_name} must have an Atom as its value" - ) + )) def visit_Upsert(self, node: logic_pb2.Upsert, *args: Any): self._check_atom_body(node, "Upsert") @@ -596,8 +634,8 @@ def visit_MonusDef(self, node: logic_pb2.MonusDef, *args: Any): class CSVConfigChecker(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) global_defs = AtomTypeChecker.collect_global_defs(txn) self.relation_types: Dict[Tuple[int, int], List[str]] = {} for _, node in global_defs: @@ -609,23 +647,23 @@ def __init__(self, txn: transactions_pb2.Transaction): def visit_ExportCSVConfig(self, node: transactions_pb2.ExportCSVConfig, *args: Any): if node.HasField("syntax_delim") and len(node.syntax_delim) != 1: - raise ValidationError( + raise ValidationError(self._format_location( f"CSV delimiter should be a single character, got '{node.syntax_delim}'" - ) + )) if node.HasField("syntax_quotechar") and len(node.syntax_quotechar) != 1: - raise ValidationError( + raise ValidationError(self._format_location( f"CSV quotechar should be a single character, got '{node.syntax_quotechar}'" - ) + )) if node.HasField("syntax_escapechar") and len(node.syntax_escapechar) != 1: - raise ValidationError( + raise ValidationError(self._format_location( f"CSV escapechar should be a single character, got '{node.syntax_escapechar}'" - ) + )) valid_compressions = {"", "gzip"} if node.HasField("compression") and node.compression not in valid_compressions: - raise ValidationError( + raise ValidationError(self._format_location( f"CSV compression should be one of {valid_compressions}, got '{node.compression}'" - ) + )) column_0_key_types: Optional[List[str]] = None column_0_name: Optional[str] = None @@ -636,53 +674,53 @@ def visit_ExportCSVConfig(self, node: transactions_pb2.ExportCSVConfig, *args: A column_types = self.relation_types[key] if len(column_types) < 1: - raise ValidationError( + raise ValidationError(self._format_location( f"Data column relation must have at least one column, " f"got zero columns in '{self.get_original_name(column.column_data)}'" - ) + )) key_types = column_types[:-1] if column_0_key_types is None: column_0_key_types = key_types column_0_name = self.get_original_name(column.column_data) else: if column_0_key_types != key_types: - raise ValidationError( + raise ValidationError(self._format_location( f"All data columns in ExportCSVConfig must have the same key types. " f"Got '{column_0_name}' with key types {[str(t) for t in column_0_key_types]} " f"and '{self.get_original_name(column.column_data)}' with key types {[str(t) for t in key_types]}." - ) + )) class FDVarsChecker(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, provenance=None): + super().__init__(provenance) self.visit(txn) def visit_FunctionalDependency(self, node: logic_pb2.FunctionalDependency, *args: Any): guard_var_names = {b.var.name for b in node.guard.vars} for var in node.keys: if var.name not in guard_var_names: - raise ValidationError( + raise ValidationError(self._format_location( f"Key variable '{var.name}' not declared in guard" - ) + )) for var in node.values: if var.name not in guard_var_names: - raise ValidationError( + raise ValidationError(self._format_location( f"Value variable '{var.name}' not declared in guard" - ) + )) # --- Entry point --- -def validate_proto(txn: transactions_pb2.Transaction) -> None: +def validate_proto(txn: transactions_pb2.Transaction, provenance=None) -> None: """Validate a protobuf Transaction message.""" - ShadowedVariableFinder(txn) - UnusedVariableVisitor(txn) - DuplicateRelationIdFinder(txn) - DuplicateFragmentDefinitionFinder(txn) - AtomTypeChecker(txn) - LoopyBadBreakFinder(txn) - LoopyBadGlobalFinder(txn) - LoopyUpdatesShouldBeAtoms(txn) - CSVConfigChecker(txn) - FDVarsChecker(txn) + ShadowedVariableFinder(txn, provenance) + UnusedVariableVisitor(txn, provenance) + DuplicateRelationIdFinder(txn, provenance) + DuplicateFragmentDefinitionFinder(txn, provenance) + AtomTypeChecker(txn, provenance) + LoopyBadBreakFinder(txn, provenance) + LoopyBadGlobalFinder(txn, provenance) + LoopyUpdatesShouldBeAtoms(txn, provenance) + CSVConfigChecker(txn, provenance) + FDVarsChecker(txn, provenance) diff --git a/python-tools/src/meta/codegen_templates.py b/python-tools/src/meta/codegen_templates.py index 859ea135..60003321 100644 --- a/python-tools/src/meta/codegen_templates.py +++ b/python-tools/src/meta/codegen_templates.py @@ -94,6 +94,11 @@ class BuiltinTemplate: "subtract": BuiltinTemplate("({0} - {1})"), "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), "list_sort": BuiltinTemplate("sorted({0})"), + # Provenance tracking + "push_path": BuiltinTemplate("None", ["self._push_path({0})"]), + "pop_path": BuiltinTemplate("None", ["self._pop_path()"]), + "span_start": BuiltinTemplate("self._span_start()"), + "record_span": BuiltinTemplate("None", ["self._record_span({0})"]), } @@ -170,6 +175,11 @@ class BuiltinTemplate: "subtract": BuiltinTemplate("({0} - {1})"), "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), "list_sort": BuiltinTemplate("sort({0})"), + # Provenance tracking + "push_path": BuiltinTemplate("nothing", ["push_path!(parser, {0})"]), + "pop_path": BuiltinTemplate("nothing", ["pop_path!(parser)"]), + "span_start": BuiltinTemplate("span_start(parser)"), + "record_span": BuiltinTemplate("nothing", ["record_span!(parser, {0})"]), } @@ -252,6 +262,11 @@ class BuiltinTemplate: "relation_id_to_uint128": BuiltinTemplate("p.relationIdToUint128({0})"), "subtract": BuiltinTemplate("({0} - {1})"), "list_slice": BuiltinTemplate("{0}[{1}:{2}]"), + # Provenance tracking + "push_path": BuiltinTemplate("nil", ["p.pushPath({0})"]), + "pop_path": BuiltinTemplate("nil", ["p.popPath()"]), + "span_start": BuiltinTemplate("p.spanStart()"), + "record_span": BuiltinTemplate("nil", ["p.recordSpan({0})"]), } __all__ = [ diff --git a/python-tools/src/meta/parser_gen.py b/python-tools/src/meta/parser_gen.py index e3c6cd83..7438f5d9 100644 --- a/python-tools/src/meta/parser_gen.py +++ b/python-tools/src/meta/parser_gen.py @@ -79,7 +79,7 @@ from typing import Dict, List, Optional, Set, Tuple from .grammar import Grammar, Rule, Rhs, LitTerminal, NamedTerminal, Nonterminal, Star, Option, Terminal, Sequence from .grammar_utils import is_epsilon, rhs_elements -from .target import Lambda, Call, ParseNonterminalDef, Var, Lit, Let, IfElse, BaseType, ListType, ListExpr, TargetExpr, Seq, While, Assign, ParseNonterminal +from .target import Lambda, Call, ParseNonterminalDef, Var, Lit, Let, IfElse, BaseType, ListType, ListExpr, TargetExpr, Seq, While, Assign, ParseNonterminal, NewMessage, OneOf from .target_builtins import make_builtin, make_builtin_with_type from .target_utils import apply_lambda from .gensym import gensym @@ -103,23 +103,23 @@ class AmbiguousGrammarError(Exception): pass -def generate_parse_functions(grammar: Grammar, indent: str = "") -> List[ParseNonterminalDef]: +def generate_parse_functions(grammar: Grammar, indent: str = "", proto_messages=None) -> List[ParseNonterminalDef]: parser_methods = [] reachable, _ = grammar.analysis.partition_nonterminals_by_reachability() for nt in reachable: rules = grammar.rules[nt] - method_code = _generate_parse_method(nt, rules, grammar, indent) + method_code = _generate_parse_method(nt, rules, grammar, indent, proto_messages) parser_methods.append(method_code) return parser_methods -def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar, indent: str = "") -> ParseNonterminalDef: +def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar, indent: str = "", proto_messages=None) -> ParseNonterminalDef: """Generate parse method code as string (preserving existing logic).""" return_type = None rhs = None follow_set = FollowSet(grammar, lhs) if len(rules) == 1: rule = rules[0] - rhs = _generate_parse_rhs_ir(rule.rhs, grammar, follow_set, True, rule.constructor) + rhs = _generate_parse_rhs_ir(rule.rhs, grammar, follow_set, True, rule.constructor, proto_messages=proto_messages) return_type = rule.constructor.return_type else: predictor = _build_predictor(grammar, rules) @@ -135,10 +135,16 @@ def _generate_parse_method(lhs: Nonterminal, rules: List[Rule], grammar: Grammar return_type = rule.constructor.return_type if is_epsilon(rule.rhs): continue - tail = IfElse(Call(make_builtin('equal'), [Var(prediction, BaseType('Int64')), Lit(i)]), _generate_parse_rhs_ir(rule.rhs, grammar, follow_set, True, rule.constructor), tail) + tail = IfElse(Call(make_builtin('equal'), [Var(prediction, BaseType('Int64')), Lit(i)]), _generate_parse_rhs_ir(rule.rhs, grammar, follow_set, True, rule.constructor, proto_messages=proto_messages), tail) rhs = Let(Var(prediction, BaseType('Int64')), predictor, tail) assert return_type is not None - return ParseNonterminalDef(lhs, [], return_type, rhs, indent) + # Wrap with span recording: capture start position, parse, record span + span_start_var = Var(gensym('span_start'), BaseType('Int64')) + result_var = Var(gensym('result'), return_type) + wrapped_rhs = Let(span_start_var, Call(make_builtin('span_start'), []), + Let(result_var, rhs, + Seq([Call(make_builtin('record_span'), [span_start_var]), result_var]))) + return ParseNonterminalDef(lhs, [], return_type, wrapped_rhs, indent) def _build_predictor(grammar: Grammar, rules: List[Rule]) -> TargetExpr: """Build a predictor expression that returns the index of the matching rule. @@ -293,7 +299,64 @@ def _build_option_predictor(grammar: Grammar, element: Rhs, follow_set: Terminal conflict_msg = f'Ambiguous Option/Star: FIRST_{MAX_LOOKAHEAD}({element}) and follow set overlap' raise AmbiguousGrammarError(conflict_msg) -def _generate_parse_rhs_ir(rhs: Rhs, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool=False, action: Optional[Lambda]=None) -> TargetExpr: +def _build_param_field_numbers(action: Optional[Lambda], proto_messages) -> Dict[int, int]: + """Map Lambda param indices to proto field numbers by inspecting NewMessage body. + + When the action body is a NewMessage, each field references a Lambda param. + This maps param index -> proto field number for path tracking. + + Returns empty dict if action body is not a NewMessage or proto_messages unavailable. + """ + if action is None or proto_messages is None: + return {} + + body = action.body + if not isinstance(body, NewMessage): + return {} + + msg_key = (body.module, body.name) + proto_msg = proto_messages.get(msg_key) + if proto_msg is None: + return {} + + # Build field name -> number lookup + field_numbers: Dict[str, int] = {} + for f in proto_msg.fields: + field_numbers[f.name] = f.number + for oneof in proto_msg.oneofs: + for f in oneof.fields: + field_numbers[f.name] = f.number + + # Build param name -> param index + param_index = {p.name: i for i, p in enumerate(action.params)} + + result: Dict[int, int] = {} + for field_name, field_expr in body.fields: + if isinstance(field_expr, Var) and field_expr.name in param_index: + idx = param_index[field_expr.name] + if field_name in field_numbers: + result[idx] = field_numbers[field_name] + elif isinstance(field_expr, Call) and isinstance(field_expr.func, OneOf): + oneof_field_name = field_expr.func.field_name + if field_expr.args and isinstance(field_expr.args[0], Var): + var = field_expr.args[0] + if var.name in param_index: + idx = param_index[var.name] + if oneof_field_name in field_numbers: + result[idx] = field_numbers[oneof_field_name] + elif isinstance(field_expr, Call) and not isinstance(field_expr.func, OneOf): + # Handle builtin wrappers like unwrap_option_or(param, default) + for arg in field_expr.args: + if isinstance(arg, Var) and arg.name in param_index: + idx = param_index[arg.name] + if field_name in field_numbers: + result[idx] = field_numbers[field_name] + break + + return result + + +def _generate_parse_rhs_ir(rhs: Rhs, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool=False, action: Optional[Lambda]=None, proto_messages=None, path_field_number: Optional[int]=None) -> TargetExpr: """Generate IR for parsing an RHS. Args: @@ -307,7 +370,7 @@ def _generate_parse_rhs_ir(rhs: Rhs, grammar: Grammar, follow_set: TerminalSeque Returns None for complex cases that still use string generation. """ if isinstance(rhs, Sequence): - return _generate_parse_rhs_ir_sequence(rhs, grammar, follow_set, apply_action, action) + return _generate_parse_rhs_ir_sequence(rhs, grammar, follow_set, apply_action, action, proto_messages) elif isinstance(rhs, LitTerminal): parse_expr = Call(make_builtin('consume_literal'), [Lit(rhs.name)]) if apply_action and action: @@ -350,20 +413,48 @@ def _generate_parse_rhs_ir(rhs: Rhs, grammar: Grammar, follow_set: TerminalSeque predictor = _build_option_predictor(grammar, rhs.rhs, follow_set) parse_item = _generate_parse_rhs_ir(rhs.rhs, grammar, follow_set, False, None) item = Var(gensym('item'), rhs.rhs.target_type()) - loop_body = Seq([ - Assign(item, parse_item), - Call(make_builtin('list_push'), [xs, item]), - Assign(cond, predictor) - ]) - return Let(xs, ListExpr([], rhs.rhs.target_type()), - Let(cond, predictor, Seq([While(cond, loop_body), xs]))) + if path_field_number is not None: + idx = Var(gensym('idx'), BaseType('Int64')) + loop_body = Seq([ + Call(make_builtin('push_path'), [idx]), + Assign(item, parse_item), + Call(make_builtin('pop_path'), []), + Call(make_builtin('list_push'), [xs, item]), + Assign(idx, Call(make_builtin('add'), [idx, Lit(1)])), + Assign(cond, predictor) + ]) + return Seq([ + Call(make_builtin('push_path'), [Lit(path_field_number)]), + Let(xs, ListExpr([], rhs.rhs.target_type()), + Let(cond, predictor, + Let(idx, Lit(0), + Seq([While(cond, loop_body), + Call(make_builtin('pop_path'), []), + xs])))) + ]) + else: + idx = Var(gensym('idx'), BaseType('Int64')) + loop_body = Seq([ + Call(make_builtin('push_path'), [idx]), + Assign(item, parse_item), + Call(make_builtin('pop_path'), []), + Call(make_builtin('list_push'), [xs, item]), + Assign(idx, Call(make_builtin('add'), [idx, Lit(1)])), + Assign(cond, predictor) + ]) + return Let(xs, ListExpr([], rhs.rhs.target_type()), + Let(cond, predictor, + Let(idx, Lit(0), + Seq([While(cond, loop_body), xs])))) else: raise NotImplementedError(f'Unsupported Rhs type: {type(rhs)}') -def _generate_parse_rhs_ir_sequence(rhs: Sequence, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool=False, action: Optional[Lambda]=None) -> TargetExpr: +def _generate_parse_rhs_ir_sequence(rhs: Sequence, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool=False, action: Optional[Lambda]=None, proto_messages=None) -> TargetExpr: if is_epsilon(rhs): return Lit(None) + param_field_numbers = _build_param_field_numbers(action, proto_messages) if apply_action else {} + exprs = [] arg_vars = [] elems = list(rhs_elements(rhs)) @@ -375,10 +466,17 @@ def _generate_parse_rhs_ir_sequence(rhs: Sequence, grammar: Grammar, follow_set: follow_set_i = ConcatSet(first_following, follow_set) else: follow_set_i = follow_set - elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) if isinstance(elem, LitTerminal): + elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) exprs.append(elem_ir) else: + field_num = param_field_numbers.get(non_literal_count) + + if isinstance(elem, Star) and field_num is not None: + elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None, path_field_number=field_num) + else: + elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) + if action and non_literal_count < len(action.params): var_name = gensym(action.params[non_literal_count].name) else: @@ -389,7 +487,14 @@ def _generate_parse_rhs_ir_sequence(rhs: Sequence, grammar: Grammar, follow_set: ) var_name = gensym('arg') var = Var(var_name, elem.target_type()) - exprs.append(Assign(var, elem_ir)) + if field_num is not None and not isinstance(elem, Star): + exprs.append(Seq([ + Call(make_builtin('push_path'), [Lit(field_num)]), + Assign(var, elem_ir), + Call(make_builtin('pop_path'), []) + ])) + else: + exprs.append(Assign(var, elem_ir)) arg_vars.append(var) non_literal_count += 1 if apply_action and action: diff --git a/python-tools/src/meta/parser_gen_common.py b/python-tools/src/meta/parser_gen_common.py index 92dc5d81..b1f29558 100644 --- a/python-tools/src/meta/parser_gen_common.py +++ b/python-tools/src/meta/parser_gen_common.py @@ -31,7 +31,7 @@ def generate_parser( template = template_path.read_text() indent = codegen.parse_def_indent - defns = generate_parse_functions(grammar, indent=indent) + defns = generate_parse_functions(grammar, indent=indent, proto_messages=codegen.proto_messages) lines = [] for defn in defns: lines.append("") diff --git a/python-tools/src/meta/target_builtins.py b/python-tools/src/meta/target_builtins.py index 3f6aa586..700a860a 100644 --- a/python-tools/src/meta/target_builtins.py +++ b/python-tools/src/meta/target_builtins.py @@ -172,6 +172,12 @@ def is_builtin(name: str) -> bool: register_builtin("has_proto_field", [T, STRING], BOOLEAN) # msg.HasField(field_name) register_builtin("which_one_of", [T, STRING], STRING) # msg.WhichOneof(oneof_name) +# === Provenance tracking === +register_builtin("push_path", [INT64], VOID) +register_builtin("pop_path", [], VOID) +register_builtin("span_start", [], INT64) +register_builtin("record_span", [INT64], VOID) + # === General helpers === register_builtin("is_empty", [SequenceType(T)], BOOLEAN) # len(list) == 0 register_builtin("enum_value", [STRING, STRING], T) # enum_value(EnumType, ValueName) diff --git a/python-tools/src/meta/templates/parser.go.template b/python-tools/src/meta/templates/parser.go.template index 22ba88bb..c2dc0000 100644 --- a/python-tools/src/meta/templates/parser.go.template +++ b/python-tools/src/meta/templates/parser.go.template @@ -96,13 +96,27 @@ func (tv TokenValue) String() string {{ // Token represents a lexer token type Token struct {{ - Type string - Value TokenValue - Pos int + Type string + Value TokenValue + StartPos int + EndPos int }} func (t Token) String() string {{ - return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.Pos) + return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.StartPos) +}} + +// Location represents a source position with 1-based line and column. +type Location struct {{ + Line int + Column int + Offset int +}} + +// Span represents a source range. +type Span struct {{ + Start Location + End Location }} // tokenSpec represents a token specification for the lexer @@ -186,14 +200,15 @@ func (l *Lexer) tokenize() {{ }} l.tokens = append(l.tokens, Token{{ - Type: best.tokenType, - Value: best.action(best.value), - Pos: l.pos, + Type: best.tokenType, + Value: best.action(best.value), + StartPos: l.pos, + EndPos: best.endPos, }}) l.pos = best.endPos }} - l.tokens = append(l.tokens, Token{{Type: "$", Value: stringTokenValue(""), Pos: l.pos}}) + l.tokens = append(l.tokens, Token{{Type: "$", Value: stringTokenValue(""), StartPos: l.pos, EndPos: l.pos}}) }} // Scanner functions for each token type @@ -314,30 +329,57 @@ type Parser struct {{ pos int idToDebugInfo map[string]map[relationIdKey]string currentFragmentID []byte + Provenance map[string]Span + path []int + lineStarts []int }} // NewParser creates a new parser -func NewParser(tokens []Token) *Parser {{ +func NewParser(tokens []Token, input string) *Parser {{ return &Parser{{ tokens: tokens, pos: 0, idToDebugInfo: make(map[string]map[relationIdKey]string), currentFragmentID: nil, + Provenance: make(map[string]Span), + path: make([]int, 0), + lineStarts: computeLineStarts(input), }} }} +func computeLineStarts(text string) []int {{ + starts := []int{{0}} + for i, ch := range text {{ + if ch == '\n' {{ + starts = append(starts, i+1) + }} + }} + return starts +}} + +func pathKey(path []int) string {{ + if len(path) == 0 {{ + return "" + }} + parts := make([]string, len(path)) + for i, v := range path {{ + parts[i] = strconv.Itoa(v) + }} + return strings.Join(parts, ",") +}} + func (p *Parser) lookahead(k int) Token {{ idx := p.pos + k if idx < len(p.tokens) {{ return p.tokens[idx] }} - return Token{{Type: "$", Value: stringTokenValue(""), Pos: -1}} + return Token{{Type: "$", Value: stringTokenValue(""), StartPos: -1, EndPos: -1}} }} func (p *Parser) consumeLiteral(expected string) {{ if !p.matchLookaheadLiteral(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) }} p.pos++ }} @@ -345,7 +387,7 @@ func (p *Parser) consumeLiteral(expected string) {{ func (p *Parser) consumeTerminal(expected string) Token {{ if !p.matchLookaheadTerminal(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) }} token := p.lookahead(0) p.pos++ @@ -369,6 +411,43 @@ func (p *Parser) matchLookaheadTerminal(terminal string, k int) bool {{ return token.Type == terminal }} +func (p *Parser) pushPath(n int) {{ + p.path = append(p.path, n) +}} + +func (p *Parser) popPath() {{ + p.path = p.path[:len(p.path)-1] +}} + +func (p *Parser) spanStart() int {{ + return p.tokens[p.pos].StartPos +}} + +func (p *Parser) recordSpan(startOffset int) {{ + endOffset := p.tokens[p.pos-1].EndPos + key := pathKey(p.path) + p.Provenance[key] = Span{{ + Start: p.makeLocation(startOffset), + End: p.makeLocation(endOffset), + }} +}} + +func (p *Parser) makeLocation(offset int) Location {{ + // Binary search for the line containing offset + lo, hi := 0, len(p.lineStarts)-1 + for lo < hi {{ + mid := (lo + hi + 1) / 2 + if p.lineStarts[mid] <= offset {{ + lo = mid + }} else {{ + hi = mid - 1 + }} + }} + line := lo + 1 + column := offset - p.lineStarts[lo] + 1 + return Location{{Line: line, Column: column, Offset: offset}} +}} + func (p *Parser) startFragment(fragmentID *pb.FragmentId) *pb.FragmentId {{ p.currentFragmentID = fragmentID.Id return fragmentID @@ -617,8 +696,8 @@ func toPascalCase(s string) string {{ // --- Parse functions --- {parse_nonterminal_defns} -// Parse parses the input string and returns the result -func Parse(input string) (*pb.Transaction, error) {{ +// Parse parses the input string and returns the result and provenance map +func Parse(input string) (*pb.Transaction, map[string]Span, error) {{ defer func() {{ if r := recover(); r != nil {{ if pe, ok := r.(ParseError); ok {{ @@ -629,15 +708,15 @@ func Parse(input string) (*pb.Transaction, error) {{ }}() lexer := NewLexer(input) - parser := NewParser(lexer.tokens) + parser := NewParser(lexer.tokens, input) result := parser.parse_{start_name}() // Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens) {{ remainingToken := parser.lookahead(0) if remainingToken.Type != "$" {{ - return nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} + return nil, nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} }} }} - return result, nil + return result, parser.Provenance, nil }} diff --git a/python-tools/src/meta/templates/parser.jl.template b/python-tools/src/meta/templates/parser.jl.template index 984a8a71..aee18d1c 100644 --- a/python-tools/src/meta/templates/parser.jl.template +++ b/python-tools/src/meta/templates/parser.jl.template @@ -46,13 +46,25 @@ end Base.showerror(io::IO, e::ParseError) = print(io, "ParseError: ", e.msg) +struct Location + line::Int + column::Int + offset::Int +end + +struct Span + start_::Location + end_::Location +end + struct Token type::String value::Any - pos::Int + start_pos::Int + end_pos::Int end -Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.pos, ")") +Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.start_pos, ")") mutable struct Lexer @@ -108,11 +120,11 @@ function tokenize!(lexer::Lexer) # Pick the longest match token_type, value, action, end_pos = candidates[argmax([c[4] for c in candidates])] - push!(lexer.tokens, Token(token_type, action(value), lexer.pos)) + push!(lexer.tokens, Token(token_type, action(value), lexer.pos, end_pos)) lexer.pos = end_pos end - push!(lexer.tokens, Token("\$", "", lexer.pos)) + push!(lexer.tokens, Token("\$", "", lexer.pos, lexer.pos)) return nothing end @@ -187,23 +199,37 @@ mutable struct Parser id_to_debuginfo::Dict{{Vector{{UInt8}},Vector{{Pair{{Tuple{{UInt64,UInt64}},String}}}}}} _current_fragment_id::Union{{Nothing,Vector{{UInt8}}}} _relation_id_to_name::Dict{{Tuple{{UInt64,UInt64}},String}} + provenance::Dict{{Tuple{{Vararg{{Int}}}},Span}} + _path::Vector{{Int}} + _line_starts::Vector{{Int}} + + function Parser(tokens::Vector{{Token}}, input::String) + line_starts = _compute_line_starts(input) + return new(tokens, 1, Dict(), nothing, Dict(), Dict(), Int[], line_starts) + end +end - function Parser(tokens::Vector{{Token}}) - return new(tokens, 1, Dict(), nothing, Dict()) +function _compute_line_starts(text::String)::Vector{{Int}} + starts = [0] + for (i, ch) in enumerate(text) + if ch == '\n' + push!(starts, i) + end end + return starts end function lookahead(parser::Parser, k::Int=0)::Token idx = parser.pos + k - return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1) + return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1, -1) end function consume_literal!(parser::Parser, expected::String) if !match_lookahead_literal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) + throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) end parser.pos += 1 return nothing @@ -213,7 +239,7 @@ end function consume_terminal!(parser::Parser, expected::String) if !match_lookahead_terminal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) + throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) end token = lookahead(parser, 0) parser.pos += 1 @@ -240,6 +266,35 @@ function match_lookahead_terminal(parser::Parser, terminal::String, k::Int)::Boo end +function push_path!(parser::Parser, n::Int) + push!(parser._path, n) + return nothing +end + +function pop_path!(parser::Parser) + pop!(parser._path) + return nothing +end + +function span_start(parser::Parser)::Int + return parser.tokens[parser.pos].start_pos +end + +function record_span!(parser::Parser, start_offset::Int) + end_offset = parser.tokens[parser.pos - 1].end_pos + start_loc = _make_location(parser, start_offset) + end_loc = _make_location(parser, end_offset) + parser.provenance[Tuple(parser._path)] = Span(start_loc, end_loc) + return nothing +end + +function _make_location(parser::Parser, offset::Int)::Location + # Binary search for the line containing offset + line = searchsortedlast(parser._line_starts, offset) + column = offset - parser._line_starts[line] + 1 + return Location(line, column, offset) +end + function start_fragment!(parser::Parser, fragment_id::Proto.FragmentId) parser._current_fragment_id = fragment_id.id return fragment_id @@ -303,7 +358,7 @@ end function parse(input::String) lexer = Lexer(input) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input) result = parse_{start_name}(parser) # Check for unconsumed tokens (except EOF) if parser.pos <= length(parser.tokens) @@ -312,5 +367,5 @@ function parse(input::String) throw(ParseError("Unexpected token at end of input: $remaining_token")) end end - return result + return result, parser.provenance end diff --git a/python-tools/src/meta/templates/parser.py.template b/python-tools/src/meta/templates/parser.py.template index 5fd019a3..8c60d976 100644 --- a/python-tools/src/meta/templates/parser.py.template +++ b/python-tools/src/meta/templates/parser.py.template @@ -8,10 +8,12 @@ in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. {command_line_comment}""" import ast +import bisect import hashlib import re from collections.abc import Sequence -from typing import List, Optional, Any, Tuple, Callable +from dataclasses import dataclass +from typing import Dict, List, Optional, Any, Tuple, Callable from decimal import Decimal from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -22,15 +24,31 @@ class ParseError(Exception): pass +@dataclass(frozen=True) +class Location: + """Source location with 1-based line and column.""" + line: int + column: int + offset: int + + +@dataclass(frozen=True) +class Span: + """Source span from start to end location.""" + start: Location + end: Location + + class Token: """Token representation.""" - def __init__(self, type: str, value: str, pos: int): + def __init__(self, type: str, value: str, start_pos: int, end_pos: int): self.type = type self.value = value - self.pos = pos + self.start_pos = start_pos + self.end_pos = end_pos def __repr__(self) -> str: - return f"Token({{self.type}}, {{self.value!r}}, {{self.pos}})" + return f"Token({{self.type}}, {{self.value!r}}, {{self.start_pos}})" class Lexer: @@ -74,10 +92,10 @@ class Lexer: # Pick the longest match token_type, value, action, end_pos = max(candidates, key=lambda x: x[3]) - self.tokens.append(Token(token_type, action(value), self.pos)) + self.tokens.append(Token(token_type, action(value), self.pos, end_pos)) self.pos = end_pos - self.tokens.append(Token('$', '', self.pos)) + self.tokens.append(Token('$', '', self.pos, self.pos)) @staticmethod def scan_symbol(s: str) -> str: @@ -151,32 +169,45 @@ class Lexer: return logic_pb2.DecimalValue(precision=precision, scale=scale, value=value) +def _compute_line_starts(text: str) -> List[int]: + """Compute byte offsets where each line begins.""" + starts = [0] + for i, ch in enumerate(text): + if ch == '\n': + starts.append(i + 1) + return starts + + class Parser: """LL(k) recursive-descent parser with backtracking.""" - def __init__(self, tokens: List[Token]): + def __init__(self, tokens: List[Token], input_str: str): self.tokens = tokens self.pos = 0 self.id_to_debuginfo = {{}} self._current_fragment_id: bytes | None = None self._relation_id_to_name = {{}} + self.provenance: Dict[Tuple[int, ...], Span] = {{}} + self._path: List[int] = [] + self._input_str = input_str + self._line_starts = _compute_line_starts(input_str) def lookahead(self, k: int = 0) -> Token: """Get lookahead token at offset k.""" idx = self.pos + k - return self.tokens[idx] if idx < len(self.tokens) else Token('$', '', -1) + return self.tokens[idx] if idx < len(self.tokens) else Token('$', '', -1, -1) def consume_literal(self, expected: str) -> None: """Consume a literal token.""" if not self.match_lookahead_literal(expected, 0): token = self.lookahead(0) - raise ParseError(f'Expected literal {{expected!r}} but got {{token.type}}=`{{token.value!r}}` at position {{token.pos}}') + raise ParseError(f'Expected literal {{expected!r}} but got {{token.type}}=`{{token.value!r}}` at position {{token.start_pos}}') self.pos += 1 def consume_terminal(self, expected: str) -> Any: """Consume a terminal token and return parsed value.""" if not self.match_lookahead_terminal(expected, 0): token = self.lookahead(0) - raise ParseError(f'Expected terminal {{expected}} but got {{token.type}}=`{{token.value!r}}` at position {{token.pos}}') + raise ParseError(f'Expected terminal {{expected}} but got {{token.type}}=`{{token.value!r}}` at position {{token.start_pos}}') token = self.lookahead(0) self.pos += 1 return token.value @@ -199,6 +230,25 @@ class Parser: token = self.lookahead(k) return token.type == terminal + def _push_path(self, n: int) -> None: + self._path.append(n) + + def _pop_path(self) -> None: + self._path.pop() + + def _span_start(self) -> int: + return self.tokens[self.pos].start_pos + + def _record_span(self, start_offset: int) -> None: + end_offset = self.tokens[self.pos - 1].end_pos + span = Span(self._make_location(start_offset), self._make_location(end_offset)) + self.provenance[tuple(self._path)] = span + + def _make_location(self, offset: int) -> Location: + line = bisect.bisect_right(self._line_starts, offset) + column = offset - self._line_starts[line - 1] + 1 + return Location(line, column, offset) + def start_fragment(self, fragment_id: fragments_pb2.FragmentId) -> fragments_pb2.FragmentId: """Set current fragment ID for debug info tracking.""" self._current_fragment_id = fragment_id.id @@ -254,14 +304,14 @@ class Parser: # --- Parse methods --- {parse_nonterminal_defns} -def parse(input_str: str) -> Any: - """Parse input string and return parse tree.""" +def parse(input_str: str) -> Tuple[Any, Dict[Tuple[int, ...], Span]]: + """Parse input string and return (parse tree, provenance map).""" lexer = Lexer(input_str) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input_str) result = parser.parse_{start_name}() # Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens): remaining_token = parser.lookahead(0) if remaining_token.type != '$': raise ParseError(f"Unexpected token at end of input: {{remaining_token}}") - return result + return result, parser.provenance diff --git a/python-tools/tests/test_generated_parser.py b/python-tools/tests/test_generated_parser.py index a6dbe077..727910a6 100644 --- a/python-tools/tests/test_generated_parser.py +++ b/python-tools/tests/test_generated_parser.py @@ -48,8 +48,8 @@ def test_generated_parser_matches_lark_parser(input_file): lark_proto = ir_to_proto(lark_ir) lark_binary = lark_proto.SerializeToString() - # Parse with generated parser (returns protobuf directly) - generated_proto = generated_parse(content) + # Parse with generated parser (returns protobuf and provenance) + generated_proto, _ = generated_parse(content) generated_binary = generated_proto.SerializeToString() # Compare serialized protobufs diff --git a/python-tools/tests/test_generated_pretty_printer.py b/python-tools/tests/test_generated_pretty_printer.py index 7dadd83e..a3912753 100644 --- a/python-tools/tests/test_generated_pretty_printer.py +++ b/python-tools/tests/test_generated_pretty_printer.py @@ -98,7 +98,7 @@ def test_roundtrip_idempotent(input_file): text1 = _parse_and_pretty(input_file) # Second pass: parse printed output → proto → pretty-print again - proto2 = generated_parse(text1) + proto2, _ = generated_parse(text1) text2 = pretty(proto2) assert text1 == text2, ( @@ -150,7 +150,7 @@ def test_bin_roundtrip(input_file): # Pretty-print → re-parse text = pretty(proto1) - proto2 = generated_parse(text) + proto2, _ = generated_parse(text) # Clear debug info before comparison since pretty printer # consumes but does not output debug info diff --git a/python-tools/tests/test_proto_validator.py b/python-tools/tests/test_proto_validator.py index 887bd2da..b81d3017 100644 --- a/python-tools/tests/test_proto_validator.py +++ b/python-tools/tests/test_proto_validator.py @@ -31,8 +31,8 @@ def extract_expected_error(file_path): def test_validate_proto_lqp_inputs(input_file): with open(input_file, "r") as f: content = f.read() - txn_proto = parse(content) - validate_proto(txn_proto) + txn_proto, provenance = parse(content) + validate_proto(txn_proto, provenance) @pytest.mark.parametrize( @@ -43,8 +43,8 @@ def test_valid_proto_validator_files(validator_file): file_path = VALIDATOR_DIR / validator_file with open(file_path, "r") as f: content = f.read() - txn_proto = parse(content) - validate_proto(txn_proto) + txn_proto, provenance = parse(content) + validate_proto(txn_proto, provenance) @pytest.mark.parametrize( @@ -59,10 +59,10 @@ def test_proto_validator_failure_files(validator_file): return with open(file_path, "r") as f: content = f.read() - txn_proto = parse(content) + txn_proto, provenance = parse(content) with pytest.raises(ValidationError) as exc_info: - validate_proto(txn_proto) - error_message = str(exc_info.value) + validate_proto(txn_proto, provenance) + error_message = strip_source_location(str(exc_info.value)) stripped_expected = strip_source_location(expected_error) assert stripped_expected in error_message, ( f"Expected '{stripped_expected}' in error message: '{error_message}'" @@ -90,9 +90,9 @@ def test_proto_validator_matches_ir_validator(validator_file): validate_lqp(ir_result) # Proto validator - txn_proto = parse(content) + txn_proto, provenance = parse(content) with pytest.raises(ValidationError) as proto_exc: - validate_proto(txn_proto) + validate_proto(txn_proto, provenance) # Compare error messages (ignoring source locations) ir_msg = strip_source_location(str(ir_exc.value)) From 646e9e4202a641aa14f269e2f1597fcf218a9610 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 25 Feb 2026 14:58:15 +0100 Subject: [PATCH 22/25] revert to main --- meta/src/meta/cli.py | 33 ---- meta/src/meta/parser_gen.py | 181 ++------------------- meta/src/meta/parser_gen_common.py | 2 +- meta/src/meta/target_builtins.py | 6 - meta/src/meta/templates/parser.go.template | 105 ++---------- meta/src/meta/templates/parser.jl.template | 76 ++------- meta/src/meta/templates/parser.py.template | 78 ++------- sdks/go/test/parser_test.go | 44 ++--- 8 files changed, 74 insertions(+), 451 deletions(-) diff --git a/meta/src/meta/cli.py b/meta/src/meta/cli.py index 502c35b1..dbc9b548 100644 --- a/meta/src/meta/cli.py +++ b/meta/src/meta/cli.py @@ -85,12 +85,6 @@ def parse_args(): choices=["ir"] + _LANGUAGES, help="Output the generated pretty printer", ) - output_group.add_argument( - "--printer", - type=str, - choices=["ir", "python", "julia"], - help="Output the generated pretty printer (ir, python, or julia)" - ) args = parser.parse_args() @@ -161,14 +155,6 @@ def run(args) -> int: (msg.module, name): msg for name, msg in proto_parser.messages.items() } - def make_command_line(*extra_args): - """Build a reproducible command line using basenames to avoid embedding absolute paths.""" - parts = ["python -m meta.cli"] - parts += [f.name for f in args.proto_files] - parts += ["--grammar", args.grammar.name] - parts += list(extra_args) - return " ".join(parts) - # Load grammar rules from file (yacc format) grammar_config = load_yacc_grammar_file( grammar_path, proto_messages, proto_parser.enums @@ -319,25 +305,6 @@ def make_command_line(*extra_args): f"Generated pretty printer written to {args.output}", ) - if args.printer: - if args.printer == "ir": - from .pretty_gen import generate_pretty_functions - pretty_functions = generate_pretty_functions(grammar, proto_messages) - output_lines = [] - for defn in pretty_functions: - output_lines.append(str(defn)) - output_lines.append("") - output_text = "\n".join(output_lines) - write_output(output_text, args.output, f"Generated printer IR written to {args.output}") - elif args.printer == "python": - command_line = make_command_line("--printer", args.printer) - from .pretty_gen_python import generate_pretty_printer_python - output_text = generate_pretty_printer_python(grammar, command_line, proto_messages) - write_output(output_text, args.output, f"Generated pretty printer written to {args.output}") - else: - print(f"Error: Pretty printer generation for '{args.printer}' is not yet implemented", file=sys.stderr) - return 1 - return 0 diff --git a/meta/src/meta/parser_gen.py b/meta/src/meta/parser_gen.py index ac3e4c60..7d077b28 100644 --- a/meta/src/meta/parser_gen.py +++ b/meta/src/meta/parser_gen.py @@ -100,8 +100,6 @@ ListExpr, ListType, Lit, - NewMessage, - OneOf, ParseNonterminal, ParseNonterminalDef, Seq, @@ -134,25 +132,19 @@ class AmbiguousGrammarError(Exception): def generate_parse_functions( - grammar: Grammar, indent: str = "", proto_messages=None + grammar: Grammar, indent: str = "" ) -> list[ParseNonterminalDef]: parser_methods = [] reachable, _ = grammar.analysis.partition_nonterminals_by_reachability() for nt in reachable: rules = grammar.rules[nt] - method_code = _generate_parse_method( - nt, rules, grammar, indent, proto_messages - ) + method_code = _generate_parse_method(nt, rules, grammar, indent) parser_methods.append(method_code) return parser_methods def _generate_parse_method( - lhs: Nonterminal, - rules: list[Rule], - grammar: Grammar, - indent: str = "", - proto_messages=None, + lhs: Nonterminal, rules: list[Rule], grammar: Grammar, indent: str = "" ) -> ParseNonterminalDef: """Generate parse method code as string (preserving existing logic).""" return_type = None @@ -161,8 +153,7 @@ def _generate_parse_method( if len(rules) == 1: rule = rules[0] rhs = _generate_parse_rhs_ir( - rule.rhs, grammar, follow_set, True, rule.constructor, - proto_messages=proto_messages, + rule.rhs, grammar, follow_set, True, rule.constructor ) return_type = rule.constructor.return_type else: @@ -192,26 +183,13 @@ def _generate_parse_method( make_builtin("equal"), [Var(prediction, BaseType("Int64")), Lit(i)] ), _generate_parse_rhs_ir( - rule.rhs, grammar, follow_set, True, rule.constructor, - proto_messages=proto_messages, + rule.rhs, grammar, follow_set, True, rule.constructor ), tail, ) rhs = Let(Var(prediction, BaseType("Int64")), predictor, tail) assert return_type is not None - # Wrap with span recording: capture start position, parse, record span - span_start_var = Var(gensym("span_start"), BaseType("Int64")) - result_var = Var(gensym("result"), return_type) - wrapped_rhs = Let( - span_start_var, - Call(make_builtin("span_start"), []), - Let( - result_var, - rhs, - Seq([Call(make_builtin("record_span"), [span_start_var]), result_var]), - ), - ) - return ParseNonterminalDef(lhs, [], return_type, wrapped_rhs, indent) + return ParseNonterminalDef(lhs, [], return_type, rhs, indent) def _build_predictor(grammar: Grammar, rules: list[Rule]) -> TargetExpr: @@ -393,73 +371,12 @@ def _build_option_predictor( raise AmbiguousGrammarError(conflict_msg) -def _build_param_field_numbers( - action: Lambda | None, proto_messages -) -> dict[int, int]: - """Map Lambda param indices to proto field numbers by inspecting NewMessage body. - - When the action body is a NewMessage, each field references a Lambda param. - This maps param index -> proto field number for path tracking. - - Returns empty dict if action body is not a NewMessage or proto_messages unavailable. - """ - if action is None or proto_messages is None: - return {} - - body = action.body - if not isinstance(body, NewMessage): - return {} - - msg_key = (body.module, body.name) - proto_msg = proto_messages.get(msg_key) - if proto_msg is None: - return {} - - # Build field name -> number lookup - field_numbers: dict[str, int] = {} - for f in proto_msg.fields: - field_numbers[f.name] = f.number - for oneof in proto_msg.oneofs: - for f in oneof.fields: - field_numbers[f.name] = f.number - - # Build param name -> param index - param_index = {p.name: i for i, p in enumerate(action.params)} - - result: dict[int, int] = {} - for field_name, field_expr in body.fields: - if isinstance(field_expr, Var) and field_expr.name in param_index: - idx = param_index[field_expr.name] - if field_name in field_numbers: - result[idx] = field_numbers[field_name] - elif isinstance(field_expr, Call) and isinstance(field_expr.func, OneOf): - oneof_field_name = field_expr.func.field_name - if field_expr.args and isinstance(field_expr.args[0], Var): - var = field_expr.args[0] - if var.name in param_index: - idx = param_index[var.name] - if oneof_field_name in field_numbers: - result[idx] = field_numbers[oneof_field_name] - elif isinstance(field_expr, Call) and not isinstance(field_expr.func, OneOf): - # Handle builtin wrappers like unwrap_option_or(param, default) - for arg in field_expr.args: - if isinstance(arg, Var) and arg.name in param_index: - idx = param_index[arg.name] - if field_name in field_numbers: - result[idx] = field_numbers[field_name] - break - - return result - - def _generate_parse_rhs_ir( rhs: Rhs, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool = False, action: Lambda | None = None, - proto_messages=None, - path_field_number: int | None = None, ) -> TargetExpr: """Generate IR for parsing an RHS. @@ -475,8 +392,7 @@ def _generate_parse_rhs_ir( """ if isinstance(rhs, Sequence): return _generate_parse_rhs_ir_sequence( - rhs, grammar, follow_set, apply_action, action, - proto_messages=proto_messages, + rhs, grammar, follow_set, apply_action, action ) elif isinstance(rhs, LitTerminal): parse_expr = Call(make_builtin("consume_literal"), [Lit(rhs.name)]) @@ -520,55 +436,18 @@ def _generate_parse_rhs_ir( predictor = _build_option_predictor(grammar, rhs.rhs, follow_set) parse_item = _generate_parse_rhs_ir(rhs.rhs, grammar, follow_set, False, None) item = Var(gensym("item"), rhs.rhs.target_type()) - if path_field_number is not None: - idx = Var(gensym("idx"), BaseType("Int64")) - loop_body = Seq([ - Call(make_builtin("push_path"), [idx]), - Assign(item, parse_item), - Call(make_builtin("pop_path"), []), - Call(make_builtin("list_push"), [xs, item]), - Assign(idx, Call(make_builtin("add"), [idx, Lit(1)])), - Assign(cond, predictor), - ]) - return Seq([ - Call(make_builtin("push_path"), [Lit(path_field_number)]), - Let( - xs, - ListExpr([], rhs.rhs.target_type()), - Let( - cond, - predictor, - Let( - idx, - Lit(0), - Seq([ - While(cond, loop_body), - Call(make_builtin("pop_path"), []), - xs, - ]), - ), - ), - ), - ]) - else: - idx = Var(gensym("idx"), BaseType("Int64")) - loop_body = Seq([ - Call(make_builtin("push_path"), [idx]), + loop_body = Seq( + [ Assign(item, parse_item), - Call(make_builtin("pop_path"), []), Call(make_builtin("list_push"), [xs, item]), - Assign(idx, Call(make_builtin("add"), [idx, Lit(1)])), Assign(cond, predictor), - ]) - return Let( - xs, - ListExpr([], rhs.rhs.target_type()), - Let( - cond, - predictor, - Let(idx, Lit(0), Seq([While(cond, loop_body), xs])), - ), - ) + ] + ) + return Let( + xs, + ListExpr([], rhs.rhs.target_type()), + Let(cond, predictor, Seq([While(cond, loop_body), xs])), + ) else: raise NotImplementedError(f"Unsupported Rhs type: {type(rhs)}") @@ -579,15 +458,10 @@ def _generate_parse_rhs_ir_sequence( follow_set: TerminalSequenceSet, apply_action: bool = False, action: Lambda | None = None, - proto_messages=None, ) -> TargetExpr: if is_epsilon(rhs): return Lit(None) - param_field_numbers = ( - _build_param_field_numbers(action, proto_messages) if apply_action else {} - ) - exprs = [] arg_vars = [] elems = list(rhs_elements(rhs)) @@ -599,22 +473,10 @@ def _generate_parse_rhs_ir_sequence( follow_set_i = ConcatSet(first_following, follow_set) else: follow_set_i = follow_set + elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) if isinstance(elem, LitTerminal): - elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) exprs.append(elem_ir) else: - field_num = param_field_numbers.get(non_literal_count) - - if isinstance(elem, Star) and field_num is not None: - elem_ir = _generate_parse_rhs_ir( - elem, grammar, follow_set_i, False, None, - path_field_number=field_num, - ) - else: - elem_ir = _generate_parse_rhs_ir( - elem, grammar, follow_set_i, False, None, - ) - if action and non_literal_count < len(action.params): var_name = gensym(action.params[non_literal_count].name) else: @@ -625,14 +487,7 @@ def _generate_parse_rhs_ir_sequence( ) var_name = gensym("arg") var = Var(var_name, elem.target_type()) - if field_num is not None and not isinstance(elem, Star): - exprs.append(Seq([ - Call(make_builtin("push_path"), [Lit(field_num)]), - Assign(var, elem_ir), - Call(make_builtin("pop_path"), []), - ])) - else: - exprs.append(Assign(var, elem_ir)) + exprs.append(Assign(var, elem_ir)) arg_vars.append(var) non_literal_count += 1 if apply_action and action: diff --git a/meta/src/meta/parser_gen_common.py b/meta/src/meta/parser_gen_common.py index 19c2ed56..584bcc2a 100644 --- a/meta/src/meta/parser_gen_common.py +++ b/meta/src/meta/parser_gen_common.py @@ -31,7 +31,7 @@ def generate_parser( template = template_path.read_text() indent = codegen.parse_def_indent - defns = generate_parse_functions(grammar, indent=indent, proto_messages=codegen.proto_messages) + defns = generate_parse_functions(grammar, indent=indent) lines = [] for defn in defns: lines.append("") diff --git a/meta/src/meta/target_builtins.py b/meta/src/meta/target_builtins.py index 74b923d9..f9a6308f 100644 --- a/meta/src/meta/target_builtins.py +++ b/meta/src/meta/target_builtins.py @@ -217,12 +217,6 @@ def is_builtin(name: str) -> bool: register_builtin("has_proto_field", [T, STRING], BOOLEAN) # msg.HasField(field_name) register_builtin("which_one_of", [T, STRING], STRING) # msg.WhichOneof(oneof_name) -# === Provenance tracking === -register_builtin("push_path", [INT64], VOID) -register_builtin("pop_path", [], VOID) -register_builtin("span_start", [], INT64) -register_builtin("record_span", [INT64], VOID) - # === General helpers === register_builtin("is_empty", [SequenceType(T)], BOOLEAN) # len(list) == 0 register_builtin("enum_value", [STRING, STRING], T) # enum_value(EnumType, ValueName) diff --git a/meta/src/meta/templates/parser.go.template b/meta/src/meta/templates/parser.go.template index 1153d03b..769acdac 100644 --- a/meta/src/meta/templates/parser.go.template +++ b/meta/src/meta/templates/parser.go.template @@ -15,7 +15,6 @@ import ( "math/big" "reflect" "regexp" - "sort" "strconv" "strings" @@ -83,27 +82,13 @@ func (tv TokenValue) String() string {{ // Token represents a lexer token type Token struct {{ - Type string - Value TokenValue - StartPos int - EndPos int + Type string + Value TokenValue + Pos int }} func (t Token) String() string {{ - return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.StartPos) -}} - -// Location represents a source position with 1-based line and column. -type Location struct {{ - Line int - Column int - Offset int -}} - -// Span represents a source range. -type Span struct {{ - Start Location - End Location + return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.Pos) }} // tokenSpec represents a token specification for the lexer @@ -188,15 +173,14 @@ func (l *Lexer) tokenize() {{ }} l.tokens = append(l.tokens, Token{{ - Type: best.tokenType, - Value: best.action(best.value), - StartPos: l.pos, - EndPos: best.endPos, + Type: best.tokenType, + Value: best.action(best.value), + Pos: l.pos, }}) l.pos = best.endPos }} - l.tokens = append(l.tokens, Token{{Type: "$", Value: TokenValue{{}}, StartPos: l.pos, EndPos: l.pos}}) + l.tokens = append(l.tokens, Token{{Type: "$", Value: TokenValue{{}}, Pos: l.pos}}) }} // Scanner functions for each token type @@ -317,43 +301,16 @@ type Parser struct {{ pos int idToDebugInfo map[string]map[relationIdKey]string currentFragmentID []byte - Provenance map[string]Span - path []int - lineStarts []int }} // NewParser creates a new parser -func NewParser(tokens []Token, input string) *Parser {{ +func NewParser(tokens []Token) *Parser {{ return &Parser{{ tokens: tokens, pos: 0, idToDebugInfo: make(map[string]map[relationIdKey]string), currentFragmentID: nil, - Provenance: make(map[string]Span), - path: make([]int, 0), - lineStarts: computeLineStarts(input), - }} -}} - -func computeLineStarts(text string) []int {{ - starts := []int{{0}} - for i, ch := range text {{ - if ch == '\n' {{ - starts = append(starts, i+1) - }} - }} - return starts -}} - -func pathKey(path []int) string {{ - if len(path) == 0 {{ - return "" - }} - parts := make([]string, len(path)) - for i, v := range path {{ - parts[i] = strconv.Itoa(v) }} - return strings.Join(parts, ",") }} func (p *Parser) lookahead(k int) Token {{ @@ -361,13 +318,13 @@ func (p *Parser) lookahead(k int) Token {{ if idx < len(p.tokens) {{ return p.tokens[idx] }} - return Token{{Type: "$", Value: TokenValue{{}}, StartPos: -1, EndPos: -1}} + return Token{{Type: "$", Value: TokenValue{{}}, Pos: -1}} }} func (p *Parser) consumeLiteral(expected string) {{ if !p.matchLookaheadLiteral(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) }} p.pos++ }} @@ -375,7 +332,7 @@ func (p *Parser) consumeLiteral(expected string) {{ func (p *Parser) consumeTerminal(expected string) Token {{ if !p.matchLookaheadTerminal(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) }} token := p.lookahead(0) p.pos++ @@ -399,34 +356,6 @@ func (p *Parser) matchLookaheadTerminal(terminal string, k int) bool {{ return token.Type == terminal }} -func (p *Parser) pushPath(n int) {{ - p.path = append(p.path, n) -}} - -func (p *Parser) popPath() {{ - p.path = p.path[:len(p.path)-1] -}} - -func (p *Parser) spanStart() int {{ - return p.tokens[p.pos].StartPos -}} - -func (p *Parser) recordSpan(startOffset int) {{ - endOffset := p.tokens[p.pos-1].EndPos - key := pathKey(p.path) - p.Provenance[key] = Span{{ - Start: p.makeLocation(startOffset), - End: p.makeLocation(endOffset), - }} -}} - -func (p *Parser) makeLocation(offset int) Location {{ - // Binary search for the line containing offset - line := sort.SearchInts(p.lineStarts, offset+1) - column := offset - p.lineStarts[line-1] + 1 - return Location{{Line: line, Column: column, Offset: offset}} -}} - func (p *Parser) startFragment(fragmentID *pb.FragmentId) *pb.FragmentId {{ p.currentFragmentID = fragmentID.Id return fragmentID @@ -572,8 +501,8 @@ func toPascalCase(s string) string {{ // --- Parse functions --- {parse_nonterminal_defns} -// Parse parses the input string and returns the result and provenance map -func Parse(input string) (result *pb.Transaction, provenance map[string]Span, err error) {{ +// Parse parses the input string and returns the result +func Parse(input string) (result *pb.Transaction, err error) {{ defer func() {{ if r := recover(); r != nil {{ if pe, ok := r.(ParseError); ok {{ @@ -585,15 +514,15 @@ func Parse(input string) (result *pb.Transaction, provenance map[string]Span, er }}() lexer := NewLexer(input) - parser := NewParser(lexer.tokens, input) + parser := NewParser(lexer.tokens) result = parser.parse_{start_name}() // Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens) {{ remainingToken := parser.lookahead(0) if remainingToken.Type != "$" {{ - return nil, nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} + return nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} }} }} - return result, parser.Provenance, nil + return result, nil }} diff --git a/meta/src/meta/templates/parser.jl.template b/meta/src/meta/templates/parser.jl.template index 66251c43..8f34aba1 100644 --- a/meta/src/meta/templates/parser.jl.template +++ b/meta/src/meta/templates/parser.jl.template @@ -28,25 +28,13 @@ end Base.showerror(io::IO, e::ParseError) = print(io, "ParseError: ", e.msg) -struct Location - line::Int - column::Int - offset::Int -end - -struct Span - start_::Location - end_::Location -end - struct Token type::String value::Any - start_pos::Int - end_pos::Int + pos::Int end -Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.start_pos, ")") +Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.pos, ")") mutable struct Lexer @@ -163,52 +151,38 @@ function tokenize!(lexer::Lexer) # Pick the longest match token_type, value, action, end_pos = candidates[argmax([c[4] for c in candidates])] - push!(lexer.tokens, Token(token_type, action(value), lexer.pos, end_pos)) + push!(lexer.tokens, Token(token_type, action(value), lexer.pos)) lexer.pos = end_pos end - push!(lexer.tokens, Token("\$", "", lexer.pos, lexer.pos)) + push!(lexer.tokens, Token("\$", "", lexer.pos)) return nothing end -function _compute_line_starts(text::String)::Vector{{Int}} - starts = [0] - for (i, ch) in enumerate(text) - if ch == '\n' - push!(starts, i) - end - end - return starts -end - mutable struct ParserState tokens::Vector{{Token}} pos::Int id_to_debuginfo::Dict{{Vector{{UInt8}},Vector{{Pair{{Tuple{{UInt64,UInt64}},String}}}}}} _current_fragment_id::Union{{Nothing,Vector{{UInt8}}}} _relation_id_to_name::Dict{{Tuple{{UInt64,UInt64}},String}} - provenance::Dict{{Tuple{{Vararg{{Int}}}},Span}} - _path::Vector{{Int}} - _line_starts::Vector{{Int}} - function ParserState(tokens::Vector{{Token}}, input::String) - line_starts = _compute_line_starts(input) - return new(tokens, 1, Dict(), nothing, Dict(), Dict(), Int[], line_starts) + function ParserState(tokens::Vector{{Token}}) + return new(tokens, 1, Dict(), nothing, Dict()) end end function lookahead(parser::ParserState, k::Int=0)::Token idx = parser.pos + k - return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1, -1) + return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1) end function consume_literal!(parser::ParserState, expected::String) if !match_lookahead_literal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) + throw(ParseError("Expected literal $(repr(expected)) but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) end parser.pos += 1 return nothing @@ -218,7 +192,7 @@ end function consume_terminal!(parser::ParserState, expected::String) if !match_lookahead_terminal(parser, expected, 0) token = lookahead(parser, 0) - throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.start_pos)")) + throw(ParseError("Expected terminal $expected but got $(token.type)=`$(repr(token.value))` at position $(token.pos)")) end token = lookahead(parser, 0) parser.pos += 1 @@ -245,34 +219,6 @@ function match_lookahead_terminal(parser::ParserState, terminal::String, k::Int) end -function push_path!(parser::ParserState, n::Int) - push!(parser._path, n) - return nothing -end - -function pop_path!(parser::ParserState) - pop!(parser._path) - return nothing -end - -function span_start(parser::ParserState)::Int - return parser.tokens[parser.pos].start_pos -end - -function record_span!(parser::ParserState, start_offset::Int) - end_offset = parser.tokens[parser.pos - 1].end_pos - start_loc = _make_location(parser, start_offset) - end_loc = _make_location(parser, end_offset) - parser.provenance[Tuple(parser._path)] = Span(start_loc, end_loc) - return nothing -end - -function _make_location(parser::ParserState, offset::Int)::Location - line = searchsortedlast(parser._line_starts, offset) - column = offset - parser._line_starts[line] + 1 - return Location(line, column, offset) -end - function start_fragment!(parser::ParserState, fragment_id::Proto.FragmentId) parser._current_fragment_id = fragment_id.id return fragment_id @@ -335,7 +281,7 @@ end function parse(input::String) lexer = Lexer(input) - parser = ParserState(lexer.tokens, input) + parser = ParserState(lexer.tokens) result = parse_{start_name}(parser) # Check for unconsumed tokens (except EOF) if parser.pos <= length(parser.tokens) @@ -344,7 +290,7 @@ function parse(input::String) throw(ParseError("Unexpected token at end of input: $remaining_token")) end end - return result, parser.provenance + return result end # Export main parse function and error type diff --git a/meta/src/meta/templates/parser.py.template b/meta/src/meta/templates/parser.py.template index 5b0c3381..a7847d68 100644 --- a/meta/src/meta/templates/parser.py.template +++ b/meta/src/meta/templates/parser.py.template @@ -8,12 +8,10 @@ in `meta/` or edit the protobuf specification in `proto/v1`. {command_line_comment}""" import ast -import bisect import hashlib import re from collections.abc import Sequence -from dataclasses import dataclass -from typing import Dict, List, Optional, Any, Tuple, Callable +from typing import List, Optional, Any, Tuple, Callable from decimal import Decimal from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -25,32 +23,16 @@ class ParseError(Exception): pass -@dataclass(frozen=True) -class Location: - """Source location with 1-based line and column.""" - line: int - column: int - offset: int - - -@dataclass(frozen=True) -class Span: - """Source span from start to end location.""" - start: Location - end: Location - - class Token: """Token representation.""" - def __init__(self, type: str, value: str, start_pos: int, end_pos: int): + def __init__(self, type: str, value: str, pos: int): self.type = type self.value = value - self.start_pos = start_pos - self.end_pos = end_pos + self.pos = pos def __repr__(self) -> str: - return f"Token({{self.type}}, {{self.value!r}}, {{self.start_pos}})" + return f"Token({{self.type}}, {{self.value!r}}, {{self.pos}})" _WHITESPACE_RE = re.compile(r"\s+") @@ -97,10 +79,10 @@ class Lexer: # Pick the longest match token_type, value, action, end_pos = max(candidates, key=lambda x: x[3]) - self.tokens.append(Token(token_type, action(value), self.pos, end_pos)) + self.tokens.append(Token(token_type, action(value), self.pos)) self.pos = end_pos - self.tokens.append(Token("$", "", self.pos, self.pos)) + self.tokens.append(Token("$", "", self.pos)) @staticmethod def scan_symbol(s: str) -> str: @@ -169,40 +151,27 @@ class Lexer: return logic_pb2.DecimalValue(precision=precision, scale=scale, value=value) -def _compute_line_starts(text: str) -> List[int]: - """Compute byte offsets where each line begins.""" - starts = [0] - for i, ch in enumerate(text): - if ch == '\n': - starts.append(i + 1) - return starts - - class Parser: """LL(k) recursive-descent parser with backtracking.""" - def __init__(self, tokens: List[Token], input_str: str): + def __init__(self, tokens: List[Token]): self.tokens = tokens self.pos = 0 self.id_to_debuginfo = {{}} self._current_fragment_id: bytes | None = None self._relation_id_to_name = {{}} - self.provenance: Dict[Tuple[int, ...], Span] = {{}} - self._path: List[int] = [] - self._input_str = input_str - self._line_starts = _compute_line_starts(input_str) def lookahead(self, k: int = 0) -> Token: """Get lookahead token at offset k.""" idx = self.pos + k - return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1, -1) + return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1) def consume_literal(self, expected: str) -> None: """Consume a literal token.""" if not self.match_lookahead_literal(expected, 0): token = self.lookahead(0) raise ParseError( - f"Expected literal {{expected!r}} but got {{token.type}}=`{{token.value!r}}` at position {{token.start_pos}}" + f"Expected literal {{expected!r}} but got {{token.type}}=`{{token.value!r}}` at position {{token.pos}}" ) self.pos += 1 @@ -211,7 +180,7 @@ class Parser: if not self.match_lookahead_terminal(expected, 0): token = self.lookahead(0) raise ParseError( - f"Expected terminal {{expected}} but got {{token.type}}=`{{token.value!r}}` at position {{token.start_pos}}" + f"Expected terminal {{expected}} but got {{token.type}}=`{{token.value!r}}` at position {{token.pos}}" ) token = self.lookahead(0) self.pos += 1 @@ -235,25 +204,6 @@ class Parser: token = self.lookahead(k) return token.type == terminal - def _push_path(self, n: int) -> None: - self._path.append(n) - - def _pop_path(self) -> None: - self._path.pop() - - def _span_start(self) -> int: - return self.tokens[self.pos].start_pos - - def _record_span(self, start_offset: int) -> None: - end_offset = self.tokens[self.pos - 1].end_pos - span = Span(self._make_location(start_offset), self._make_location(end_offset)) - self.provenance[tuple(self._path)] = span - - def _make_location(self, offset: int) -> Location: - line = bisect.bisect_right(self._line_starts, offset) - column = offset - self._line_starts[line - 1] + 1 - return Location(line, column, offset) - def start_fragment( self, fragment_id: fragments_pb2.FragmentId ) -> fragments_pb2.FragmentId: @@ -321,14 +271,14 @@ class Parser: # --- Parse methods --- {parse_nonterminal_defns} -def parse(input_str: str) -> Tuple[Any, Dict[Tuple[int, ...], Span]]: - """Parse input string and return (parse tree, provenance map).""" +def parse(input_str: str) -> Any: + """Parse input string and return parse tree.""" lexer = Lexer(input_str) - parser = Parser(lexer.tokens, input_str) + parser = Parser(lexer.tokens) result = parser.parse_{start_name}() # Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens): remaining_token = parser.lookahead(0) if remaining_token.type != "$": raise ParseError(f"Unexpected token at end of input: {{remaining_token}}") - return result, parser.provenance + return result diff --git a/sdks/go/test/parser_test.go b/sdks/go/test/parser_test.go index 8af81894..423016c4 100644 --- a/sdks/go/test/parser_test.go +++ b/sdks/go/test/parser_test.go @@ -6,13 +6,13 @@ import ( "strings" "testing" - lqp "logical-query-protocol/src" - pb "logical-query-protocol/src/lqp/v1" + lqp "github.com/RelationalAI/logical-query-protocol/sdks/go/src" + pb "github.com/RelationalAI/logical-query-protocol/sdks/go/src/lqp/v1" "google.golang.org/protobuf/proto" ) -// TestBasicParsing tests simple transaction parsing +// TestBasicParsing tests simple transaction parsing. func TestBasicParsing(t *testing.T) { input := ` (transaction @@ -20,7 +20,7 @@ func TestBasicParsing(t *testing.T) { (writes) (reads))) ` - result, _, err := lqp.Parse(input) + result, err := lqp.Parse(input) if err != nil { t.Fatalf("Failed to parse basic transaction: %v", err) } @@ -32,21 +32,12 @@ func TestBasicParsing(t *testing.T) { } } -// TestParseLQPFiles parses all LQP files and compares against binary snapshots +// TestParseLQPFiles parses all LQP files and compares against binary snapshots. func TestParseLQPFiles(t *testing.T) { - // Get the repository root directory (go up two levels from test directory) - testDir, err := filepath.Abs(".") - if err != nil { - t.Fatalf("Failed to get test directory: %v", err) - } - - // Go up to the repository root (from go/test to repo root) - repoRoot := filepath.Join(testDir, "..", "..") - - lqpDir := filepath.Join(repoRoot, "python-tools", "tests", "test_files", "lqp") - binDir := filepath.Join(repoRoot, "python-tools", "tests", "test_files", "bin") + root := repoRoot(t) + lqpDir := filepath.Join(root, "tests", "lqp") + binDir := filepath.Join(root, "tests", "bin") - // Read all .lqp files entries, err := os.ReadDir(lqpDir) if err != nil { t.Fatalf("Failed to read LQP directory: %v", err) @@ -58,15 +49,12 @@ func TestParseLQPFiles(t *testing.T) { } t.Run(entry.Name(), func(t *testing.T) { - // Read LQP file - lqpPath := filepath.Join(lqpDir, entry.Name()) - content, err := os.ReadFile(lqpPath) + content, err := os.ReadFile(filepath.Join(lqpDir, entry.Name())) if err != nil { t.Fatalf("Failed to read LQP file %s: %v", entry.Name(), err) } - // Parse the LQP file - result, _, err := lqp.Parse(string(content)) + result, err := lqp.Parse(string(content)) if err != nil { t.Fatalf("Failed to parse LQP file %s: %v", entry.Name(), err) } @@ -74,35 +62,29 @@ func TestParseLQPFiles(t *testing.T) { t.Fatalf("Parse returned nil for %s", entry.Name()) } - // Serialize to binary generatedBinary, err := proto.Marshal(result) if err != nil { t.Fatalf("Failed to marshal parsed result for %s: %v", entry.Name(), err) } - // Read expected binary binName := strings.Replace(entry.Name(), ".lqp", ".bin", 1) - binPath := filepath.Join(binDir, binName) - expectedBinary, err := os.ReadFile(binPath) + expectedBinary, err := os.ReadFile(filepath.Join(binDir, binName)) if err != nil { t.Logf("Warning: No binary snapshot found for %s, skipping binary comparison", entry.Name()) return } - // Compare binaries if string(generatedBinary) != string(expectedBinary) { - // If binaries don't match exactly, parse both and compare via pretty-print - // (protobuf serialization can vary in field order, especially for maps/repeated fields) expectedTransaction := &pb.Transaction{} if err := proto.Unmarshal(expectedBinary, expectedTransaction); err != nil { t.Fatalf("Failed to unmarshal expected binary for %s: %v", entry.Name(), err) } - // Compare via pretty-print since debug_info ordering may vary generatedPretty := lqp.ProgramToStr(result) expectedPretty := lqp.ProgramToStr(expectedTransaction) if generatedPretty != expectedPretty { - t.Errorf("Parsed result does not match expected for %s\n\nParsed:\n%s\n\nExpected:\n%s", entry.Name(), generatedPretty, expectedPretty) + t.Errorf("Parsed result does not match expected for %s\n\nParsed:\n%s\n\nExpected:\n%s", + entry.Name(), generatedPretty, expectedPretty) } } }) From 9542d3e4602c8174f8c010afbcfd1f51ca2dcbd5 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 25 Feb 2026 16:35:42 +0100 Subject: [PATCH 23/25] Add provenance to LQP parser --- meta/src/meta/codegen_python.py | 2 +- meta/src/meta/codegen_templates.py | 15 + meta/src/meta/parser_gen.py | 219 +- meta/src/meta/parser_gen_common.py | 6 +- meta/src/meta/parser_gen_go.py | 4 +- meta/src/meta/parser_gen_julia.py | 4 +- meta/src/meta/parser_gen_python.py | 4 +- meta/src/meta/target_builtins.py | 6 + meta/src/meta/templates/parser.go.template | 115 +- meta/src/meta/templates/parser.jl.template | 79 +- meta/src/meta/templates/parser.py.template | 117 +- .../meta/templates/pretty_printer.py.template | 12 +- meta/tests/meta/test_codegen_python.py | 6 +- sdks/go/src/parser.go | 4551 ++++++++++------- sdks/go/test/parser_test.go | 4 +- sdks/go/test/print_test.go | 6 +- sdks/go/test/provenance_test.go | 150 + .../LogicalQueryProtocol.jl/src/parser.jl | 3839 ++++++++------ .../test/parser_tests.jl | 4 +- .../test/parser_testsetup.jl | 4 +- .../test/pretty_tests.jl | 20 +- .../test/provenance_tests.jl | 100 + sdks/python/src/lqp/cli.py | 2 +- sdks/python/src/lqp/gen/parser.py | 4013 +++++++++------ sdks/python/src/lqp/gen/pretty.py | 14 +- .../src/lqp/generated_pretty_printer.py | 4056 --------------- sdks/python/tests/test_generated_pretty.py | 42 +- .../tests/test_generated_pretty_printer.py | 167 - sdks/python/tests/test_parser.py | 2 +- sdks/python/tests/test_proto_validator.py | 6 +- sdks/python/tests/test_provenance.py | 115 + 31 files changed, 8132 insertions(+), 9552 deletions(-) create mode 100644 sdks/go/test/provenance_test.go create mode 100644 sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl delete mode 100644 sdks/python/src/lqp/generated_pretty_printer.py delete mode 100644 sdks/python/tests/test_generated_pretty_printer.py create mode 100644 sdks/python/tests/test_provenance.py diff --git a/meta/src/meta/codegen_python.py b/meta/src/meta/codegen_python.py index 8b1ce0df..d69a4aec 100644 --- a/meta/src/meta/codegen_python.py +++ b/meta/src/meta/codegen_python.py @@ -174,7 +174,7 @@ def gen_list_type(self, element_type: str) -> str: return f"list[{element_type}]" def gen_option_type(self, element_type: str) -> str: - return f"Optional[{element_type}]" + return f"{element_type} | None" def gen_dict_type(self, key_type: str, value_type: str) -> str: return f"dict[{key_type}, {value_type}]" diff --git a/meta/src/meta/codegen_templates.py b/meta/src/meta/codegen_templates.py index 48c59425..560334a7 100644 --- a/meta/src/meta/codegen_templates.py +++ b/meta/src/meta/codegen_templates.py @@ -106,6 +106,11 @@ class BuiltinTemplate: "format_bytes": BuiltinTemplate('"0x" + {0}.hex()'), "pp_dispatch": BuiltinTemplate("None", ["self.pprint_dispatch({0})"]), "get_at": BuiltinTemplate("{0}[{1}]"), + # Provenance tracking + "push_path": BuiltinTemplate("None", ["self.push_path({0})"]), + "pop_path": BuiltinTemplate("None", ["self.pop_path()"]), + "span_start": BuiltinTemplate("self.span_start()"), + "record_span": BuiltinTemplate("None", ["self.record_span({0})"]), } @@ -191,6 +196,11 @@ class BuiltinTemplate: "format_bytes": BuiltinTemplate('"0x" * bytes2hex({0})'), "pp_dispatch": BuiltinTemplate("nothing", ["_pprint_dispatch(pp, {0})"]), "get_at": BuiltinTemplate("{0}[{1} + 1]"), + # Provenance tracking + "push_path": BuiltinTemplate("nothing", ["push_path!(parser, {0})"]), + "pop_path": BuiltinTemplate("nothing", ["pop_path!(parser)"]), + "span_start": BuiltinTemplate("span_start(parser)"), + "record_span": BuiltinTemplate("nothing", ["record_span!(parser, {0})"]), } @@ -280,6 +290,11 @@ class BuiltinTemplate: "format_bytes": BuiltinTemplate('fmt.Sprintf("0x%x", {0})'), "pp_dispatch": BuiltinTemplate("nil", ["p.pprintDispatch({0})"]), "get_at": BuiltinTemplate("{0}[{1}]"), + # Provenance tracking + "push_path": BuiltinTemplate("nil", ["p.pushPath(int({0}))"]), + "pop_path": BuiltinTemplate("nil", ["p.popPath()"]), + "span_start": BuiltinTemplate("int64(p.spanStart())"), + "record_span": BuiltinTemplate("nil", ["p.recordSpan(int({0}))"]), } __all__ = [ diff --git a/meta/src/meta/parser_gen.py b/meta/src/meta/parser_gen.py index 7d077b28..4d07c45c 100644 --- a/meta/src/meta/parser_gen.py +++ b/meta/src/meta/parser_gen.py @@ -90,6 +90,7 @@ Terminal, ) from .grammar_utils import is_epsilon, rhs_elements +from .proto_ast import ProtoMessage from .target import ( Assign, BaseType, @@ -100,6 +101,8 @@ ListExpr, ListType, Lit, + NewMessage, + OneOf, ParseNonterminal, ParseNonterminalDef, Seq, @@ -131,29 +134,117 @@ class AmbiguousGrammarError(Exception): pass +def _build_param_field_numbers( + action: Lambda, + proto_messages: dict[tuple[str, str], ProtoMessage] | None, +) -> dict[int, int]: + """Map lambda parameter indices to protobuf field numbers. + + Inspects the semantic action's body. When it is a NewMessage, cross-references + field names with proto_messages to find field numbers. + + Returns dict mapping parameter index to proto field number. + """ + if proto_messages is None: + return {} + body = action.body + if not isinstance(body, NewMessage): + return {} + key = (body.module, body.name) + proto_msg = proto_messages.get(key) + if proto_msg is None: + return {} + # Build name -> field number map from proto definition + name_to_number: dict[str, int] = {} + for f in proto_msg.fields: + name_to_number[f.name] = f.number + for oneof in proto_msg.oneofs: + for f in oneof.fields: + name_to_number[f.name] = f.number + # Map each message field to the lambda param that provides its value + param_names = [p.name for p in action.params] + result: dict[int, int] = {} + for field_name, field_expr in body.fields: + field_num = name_to_number.get(field_name) + if field_num is None: + continue + # Determine which param provides this field + param_name = _extract_param_name(field_expr, param_names) + if param_name is not None and param_name in param_names: + param_idx = param_names.index(param_name) + result[param_idx] = field_num + return result + + +def _extract_param_name(expr: TargetExpr, param_names: list[str]) -> str | None: + """Extract the parameter name from a field expression. + + Handles: + - Direct Var reference + - Call(OneOf(...), [Var(...)]) wrapper + - Call(Builtin(...), [Var(...), ...]) e.g. unwrap_option_or + """ + from .target import Builtin + + if isinstance(expr, Var) and expr.name in param_names: + return expr.name + if isinstance(expr, Call): + if isinstance(expr.func, OneOf) and expr.args: + return _extract_param_name(expr.args[0], param_names) + if isinstance(expr.func, Builtin) and expr.args: + return _extract_param_name(expr.args[0], param_names) + return None + + def generate_parse_functions( - grammar: Grammar, indent: str = "" + grammar: Grammar, + indent: str = "", + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, ) -> list[ParseNonterminalDef]: parser_methods = [] reachable, _ = grammar.analysis.partition_nonterminals_by_reachability() for nt in reachable: rules = grammar.rules[nt] - method_code = _generate_parse_method(nt, rules, grammar, indent) + method_code = _generate_parse_method(nt, rules, grammar, indent, proto_messages) parser_methods.append(method_code) return parser_methods +def _wrap_with_span(body: TargetExpr, return_type) -> TargetExpr: + """Wrap a nonterminal body with span_start/record_span.""" + span_var = Var(gensym("span_start"), BaseType("Int64")) + result_var = Var(gensym("result"), return_type) + return Let( + span_var, + Call(make_builtin("span_start"), []), + Let( + result_var, + body, + Seq( + [ + Call(make_builtin("record_span"), [span_var]), + result_var, + ] + ), + ), + ) + + def _generate_parse_method( - lhs: Nonterminal, rules: list[Rule], grammar: Grammar, indent: str = "" + lhs: Nonterminal, + rules: list[Rule], + grammar: Grammar, + indent: str = "", + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, ) -> ParseNonterminalDef: - """Generate parse method code as string (preserving existing logic).""" + """Generate parse method for a nonterminal with provenance tracking.""" return_type = None rhs = None follow_set = FollowSet(grammar, lhs) if len(rules) == 1: rule = rules[0] rhs = _generate_parse_rhs_ir( - rule.rhs, grammar, follow_set, True, rule.constructor + rule.rhs, grammar, follow_set, True, rule.constructor, proto_messages ) return_type = rule.constructor.return_type else: @@ -171,7 +262,6 @@ def _generate_parse_method( ], ) for i, rule in enumerate(rules): - # Ensure the return type is the same for all actions for this nonterminal. assert return_type is None or return_type == rule.constructor.return_type, ( f"Return type mismatch at rule {i}: {return_type} != {rule.constructor.return_type}" ) @@ -183,12 +273,18 @@ def _generate_parse_method( make_builtin("equal"), [Var(prediction, BaseType("Int64")), Lit(i)] ), _generate_parse_rhs_ir( - rule.rhs, grammar, follow_set, True, rule.constructor + rule.rhs, + grammar, + follow_set, + True, + rule.constructor, + proto_messages, ), tail, ) rhs = Let(Var(prediction, BaseType("Int64")), predictor, tail) assert return_type is not None + rhs = _wrap_with_span(rhs, return_type) return ParseNonterminalDef(lhs, [], return_type, rhs, indent) @@ -377,22 +473,12 @@ def _generate_parse_rhs_ir( follow_set: TerminalSequenceSet, apply_action: bool = False, action: Lambda | None = None, + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, ) -> TargetExpr: - """Generate IR for parsing an RHS. - - Args: - rhs: The RHS to parse - grammar: The grammar - follow_set: TerminalSequenceSet for computing follow lazily - apply_action: Whether to apply the semantic action - action: The semantic action to apply (required if apply_action is True) - - Returns IR expression for leaf nodes (Literal, Terminal, Nonterminal). - Returns None for complex cases that still use string generation. - """ + """Generate IR for parsing an RHS with provenance tracking.""" if isinstance(rhs, Sequence): return _generate_parse_rhs_ir_sequence( - rhs, grammar, follow_set, apply_action, action + rhs, grammar, follow_set, apply_action, action, proto_messages ) elif isinstance(rhs, LitTerminal): parse_expr = Call(make_builtin("consume_literal"), [Lit(rhs.name)]) @@ -400,7 +486,6 @@ def _generate_parse_rhs_ir( return Seq([parse_expr, apply_lambda(action, [])]) return parse_expr elif isinstance(rhs, NamedTerminal): - # Use terminal's actual type for consume_terminal instead of generic Token from .target import FunctionType terminal_type = rhs.target_type() @@ -427,14 +512,18 @@ def _generate_parse_rhs_ir( elif isinstance(rhs, Option): assert grammar is not None predictor = _build_option_predictor(grammar, rhs.rhs, follow_set) - parse_result = _generate_parse_rhs_ir(rhs.rhs, grammar, follow_set, False, None) + parse_result = _generate_parse_rhs_ir( + rhs.rhs, grammar, follow_set, False, None, proto_messages + ) return IfElse(predictor, Call(make_builtin("some"), [parse_result]), Lit(None)) elif isinstance(rhs, Star): assert grammar is not None xs = Var(gensym("xs"), ListType(rhs.rhs.target_type())) cond = Var(gensym("cond"), BaseType("Boolean")) predictor = _build_option_predictor(grammar, rhs.rhs, follow_set) - parse_item = _generate_parse_rhs_ir(rhs.rhs, grammar, follow_set, False, None) + parse_item = _generate_parse_rhs_ir( + rhs.rhs, grammar, follow_set, False, None, proto_messages + ) item = Var(gensym("item"), rhs.rhs.target_type()) loop_body = Seq( [ @@ -452,16 +541,31 @@ def _generate_parse_rhs_ir( raise NotImplementedError(f"Unsupported Rhs type: {type(rhs)}") +def _wrap_with_path(field_num: int, var: Var, inner: TargetExpr) -> list[TargetExpr]: + """Return statements that push path, assign inner to var, then pop path.""" + return [ + Call(make_builtin("push_path"), [Lit(field_num)]), + Assign(var, inner), + Call(make_builtin("pop_path"), []), + ] + + def _generate_parse_rhs_ir_sequence( rhs: Sequence, grammar: Grammar, follow_set: TerminalSequenceSet, apply_action: bool = False, action: Lambda | None = None, + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, ) -> TargetExpr: if is_epsilon(rhs): return Lit(None) + # Compute param->field_number mapping for provenance + param_field_numbers: dict[int, int] = {} + if action is not None and proto_messages is not None: + param_field_numbers = _build_param_field_numbers(action, proto_messages) + exprs = [] arg_vars = [] elems = list(rhs_elements(rhs)) @@ -473,7 +577,9 @@ def _generate_parse_rhs_ir_sequence( follow_set_i = ConcatSet(first_following, follow_set) else: follow_set_i = follow_set - elem_ir = _generate_parse_rhs_ir(elem, grammar, follow_set_i, False, None) + elem_ir = _generate_parse_rhs_ir( + elem, grammar, follow_set_i, False, None, proto_messages + ) if isinstance(elem, LitTerminal): exprs.append(elem_ir) else: @@ -487,23 +593,80 @@ def _generate_parse_rhs_ir_sequence( ) var_name = gensym("arg") var = Var(var_name, elem.target_type()) - exprs.append(Assign(var, elem_ir)) + field_num = param_field_numbers.get(non_literal_count) + if field_num is not None and isinstance(elem, Star): + # For repeated fields: push field number around the whole + # Star loop, and push/pop a 0-based index inside the loop + stmts = _wrap_star_with_index_path( + elem, var, grammar, follow_set_i, field_num, proto_messages + ) + exprs.extend(stmts) + elif field_num is not None: + exprs.extend(_wrap_with_path(field_num, var, elem_ir)) + else: + exprs.append(Assign(var, elem_ir)) arg_vars.append(var) non_literal_count += 1 if apply_action and action: lambda_call = apply_lambda(action, arg_vars) exprs.append(lambda_call) elif len(arg_vars) > 1: - # Multiple values - wrap in tuple exprs.append(Call(make_builtin("tuple"), arg_vars)) elif len(arg_vars) == 1: - # Single value - return the variable exprs.append(arg_vars[0]) else: - # no non-literal elements, return None return Lit(None) if len(exprs) == 1: return exprs[0] else: return Seq(exprs) + + +def _wrap_star_with_index_path( + star: Star, + result_var: Var, + grammar: Grammar, + follow_set: TerminalSequenceSet, + field_num: int, + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, +) -> list[TargetExpr]: + """Return statements for a Star loop wrapped with push_path(field_num) + and push_path(index)/pop_path() around each element. + Assigns the resulting list to result_var.""" + xs = Var(gensym("xs"), ListType(star.rhs.target_type())) + cond = Var(gensym("cond"), BaseType("Boolean")) + idx = Var(gensym("idx"), BaseType("Int64")) + predictor = _build_option_predictor(grammar, star.rhs, follow_set) + parse_item = _generate_parse_rhs_ir( + star.rhs, grammar, follow_set, False, None, proto_messages + ) + item = Var(gensym("item"), star.rhs.target_type()) + loop_body = Seq( + [ + Call(make_builtin("push_path"), [idx]), + Assign(item, parse_item), + Call(make_builtin("pop_path"), []), + Call(make_builtin("list_push"), [xs, item]), + Assign(idx, Call(make_builtin("add"), [idx, Lit(1)])), + Assign(cond, predictor), + ] + ) + inner = Let( + xs, + ListExpr([], star.rhs.target_type()), + Let( + cond, + predictor, + Let( + idx, + Lit(0), + Seq([While(cond, loop_body), xs]), + ), + ), + ) + return [ + Call(make_builtin("push_path"), [Lit(field_num)]), + Assign(result_var, inner), + Call(make_builtin("pop_path"), []), + ] diff --git a/meta/src/meta/parser_gen_common.py b/meta/src/meta/parser_gen_common.py index 584bcc2a..9a9d27f2 100644 --- a/meta/src/meta/parser_gen_common.py +++ b/meta/src/meta/parser_gen_common.py @@ -19,6 +19,7 @@ def generate_parser( codegen: CodeGenerator, template_path: Path, command_line: str | None = None, + proto_messages=None, ) -> str: """Generate a parser from a grammar using the given code generator and template. @@ -27,11 +28,14 @@ def generate_parser( codegen: Language-specific code generator template_path: Path to the language-specific template file command_line: Optional command line string for the file header + proto_messages: Optional proto message definitions for provenance tracking """ template = template_path.read_text() indent = codegen.parse_def_indent - defns = generate_parse_functions(grammar, indent=indent) + defns = generate_parse_functions( + grammar, indent=indent, proto_messages=proto_messages + ) lines = [] for defn in defns: lines.append("") diff --git a/meta/src/meta/parser_gen_go.py b/meta/src/meta/parser_gen_go.py index eaf5d903..1b22f80c 100644 --- a/meta/src/meta/parser_gen_go.py +++ b/meta/src/meta/parser_gen_go.py @@ -14,7 +14,9 @@ def generate_parser_go( ) -> str: """Generate LL(k) recursive-descent parser in Go.""" codegen = GoCodeGenerator(proto_messages=proto_messages) - return generate_parser(grammar, codegen, _TEMPLATE_PATH, command_line) + return generate_parser( + grammar, codegen, _TEMPLATE_PATH, command_line, proto_messages + ) __all__ = [ diff --git a/meta/src/meta/parser_gen_julia.py b/meta/src/meta/parser_gen_julia.py index c51d8eeb..f313d6ed 100644 --- a/meta/src/meta/parser_gen_julia.py +++ b/meta/src/meta/parser_gen_julia.py @@ -15,7 +15,9 @@ def generate_parser_julia( ) -> str: """Generate LL(k) recursive-descent parser in Julia.""" codegen = JuliaCodeGenerator(proto_messages=proto_messages, config=PARSER_CONFIG) - return generate_parser(grammar, codegen, _TEMPLATE_PATH, command_line) + return generate_parser( + grammar, codegen, _TEMPLATE_PATH, command_line, proto_messages + ) __all__ = [ diff --git a/meta/src/meta/parser_gen_python.py b/meta/src/meta/parser_gen_python.py index 9f8c46ea..eaa0897f 100644 --- a/meta/src/meta/parser_gen_python.py +++ b/meta/src/meta/parser_gen_python.py @@ -14,4 +14,6 @@ def generate_parser_python( ) -> str: """Generate LL(k) recursive-descent parser in Python.""" codegen = PythonCodeGenerator(proto_messages=proto_messages) - return generate_parser(grammar, codegen, _TEMPLATE_PATH, command_line) + return generate_parser( + grammar, codegen, _TEMPLATE_PATH, command_line, proto_messages + ) diff --git a/meta/src/meta/target_builtins.py b/meta/src/meta/target_builtins.py index f9a6308f..ccb7c9eb 100644 --- a/meta/src/meta/target_builtins.py +++ b/meta/src/meta/target_builtins.py @@ -249,6 +249,12 @@ def is_builtin(name: str) -> bool: # === Sequence indexing === register_builtin("get_at", [SequenceType(T), INT64], T) +# === Provenance tracking === +register_builtin("push_path", [INT64], VOID) +register_builtin("pop_path", [], VOID) +register_builtin("span_start", [], INT64) +register_builtin("record_span", [INT64], VOID) + # === Validation functions === diff --git a/meta/src/meta/templates/parser.go.template b/meta/src/meta/templates/parser.go.template index 769acdac..d1405893 100644 --- a/meta/src/meta/templates/parser.go.template +++ b/meta/src/meta/templates/parser.go.template @@ -22,6 +22,19 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) +// Location represents a source location (1-based line/column, 0-based byte offset). +type Location struct {{ + Line int + Column int + Offset int +}} + +// Span represents a source span from start to end location. +type Span struct {{ + Start Location + End Location +}} + // ParseError represents a parse error type ParseError struct {{ msg string @@ -82,13 +95,17 @@ func (tv TokenValue) String() string {{ // Token represents a lexer token type Token struct {{ - Type string - Value TokenValue - Pos int + Type string + Value TokenValue + StartPos int + EndPos int }} +// Pos returns the start position for backwards compatibility. +func (t Token) Pos() int {{ return t.StartPos }} + func (t Token) String() string {{ - return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.Pos) + return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.StartPos) }} // tokenSpec represents a token specification for the lexer @@ -173,14 +190,15 @@ func (l *Lexer) tokenize() {{ }} l.tokens = append(l.tokens, Token{{ - Type: best.tokenType, - Value: best.action(best.value), - Pos: l.pos, + Type: best.tokenType, + Value: best.action(best.value), + StartPos: l.pos, + EndPos: best.endPos, }}) l.pos = best.endPos }} - l.tokens = append(l.tokens, Token{{Type: "$", Value: TokenValue{{}}, Pos: l.pos}}) + l.tokens = append(l.tokens, Token{{Type: "$", Value: TokenValue{{}}, StartPos: l.pos, EndPos: l.pos}}) }} // Scanner functions for each token type @@ -295,22 +313,85 @@ type relationIdKey struct {{ High uint64 }} +func computeLineStarts(text string) []int {{ + starts := []int{{0}} + for i, ch := range text {{ + if ch == '\n' {{ + starts = append(starts, i+1) + }} + }} + return starts +}} + // Parser is an LL(k) recursive-descent parser type Parser struct {{ tokens []Token pos int idToDebugInfo map[string]map[relationIdKey]string currentFragmentID []byte + Provenance map[string]Span + path []int + lineStarts []int }} // NewParser creates a new parser -func NewParser(tokens []Token) *Parser {{ +func NewParser(tokens []Token, input string) *Parser {{ return &Parser{{ tokens: tokens, pos: 0, idToDebugInfo: make(map[string]map[relationIdKey]string), currentFragmentID: nil, + Provenance: make(map[string]Span), + path: nil, + lineStarts: computeLineStarts(input), + }} +}} + +func (p *Parser) makeLocation(offset int) Location {{ + lo, hi := 0, len(p.lineStarts) + for lo < hi {{ + mid := (lo + hi) / 2 + if p.lineStarts[mid] <= offset {{ + lo = mid + 1 + }} else {{ + hi = mid + }} + }} + lineIdx := lo - 1 + col := offset - p.lineStarts[lineIdx] + return Location{{Line: lineIdx + 1, Column: col + 1, Offset: offset}} +}} + +func (p *Parser) pushPath(n int) {{ + p.path = append(p.path, n) +}} + +func (p *Parser) popPath() {{ + p.path = p.path[:len(p.path)-1] +}} + +func (p *Parser) spanStart() int {{ + return p.lookahead(0).StartPos +}} + +func (p *Parser) recordSpan(startOffset int) {{ + endOffset := startOffset + if p.pos > 0 {{ + endOffset = p.tokens[p.pos-1].EndPos + }} + s := Span{{ + Start: p.makeLocation(startOffset), + End: p.makeLocation(endOffset), + }} + // Build comma-separated path key + key := "" + for i, v := range p.path {{ + if i > 0 {{ + key += "," + }} + key += fmt.Sprintf("%d", v) }} + p.Provenance[key] = s }} func (p *Parser) lookahead(k int) Token {{ @@ -318,13 +399,13 @@ func (p *Parser) lookahead(k int) Token {{ if idx < len(p.tokens) {{ return p.tokens[idx] }} - return Token{{Type: "$", Value: TokenValue{{}}, Pos: -1}} + return Token{{Type: "$", Value: TokenValue{{}}, StartPos: -1, EndPos: -1}} }} func (p *Parser) consumeLiteral(expected string) {{ if !p.matchLookaheadLiteral(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) }} p.pos++ }} @@ -332,7 +413,7 @@ func (p *Parser) consumeLiteral(expected string) {{ func (p *Parser) consumeTerminal(expected string) Token {{ if !p.matchLookaheadTerminal(expected, 0) {{ token := p.lookahead(0) - panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}}) + panic(ParseError{{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}}) }} token := p.lookahead(0) p.pos++ @@ -501,8 +582,8 @@ func toPascalCase(s string) string {{ // --- Parse functions --- {parse_nonterminal_defns} -// Parse parses the input string and returns the result -func Parse(input string) (result *pb.Transaction, err error) {{ +// Parse parses the input string and returns (result, provenance, error). +func Parse(input string) (result *pb.Transaction, provenance map[string]Span, err error) {{ defer func() {{ if r := recover(); r != nil {{ if pe, ok := r.(ParseError); ok {{ @@ -514,15 +595,15 @@ func Parse(input string) (result *pb.Transaction, err error) {{ }}() lexer := NewLexer(input) - parser := NewParser(lexer.tokens) + parser := NewParser(lexer.tokens, input) result = parser.parse_{start_name}() // Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens) {{ remainingToken := parser.lookahead(0) if remainingToken.Type != "$" {{ - return nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} + return nil, nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}} }} }} - return result, nil + return result, parser.Provenance, nil }} diff --git a/meta/src/meta/templates/parser.jl.template b/meta/src/meta/templates/parser.jl.template index 8f34aba1..19ac964f 100644 --- a/meta/src/meta/templates/parser.jl.template +++ b/meta/src/meta/templates/parser.jl.template @@ -28,13 +28,26 @@ end Base.showerror(io::IO, e::ParseError) = print(io, "ParseError: ", e.msg) +struct Location + line::Int + column::Int + offset::Int +end + +struct Span + start::Location + var"end"::Location +end + struct Token type::String value::Any - pos::Int + start_pos::Int + end_pos::Int end -Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.pos, ")") +Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.start_pos, ")") +Base.getproperty(t::Token, s::Symbol) = s === :pos ? getfield(t, :start_pos) : getfield(t, s) mutable struct Lexer @@ -151,31 +164,75 @@ function tokenize!(lexer::Lexer) # Pick the longest match token_type, value, action, end_pos = candidates[argmax([c[4] for c in candidates])] - push!(lexer.tokens, Token(token_type, action(value), lexer.pos)) + push!(lexer.tokens, Token(token_type, action(value), lexer.pos, end_pos)) lexer.pos = end_pos end - push!(lexer.tokens, Token("\$", "", lexer.pos)) + push!(lexer.tokens, Token("\$", "", lexer.pos, lexer.pos)) return nothing end +function _compute_line_starts(text::String)::Vector{{Int}} + starts = [1] + for i in eachindex(text) + if text[i] == '\n' + push!(starts, nextind(text, i)) + end + end + return starts +end + mutable struct ParserState tokens::Vector{{Token}} pos::Int id_to_debuginfo::Dict{{Vector{{UInt8}},Vector{{Pair{{Tuple{{UInt64,UInt64}},String}}}}}} _current_fragment_id::Union{{Nothing,Vector{{UInt8}}}} _relation_id_to_name::Dict{{Tuple{{UInt64,UInt64}},String}} + provenance::Dict{{Tuple{{Vararg{{Int}}}},Span}} + _path::Vector{{Int}} + _line_starts::Vector{{Int}} - function ParserState(tokens::Vector{{Token}}) - return new(tokens, 1, Dict(), nothing, Dict()) + function ParserState(tokens::Vector{{Token}}, input_str::String) + return new(tokens, 1, Dict(), nothing, Dict(), Dict(), Int[], _compute_line_starts(input_str)) end end +function _make_location(parser::ParserState, offset::Int)::Location + line_idx = searchsortedlast(parser._line_starts, offset) + col = offset - parser._line_starts[line_idx] + return Location(line_idx, col + 1, offset) +end + +function push_path!(parser::ParserState, n::Int) + push!(parser._path, n) + return nothing +end + +function pop_path!(parser::ParserState) + pop!(parser._path) + return nothing +end + +function span_start(parser::ParserState)::Int + return lookahead(parser, 0).start_pos +end + +function record_span!(parser::ParserState, start_offset::Int) + if parser.pos > 1 + end_offset = parser.tokens[parser.pos - 1].end_pos + else + end_offset = start_offset + end + s = Span(_make_location(parser, start_offset), _make_location(parser, end_offset)) + parser.provenance[Tuple(parser._path)] = s + return nothing +end + function lookahead(parser::ParserState, k::Int=0)::Token idx = parser.pos + k - return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1) + return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1, -1) end @@ -281,7 +338,7 @@ end function parse(input::String) lexer = Lexer(input) - parser = ParserState(lexer.tokens) + parser = ParserState(lexer.tokens, input) result = parse_{start_name}(parser) # Check for unconsumed tokens (except EOF) if parser.pos <= length(parser.tokens) @@ -290,14 +347,14 @@ function parse(input::String) throw(ParseError("Unexpected token at end of input: $remaining_token")) end end - return result + return result, parser.provenance end # Export main parse function and error type export parse, ParseError # Export scanner functions for testing export scan_string, scan_int, scan_float, scan_int128, scan_uint128, scan_decimal -# Export Lexer for testing -export Lexer +# Export Lexer and provenance types for testing +export Lexer, Location, Span end # module Parser diff --git a/meta/src/meta/templates/parser.py.template b/meta/src/meta/templates/parser.py.template index a7847d68..0ca8ebb7 100644 --- a/meta/src/meta/templates/parser.py.template +++ b/meta/src/meta/templates/parser.py.template @@ -8,11 +8,11 @@ in `meta/` or edit the protobuf specification in `proto/v1`. {command_line_comment}""" import ast +import bisect import hashlib import re from collections.abc import Sequence -from typing import List, Optional, Any, Tuple, Callable -from decimal import Decimal +from typing import Any from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -23,16 +23,64 @@ class ParseError(Exception): pass +class Location: + """Source location (1-based line and column, 0-based byte offset).""" + + __slots__ = ("line", "column", "offset") + + def __init__(self, line: int, column: int, offset: int): + self.line = line + self.column = column + self.offset = offset + + def __repr__(self) -> str: + return f"Location({{self.line}}, {{self.column}}, {{self.offset}})" + + def __eq__(self, other) -> bool: + if not isinstance(other, Location): + return NotImplemented + return self.line == other.line and self.column == other.column and self.offset == other.offset + + def __hash__(self) -> int: + return hash((self.line, self.column, self.offset)) + + +class Span: + """Source span from start to end location.""" + + __slots__ = ("start", "end") + + def __init__(self, start: Location, end: Location): + self.start = start + self.end = end + + def __repr__(self) -> str: + return f"Span({{self.start}}, {{self.end}})" + + def __eq__(self, other) -> bool: + if not isinstance(other, Span): + return NotImplemented + return self.start == other.start and self.end == other.end + + def __hash__(self) -> int: + return hash((self.start, self.end)) + + class Token: """Token representation.""" - def __init__(self, type: str, value: str, pos: int): + def __init__(self, type: str, value: str, start_pos: int, end_pos: int): self.type = type self.value = value - self.pos = pos + self.start_pos = start_pos + self.end_pos = end_pos + + @property + def pos(self) -> int: + return self.start_pos def __repr__(self) -> str: - return f"Token({{self.type}}, {{self.value!r}}, {{self.pos}})" + return f"Token({{self.type}}, {{self.value!r}}, {{self.start_pos}})" _WHITESPACE_RE = re.compile(r"\s+") @@ -47,7 +95,7 @@ class Lexer: def __init__(self, input_str: str): self.input = input_str self.pos = 0 - self.tokens: List[Token] = [] + self.tokens: list[Token] = [] self._tokenize() def _tokenize(self) -> None: @@ -79,10 +127,10 @@ class Lexer: # Pick the longest match token_type, value, action, end_pos = max(candidates, key=lambda x: x[3]) - self.tokens.append(Token(token_type, action(value), self.pos)) + self.tokens.append(Token(token_type, action(value), self.pos, end_pos)) self.pos = end_pos - self.tokens.append(Token("$", "", self.pos)) + self.tokens.append(Token("$", "", self.pos, self.pos)) @staticmethod def scan_symbol(s: str) -> str: @@ -151,20 +199,59 @@ class Lexer: return logic_pb2.DecimalValue(precision=precision, scale=scale, value=value) +def _compute_line_starts(text: str) -> list[int]: + """Compute byte offsets where each line starts (0-based).""" + starts = [0] + for i, ch in enumerate(text): + if ch == '\n': + starts.append(i + 1) + return starts + + class Parser: """LL(k) recursive-descent parser with backtracking.""" - def __init__(self, tokens: List[Token]): + def __init__(self, tokens: list[Token], input_str: str): self.tokens = tokens self.pos = 0 self.id_to_debuginfo = {{}} self._current_fragment_id: bytes | None = None self._relation_id_to_name = {{}} + self.provenance: dict[tuple[int, ...], Span] = {{}} + self._path: list[int] = [] + self._line_starts = _compute_line_starts(input_str) + + def _make_location(self, offset: int) -> Location: + """Convert byte offset to Location with 1-based line/column.""" + line_idx = bisect.bisect_right(self._line_starts, offset) - 1 + col = offset - self._line_starts[line_idx] + return Location(line_idx + 1, col + 1, offset) + + def push_path(self, n: int) -> None: + """Push a field number onto the provenance path.""" + self._path.append(n) + + def pop_path(self) -> None: + """Pop from the provenance path.""" + self._path.pop() + + def span_start(self) -> int: + """Return the start offset of the current token.""" + return self.lookahead(0).start_pos + + def record_span(self, start_offset: int) -> None: + """Record a span from start_offset to the previous token's end.""" + if self.pos > 0: + end_offset = self.tokens[self.pos - 1].end_pos + else: + end_offset = start_offset + span = Span(self._make_location(start_offset), self._make_location(end_offset)) + self.provenance[tuple(self._path)] = span def lookahead(self, k: int = 0) -> Token: """Get lookahead token at offset k.""" idx = self.pos + k - return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1) + return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1, -1) def consume_literal(self, expected: str) -> None: """Consume a literal token.""" @@ -229,7 +316,7 @@ class Parser: def construct_fragment( self, fragment_id: fragments_pb2.FragmentId, - declarations: List[logic_pb2.Declaration], + declarations: list[logic_pb2.Declaration], ) -> fragments_pb2.Fragment: """Construct Fragment from fragment_id, declarations, and debug info from parser state.""" # Get the debug info for this fragment @@ -271,14 +358,14 @@ class Parser: # --- Parse methods --- {parse_nonterminal_defns} -def parse(input_str: str) -> Any: - """Parse input string and return parse tree.""" +def parse(input_str: str) -> tuple[Any, dict[tuple[int, ...], Span]]: + """Parse input string and return (result, provenance) tuple.""" lexer = Lexer(input_str) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input_str) result = parser.parse_{start_name}() # Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens): remaining_token = parser.lookahead(0) if remaining_token.type != "$": raise ParseError(f"Unexpected token at end of input: {{remaining_token}}") - return result + return result, parser.provenance diff --git a/meta/src/meta/templates/pretty_printer.py.template b/meta/src/meta/templates/pretty_printer.py.template index dfcd64da..ca4ad9e8 100644 --- a/meta/src/meta/templates/pretty_printer.py.template +++ b/meta/src/meta/templates/pretty_printer.py.template @@ -12,9 +12,9 @@ from collections.abc import Sequence import sys if sys.version_info >= (3, 11): - from typing import Any, IO, Never, Optional + from typing import Any, IO, Never else: - from typing import Any, IO, NoReturn as Never, Optional + from typing import Any, IO, NoReturn as Never from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -26,7 +26,7 @@ class ParseError(Exception): class PrettyPrinter: """Pretty printer for protobuf messages.""" - def __init__(self, io: Optional[IO[str]] = None, max_width: int = 92, print_symbolic_relation_ids: bool = True): + def __init__(self, io: IO[str] | None = None, max_width: int = 92, print_symbolic_relation_ids: bool = True): self.io = io if io is not None else StringIO() self.indent_stack: list[int] = [0] self.column = 0 @@ -80,7 +80,7 @@ class PrettyPrinter: if len(self.indent_stack) > 1: self.indent_stack.pop() - def _try_flat(self, msg: Any, pretty_fn: Any) -> Optional[str]: + def _try_flat(self, msg: Any, pretty_fn: Any) -> str | None: """Try to render msg flat (space-separated). Return flat string if it fits, else None.""" msg_id = id(msg) if msg_id not in self._memo and msg_id not in self._computing: @@ -201,7 +201,7 @@ class PrettyPrinter: {pprint_dispatch_defns} {dispatch_function} -def pretty(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: +def pretty(msg: Any, io: IO[str] | None = None, max_width: int = 92) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io, max_width=max_width) printer.pretty_{start_name}(msg) @@ -209,7 +209,7 @@ def pretty(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: return printer.get_output() -def pretty_debug(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: +def pretty_debug(msg: Any, io: IO[str] | None = None, max_width: int = 92) -> str: """Pretty print a protobuf message with raw relation IDs and debug info appended as comments.""" printer = PrettyPrinter(io, max_width=max_width, print_symbolic_relation_ids=False) printer.pretty_{start_name}(msg) diff --git a/meta/tests/meta/test_codegen_python.py b/meta/tests/meta/test_codegen_python.py index a9798b7d..fcf9dfeb 100644 --- a/meta/tests/meta/test_codegen_python.py +++ b/meta/tests/meta/test_codegen_python.py @@ -462,7 +462,7 @@ def test_python_type_generation(): assert gen.gen_type(ListType(BaseType("Int64"))) == "list[int]" # Option type - assert gen.gen_type(OptionType(BaseType("String"))) == "Optional[str]" + assert gen.gen_type(OptionType(BaseType("String"))) == "str | None" # Tests for helper function codegen (FunDef from yacc grammar) @@ -492,7 +492,7 @@ def test_python_helper_function_with_if(): reset_gensym() # Equivalent to: - # def check_value(v: Optional[int], default: int) -> int: + # def check_value(v: int | None, default: int) -> int: # if v is None: # return default # return v @@ -507,7 +507,7 @@ def test_python_helper_function_with_if(): ), ) code = gen.generate_def(func) - assert "def check_value(v: Optional[int], default: int) -> int:" in code + assert "def check_value(v: int | None, default: int) -> int:" in code assert "if v is None:" in code assert "return default" in code assert "return v" in code diff --git a/sdks/go/src/parser.go b/sdks/go/src/parser.go index 32010315..a4055c07 100644 --- a/sdks/go/src/parser.go +++ b/sdks/go/src/parser.go @@ -22,6 +22,19 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) +// Location represents a source location (1-based line/column, 0-based byte offset). +type Location struct { + Line int + Column int + Offset int +} + +// Span represents a source span from start to end location. +type Span struct { + Start Location + End Location +} + // ParseError represents a parse error type ParseError struct { msg string @@ -82,13 +95,17 @@ func (tv TokenValue) String() string { // Token represents a lexer token type Token struct { - Type string - Value TokenValue - Pos int + Type string + Value TokenValue + StartPos int + EndPos int } +// Pos returns the start position for backwards compatibility. +func (t Token) Pos() int { return t.StartPos } + func (t Token) String() string { - return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.Pos) + return fmt.Sprintf("Token(%s, %v, %d)", t.Type, t.Value, t.StartPos) } // tokenSpec represents a token specification for the lexer @@ -199,14 +216,15 @@ func (l *Lexer) tokenize() { } l.tokens = append(l.tokens, Token{ - Type: best.tokenType, - Value: best.action(best.value), - Pos: l.pos, + Type: best.tokenType, + Value: best.action(best.value), + StartPos: l.pos, + EndPos: best.endPos, }) l.pos = best.endPos } - l.tokens = append(l.tokens, Token{Type: "$", Value: TokenValue{}, Pos: l.pos}) + l.tokens = append(l.tokens, Token{Type: "$", Value: TokenValue{}, StartPos: l.pos, EndPos: l.pos}) } // Scanner functions for each token type @@ -321,22 +339,85 @@ type relationIdKey struct { High uint64 } +func computeLineStarts(text string) []int { + starts := []int{0} + for i, ch := range text { + if ch == '\n' { + starts = append(starts, i+1) + } + } + return starts +} + // Parser is an LL(k) recursive-descent parser type Parser struct { tokens []Token pos int idToDebugInfo map[string]map[relationIdKey]string currentFragmentID []byte + Provenance map[string]Span + path []int + lineStarts []int } // NewParser creates a new parser -func NewParser(tokens []Token) *Parser { +func NewParser(tokens []Token, input string) *Parser { return &Parser{ tokens: tokens, pos: 0, idToDebugInfo: make(map[string]map[relationIdKey]string), currentFragmentID: nil, + Provenance: make(map[string]Span), + path: nil, + lineStarts: computeLineStarts(input), + } +} + +func (p *Parser) makeLocation(offset int) Location { + lo, hi := 0, len(p.lineStarts) + for lo < hi { + mid := (lo + hi) / 2 + if p.lineStarts[mid] <= offset { + lo = mid + 1 + } else { + hi = mid + } + } + lineIdx := lo - 1 + col := offset - p.lineStarts[lineIdx] + return Location{Line: lineIdx + 1, Column: col + 1, Offset: offset} +} + +func (p *Parser) pushPath(n int) { + p.path = append(p.path, n) +} + +func (p *Parser) popPath() { + p.path = p.path[:len(p.path)-1] +} + +func (p *Parser) spanStart() int { + return p.lookahead(0).StartPos +} + +func (p *Parser) recordSpan(startOffset int) { + endOffset := startOffset + if p.pos > 0 { + endOffset = p.tokens[p.pos-1].EndPos } + s := Span{ + Start: p.makeLocation(startOffset), + End: p.makeLocation(endOffset), + } + // Build comma-separated path key + key := "" + for i, v := range p.path { + if i > 0 { + key += "," + } + key += fmt.Sprintf("%d", v) + } + p.Provenance[key] = s } func (p *Parser) lookahead(k int) Token { @@ -344,13 +425,13 @@ func (p *Parser) lookahead(k int) Token { if idx < len(p.tokens) { return p.tokens[idx] } - return Token{Type: "$", Value: TokenValue{}, Pos: -1} + return Token{Type: "$", Value: TokenValue{}, StartPos: -1, EndPos: -1} } func (p *Parser) consumeLiteral(expected string) { if !p.matchLookaheadLiteral(expected, 0) { token := p.lookahead(0) - panic(ParseError{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}) + panic(ParseError{msg: fmt.Sprintf("Expected literal %q but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}) } p.pos++ } @@ -358,7 +439,7 @@ func (p *Parser) consumeLiteral(expected string) { func (p *Parser) consumeTerminal(expected string) Token { if !p.matchLookaheadTerminal(expected, 0) { token := p.lookahead(0) - panic(ParseError{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.Pos)}) + panic(ParseError{msg: fmt.Sprintf("Expected terminal %s but got %s=`%v` at position %d", expected, token.Type, token.Value, token.StartPos)}) } token := p.lookahead(0) p.pos++ @@ -524,150 +605,150 @@ func toPascalCase(s string) string { // --- Helper functions --- func (p *Parser) _extract_value_int32(value *pb.Value, default_ int64) int32 { - var _t1322 interface{} + var _t1846 interface{} if (value != nil && hasProtoField(value, "int_value")) { return int32(value.GetIntValue()) } - _ = _t1322 + _ = _t1846 return int32(default_) } func (p *Parser) _extract_value_int64(value *pb.Value, default_ int64) int64 { - var _t1323 interface{} + var _t1847 interface{} if (value != nil && hasProtoField(value, "int_value")) { return value.GetIntValue() } - _ = _t1323 + _ = _t1847 return default_ } func (p *Parser) _extract_value_string(value *pb.Value, default_ string) string { - var _t1324 interface{} + var _t1848 interface{} if (value != nil && hasProtoField(value, "string_value")) { return value.GetStringValue() } - _ = _t1324 + _ = _t1848 return default_ } func (p *Parser) _extract_value_boolean(value *pb.Value, default_ bool) bool { - var _t1325 interface{} + var _t1849 interface{} if (value != nil && hasProtoField(value, "boolean_value")) { return value.GetBooleanValue() } - _ = _t1325 + _ = _t1849 return default_ } func (p *Parser) _extract_value_string_list(value *pb.Value, default_ []string) []string { - var _t1326 interface{} + var _t1850 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []string{value.GetStringValue()} } - _ = _t1326 + _ = _t1850 return default_ } func (p *Parser) _try_extract_value_int64(value *pb.Value) *int64 { - var _t1327 interface{} + var _t1851 interface{} if (value != nil && hasProtoField(value, "int_value")) { return ptr(value.GetIntValue()) } - _ = _t1327 + _ = _t1851 return nil } func (p *Parser) _try_extract_value_float64(value *pb.Value) *float64 { - var _t1328 interface{} + var _t1852 interface{} if (value != nil && hasProtoField(value, "float_value")) { return ptr(value.GetFloatValue()) } - _ = _t1328 + _ = _t1852 return nil } func (p *Parser) _try_extract_value_bytes(value *pb.Value) []byte { - var _t1329 interface{} + var _t1853 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []byte(value.GetStringValue()) } - _ = _t1329 + _ = _t1853 return nil } func (p *Parser) _try_extract_value_uint128(value *pb.Value) *pb.UInt128Value { - var _t1330 interface{} + var _t1854 interface{} if (value != nil && hasProtoField(value, "uint128_value")) { return value.GetUint128Value() } - _ = _t1330 + _ = _t1854 return nil } func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig { config := dictFromList(config_dict) - _t1331 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) - header_row := _t1331 - _t1332 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) - skip := _t1332 - _t1333 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") - new_line := _t1333 - _t1334 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") - delimiter := _t1334 - _t1335 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") - quotechar := _t1335 - _t1336 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") - escapechar := _t1336 - _t1337 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") - comment := _t1337 - _t1338 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) - missing_strings := _t1338 - _t1339 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") - decimal_separator := _t1339 - _t1340 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") - encoding := _t1340 - _t1341 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") - compression := _t1341 - _t1342 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} - return _t1342 + _t1855 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) + header_row := _t1855 + _t1856 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) + skip := _t1856 + _t1857 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") + new_line := _t1857 + _t1858 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") + delimiter := _t1858 + _t1859 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") + quotechar := _t1859 + _t1860 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") + escapechar := _t1860 + _t1861 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") + comment := _t1861 + _t1862 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) + missing_strings := _t1862 + _t1863 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") + decimal_separator := _t1863 + _t1864 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") + encoding := _t1864 + _t1865 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") + compression := _t1865 + _t1866 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} + return _t1866 } func (p *Parser) construct_betree_info(key_types []*pb.Type, value_types []*pb.Type, config_dict [][]interface{}) *pb.BeTreeInfo { config := dictFromList(config_dict) - _t1343 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) - epsilon := _t1343 - _t1344 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) - max_pivots := _t1344 - _t1345 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) - max_deltas := _t1345 - _t1346 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) - max_leaf := _t1346 - _t1347 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} - storage_config := _t1347 - _t1348 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) - root_pageid := _t1348 - _t1349 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) - inline_data := _t1349 - _t1350 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) - element_count := _t1350 - _t1351 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) - tree_height := _t1351 - _t1352 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} + _t1867 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) + epsilon := _t1867 + _t1868 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) + max_pivots := _t1868 + _t1869 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) + max_deltas := _t1869 + _t1870 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) + max_leaf := _t1870 + _t1871 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} + storage_config := _t1871 + _t1872 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) + root_pageid := _t1872 + _t1873 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) + inline_data := _t1873 + _t1874 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) + element_count := _t1874 + _t1875 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) + tree_height := _t1875 + _t1876 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} if root_pageid != nil { - _t1352.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} + _t1876.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} } else { - _t1352.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} + _t1876.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} } - relation_locator := _t1352 - _t1353 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} - return _t1353 + relation_locator := _t1876 + _t1877 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} + return _t1877 } func (p *Parser) default_configure() *pb.Configure { - _t1354 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} - ivm_config := _t1354 - _t1355 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} - return _t1355 + _t1878 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} + ivm_config := _t1878 + _t1879 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} + return _t1879 } func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure { @@ -689,3060 +770,3658 @@ func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure } } } - _t1356 := &pb.IVMConfig{Level: maintenance_level} - ivm_config := _t1356 - _t1357 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) - semantics_version := _t1357 - _t1358 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} - return _t1358 + _t1880 := &pb.IVMConfig{Level: maintenance_level} + ivm_config := _t1880 + _t1881 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) + semantics_version := _t1881 + _t1882 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} + return _t1882 } func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, config_dict [][]interface{}) *pb.ExportCSVConfig { config := dictFromList(config_dict) - _t1359 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) - partition_size := _t1359 - _t1360 := p._extract_value_string(dictGetValue(config, "compression"), "") - compression := _t1360 - _t1361 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) - syntax_header_row := _t1361 - _t1362 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") - syntax_missing_string := _t1362 - _t1363 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") - syntax_delim := _t1363 - _t1364 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") - syntax_quotechar := _t1364 - _t1365 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") - syntax_escapechar := _t1365 - _t1366 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} - return _t1366 + _t1883 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) + partition_size := _t1883 + _t1884 := p._extract_value_string(dictGetValue(config, "compression"), "") + compression := _t1884 + _t1885 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) + syntax_header_row := _t1885 + _t1886 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") + syntax_missing_string := _t1886 + _t1887 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") + syntax_delim := _t1887 + _t1888 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") + syntax_quotechar := _t1888 + _t1889 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") + syntax_escapechar := _t1889 + _t1890 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} + return _t1890 } // --- Parse functions --- func (p *Parser) parse_transaction() *pb.Transaction { + span_start602 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("transaction") - var _t712 *pb.Configure + p.pushPath(int(2)) + var _t1236 *pb.Configure if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("configure", 1)) { - _t713 := p.parse_configure() - _t712 = _t713 + _t1237 := p.parse_configure() + _t1236 = _t1237 } - configure356 := _t712 - var _t714 *pb.Sync + configure592 := _t1236 + p.popPath() + p.pushPath(int(3)) + var _t1238 *pb.Sync if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("sync", 1)) { - _t715 := p.parse_sync() - _t714 = _t715 - } - sync357 := _t714 - xs358 := []*pb.Epoch{} - cond359 := p.matchLookaheadLiteral("(", 0) - for cond359 { - _t716 := p.parse_epoch() - item360 := _t716 - xs358 = append(xs358, item360) - cond359 = p.matchLookaheadLiteral("(", 0) - } - epochs361 := xs358 + _t1239 := p.parse_sync() + _t1238 = _t1239 + } + sync593 := _t1238 + p.popPath() + p.pushPath(int(1)) + xs598 := []*pb.Epoch{} + cond599 := p.matchLookaheadLiteral("(", 0) + idx600 := 0 + for cond599 { + p.pushPath(int(idx600)) + _t1240 := p.parse_epoch() + item601 := _t1240 + p.popPath() + xs598 = append(xs598, item601) + idx600 = (idx600 + 1) + cond599 = p.matchLookaheadLiteral("(", 0) + } + epochs597 := xs598 + p.popPath() p.consumeLiteral(")") - _t717 := p.default_configure() - _t718 := configure356 - if configure356 == nil { - _t718 = _t717 + _t1241 := p.default_configure() + _t1242 := configure592 + if configure592 == nil { + _t1242 = _t1241 } - _t719 := &pb.Transaction{Epochs: epochs361, Configure: _t718, Sync: sync357} - return _t719 + _t1243 := &pb.Transaction{Epochs: epochs597, Configure: _t1242, Sync: sync593} + result603 := _t1243 + p.recordSpan(int(span_start602)) + return result603 } func (p *Parser) parse_configure() *pb.Configure { + span_start605 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("configure") - _t720 := p.parse_config_dict() - config_dict362 := _t720 + _t1244 := p.parse_config_dict() + config_dict604 := _t1244 p.consumeLiteral(")") - _t721 := p.construct_configure(config_dict362) - return _t721 + _t1245 := p.construct_configure(config_dict604) + result606 := _t1245 + p.recordSpan(int(span_start605)) + return result606 } func (p *Parser) parse_config_dict() [][]interface{} { + span_start611 := int64(p.spanStart()) p.consumeLiteral("{") - xs363 := [][]interface{}{} - cond364 := p.matchLookaheadLiteral(":", 0) - for cond364 { - _t722 := p.parse_config_key_value() - item365 := _t722 - xs363 = append(xs363, item365) - cond364 = p.matchLookaheadLiteral(":", 0) - } - config_key_values366 := xs363 + xs607 := [][]interface{}{} + cond608 := p.matchLookaheadLiteral(":", 0) + for cond608 { + _t1246 := p.parse_config_key_value() + item609 := _t1246 + xs607 = append(xs607, item609) + cond608 = p.matchLookaheadLiteral(":", 0) + } + config_key_values610 := xs607 p.consumeLiteral("}") - return config_key_values366 + result612 := config_key_values610 + p.recordSpan(int(span_start611)) + return result612 } func (p *Parser) parse_config_key_value() []interface{} { + span_start615 := int64(p.spanStart()) p.consumeLiteral(":") - symbol367 := p.consumeTerminal("SYMBOL").Value.str - _t723 := p.parse_value() - value368 := _t723 - return []interface{}{symbol367, value368} + symbol613 := p.consumeTerminal("SYMBOL").Value.str + _t1247 := p.parse_value() + value614 := _t1247 + result616 := []interface{}{symbol613, value614} + p.recordSpan(int(span_start615)) + return result616 } func (p *Parser) parse_value() *pb.Value { - var _t724 int64 + span_start627 := int64(p.spanStart()) + var _t1248 int64 if p.matchLookaheadLiteral("true", 0) { - _t724 = 9 + _t1248 = 9 } else { - var _t725 int64 + var _t1249 int64 if p.matchLookaheadLiteral("missing", 0) { - _t725 = 8 + _t1249 = 8 } else { - var _t726 int64 + var _t1250 int64 if p.matchLookaheadLiteral("false", 0) { - _t726 = 9 + _t1250 = 9 } else { - var _t727 int64 + var _t1251 int64 if p.matchLookaheadLiteral("(", 0) { - var _t728 int64 + var _t1252 int64 if p.matchLookaheadLiteral("datetime", 1) { - _t728 = 1 + _t1252 = 1 } else { - var _t729 int64 + var _t1253 int64 if p.matchLookaheadLiteral("date", 1) { - _t729 = 0 + _t1253 = 0 } else { - _t729 = -1 + _t1253 = -1 } - _t728 = _t729 + _t1252 = _t1253 } - _t727 = _t728 + _t1251 = _t1252 } else { - var _t730 int64 + var _t1254 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t730 = 5 + _t1254 = 5 } else { - var _t731 int64 + var _t1255 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t731 = 2 + _t1255 = 2 } else { - var _t732 int64 + var _t1256 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t732 = 6 + _t1256 = 6 } else { - var _t733 int64 + var _t1257 int64 if p.matchLookaheadTerminal("INT", 0) { - _t733 = 3 + _t1257 = 3 } else { - var _t734 int64 + var _t1258 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t734 = 4 + _t1258 = 4 } else { - var _t735 int64 + var _t1259 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t735 = 7 + _t1259 = 7 } else { - _t735 = -1 + _t1259 = -1 } - _t734 = _t735 + _t1258 = _t1259 } - _t733 = _t734 + _t1257 = _t1258 } - _t732 = _t733 + _t1256 = _t1257 } - _t731 = _t732 + _t1255 = _t1256 } - _t730 = _t731 + _t1254 = _t1255 } - _t727 = _t730 + _t1251 = _t1254 } - _t726 = _t727 + _t1250 = _t1251 } - _t725 = _t726 + _t1249 = _t1250 } - _t724 = _t725 - } - prediction369 := _t724 - var _t736 *pb.Value - if prediction369 == 9 { - _t737 := p.parse_boolean_value() - boolean_value378 := _t737 - _t738 := &pb.Value{} - _t738.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value378} - _t736 = _t738 + _t1248 = _t1249 + } + prediction617 := _t1248 + var _t1260 *pb.Value + if prediction617 == 9 { + _t1261 := p.parse_boolean_value() + boolean_value626 := _t1261 + _t1262 := &pb.Value{} + _t1262.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value626} + _t1260 = _t1262 } else { - var _t739 *pb.Value - if prediction369 == 8 { + var _t1263 *pb.Value + if prediction617 == 8 { p.consumeLiteral("missing") - _t740 := &pb.MissingValue{} - _t741 := &pb.Value{} - _t741.Value = &pb.Value_MissingValue{MissingValue: _t740} - _t739 = _t741 + _t1264 := &pb.MissingValue{} + _t1265 := &pb.Value{} + _t1265.Value = &pb.Value_MissingValue{MissingValue: _t1264} + _t1263 = _t1265 } else { - var _t742 *pb.Value - if prediction369 == 7 { - decimal377 := p.consumeTerminal("DECIMAL").Value.decimal - _t743 := &pb.Value{} - _t743.Value = &pb.Value_DecimalValue{DecimalValue: decimal377} - _t742 = _t743 + var _t1266 *pb.Value + if prediction617 == 7 { + decimal625 := p.consumeTerminal("DECIMAL").Value.decimal + _t1267 := &pb.Value{} + _t1267.Value = &pb.Value_DecimalValue{DecimalValue: decimal625} + _t1266 = _t1267 } else { - var _t744 *pb.Value - if prediction369 == 6 { - int128376 := p.consumeTerminal("INT128").Value.int128 - _t745 := &pb.Value{} - _t745.Value = &pb.Value_Int128Value{Int128Value: int128376} - _t744 = _t745 + var _t1268 *pb.Value + if prediction617 == 6 { + int128624 := p.consumeTerminal("INT128").Value.int128 + _t1269 := &pb.Value{} + _t1269.Value = &pb.Value_Int128Value{Int128Value: int128624} + _t1268 = _t1269 } else { - var _t746 *pb.Value - if prediction369 == 5 { - uint128375 := p.consumeTerminal("UINT128").Value.uint128 - _t747 := &pb.Value{} - _t747.Value = &pb.Value_Uint128Value{Uint128Value: uint128375} - _t746 = _t747 + var _t1270 *pb.Value + if prediction617 == 5 { + uint128623 := p.consumeTerminal("UINT128").Value.uint128 + _t1271 := &pb.Value{} + _t1271.Value = &pb.Value_Uint128Value{Uint128Value: uint128623} + _t1270 = _t1271 } else { - var _t748 *pb.Value - if prediction369 == 4 { - float374 := p.consumeTerminal("FLOAT").Value.f64 - _t749 := &pb.Value{} - _t749.Value = &pb.Value_FloatValue{FloatValue: float374} - _t748 = _t749 + var _t1272 *pb.Value + if prediction617 == 4 { + float622 := p.consumeTerminal("FLOAT").Value.f64 + _t1273 := &pb.Value{} + _t1273.Value = &pb.Value_FloatValue{FloatValue: float622} + _t1272 = _t1273 } else { - var _t750 *pb.Value - if prediction369 == 3 { - int373 := p.consumeTerminal("INT").Value.i64 - _t751 := &pb.Value{} - _t751.Value = &pb.Value_IntValue{IntValue: int373} - _t750 = _t751 + var _t1274 *pb.Value + if prediction617 == 3 { + int621 := p.consumeTerminal("INT").Value.i64 + _t1275 := &pb.Value{} + _t1275.Value = &pb.Value_IntValue{IntValue: int621} + _t1274 = _t1275 } else { - var _t752 *pb.Value - if prediction369 == 2 { - string372 := p.consumeTerminal("STRING").Value.str - _t753 := &pb.Value{} - _t753.Value = &pb.Value_StringValue{StringValue: string372} - _t752 = _t753 + var _t1276 *pb.Value + if prediction617 == 2 { + string620 := p.consumeTerminal("STRING").Value.str + _t1277 := &pb.Value{} + _t1277.Value = &pb.Value_StringValue{StringValue: string620} + _t1276 = _t1277 } else { - var _t754 *pb.Value - if prediction369 == 1 { - _t755 := p.parse_datetime() - datetime371 := _t755 - _t756 := &pb.Value{} - _t756.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime371} - _t754 = _t756 + var _t1278 *pb.Value + if prediction617 == 1 { + _t1279 := p.parse_datetime() + datetime619 := _t1279 + _t1280 := &pb.Value{} + _t1280.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime619} + _t1278 = _t1280 } else { - var _t757 *pb.Value - if prediction369 == 0 { - _t758 := p.parse_date() - date370 := _t758 - _t759 := &pb.Value{} - _t759.Value = &pb.Value_DateValue{DateValue: date370} - _t757 = _t759 + var _t1281 *pb.Value + if prediction617 == 0 { + _t1282 := p.parse_date() + date618 := _t1282 + _t1283 := &pb.Value{} + _t1283.Value = &pb.Value_DateValue{DateValue: date618} + _t1281 = _t1283 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t754 = _t757 + _t1278 = _t1281 } - _t752 = _t754 + _t1276 = _t1278 } - _t750 = _t752 + _t1274 = _t1276 } - _t748 = _t750 + _t1272 = _t1274 } - _t746 = _t748 + _t1270 = _t1272 } - _t744 = _t746 + _t1268 = _t1270 } - _t742 = _t744 + _t1266 = _t1268 } - _t739 = _t742 + _t1263 = _t1266 } - _t736 = _t739 + _t1260 = _t1263 } - return _t736 + result628 := _t1260 + p.recordSpan(int(span_start627)) + return result628 } func (p *Parser) parse_date() *pb.DateValue { + span_start632 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("date") - int379 := p.consumeTerminal("INT").Value.i64 - int_3380 := p.consumeTerminal("INT").Value.i64 - int_4381 := p.consumeTerminal("INT").Value.i64 + p.pushPath(int(1)) + int629 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3630 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(3)) + int_4631 := p.consumeTerminal("INT").Value.i64 + p.popPath() p.consumeLiteral(")") - _t760 := &pb.DateValue{Year: int32(int379), Month: int32(int_3380), Day: int32(int_4381)} - return _t760 + _t1284 := &pb.DateValue{Year: int32(int629), Month: int32(int_3630), Day: int32(int_4631)} + result633 := _t1284 + p.recordSpan(int(span_start632)) + return result633 } func (p *Parser) parse_datetime() *pb.DateTimeValue { + span_start641 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("datetime") - int382 := p.consumeTerminal("INT").Value.i64 - int_3383 := p.consumeTerminal("INT").Value.i64 - int_4384 := p.consumeTerminal("INT").Value.i64 - int_5385 := p.consumeTerminal("INT").Value.i64 - int_6386 := p.consumeTerminal("INT").Value.i64 - int_7387 := p.consumeTerminal("INT").Value.i64 - var _t761 *int64 + p.pushPath(int(1)) + int634 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3635 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(3)) + int_4636 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(4)) + int_5637 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(5)) + int_6638 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(6)) + int_7639 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(7)) + var _t1285 *int64 if p.matchLookaheadTerminal("INT", 0) { - _t761 = ptr(p.consumeTerminal("INT").Value.i64) + _t1285 = ptr(p.consumeTerminal("INT").Value.i64) } - int_8388 := _t761 + int_8640 := _t1285 + p.popPath() p.consumeLiteral(")") - _t762 := &pb.DateTimeValue{Year: int32(int382), Month: int32(int_3383), Day: int32(int_4384), Hour: int32(int_5385), Minute: int32(int_6386), Second: int32(int_7387), Microsecond: int32(deref(int_8388, 0))} - return _t762 + _t1286 := &pb.DateTimeValue{Year: int32(int634), Month: int32(int_3635), Day: int32(int_4636), Hour: int32(int_5637), Minute: int32(int_6638), Second: int32(int_7639), Microsecond: int32(deref(int_8640, 0))} + result642 := _t1286 + p.recordSpan(int(span_start641)) + return result642 } func (p *Parser) parse_boolean_value() bool { - var _t763 int64 + span_start644 := int64(p.spanStart()) + var _t1287 int64 if p.matchLookaheadLiteral("true", 0) { - _t763 = 0 + _t1287 = 0 } else { - var _t764 int64 + var _t1288 int64 if p.matchLookaheadLiteral("false", 0) { - _t764 = 1 + _t1288 = 1 } else { - _t764 = -1 + _t1288 = -1 } - _t763 = _t764 + _t1287 = _t1288 } - prediction389 := _t763 - var _t765 bool - if prediction389 == 1 { + prediction643 := _t1287 + var _t1289 bool + if prediction643 == 1 { p.consumeLiteral("false") - _t765 = false + _t1289 = false } else { - var _t766 bool - if prediction389 == 0 { + var _t1290 bool + if prediction643 == 0 { p.consumeLiteral("true") - _t766 = true + _t1290 = true } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in boolean_value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t765 = _t766 + _t1289 = _t1290 } - return _t765 + result645 := _t1289 + p.recordSpan(int(span_start644)) + return result645 } func (p *Parser) parse_sync() *pb.Sync { + span_start654 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("sync") - xs390 := []*pb.FragmentId{} - cond391 := p.matchLookaheadLiteral(":", 0) - for cond391 { - _t767 := p.parse_fragment_id() - item392 := _t767 - xs390 = append(xs390, item392) - cond391 = p.matchLookaheadLiteral(":", 0) - } - fragment_ids393 := xs390 + p.pushPath(int(1)) + xs650 := []*pb.FragmentId{} + cond651 := p.matchLookaheadLiteral(":", 0) + idx652 := 0 + for cond651 { + p.pushPath(int(idx652)) + _t1291 := p.parse_fragment_id() + item653 := _t1291 + p.popPath() + xs650 = append(xs650, item653) + idx652 = (idx652 + 1) + cond651 = p.matchLookaheadLiteral(":", 0) + } + fragment_ids649 := xs650 + p.popPath() p.consumeLiteral(")") - _t768 := &pb.Sync{Fragments: fragment_ids393} - return _t768 + _t1292 := &pb.Sync{Fragments: fragment_ids649} + result655 := _t1292 + p.recordSpan(int(span_start654)) + return result655 } func (p *Parser) parse_fragment_id() *pb.FragmentId { + span_start657 := int64(p.spanStart()) p.consumeLiteral(":") - symbol394 := p.consumeTerminal("SYMBOL").Value.str - return &pb.FragmentId{Id: []byte(symbol394)} + symbol656 := p.consumeTerminal("SYMBOL").Value.str + result658 := &pb.FragmentId{Id: []byte(symbol656)} + p.recordSpan(int(span_start657)) + return result658 } func (p *Parser) parse_epoch() *pb.Epoch { + span_start661 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("epoch") - var _t769 []*pb.Write + p.pushPath(int(1)) + var _t1293 []*pb.Write if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("writes", 1)) { - _t770 := p.parse_epoch_writes() - _t769 = _t770 + _t1294 := p.parse_epoch_writes() + _t1293 = _t1294 } - epoch_writes395 := _t769 - var _t771 []*pb.Read + epoch_writes659 := _t1293 + p.popPath() + p.pushPath(int(2)) + var _t1295 []*pb.Read if p.matchLookaheadLiteral("(", 0) { - _t772 := p.parse_epoch_reads() - _t771 = _t772 + _t1296 := p.parse_epoch_reads() + _t1295 = _t1296 } - epoch_reads396 := _t771 + epoch_reads660 := _t1295 + p.popPath() p.consumeLiteral(")") - _t773 := epoch_writes395 - if epoch_writes395 == nil { - _t773 = []*pb.Write{} + _t1297 := epoch_writes659 + if epoch_writes659 == nil { + _t1297 = []*pb.Write{} } - _t774 := epoch_reads396 - if epoch_reads396 == nil { - _t774 = []*pb.Read{} + _t1298 := epoch_reads660 + if epoch_reads660 == nil { + _t1298 = []*pb.Read{} } - _t775 := &pb.Epoch{Writes: _t773, Reads: _t774} - return _t775 + _t1299 := &pb.Epoch{Writes: _t1297, Reads: _t1298} + result662 := _t1299 + p.recordSpan(int(span_start661)) + return result662 } func (p *Parser) parse_epoch_writes() []*pb.Write { + span_start667 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("writes") - xs397 := []*pb.Write{} - cond398 := p.matchLookaheadLiteral("(", 0) - for cond398 { - _t776 := p.parse_write() - item399 := _t776 - xs397 = append(xs397, item399) - cond398 = p.matchLookaheadLiteral("(", 0) - } - writes400 := xs397 + xs663 := []*pb.Write{} + cond664 := p.matchLookaheadLiteral("(", 0) + for cond664 { + _t1300 := p.parse_write() + item665 := _t1300 + xs663 = append(xs663, item665) + cond664 = p.matchLookaheadLiteral("(", 0) + } + writes666 := xs663 p.consumeLiteral(")") - return writes400 + result668 := writes666 + p.recordSpan(int(span_start667)) + return result668 } func (p *Parser) parse_write() *pb.Write { - var _t777 int64 + span_start674 := int64(p.spanStart()) + var _t1301 int64 if p.matchLookaheadLiteral("(", 0) { - var _t778 int64 + var _t1302 int64 if p.matchLookaheadLiteral("undefine", 1) { - _t778 = 1 + _t1302 = 1 } else { - var _t779 int64 + var _t1303 int64 if p.matchLookaheadLiteral("snapshot", 1) { - _t779 = 3 + _t1303 = 3 } else { - var _t780 int64 + var _t1304 int64 if p.matchLookaheadLiteral("define", 1) { - _t780 = 0 + _t1304 = 0 } else { - var _t781 int64 + var _t1305 int64 if p.matchLookaheadLiteral("context", 1) { - _t781 = 2 + _t1305 = 2 } else { - _t781 = -1 + _t1305 = -1 } - _t780 = _t781 + _t1304 = _t1305 } - _t779 = _t780 + _t1303 = _t1304 } - _t778 = _t779 + _t1302 = _t1303 } - _t777 = _t778 + _t1301 = _t1302 } else { - _t777 = -1 - } - prediction401 := _t777 - var _t782 *pb.Write - if prediction401 == 3 { - _t783 := p.parse_snapshot() - snapshot405 := _t783 - _t784 := &pb.Write{} - _t784.WriteType = &pb.Write_Snapshot{Snapshot: snapshot405} - _t782 = _t784 + _t1301 = -1 + } + prediction669 := _t1301 + var _t1306 *pb.Write + if prediction669 == 3 { + _t1307 := p.parse_snapshot() + snapshot673 := _t1307 + _t1308 := &pb.Write{} + _t1308.WriteType = &pb.Write_Snapshot{Snapshot: snapshot673} + _t1306 = _t1308 } else { - var _t785 *pb.Write - if prediction401 == 2 { - _t786 := p.parse_context() - context404 := _t786 - _t787 := &pb.Write{} - _t787.WriteType = &pb.Write_Context{Context: context404} - _t785 = _t787 + var _t1309 *pb.Write + if prediction669 == 2 { + _t1310 := p.parse_context() + context672 := _t1310 + _t1311 := &pb.Write{} + _t1311.WriteType = &pb.Write_Context{Context: context672} + _t1309 = _t1311 } else { - var _t788 *pb.Write - if prediction401 == 1 { - _t789 := p.parse_undefine() - undefine403 := _t789 - _t790 := &pb.Write{} - _t790.WriteType = &pb.Write_Undefine{Undefine: undefine403} - _t788 = _t790 + var _t1312 *pb.Write + if prediction669 == 1 { + _t1313 := p.parse_undefine() + undefine671 := _t1313 + _t1314 := &pb.Write{} + _t1314.WriteType = &pb.Write_Undefine{Undefine: undefine671} + _t1312 = _t1314 } else { - var _t791 *pb.Write - if prediction401 == 0 { - _t792 := p.parse_define() - define402 := _t792 - _t793 := &pb.Write{} - _t793.WriteType = &pb.Write_Define{Define: define402} - _t791 = _t793 + var _t1315 *pb.Write + if prediction669 == 0 { + _t1316 := p.parse_define() + define670 := _t1316 + _t1317 := &pb.Write{} + _t1317.WriteType = &pb.Write_Define{Define: define670} + _t1315 = _t1317 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in write", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t788 = _t791 + _t1312 = _t1315 } - _t785 = _t788 + _t1309 = _t1312 } - _t782 = _t785 + _t1306 = _t1309 } - return _t782 + result675 := _t1306 + p.recordSpan(int(span_start674)) + return result675 } func (p *Parser) parse_define() *pb.Define { + span_start677 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("define") - _t794 := p.parse_fragment() - fragment406 := _t794 + p.pushPath(int(1)) + _t1318 := p.parse_fragment() + fragment676 := _t1318 + p.popPath() p.consumeLiteral(")") - _t795 := &pb.Define{Fragment: fragment406} - return _t795 + _t1319 := &pb.Define{Fragment: fragment676} + result678 := _t1319 + p.recordSpan(int(span_start677)) + return result678 } func (p *Parser) parse_fragment() *pb.Fragment { + span_start684 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("fragment") - _t796 := p.parse_new_fragment_id() - new_fragment_id407 := _t796 - xs408 := []*pb.Declaration{} - cond409 := p.matchLookaheadLiteral("(", 0) - for cond409 { - _t797 := p.parse_declaration() - item410 := _t797 - xs408 = append(xs408, item410) - cond409 = p.matchLookaheadLiteral("(", 0) - } - declarations411 := xs408 + _t1320 := p.parse_new_fragment_id() + new_fragment_id679 := _t1320 + xs680 := []*pb.Declaration{} + cond681 := p.matchLookaheadLiteral("(", 0) + for cond681 { + _t1321 := p.parse_declaration() + item682 := _t1321 + xs680 = append(xs680, item682) + cond681 = p.matchLookaheadLiteral("(", 0) + } + declarations683 := xs680 p.consumeLiteral(")") - return p.constructFragment(new_fragment_id407, declarations411) + result685 := p.constructFragment(new_fragment_id679, declarations683) + p.recordSpan(int(span_start684)) + return result685 } func (p *Parser) parse_new_fragment_id() *pb.FragmentId { - _t798 := p.parse_fragment_id() - fragment_id412 := _t798 - p.startFragment(fragment_id412) - return fragment_id412 + span_start687 := int64(p.spanStart()) + _t1322 := p.parse_fragment_id() + fragment_id686 := _t1322 + p.startFragment(fragment_id686) + result688 := fragment_id686 + p.recordSpan(int(span_start687)) + return result688 } func (p *Parser) parse_declaration() *pb.Declaration { - var _t799 int64 + span_start694 := int64(p.spanStart()) + var _t1323 int64 if p.matchLookaheadLiteral("(", 0) { - var _t800 int64 + var _t1324 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t800 = 3 + _t1324 = 3 } else { - var _t801 int64 + var _t1325 int64 if p.matchLookaheadLiteral("functional_dependency", 1) { - _t801 = 2 + _t1325 = 2 } else { - var _t802 int64 + var _t1326 int64 if p.matchLookaheadLiteral("def", 1) { - _t802 = 0 + _t1326 = 0 } else { - var _t803 int64 + var _t1327 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t803 = 3 + _t1327 = 3 } else { - var _t804 int64 + var _t1328 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t804 = 3 + _t1328 = 3 } else { - var _t805 int64 + var _t1329 int64 if p.matchLookaheadLiteral("algorithm", 1) { - _t805 = 1 + _t1329 = 1 } else { - _t805 = -1 + _t1329 = -1 } - _t804 = _t805 + _t1328 = _t1329 } - _t803 = _t804 + _t1327 = _t1328 } - _t802 = _t803 + _t1326 = _t1327 } - _t801 = _t802 + _t1325 = _t1326 } - _t800 = _t801 + _t1324 = _t1325 } - _t799 = _t800 + _t1323 = _t1324 } else { - _t799 = -1 - } - prediction413 := _t799 - var _t806 *pb.Declaration - if prediction413 == 3 { - _t807 := p.parse_data() - data417 := _t807 - _t808 := &pb.Declaration{} - _t808.DeclarationType = &pb.Declaration_Data{Data: data417} - _t806 = _t808 + _t1323 = -1 + } + prediction689 := _t1323 + var _t1330 *pb.Declaration + if prediction689 == 3 { + _t1331 := p.parse_data() + data693 := _t1331 + _t1332 := &pb.Declaration{} + _t1332.DeclarationType = &pb.Declaration_Data{Data: data693} + _t1330 = _t1332 } else { - var _t809 *pb.Declaration - if prediction413 == 2 { - _t810 := p.parse_constraint() - constraint416 := _t810 - _t811 := &pb.Declaration{} - _t811.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint416} - _t809 = _t811 + var _t1333 *pb.Declaration + if prediction689 == 2 { + _t1334 := p.parse_constraint() + constraint692 := _t1334 + _t1335 := &pb.Declaration{} + _t1335.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint692} + _t1333 = _t1335 } else { - var _t812 *pb.Declaration - if prediction413 == 1 { - _t813 := p.parse_algorithm() - algorithm415 := _t813 - _t814 := &pb.Declaration{} - _t814.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm415} - _t812 = _t814 + var _t1336 *pb.Declaration + if prediction689 == 1 { + _t1337 := p.parse_algorithm() + algorithm691 := _t1337 + _t1338 := &pb.Declaration{} + _t1338.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm691} + _t1336 = _t1338 } else { - var _t815 *pb.Declaration - if prediction413 == 0 { - _t816 := p.parse_def() - def414 := _t816 - _t817 := &pb.Declaration{} - _t817.DeclarationType = &pb.Declaration_Def{Def: def414} - _t815 = _t817 + var _t1339 *pb.Declaration + if prediction689 == 0 { + _t1340 := p.parse_def() + def690 := _t1340 + _t1341 := &pb.Declaration{} + _t1341.DeclarationType = &pb.Declaration_Def{Def: def690} + _t1339 = _t1341 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in declaration", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t812 = _t815 + _t1336 = _t1339 } - _t809 = _t812 + _t1333 = _t1336 } - _t806 = _t809 + _t1330 = _t1333 } - return _t806 + result695 := _t1330 + p.recordSpan(int(span_start694)) + return result695 } func (p *Parser) parse_def() *pb.Def { + span_start699 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("def") - _t818 := p.parse_relation_id() - relation_id418 := _t818 - _t819 := p.parse_abstraction() - abstraction419 := _t819 - var _t820 []*pb.Attribute + p.pushPath(int(1)) + _t1342 := p.parse_relation_id() + relation_id696 := _t1342 + p.popPath() + p.pushPath(int(2)) + _t1343 := p.parse_abstraction() + abstraction697 := _t1343 + p.popPath() + p.pushPath(int(3)) + var _t1344 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t821 := p.parse_attrs() - _t820 = _t821 + _t1345 := p.parse_attrs() + _t1344 = _t1345 } - attrs420 := _t820 + attrs698 := _t1344 + p.popPath() p.consumeLiteral(")") - _t822 := attrs420 - if attrs420 == nil { - _t822 = []*pb.Attribute{} + _t1346 := attrs698 + if attrs698 == nil { + _t1346 = []*pb.Attribute{} } - _t823 := &pb.Def{Name: relation_id418, Body: abstraction419, Attrs: _t822} - return _t823 + _t1347 := &pb.Def{Name: relation_id696, Body: abstraction697, Attrs: _t1346} + result700 := _t1347 + p.recordSpan(int(span_start699)) + return result700 } func (p *Parser) parse_relation_id() *pb.RelationId { - var _t824 int64 + span_start704 := int64(p.spanStart()) + var _t1348 int64 if p.matchLookaheadLiteral(":", 0) { - _t824 = 0 + _t1348 = 0 } else { - var _t825 int64 + var _t1349 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t825 = 1 + _t1349 = 1 } else { - _t825 = -1 + _t1349 = -1 } - _t824 = _t825 - } - prediction421 := _t824 - var _t826 *pb.RelationId - if prediction421 == 1 { - uint128423 := p.consumeTerminal("UINT128").Value.uint128 - _ = uint128423 - _t826 = &pb.RelationId{IdLow: uint128423.Low, IdHigh: uint128423.High} + _t1348 = _t1349 + } + prediction701 := _t1348 + var _t1350 *pb.RelationId + if prediction701 == 1 { + uint128703 := p.consumeTerminal("UINT128").Value.uint128 + _ = uint128703 + _t1350 = &pb.RelationId{IdLow: uint128703.Low, IdHigh: uint128703.High} } else { - var _t827 *pb.RelationId - if prediction421 == 0 { + var _t1351 *pb.RelationId + if prediction701 == 0 { p.consumeLiteral(":") - symbol422 := p.consumeTerminal("SYMBOL").Value.str - _t827 = p.relationIdFromString(symbol422) + symbol702 := p.consumeTerminal("SYMBOL").Value.str + _t1351 = p.relationIdFromString(symbol702) } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in relation_id", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t826 = _t827 + _t1350 = _t1351 } - return _t826 + result705 := _t1350 + p.recordSpan(int(span_start704)) + return result705 } func (p *Parser) parse_abstraction() *pb.Abstraction { + span_start708 := int64(p.spanStart()) p.consumeLiteral("(") - _t828 := p.parse_bindings() - bindings424 := _t828 - _t829 := p.parse_formula() - formula425 := _t829 + _t1352 := p.parse_bindings() + bindings706 := _t1352 + p.pushPath(int(2)) + _t1353 := p.parse_formula() + formula707 := _t1353 + p.popPath() p.consumeLiteral(")") - _t830 := &pb.Abstraction{Vars: listConcat(bindings424[0].([]*pb.Binding), bindings424[1].([]*pb.Binding)), Value: formula425} - return _t830 + _t1354 := &pb.Abstraction{Vars: listConcat(bindings706[0].([]*pb.Binding), bindings706[1].([]*pb.Binding)), Value: formula707} + result709 := _t1354 + p.recordSpan(int(span_start708)) + return result709 } func (p *Parser) parse_bindings() []interface{} { + span_start715 := int64(p.spanStart()) p.consumeLiteral("[") - xs426 := []*pb.Binding{} - cond427 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond427 { - _t831 := p.parse_binding() - item428 := _t831 - xs426 = append(xs426, item428) - cond427 = p.matchLookaheadTerminal("SYMBOL", 0) - } - bindings429 := xs426 - var _t832 []*pb.Binding + xs710 := []*pb.Binding{} + cond711 := p.matchLookaheadTerminal("SYMBOL", 0) + for cond711 { + _t1355 := p.parse_binding() + item712 := _t1355 + xs710 = append(xs710, item712) + cond711 = p.matchLookaheadTerminal("SYMBOL", 0) + } + bindings713 := xs710 + var _t1356 []*pb.Binding if p.matchLookaheadLiteral("|", 0) { - _t833 := p.parse_value_bindings() - _t832 = _t833 + _t1357 := p.parse_value_bindings() + _t1356 = _t1357 } - value_bindings430 := _t832 + value_bindings714 := _t1356 p.consumeLiteral("]") - _t834 := value_bindings430 - if value_bindings430 == nil { - _t834 = []*pb.Binding{} + _t1358 := value_bindings714 + if value_bindings714 == nil { + _t1358 = []*pb.Binding{} } - return []interface{}{bindings429, _t834} + result716 := []interface{}{bindings713, _t1358} + p.recordSpan(int(span_start715)) + return result716 } func (p *Parser) parse_binding() *pb.Binding { - symbol431 := p.consumeTerminal("SYMBOL").Value.str + span_start719 := int64(p.spanStart()) + symbol717 := p.consumeTerminal("SYMBOL").Value.str p.consumeLiteral("::") - _t835 := p.parse_type() - type432 := _t835 - _t836 := &pb.Var{Name: symbol431} - _t837 := &pb.Binding{Var: _t836, Type: type432} - return _t837 + p.pushPath(int(2)) + _t1359 := p.parse_type() + type718 := _t1359 + p.popPath() + _t1360 := &pb.Var{Name: symbol717} + _t1361 := &pb.Binding{Var: _t1360, Type: type718} + result720 := _t1361 + p.recordSpan(int(span_start719)) + return result720 } func (p *Parser) parse_type() *pb.Type { - var _t838 int64 + span_start733 := int64(p.spanStart()) + var _t1362 int64 if p.matchLookaheadLiteral("UNKNOWN", 0) { - _t838 = 0 + _t1362 = 0 } else { - var _t839 int64 + var _t1363 int64 if p.matchLookaheadLiteral("UINT128", 0) { - _t839 = 4 + _t1363 = 4 } else { - var _t840 int64 + var _t1364 int64 if p.matchLookaheadLiteral("STRING", 0) { - _t840 = 1 + _t1364 = 1 } else { - var _t841 int64 + var _t1365 int64 if p.matchLookaheadLiteral("MISSING", 0) { - _t841 = 8 + _t1365 = 8 } else { - var _t842 int64 + var _t1366 int64 if p.matchLookaheadLiteral("INT128", 0) { - _t842 = 5 + _t1366 = 5 } else { - var _t843 int64 + var _t1367 int64 if p.matchLookaheadLiteral("INT", 0) { - _t843 = 2 + _t1367 = 2 } else { - var _t844 int64 + var _t1368 int64 if p.matchLookaheadLiteral("FLOAT", 0) { - _t844 = 3 + _t1368 = 3 } else { - var _t845 int64 + var _t1369 int64 if p.matchLookaheadLiteral("DATETIME", 0) { - _t845 = 7 + _t1369 = 7 } else { - var _t846 int64 + var _t1370 int64 if p.matchLookaheadLiteral("DATE", 0) { - _t846 = 6 + _t1370 = 6 } else { - var _t847 int64 + var _t1371 int64 if p.matchLookaheadLiteral("BOOLEAN", 0) { - _t847 = 10 + _t1371 = 10 } else { - var _t848 int64 + var _t1372 int64 if p.matchLookaheadLiteral("(", 0) { - _t848 = 9 + _t1372 = 9 } else { - _t848 = -1 + _t1372 = -1 } - _t847 = _t848 + _t1371 = _t1372 } - _t846 = _t847 + _t1370 = _t1371 } - _t845 = _t846 + _t1369 = _t1370 } - _t844 = _t845 + _t1368 = _t1369 } - _t843 = _t844 + _t1367 = _t1368 } - _t842 = _t843 + _t1366 = _t1367 } - _t841 = _t842 + _t1365 = _t1366 } - _t840 = _t841 + _t1364 = _t1365 } - _t839 = _t840 + _t1363 = _t1364 } - _t838 = _t839 - } - prediction433 := _t838 - var _t849 *pb.Type - if prediction433 == 10 { - _t850 := p.parse_boolean_type() - boolean_type444 := _t850 - _t851 := &pb.Type{} - _t851.Type = &pb.Type_BooleanType{BooleanType: boolean_type444} - _t849 = _t851 + _t1362 = _t1363 + } + prediction721 := _t1362 + var _t1373 *pb.Type + if prediction721 == 10 { + _t1374 := p.parse_boolean_type() + boolean_type732 := _t1374 + _t1375 := &pb.Type{} + _t1375.Type = &pb.Type_BooleanType{BooleanType: boolean_type732} + _t1373 = _t1375 } else { - var _t852 *pb.Type - if prediction433 == 9 { - _t853 := p.parse_decimal_type() - decimal_type443 := _t853 - _t854 := &pb.Type{} - _t854.Type = &pb.Type_DecimalType{DecimalType: decimal_type443} - _t852 = _t854 + var _t1376 *pb.Type + if prediction721 == 9 { + _t1377 := p.parse_decimal_type() + decimal_type731 := _t1377 + _t1378 := &pb.Type{} + _t1378.Type = &pb.Type_DecimalType{DecimalType: decimal_type731} + _t1376 = _t1378 } else { - var _t855 *pb.Type - if prediction433 == 8 { - _t856 := p.parse_missing_type() - missing_type442 := _t856 - _t857 := &pb.Type{} - _t857.Type = &pb.Type_MissingType{MissingType: missing_type442} - _t855 = _t857 + var _t1379 *pb.Type + if prediction721 == 8 { + _t1380 := p.parse_missing_type() + missing_type730 := _t1380 + _t1381 := &pb.Type{} + _t1381.Type = &pb.Type_MissingType{MissingType: missing_type730} + _t1379 = _t1381 } else { - var _t858 *pb.Type - if prediction433 == 7 { - _t859 := p.parse_datetime_type() - datetime_type441 := _t859 - _t860 := &pb.Type{} - _t860.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type441} - _t858 = _t860 + var _t1382 *pb.Type + if prediction721 == 7 { + _t1383 := p.parse_datetime_type() + datetime_type729 := _t1383 + _t1384 := &pb.Type{} + _t1384.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type729} + _t1382 = _t1384 } else { - var _t861 *pb.Type - if prediction433 == 6 { - _t862 := p.parse_date_type() - date_type440 := _t862 - _t863 := &pb.Type{} - _t863.Type = &pb.Type_DateType{DateType: date_type440} - _t861 = _t863 + var _t1385 *pb.Type + if prediction721 == 6 { + _t1386 := p.parse_date_type() + date_type728 := _t1386 + _t1387 := &pb.Type{} + _t1387.Type = &pb.Type_DateType{DateType: date_type728} + _t1385 = _t1387 } else { - var _t864 *pb.Type - if prediction433 == 5 { - _t865 := p.parse_int128_type() - int128_type439 := _t865 - _t866 := &pb.Type{} - _t866.Type = &pb.Type_Int128Type{Int128Type: int128_type439} - _t864 = _t866 + var _t1388 *pb.Type + if prediction721 == 5 { + _t1389 := p.parse_int128_type() + int128_type727 := _t1389 + _t1390 := &pb.Type{} + _t1390.Type = &pb.Type_Int128Type{Int128Type: int128_type727} + _t1388 = _t1390 } else { - var _t867 *pb.Type - if prediction433 == 4 { - _t868 := p.parse_uint128_type() - uint128_type438 := _t868 - _t869 := &pb.Type{} - _t869.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type438} - _t867 = _t869 + var _t1391 *pb.Type + if prediction721 == 4 { + _t1392 := p.parse_uint128_type() + uint128_type726 := _t1392 + _t1393 := &pb.Type{} + _t1393.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type726} + _t1391 = _t1393 } else { - var _t870 *pb.Type - if prediction433 == 3 { - _t871 := p.parse_float_type() - float_type437 := _t871 - _t872 := &pb.Type{} - _t872.Type = &pb.Type_FloatType{FloatType: float_type437} - _t870 = _t872 + var _t1394 *pb.Type + if prediction721 == 3 { + _t1395 := p.parse_float_type() + float_type725 := _t1395 + _t1396 := &pb.Type{} + _t1396.Type = &pb.Type_FloatType{FloatType: float_type725} + _t1394 = _t1396 } else { - var _t873 *pb.Type - if prediction433 == 2 { - _t874 := p.parse_int_type() - int_type436 := _t874 - _t875 := &pb.Type{} - _t875.Type = &pb.Type_IntType{IntType: int_type436} - _t873 = _t875 + var _t1397 *pb.Type + if prediction721 == 2 { + _t1398 := p.parse_int_type() + int_type724 := _t1398 + _t1399 := &pb.Type{} + _t1399.Type = &pb.Type_IntType{IntType: int_type724} + _t1397 = _t1399 } else { - var _t876 *pb.Type - if prediction433 == 1 { - _t877 := p.parse_string_type() - string_type435 := _t877 - _t878 := &pb.Type{} - _t878.Type = &pb.Type_StringType{StringType: string_type435} - _t876 = _t878 + var _t1400 *pb.Type + if prediction721 == 1 { + _t1401 := p.parse_string_type() + string_type723 := _t1401 + _t1402 := &pb.Type{} + _t1402.Type = &pb.Type_StringType{StringType: string_type723} + _t1400 = _t1402 } else { - var _t879 *pb.Type - if prediction433 == 0 { - _t880 := p.parse_unspecified_type() - unspecified_type434 := _t880 - _t881 := &pb.Type{} - _t881.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type434} - _t879 = _t881 + var _t1403 *pb.Type + if prediction721 == 0 { + _t1404 := p.parse_unspecified_type() + unspecified_type722 := _t1404 + _t1405 := &pb.Type{} + _t1405.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type722} + _t1403 = _t1405 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in type", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t876 = _t879 + _t1400 = _t1403 } - _t873 = _t876 + _t1397 = _t1400 } - _t870 = _t873 + _t1394 = _t1397 } - _t867 = _t870 + _t1391 = _t1394 } - _t864 = _t867 + _t1388 = _t1391 } - _t861 = _t864 + _t1385 = _t1388 } - _t858 = _t861 + _t1382 = _t1385 } - _t855 = _t858 + _t1379 = _t1382 } - _t852 = _t855 + _t1376 = _t1379 } - _t849 = _t852 + _t1373 = _t1376 } - return _t849 + result734 := _t1373 + p.recordSpan(int(span_start733)) + return result734 } func (p *Parser) parse_unspecified_type() *pb.UnspecifiedType { + span_start735 := int64(p.spanStart()) p.consumeLiteral("UNKNOWN") - _t882 := &pb.UnspecifiedType{} - return _t882 + _t1406 := &pb.UnspecifiedType{} + result736 := _t1406 + p.recordSpan(int(span_start735)) + return result736 } func (p *Parser) parse_string_type() *pb.StringType { + span_start737 := int64(p.spanStart()) p.consumeLiteral("STRING") - _t883 := &pb.StringType{} - return _t883 + _t1407 := &pb.StringType{} + result738 := _t1407 + p.recordSpan(int(span_start737)) + return result738 } func (p *Parser) parse_int_type() *pb.IntType { + span_start739 := int64(p.spanStart()) p.consumeLiteral("INT") - _t884 := &pb.IntType{} - return _t884 + _t1408 := &pb.IntType{} + result740 := _t1408 + p.recordSpan(int(span_start739)) + return result740 } func (p *Parser) parse_float_type() *pb.FloatType { + span_start741 := int64(p.spanStart()) p.consumeLiteral("FLOAT") - _t885 := &pb.FloatType{} - return _t885 + _t1409 := &pb.FloatType{} + result742 := _t1409 + p.recordSpan(int(span_start741)) + return result742 } func (p *Parser) parse_uint128_type() *pb.UInt128Type { + span_start743 := int64(p.spanStart()) p.consumeLiteral("UINT128") - _t886 := &pb.UInt128Type{} - return _t886 + _t1410 := &pb.UInt128Type{} + result744 := _t1410 + p.recordSpan(int(span_start743)) + return result744 } func (p *Parser) parse_int128_type() *pb.Int128Type { + span_start745 := int64(p.spanStart()) p.consumeLiteral("INT128") - _t887 := &pb.Int128Type{} - return _t887 + _t1411 := &pb.Int128Type{} + result746 := _t1411 + p.recordSpan(int(span_start745)) + return result746 } func (p *Parser) parse_date_type() *pb.DateType { + span_start747 := int64(p.spanStart()) p.consumeLiteral("DATE") - _t888 := &pb.DateType{} - return _t888 + _t1412 := &pb.DateType{} + result748 := _t1412 + p.recordSpan(int(span_start747)) + return result748 } func (p *Parser) parse_datetime_type() *pb.DateTimeType { + span_start749 := int64(p.spanStart()) p.consumeLiteral("DATETIME") - _t889 := &pb.DateTimeType{} - return _t889 + _t1413 := &pb.DateTimeType{} + result750 := _t1413 + p.recordSpan(int(span_start749)) + return result750 } func (p *Parser) parse_missing_type() *pb.MissingType { + span_start751 := int64(p.spanStart()) p.consumeLiteral("MISSING") - _t890 := &pb.MissingType{} - return _t890 + _t1414 := &pb.MissingType{} + result752 := _t1414 + p.recordSpan(int(span_start751)) + return result752 } func (p *Parser) parse_decimal_type() *pb.DecimalType { + span_start755 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("DECIMAL") - int445 := p.consumeTerminal("INT").Value.i64 - int_3446 := p.consumeTerminal("INT").Value.i64 + p.pushPath(int(1)) + int753 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3754 := p.consumeTerminal("INT").Value.i64 + p.popPath() p.consumeLiteral(")") - _t891 := &pb.DecimalType{Precision: int32(int445), Scale: int32(int_3446)} - return _t891 + _t1415 := &pb.DecimalType{Precision: int32(int753), Scale: int32(int_3754)} + result756 := _t1415 + p.recordSpan(int(span_start755)) + return result756 } func (p *Parser) parse_boolean_type() *pb.BooleanType { + span_start757 := int64(p.spanStart()) p.consumeLiteral("BOOLEAN") - _t892 := &pb.BooleanType{} - return _t892 + _t1416 := &pb.BooleanType{} + result758 := _t1416 + p.recordSpan(int(span_start757)) + return result758 } func (p *Parser) parse_value_bindings() []*pb.Binding { + span_start763 := int64(p.spanStart()) p.consumeLiteral("|") - xs447 := []*pb.Binding{} - cond448 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond448 { - _t893 := p.parse_binding() - item449 := _t893 - xs447 = append(xs447, item449) - cond448 = p.matchLookaheadTerminal("SYMBOL", 0) + xs759 := []*pb.Binding{} + cond760 := p.matchLookaheadTerminal("SYMBOL", 0) + for cond760 { + _t1417 := p.parse_binding() + item761 := _t1417 + xs759 = append(xs759, item761) + cond760 = p.matchLookaheadTerminal("SYMBOL", 0) } - bindings450 := xs447 - return bindings450 + bindings762 := xs759 + result764 := bindings762 + p.recordSpan(int(span_start763)) + return result764 } func (p *Parser) parse_formula() *pb.Formula { - var _t894 int64 + span_start779 := int64(p.spanStart()) + var _t1418 int64 if p.matchLookaheadLiteral("(", 0) { - var _t895 int64 + var _t1419 int64 if p.matchLookaheadLiteral("true", 1) { - _t895 = 0 + _t1419 = 0 } else { - var _t896 int64 + var _t1420 int64 if p.matchLookaheadLiteral("relatom", 1) { - _t896 = 11 + _t1420 = 11 } else { - var _t897 int64 + var _t1421 int64 if p.matchLookaheadLiteral("reduce", 1) { - _t897 = 3 + _t1421 = 3 } else { - var _t898 int64 + var _t1422 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t898 = 10 + _t1422 = 10 } else { - var _t899 int64 + var _t1423 int64 if p.matchLookaheadLiteral("pragma", 1) { - _t899 = 9 + _t1423 = 9 } else { - var _t900 int64 + var _t1424 int64 if p.matchLookaheadLiteral("or", 1) { - _t900 = 5 + _t1424 = 5 } else { - var _t901 int64 + var _t1425 int64 if p.matchLookaheadLiteral("not", 1) { - _t901 = 6 + _t1425 = 6 } else { - var _t902 int64 + var _t1426 int64 if p.matchLookaheadLiteral("ffi", 1) { - _t902 = 7 + _t1426 = 7 } else { - var _t903 int64 + var _t1427 int64 if p.matchLookaheadLiteral("false", 1) { - _t903 = 1 + _t1427 = 1 } else { - var _t904 int64 + var _t1428 int64 if p.matchLookaheadLiteral("exists", 1) { - _t904 = 2 + _t1428 = 2 } else { - var _t905 int64 + var _t1429 int64 if p.matchLookaheadLiteral("cast", 1) { - _t905 = 12 + _t1429 = 12 } else { - var _t906 int64 + var _t1430 int64 if p.matchLookaheadLiteral("atom", 1) { - _t906 = 8 + _t1430 = 8 } else { - var _t907 int64 + var _t1431 int64 if p.matchLookaheadLiteral("and", 1) { - _t907 = 4 + _t1431 = 4 } else { - var _t908 int64 + var _t1432 int64 if p.matchLookaheadLiteral(">=", 1) { - _t908 = 10 + _t1432 = 10 } else { - var _t909 int64 + var _t1433 int64 if p.matchLookaheadLiteral(">", 1) { - _t909 = 10 + _t1433 = 10 } else { - var _t910 int64 + var _t1434 int64 if p.matchLookaheadLiteral("=", 1) { - _t910 = 10 + _t1434 = 10 } else { - var _t911 int64 + var _t1435 int64 if p.matchLookaheadLiteral("<=", 1) { - _t911 = 10 + _t1435 = 10 } else { - var _t912 int64 + var _t1436 int64 if p.matchLookaheadLiteral("<", 1) { - _t912 = 10 + _t1436 = 10 } else { - var _t913 int64 + var _t1437 int64 if p.matchLookaheadLiteral("/", 1) { - _t913 = 10 + _t1437 = 10 } else { - var _t914 int64 + var _t1438 int64 if p.matchLookaheadLiteral("-", 1) { - _t914 = 10 + _t1438 = 10 } else { - var _t915 int64 + var _t1439 int64 if p.matchLookaheadLiteral("+", 1) { - _t915 = 10 + _t1439 = 10 } else { - var _t916 int64 + var _t1440 int64 if p.matchLookaheadLiteral("*", 1) { - _t916 = 10 + _t1440 = 10 } else { - _t916 = -1 + _t1440 = -1 } - _t915 = _t916 + _t1439 = _t1440 } - _t914 = _t915 + _t1438 = _t1439 } - _t913 = _t914 + _t1437 = _t1438 } - _t912 = _t913 + _t1436 = _t1437 } - _t911 = _t912 + _t1435 = _t1436 } - _t910 = _t911 + _t1434 = _t1435 } - _t909 = _t910 + _t1433 = _t1434 } - _t908 = _t909 + _t1432 = _t1433 } - _t907 = _t908 + _t1431 = _t1432 } - _t906 = _t907 + _t1430 = _t1431 } - _t905 = _t906 + _t1429 = _t1430 } - _t904 = _t905 + _t1428 = _t1429 } - _t903 = _t904 + _t1427 = _t1428 } - _t902 = _t903 + _t1426 = _t1427 } - _t901 = _t902 + _t1425 = _t1426 } - _t900 = _t901 + _t1424 = _t1425 } - _t899 = _t900 + _t1423 = _t1424 } - _t898 = _t899 + _t1422 = _t1423 } - _t897 = _t898 + _t1421 = _t1422 } - _t896 = _t897 + _t1420 = _t1421 } - _t895 = _t896 + _t1419 = _t1420 } - _t894 = _t895 + _t1418 = _t1419 } else { - _t894 = -1 - } - prediction451 := _t894 - var _t917 *pb.Formula - if prediction451 == 12 { - _t918 := p.parse_cast() - cast464 := _t918 - _t919 := &pb.Formula{} - _t919.FormulaType = &pb.Formula_Cast{Cast: cast464} - _t917 = _t919 + _t1418 = -1 + } + prediction765 := _t1418 + var _t1441 *pb.Formula + if prediction765 == 12 { + _t1442 := p.parse_cast() + cast778 := _t1442 + _t1443 := &pb.Formula{} + _t1443.FormulaType = &pb.Formula_Cast{Cast: cast778} + _t1441 = _t1443 } else { - var _t920 *pb.Formula - if prediction451 == 11 { - _t921 := p.parse_rel_atom() - rel_atom463 := _t921 - _t922 := &pb.Formula{} - _t922.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom463} - _t920 = _t922 + var _t1444 *pb.Formula + if prediction765 == 11 { + _t1445 := p.parse_rel_atom() + rel_atom777 := _t1445 + _t1446 := &pb.Formula{} + _t1446.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom777} + _t1444 = _t1446 } else { - var _t923 *pb.Formula - if prediction451 == 10 { - _t924 := p.parse_primitive() - primitive462 := _t924 - _t925 := &pb.Formula{} - _t925.FormulaType = &pb.Formula_Primitive{Primitive: primitive462} - _t923 = _t925 + var _t1447 *pb.Formula + if prediction765 == 10 { + _t1448 := p.parse_primitive() + primitive776 := _t1448 + _t1449 := &pb.Formula{} + _t1449.FormulaType = &pb.Formula_Primitive{Primitive: primitive776} + _t1447 = _t1449 } else { - var _t926 *pb.Formula - if prediction451 == 9 { - _t927 := p.parse_pragma() - pragma461 := _t927 - _t928 := &pb.Formula{} - _t928.FormulaType = &pb.Formula_Pragma{Pragma: pragma461} - _t926 = _t928 + var _t1450 *pb.Formula + if prediction765 == 9 { + _t1451 := p.parse_pragma() + pragma775 := _t1451 + _t1452 := &pb.Formula{} + _t1452.FormulaType = &pb.Formula_Pragma{Pragma: pragma775} + _t1450 = _t1452 } else { - var _t929 *pb.Formula - if prediction451 == 8 { - _t930 := p.parse_atom() - atom460 := _t930 - _t931 := &pb.Formula{} - _t931.FormulaType = &pb.Formula_Atom{Atom: atom460} - _t929 = _t931 + var _t1453 *pb.Formula + if prediction765 == 8 { + _t1454 := p.parse_atom() + atom774 := _t1454 + _t1455 := &pb.Formula{} + _t1455.FormulaType = &pb.Formula_Atom{Atom: atom774} + _t1453 = _t1455 } else { - var _t932 *pb.Formula - if prediction451 == 7 { - _t933 := p.parse_ffi() - ffi459 := _t933 - _t934 := &pb.Formula{} - _t934.FormulaType = &pb.Formula_Ffi{Ffi: ffi459} - _t932 = _t934 + var _t1456 *pb.Formula + if prediction765 == 7 { + _t1457 := p.parse_ffi() + ffi773 := _t1457 + _t1458 := &pb.Formula{} + _t1458.FormulaType = &pb.Formula_Ffi{Ffi: ffi773} + _t1456 = _t1458 } else { - var _t935 *pb.Formula - if prediction451 == 6 { - _t936 := p.parse_not() - not458 := _t936 - _t937 := &pb.Formula{} - _t937.FormulaType = &pb.Formula_Not{Not: not458} - _t935 = _t937 + var _t1459 *pb.Formula + if prediction765 == 6 { + _t1460 := p.parse_not() + not772 := _t1460 + _t1461 := &pb.Formula{} + _t1461.FormulaType = &pb.Formula_Not{Not: not772} + _t1459 = _t1461 } else { - var _t938 *pb.Formula - if prediction451 == 5 { - _t939 := p.parse_disjunction() - disjunction457 := _t939 - _t940 := &pb.Formula{} - _t940.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction457} - _t938 = _t940 + var _t1462 *pb.Formula + if prediction765 == 5 { + _t1463 := p.parse_disjunction() + disjunction771 := _t1463 + _t1464 := &pb.Formula{} + _t1464.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction771} + _t1462 = _t1464 } else { - var _t941 *pb.Formula - if prediction451 == 4 { - _t942 := p.parse_conjunction() - conjunction456 := _t942 - _t943 := &pb.Formula{} - _t943.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction456} - _t941 = _t943 + var _t1465 *pb.Formula + if prediction765 == 4 { + _t1466 := p.parse_conjunction() + conjunction770 := _t1466 + _t1467 := &pb.Formula{} + _t1467.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction770} + _t1465 = _t1467 } else { - var _t944 *pb.Formula - if prediction451 == 3 { - _t945 := p.parse_reduce() - reduce455 := _t945 - _t946 := &pb.Formula{} - _t946.FormulaType = &pb.Formula_Reduce{Reduce: reduce455} - _t944 = _t946 + var _t1468 *pb.Formula + if prediction765 == 3 { + _t1469 := p.parse_reduce() + reduce769 := _t1469 + _t1470 := &pb.Formula{} + _t1470.FormulaType = &pb.Formula_Reduce{Reduce: reduce769} + _t1468 = _t1470 } else { - var _t947 *pb.Formula - if prediction451 == 2 { - _t948 := p.parse_exists() - exists454 := _t948 - _t949 := &pb.Formula{} - _t949.FormulaType = &pb.Formula_Exists{Exists: exists454} - _t947 = _t949 + var _t1471 *pb.Formula + if prediction765 == 2 { + _t1472 := p.parse_exists() + exists768 := _t1472 + _t1473 := &pb.Formula{} + _t1473.FormulaType = &pb.Formula_Exists{Exists: exists768} + _t1471 = _t1473 } else { - var _t950 *pb.Formula - if prediction451 == 1 { - _t951 := p.parse_false() - false453 := _t951 - _t952 := &pb.Formula{} - _t952.FormulaType = &pb.Formula_Disjunction{Disjunction: false453} - _t950 = _t952 + var _t1474 *pb.Formula + if prediction765 == 1 { + _t1475 := p.parse_false() + false767 := _t1475 + _t1476 := &pb.Formula{} + _t1476.FormulaType = &pb.Formula_Disjunction{Disjunction: false767} + _t1474 = _t1476 } else { - var _t953 *pb.Formula - if prediction451 == 0 { - _t954 := p.parse_true() - true452 := _t954 - _t955 := &pb.Formula{} - _t955.FormulaType = &pb.Formula_Conjunction{Conjunction: true452} - _t953 = _t955 + var _t1477 *pb.Formula + if prediction765 == 0 { + _t1478 := p.parse_true() + true766 := _t1478 + _t1479 := &pb.Formula{} + _t1479.FormulaType = &pb.Formula_Conjunction{Conjunction: true766} + _t1477 = _t1479 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in formula", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t950 = _t953 + _t1474 = _t1477 } - _t947 = _t950 + _t1471 = _t1474 } - _t944 = _t947 + _t1468 = _t1471 } - _t941 = _t944 + _t1465 = _t1468 } - _t938 = _t941 + _t1462 = _t1465 } - _t935 = _t938 + _t1459 = _t1462 } - _t932 = _t935 + _t1456 = _t1459 } - _t929 = _t932 + _t1453 = _t1456 } - _t926 = _t929 + _t1450 = _t1453 } - _t923 = _t926 + _t1447 = _t1450 } - _t920 = _t923 + _t1444 = _t1447 } - _t917 = _t920 + _t1441 = _t1444 } - return _t917 + result780 := _t1441 + p.recordSpan(int(span_start779)) + return result780 } func (p *Parser) parse_true() *pb.Conjunction { + span_start781 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("true") p.consumeLiteral(")") - _t956 := &pb.Conjunction{Args: []*pb.Formula{}} - return _t956 + _t1480 := &pb.Conjunction{Args: []*pb.Formula{}} + result782 := _t1480 + p.recordSpan(int(span_start781)) + return result782 } func (p *Parser) parse_false() *pb.Disjunction { + span_start783 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("false") p.consumeLiteral(")") - _t957 := &pb.Disjunction{Args: []*pb.Formula{}} - return _t957 + _t1481 := &pb.Disjunction{Args: []*pb.Formula{}} + result784 := _t1481 + p.recordSpan(int(span_start783)) + return result784 } func (p *Parser) parse_exists() *pb.Exists { + span_start787 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("exists") - _t958 := p.parse_bindings() - bindings465 := _t958 - _t959 := p.parse_formula() - formula466 := _t959 + _t1482 := p.parse_bindings() + bindings785 := _t1482 + _t1483 := p.parse_formula() + formula786 := _t1483 p.consumeLiteral(")") - _t960 := &pb.Abstraction{Vars: listConcat(bindings465[0].([]*pb.Binding), bindings465[1].([]*pb.Binding)), Value: formula466} - _t961 := &pb.Exists{Body: _t960} - return _t961 + _t1484 := &pb.Abstraction{Vars: listConcat(bindings785[0].([]*pb.Binding), bindings785[1].([]*pb.Binding)), Value: formula786} + _t1485 := &pb.Exists{Body: _t1484} + result788 := _t1485 + p.recordSpan(int(span_start787)) + return result788 } func (p *Parser) parse_reduce() *pb.Reduce { + span_start792 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("reduce") - _t962 := p.parse_abstraction() - abstraction467 := _t962 - _t963 := p.parse_abstraction() - abstraction_3468 := _t963 - _t964 := p.parse_terms() - terms469 := _t964 + p.pushPath(int(1)) + _t1486 := p.parse_abstraction() + abstraction789 := _t1486 + p.popPath() + p.pushPath(int(2)) + _t1487 := p.parse_abstraction() + abstraction_3790 := _t1487 + p.popPath() + p.pushPath(int(3)) + _t1488 := p.parse_terms() + terms791 := _t1488 + p.popPath() p.consumeLiteral(")") - _t965 := &pb.Reduce{Op: abstraction467, Body: abstraction_3468, Terms: terms469} - return _t965 + _t1489 := &pb.Reduce{Op: abstraction789, Body: abstraction_3790, Terms: terms791} + result793 := _t1489 + p.recordSpan(int(span_start792)) + return result793 } func (p *Parser) parse_terms() []*pb.Term { + span_start798 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("terms") - xs470 := []*pb.Term{} - cond471 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond471 { - _t966 := p.parse_term() - item472 := _t966 - xs470 = append(xs470, item472) - cond471 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms473 := xs470 + xs794 := []*pb.Term{} + cond795 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + for cond795 { + _t1490 := p.parse_term() + item796 := _t1490 + xs794 = append(xs794, item796) + cond795 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + terms797 := xs794 p.consumeLiteral(")") - return terms473 + result799 := terms797 + p.recordSpan(int(span_start798)) + return result799 } func (p *Parser) parse_term() *pb.Term { - var _t967 int64 + span_start803 := int64(p.spanStart()) + var _t1491 int64 if p.matchLookaheadLiteral("true", 0) { - _t967 = 1 + _t1491 = 1 } else { - var _t968 int64 + var _t1492 int64 if p.matchLookaheadLiteral("missing", 0) { - _t968 = 1 + _t1492 = 1 } else { - var _t969 int64 + var _t1493 int64 if p.matchLookaheadLiteral("false", 0) { - _t969 = 1 + _t1493 = 1 } else { - var _t970 int64 + var _t1494 int64 if p.matchLookaheadLiteral("(", 0) { - _t970 = 1 + _t1494 = 1 } else { - var _t971 int64 + var _t1495 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t971 = 1 + _t1495 = 1 } else { - var _t972 int64 + var _t1496 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t972 = 0 + _t1496 = 0 } else { - var _t973 int64 + var _t1497 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t973 = 1 + _t1497 = 1 } else { - var _t974 int64 + var _t1498 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t974 = 1 + _t1498 = 1 } else { - var _t975 int64 + var _t1499 int64 if p.matchLookaheadTerminal("INT", 0) { - _t975 = 1 + _t1499 = 1 } else { - var _t976 int64 + var _t1500 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t976 = 1 + _t1500 = 1 } else { - var _t977 int64 + var _t1501 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t977 = 1 + _t1501 = 1 } else { - _t977 = -1 + _t1501 = -1 } - _t976 = _t977 + _t1500 = _t1501 } - _t975 = _t976 + _t1499 = _t1500 } - _t974 = _t975 + _t1498 = _t1499 } - _t973 = _t974 + _t1497 = _t1498 } - _t972 = _t973 + _t1496 = _t1497 } - _t971 = _t972 + _t1495 = _t1496 } - _t970 = _t971 + _t1494 = _t1495 } - _t969 = _t970 + _t1493 = _t1494 } - _t968 = _t969 + _t1492 = _t1493 } - _t967 = _t968 - } - prediction474 := _t967 - var _t978 *pb.Term - if prediction474 == 1 { - _t979 := p.parse_constant() - constant476 := _t979 - _t980 := &pb.Term{} - _t980.TermType = &pb.Term_Constant{Constant: constant476} - _t978 = _t980 + _t1491 = _t1492 + } + prediction800 := _t1491 + var _t1502 *pb.Term + if prediction800 == 1 { + _t1503 := p.parse_constant() + constant802 := _t1503 + _t1504 := &pb.Term{} + _t1504.TermType = &pb.Term_Constant{Constant: constant802} + _t1502 = _t1504 } else { - var _t981 *pb.Term - if prediction474 == 0 { - _t982 := p.parse_var() - var475 := _t982 - _t983 := &pb.Term{} - _t983.TermType = &pb.Term_Var{Var: var475} - _t981 = _t983 + var _t1505 *pb.Term + if prediction800 == 0 { + _t1506 := p.parse_var() + var801 := _t1506 + _t1507 := &pb.Term{} + _t1507.TermType = &pb.Term_Var{Var: var801} + _t1505 = _t1507 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t978 = _t981 + _t1502 = _t1505 } - return _t978 + result804 := _t1502 + p.recordSpan(int(span_start803)) + return result804 } func (p *Parser) parse_var() *pb.Var { - symbol477 := p.consumeTerminal("SYMBOL").Value.str - _t984 := &pb.Var{Name: symbol477} - return _t984 + span_start806 := int64(p.spanStart()) + symbol805 := p.consumeTerminal("SYMBOL").Value.str + _t1508 := &pb.Var{Name: symbol805} + result807 := _t1508 + p.recordSpan(int(span_start806)) + return result807 } func (p *Parser) parse_constant() *pb.Value { - _t985 := p.parse_value() - value478 := _t985 - return value478 + span_start809 := int64(p.spanStart()) + _t1509 := p.parse_value() + value808 := _t1509 + result810 := value808 + p.recordSpan(int(span_start809)) + return result810 } func (p *Parser) parse_conjunction() *pb.Conjunction { + span_start819 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("and") - xs479 := []*pb.Formula{} - cond480 := p.matchLookaheadLiteral("(", 0) - for cond480 { - _t986 := p.parse_formula() - item481 := _t986 - xs479 = append(xs479, item481) - cond480 = p.matchLookaheadLiteral("(", 0) - } - formulas482 := xs479 + p.pushPath(int(1)) + xs815 := []*pb.Formula{} + cond816 := p.matchLookaheadLiteral("(", 0) + idx817 := 0 + for cond816 { + p.pushPath(int(idx817)) + _t1510 := p.parse_formula() + item818 := _t1510 + p.popPath() + xs815 = append(xs815, item818) + idx817 = (idx817 + 1) + cond816 = p.matchLookaheadLiteral("(", 0) + } + formulas814 := xs815 + p.popPath() p.consumeLiteral(")") - _t987 := &pb.Conjunction{Args: formulas482} - return _t987 + _t1511 := &pb.Conjunction{Args: formulas814} + result820 := _t1511 + p.recordSpan(int(span_start819)) + return result820 } func (p *Parser) parse_disjunction() *pb.Disjunction { + span_start829 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("or") - xs483 := []*pb.Formula{} - cond484 := p.matchLookaheadLiteral("(", 0) - for cond484 { - _t988 := p.parse_formula() - item485 := _t988 - xs483 = append(xs483, item485) - cond484 = p.matchLookaheadLiteral("(", 0) - } - formulas486 := xs483 + p.pushPath(int(1)) + xs825 := []*pb.Formula{} + cond826 := p.matchLookaheadLiteral("(", 0) + idx827 := 0 + for cond826 { + p.pushPath(int(idx827)) + _t1512 := p.parse_formula() + item828 := _t1512 + p.popPath() + xs825 = append(xs825, item828) + idx827 = (idx827 + 1) + cond826 = p.matchLookaheadLiteral("(", 0) + } + formulas824 := xs825 + p.popPath() p.consumeLiteral(")") - _t989 := &pb.Disjunction{Args: formulas486} - return _t989 + _t1513 := &pb.Disjunction{Args: formulas824} + result830 := _t1513 + p.recordSpan(int(span_start829)) + return result830 } func (p *Parser) parse_not() *pb.Not { + span_start832 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("not") - _t990 := p.parse_formula() - formula487 := _t990 + p.pushPath(int(1)) + _t1514 := p.parse_formula() + formula831 := _t1514 + p.popPath() p.consumeLiteral(")") - _t991 := &pb.Not{Arg: formula487} - return _t991 + _t1515 := &pb.Not{Arg: formula831} + result833 := _t1515 + p.recordSpan(int(span_start832)) + return result833 } func (p *Parser) parse_ffi() *pb.FFI { + span_start837 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("ffi") - _t992 := p.parse_name() - name488 := _t992 - _t993 := p.parse_ffi_args() - ffi_args489 := _t993 - _t994 := p.parse_terms() - terms490 := _t994 + p.pushPath(int(1)) + _t1516 := p.parse_name() + name834 := _t1516 + p.popPath() + p.pushPath(int(2)) + _t1517 := p.parse_ffi_args() + ffi_args835 := _t1517 + p.popPath() + p.pushPath(int(3)) + _t1518 := p.parse_terms() + terms836 := _t1518 + p.popPath() p.consumeLiteral(")") - _t995 := &pb.FFI{Name: name488, Args: ffi_args489, Terms: terms490} - return _t995 + _t1519 := &pb.FFI{Name: name834, Args: ffi_args835, Terms: terms836} + result838 := _t1519 + p.recordSpan(int(span_start837)) + return result838 } func (p *Parser) parse_name() string { + span_start840 := int64(p.spanStart()) p.consumeLiteral(":") - symbol491 := p.consumeTerminal("SYMBOL").Value.str - return symbol491 + symbol839 := p.consumeTerminal("SYMBOL").Value.str + result841 := symbol839 + p.recordSpan(int(span_start840)) + return result841 } func (p *Parser) parse_ffi_args() []*pb.Abstraction { + span_start846 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("args") - xs492 := []*pb.Abstraction{} - cond493 := p.matchLookaheadLiteral("(", 0) - for cond493 { - _t996 := p.parse_abstraction() - item494 := _t996 - xs492 = append(xs492, item494) - cond493 = p.matchLookaheadLiteral("(", 0) - } - abstractions495 := xs492 + xs842 := []*pb.Abstraction{} + cond843 := p.matchLookaheadLiteral("(", 0) + for cond843 { + _t1520 := p.parse_abstraction() + item844 := _t1520 + xs842 = append(xs842, item844) + cond843 = p.matchLookaheadLiteral("(", 0) + } + abstractions845 := xs842 p.consumeLiteral(")") - return abstractions495 + result847 := abstractions845 + p.recordSpan(int(span_start846)) + return result847 } func (p *Parser) parse_atom() *pb.Atom { + span_start857 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("atom") - _t997 := p.parse_relation_id() - relation_id496 := _t997 - xs497 := []*pb.Term{} - cond498 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond498 { - _t998 := p.parse_term() - item499 := _t998 - xs497 = append(xs497, item499) - cond498 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms500 := xs497 + p.pushPath(int(1)) + _t1521 := p.parse_relation_id() + relation_id848 := _t1521 + p.popPath() + p.pushPath(int(2)) + xs853 := []*pb.Term{} + cond854 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx855 := 0 + for cond854 { + p.pushPath(int(idx855)) + _t1522 := p.parse_term() + item856 := _t1522 + p.popPath() + xs853 = append(xs853, item856) + idx855 = (idx855 + 1) + cond854 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + terms852 := xs853 + p.popPath() p.consumeLiteral(")") - _t999 := &pb.Atom{Name: relation_id496, Terms: terms500} - return _t999 + _t1523 := &pb.Atom{Name: relation_id848, Terms: terms852} + result858 := _t1523 + p.recordSpan(int(span_start857)) + return result858 } func (p *Parser) parse_pragma() *pb.Pragma { + span_start868 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("pragma") - _t1000 := p.parse_name() - name501 := _t1000 - xs502 := []*pb.Term{} - cond503 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond503 { - _t1001 := p.parse_term() - item504 := _t1001 - xs502 = append(xs502, item504) - cond503 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms505 := xs502 + p.pushPath(int(1)) + _t1524 := p.parse_name() + name859 := _t1524 + p.popPath() + p.pushPath(int(2)) + xs864 := []*pb.Term{} + cond865 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx866 := 0 + for cond865 { + p.pushPath(int(idx866)) + _t1525 := p.parse_term() + item867 := _t1525 + p.popPath() + xs864 = append(xs864, item867) + idx866 = (idx866 + 1) + cond865 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + terms863 := xs864 + p.popPath() p.consumeLiteral(")") - _t1002 := &pb.Pragma{Name: name501, Terms: terms505} - return _t1002 + _t1526 := &pb.Pragma{Name: name859, Terms: terms863} + result869 := _t1526 + p.recordSpan(int(span_start868)) + return result869 } func (p *Parser) parse_primitive() *pb.Primitive { - var _t1003 int64 + span_start889 := int64(p.spanStart()) + var _t1527 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1004 int64 + var _t1528 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t1004 = 9 + _t1528 = 9 } else { - var _t1005 int64 + var _t1529 int64 if p.matchLookaheadLiteral(">=", 1) { - _t1005 = 4 + _t1529 = 4 } else { - var _t1006 int64 + var _t1530 int64 if p.matchLookaheadLiteral(">", 1) { - _t1006 = 3 + _t1530 = 3 } else { - var _t1007 int64 + var _t1531 int64 if p.matchLookaheadLiteral("=", 1) { - _t1007 = 0 + _t1531 = 0 } else { - var _t1008 int64 + var _t1532 int64 if p.matchLookaheadLiteral("<=", 1) { - _t1008 = 2 + _t1532 = 2 } else { - var _t1009 int64 + var _t1533 int64 if p.matchLookaheadLiteral("<", 1) { - _t1009 = 1 + _t1533 = 1 } else { - var _t1010 int64 + var _t1534 int64 if p.matchLookaheadLiteral("/", 1) { - _t1010 = 8 + _t1534 = 8 } else { - var _t1011 int64 + var _t1535 int64 if p.matchLookaheadLiteral("-", 1) { - _t1011 = 6 + _t1535 = 6 } else { - var _t1012 int64 + var _t1536 int64 if p.matchLookaheadLiteral("+", 1) { - _t1012 = 5 + _t1536 = 5 } else { - var _t1013 int64 + var _t1537 int64 if p.matchLookaheadLiteral("*", 1) { - _t1013 = 7 + _t1537 = 7 } else { - _t1013 = -1 + _t1537 = -1 } - _t1012 = _t1013 + _t1536 = _t1537 } - _t1011 = _t1012 + _t1535 = _t1536 } - _t1010 = _t1011 + _t1534 = _t1535 } - _t1009 = _t1010 + _t1533 = _t1534 } - _t1008 = _t1009 + _t1532 = _t1533 } - _t1007 = _t1008 + _t1531 = _t1532 } - _t1006 = _t1007 + _t1530 = _t1531 } - _t1005 = _t1006 + _t1529 = _t1530 } - _t1004 = _t1005 + _t1528 = _t1529 } - _t1003 = _t1004 + _t1527 = _t1528 } else { - _t1003 = -1 + _t1527 = -1 } - prediction506 := _t1003 - var _t1014 *pb.Primitive - if prediction506 == 9 { + prediction870 := _t1527 + var _t1538 *pb.Primitive + if prediction870 == 9 { p.consumeLiteral("(") p.consumeLiteral("primitive") - _t1015 := p.parse_name() - name516 := _t1015 - xs517 := []*pb.RelTerm{} - cond518 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond518 { - _t1016 := p.parse_rel_term() - item519 := _t1016 - xs517 = append(xs517, item519) - cond518 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + p.pushPath(int(1)) + _t1539 := p.parse_name() + name880 := _t1539 + p.popPath() + p.pushPath(int(2)) + xs885 := []*pb.RelTerm{} + cond886 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx887 := 0 + for cond886 { + p.pushPath(int(idx887)) + _t1540 := p.parse_rel_term() + item888 := _t1540 + p.popPath() + xs885 = append(xs885, item888) + idx887 = (idx887 + 1) + cond886 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - rel_terms520 := xs517 + rel_terms884 := xs885 + p.popPath() p.consumeLiteral(")") - _t1017 := &pb.Primitive{Name: name516, Terms: rel_terms520} - _t1014 = _t1017 + _t1541 := &pb.Primitive{Name: name880, Terms: rel_terms884} + _t1538 = _t1541 } else { - var _t1018 *pb.Primitive - if prediction506 == 8 { - _t1019 := p.parse_divide() - divide515 := _t1019 - _t1018 = divide515 + var _t1542 *pb.Primitive + if prediction870 == 8 { + _t1543 := p.parse_divide() + divide879 := _t1543 + _t1542 = divide879 } else { - var _t1020 *pb.Primitive - if prediction506 == 7 { - _t1021 := p.parse_multiply() - multiply514 := _t1021 - _t1020 = multiply514 + var _t1544 *pb.Primitive + if prediction870 == 7 { + _t1545 := p.parse_multiply() + multiply878 := _t1545 + _t1544 = multiply878 } else { - var _t1022 *pb.Primitive - if prediction506 == 6 { - _t1023 := p.parse_minus() - minus513 := _t1023 - _t1022 = minus513 + var _t1546 *pb.Primitive + if prediction870 == 6 { + _t1547 := p.parse_minus() + minus877 := _t1547 + _t1546 = minus877 } else { - var _t1024 *pb.Primitive - if prediction506 == 5 { - _t1025 := p.parse_add() - add512 := _t1025 - _t1024 = add512 + var _t1548 *pb.Primitive + if prediction870 == 5 { + _t1549 := p.parse_add() + add876 := _t1549 + _t1548 = add876 } else { - var _t1026 *pb.Primitive - if prediction506 == 4 { - _t1027 := p.parse_gt_eq() - gt_eq511 := _t1027 - _t1026 = gt_eq511 + var _t1550 *pb.Primitive + if prediction870 == 4 { + _t1551 := p.parse_gt_eq() + gt_eq875 := _t1551 + _t1550 = gt_eq875 } else { - var _t1028 *pb.Primitive - if prediction506 == 3 { - _t1029 := p.parse_gt() - gt510 := _t1029 - _t1028 = gt510 + var _t1552 *pb.Primitive + if prediction870 == 3 { + _t1553 := p.parse_gt() + gt874 := _t1553 + _t1552 = gt874 } else { - var _t1030 *pb.Primitive - if prediction506 == 2 { - _t1031 := p.parse_lt_eq() - lt_eq509 := _t1031 - _t1030 = lt_eq509 + var _t1554 *pb.Primitive + if prediction870 == 2 { + _t1555 := p.parse_lt_eq() + lt_eq873 := _t1555 + _t1554 = lt_eq873 } else { - var _t1032 *pb.Primitive - if prediction506 == 1 { - _t1033 := p.parse_lt() - lt508 := _t1033 - _t1032 = lt508 + var _t1556 *pb.Primitive + if prediction870 == 1 { + _t1557 := p.parse_lt() + lt872 := _t1557 + _t1556 = lt872 } else { - var _t1034 *pb.Primitive - if prediction506 == 0 { - _t1035 := p.parse_eq() - eq507 := _t1035 - _t1034 = eq507 + var _t1558 *pb.Primitive + if prediction870 == 0 { + _t1559 := p.parse_eq() + eq871 := _t1559 + _t1558 = eq871 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in primitive", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1032 = _t1034 + _t1556 = _t1558 } - _t1030 = _t1032 + _t1554 = _t1556 } - _t1028 = _t1030 + _t1552 = _t1554 } - _t1026 = _t1028 + _t1550 = _t1552 } - _t1024 = _t1026 + _t1548 = _t1550 } - _t1022 = _t1024 + _t1546 = _t1548 } - _t1020 = _t1022 + _t1544 = _t1546 } - _t1018 = _t1020 + _t1542 = _t1544 } - _t1014 = _t1018 + _t1538 = _t1542 } - return _t1014 + result890 := _t1538 + p.recordSpan(int(span_start889)) + return result890 } func (p *Parser) parse_eq() *pb.Primitive { + span_start893 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("=") - _t1036 := p.parse_term() - term521 := _t1036 - _t1037 := p.parse_term() - term_3522 := _t1037 + _t1560 := p.parse_term() + term891 := _t1560 + _t1561 := p.parse_term() + term_3892 := _t1561 p.consumeLiteral(")") - _t1038 := &pb.RelTerm{} - _t1038.RelTermType = &pb.RelTerm_Term{Term: term521} - _t1039 := &pb.RelTerm{} - _t1039.RelTermType = &pb.RelTerm_Term{Term: term_3522} - _t1040 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t1038, _t1039}} - return _t1040 + _t1562 := &pb.RelTerm{} + _t1562.RelTermType = &pb.RelTerm_Term{Term: term891} + _t1563 := &pb.RelTerm{} + _t1563.RelTermType = &pb.RelTerm_Term{Term: term_3892} + _t1564 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t1562, _t1563}} + result894 := _t1564 + p.recordSpan(int(span_start893)) + return result894 } func (p *Parser) parse_lt() *pb.Primitive { + span_start897 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<") - _t1041 := p.parse_term() - term523 := _t1041 - _t1042 := p.parse_term() - term_3524 := _t1042 + _t1565 := p.parse_term() + term895 := _t1565 + _t1566 := p.parse_term() + term_3896 := _t1566 p.consumeLiteral(")") - _t1043 := &pb.RelTerm{} - _t1043.RelTermType = &pb.RelTerm_Term{Term: term523} - _t1044 := &pb.RelTerm{} - _t1044.RelTermType = &pb.RelTerm_Term{Term: term_3524} - _t1045 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t1043, _t1044}} - return _t1045 + _t1567 := &pb.RelTerm{} + _t1567.RelTermType = &pb.RelTerm_Term{Term: term895} + _t1568 := &pb.RelTerm{} + _t1568.RelTermType = &pb.RelTerm_Term{Term: term_3896} + _t1569 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t1567, _t1568}} + result898 := _t1569 + p.recordSpan(int(span_start897)) + return result898 } func (p *Parser) parse_lt_eq() *pb.Primitive { + span_start901 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<=") - _t1046 := p.parse_term() - term525 := _t1046 - _t1047 := p.parse_term() - term_3526 := _t1047 + _t1570 := p.parse_term() + term899 := _t1570 + _t1571 := p.parse_term() + term_3900 := _t1571 p.consumeLiteral(")") - _t1048 := &pb.RelTerm{} - _t1048.RelTermType = &pb.RelTerm_Term{Term: term525} - _t1049 := &pb.RelTerm{} - _t1049.RelTermType = &pb.RelTerm_Term{Term: term_3526} - _t1050 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t1048, _t1049}} - return _t1050 + _t1572 := &pb.RelTerm{} + _t1572.RelTermType = &pb.RelTerm_Term{Term: term899} + _t1573 := &pb.RelTerm{} + _t1573.RelTermType = &pb.RelTerm_Term{Term: term_3900} + _t1574 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t1572, _t1573}} + result902 := _t1574 + p.recordSpan(int(span_start901)) + return result902 } func (p *Parser) parse_gt() *pb.Primitive { + span_start905 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">") - _t1051 := p.parse_term() - term527 := _t1051 - _t1052 := p.parse_term() - term_3528 := _t1052 + _t1575 := p.parse_term() + term903 := _t1575 + _t1576 := p.parse_term() + term_3904 := _t1576 p.consumeLiteral(")") - _t1053 := &pb.RelTerm{} - _t1053.RelTermType = &pb.RelTerm_Term{Term: term527} - _t1054 := &pb.RelTerm{} - _t1054.RelTermType = &pb.RelTerm_Term{Term: term_3528} - _t1055 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t1053, _t1054}} - return _t1055 + _t1577 := &pb.RelTerm{} + _t1577.RelTermType = &pb.RelTerm_Term{Term: term903} + _t1578 := &pb.RelTerm{} + _t1578.RelTermType = &pb.RelTerm_Term{Term: term_3904} + _t1579 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t1577, _t1578}} + result906 := _t1579 + p.recordSpan(int(span_start905)) + return result906 } func (p *Parser) parse_gt_eq() *pb.Primitive { + span_start909 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">=") - _t1056 := p.parse_term() - term529 := _t1056 - _t1057 := p.parse_term() - term_3530 := _t1057 + _t1580 := p.parse_term() + term907 := _t1580 + _t1581 := p.parse_term() + term_3908 := _t1581 p.consumeLiteral(")") - _t1058 := &pb.RelTerm{} - _t1058.RelTermType = &pb.RelTerm_Term{Term: term529} - _t1059 := &pb.RelTerm{} - _t1059.RelTermType = &pb.RelTerm_Term{Term: term_3530} - _t1060 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t1058, _t1059}} - return _t1060 + _t1582 := &pb.RelTerm{} + _t1582.RelTermType = &pb.RelTerm_Term{Term: term907} + _t1583 := &pb.RelTerm{} + _t1583.RelTermType = &pb.RelTerm_Term{Term: term_3908} + _t1584 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t1582, _t1583}} + result910 := _t1584 + p.recordSpan(int(span_start909)) + return result910 } func (p *Parser) parse_add() *pb.Primitive { + span_start914 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("+") - _t1061 := p.parse_term() - term531 := _t1061 - _t1062 := p.parse_term() - term_3532 := _t1062 - _t1063 := p.parse_term() - term_4533 := _t1063 - p.consumeLiteral(")") - _t1064 := &pb.RelTerm{} - _t1064.RelTermType = &pb.RelTerm_Term{Term: term531} - _t1065 := &pb.RelTerm{} - _t1065.RelTermType = &pb.RelTerm_Term{Term: term_3532} - _t1066 := &pb.RelTerm{} - _t1066.RelTermType = &pb.RelTerm_Term{Term: term_4533} - _t1067 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t1064, _t1065, _t1066}} - return _t1067 + _t1585 := p.parse_term() + term911 := _t1585 + _t1586 := p.parse_term() + term_3912 := _t1586 + _t1587 := p.parse_term() + term_4913 := _t1587 + p.consumeLiteral(")") + _t1588 := &pb.RelTerm{} + _t1588.RelTermType = &pb.RelTerm_Term{Term: term911} + _t1589 := &pb.RelTerm{} + _t1589.RelTermType = &pb.RelTerm_Term{Term: term_3912} + _t1590 := &pb.RelTerm{} + _t1590.RelTermType = &pb.RelTerm_Term{Term: term_4913} + _t1591 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t1588, _t1589, _t1590}} + result915 := _t1591 + p.recordSpan(int(span_start914)) + return result915 } func (p *Parser) parse_minus() *pb.Primitive { + span_start919 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("-") - _t1068 := p.parse_term() - term534 := _t1068 - _t1069 := p.parse_term() - term_3535 := _t1069 - _t1070 := p.parse_term() - term_4536 := _t1070 - p.consumeLiteral(")") - _t1071 := &pb.RelTerm{} - _t1071.RelTermType = &pb.RelTerm_Term{Term: term534} - _t1072 := &pb.RelTerm{} - _t1072.RelTermType = &pb.RelTerm_Term{Term: term_3535} - _t1073 := &pb.RelTerm{} - _t1073.RelTermType = &pb.RelTerm_Term{Term: term_4536} - _t1074 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t1071, _t1072, _t1073}} - return _t1074 + _t1592 := p.parse_term() + term916 := _t1592 + _t1593 := p.parse_term() + term_3917 := _t1593 + _t1594 := p.parse_term() + term_4918 := _t1594 + p.consumeLiteral(")") + _t1595 := &pb.RelTerm{} + _t1595.RelTermType = &pb.RelTerm_Term{Term: term916} + _t1596 := &pb.RelTerm{} + _t1596.RelTermType = &pb.RelTerm_Term{Term: term_3917} + _t1597 := &pb.RelTerm{} + _t1597.RelTermType = &pb.RelTerm_Term{Term: term_4918} + _t1598 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t1595, _t1596, _t1597}} + result920 := _t1598 + p.recordSpan(int(span_start919)) + return result920 } func (p *Parser) parse_multiply() *pb.Primitive { + span_start924 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("*") - _t1075 := p.parse_term() - term537 := _t1075 - _t1076 := p.parse_term() - term_3538 := _t1076 - _t1077 := p.parse_term() - term_4539 := _t1077 - p.consumeLiteral(")") - _t1078 := &pb.RelTerm{} - _t1078.RelTermType = &pb.RelTerm_Term{Term: term537} - _t1079 := &pb.RelTerm{} - _t1079.RelTermType = &pb.RelTerm_Term{Term: term_3538} - _t1080 := &pb.RelTerm{} - _t1080.RelTermType = &pb.RelTerm_Term{Term: term_4539} - _t1081 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t1078, _t1079, _t1080}} - return _t1081 + _t1599 := p.parse_term() + term921 := _t1599 + _t1600 := p.parse_term() + term_3922 := _t1600 + _t1601 := p.parse_term() + term_4923 := _t1601 + p.consumeLiteral(")") + _t1602 := &pb.RelTerm{} + _t1602.RelTermType = &pb.RelTerm_Term{Term: term921} + _t1603 := &pb.RelTerm{} + _t1603.RelTermType = &pb.RelTerm_Term{Term: term_3922} + _t1604 := &pb.RelTerm{} + _t1604.RelTermType = &pb.RelTerm_Term{Term: term_4923} + _t1605 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t1602, _t1603, _t1604}} + result925 := _t1605 + p.recordSpan(int(span_start924)) + return result925 } func (p *Parser) parse_divide() *pb.Primitive { + span_start929 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("/") - _t1082 := p.parse_term() - term540 := _t1082 - _t1083 := p.parse_term() - term_3541 := _t1083 - _t1084 := p.parse_term() - term_4542 := _t1084 - p.consumeLiteral(")") - _t1085 := &pb.RelTerm{} - _t1085.RelTermType = &pb.RelTerm_Term{Term: term540} - _t1086 := &pb.RelTerm{} - _t1086.RelTermType = &pb.RelTerm_Term{Term: term_3541} - _t1087 := &pb.RelTerm{} - _t1087.RelTermType = &pb.RelTerm_Term{Term: term_4542} - _t1088 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t1085, _t1086, _t1087}} - return _t1088 + _t1606 := p.parse_term() + term926 := _t1606 + _t1607 := p.parse_term() + term_3927 := _t1607 + _t1608 := p.parse_term() + term_4928 := _t1608 + p.consumeLiteral(")") + _t1609 := &pb.RelTerm{} + _t1609.RelTermType = &pb.RelTerm_Term{Term: term926} + _t1610 := &pb.RelTerm{} + _t1610.RelTermType = &pb.RelTerm_Term{Term: term_3927} + _t1611 := &pb.RelTerm{} + _t1611.RelTermType = &pb.RelTerm_Term{Term: term_4928} + _t1612 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t1609, _t1610, _t1611}} + result930 := _t1612 + p.recordSpan(int(span_start929)) + return result930 } func (p *Parser) parse_rel_term() *pb.RelTerm { - var _t1089 int64 + span_start934 := int64(p.spanStart()) + var _t1613 int64 if p.matchLookaheadLiteral("true", 0) { - _t1089 = 1 + _t1613 = 1 } else { - var _t1090 int64 + var _t1614 int64 if p.matchLookaheadLiteral("missing", 0) { - _t1090 = 1 + _t1614 = 1 } else { - var _t1091 int64 + var _t1615 int64 if p.matchLookaheadLiteral("false", 0) { - _t1091 = 1 + _t1615 = 1 } else { - var _t1092 int64 + var _t1616 int64 if p.matchLookaheadLiteral("(", 0) { - _t1092 = 1 + _t1616 = 1 } else { - var _t1093 int64 + var _t1617 int64 if p.matchLookaheadLiteral("#", 0) { - _t1093 = 0 + _t1617 = 0 } else { - var _t1094 int64 + var _t1618 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1094 = 1 + _t1618 = 1 } else { - var _t1095 int64 + var _t1619 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t1095 = 1 + _t1619 = 1 } else { - var _t1096 int64 + var _t1620 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t1096 = 1 + _t1620 = 1 } else { - var _t1097 int64 + var _t1621 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t1097 = 1 + _t1621 = 1 } else { - var _t1098 int64 + var _t1622 int64 if p.matchLookaheadTerminal("INT", 0) { - _t1098 = 1 + _t1622 = 1 } else { - var _t1099 int64 + var _t1623 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t1099 = 1 + _t1623 = 1 } else { - var _t1100 int64 + var _t1624 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t1100 = 1 + _t1624 = 1 } else { - _t1100 = -1 + _t1624 = -1 } - _t1099 = _t1100 + _t1623 = _t1624 } - _t1098 = _t1099 + _t1622 = _t1623 } - _t1097 = _t1098 + _t1621 = _t1622 } - _t1096 = _t1097 + _t1620 = _t1621 } - _t1095 = _t1096 + _t1619 = _t1620 } - _t1094 = _t1095 + _t1618 = _t1619 } - _t1093 = _t1094 + _t1617 = _t1618 } - _t1092 = _t1093 + _t1616 = _t1617 } - _t1091 = _t1092 + _t1615 = _t1616 } - _t1090 = _t1091 + _t1614 = _t1615 } - _t1089 = _t1090 - } - prediction543 := _t1089 - var _t1101 *pb.RelTerm - if prediction543 == 1 { - _t1102 := p.parse_term() - term545 := _t1102 - _t1103 := &pb.RelTerm{} - _t1103.RelTermType = &pb.RelTerm_Term{Term: term545} - _t1101 = _t1103 + _t1613 = _t1614 + } + prediction931 := _t1613 + var _t1625 *pb.RelTerm + if prediction931 == 1 { + _t1626 := p.parse_term() + term933 := _t1626 + _t1627 := &pb.RelTerm{} + _t1627.RelTermType = &pb.RelTerm_Term{Term: term933} + _t1625 = _t1627 } else { - var _t1104 *pb.RelTerm - if prediction543 == 0 { - _t1105 := p.parse_specialized_value() - specialized_value544 := _t1105 - _t1106 := &pb.RelTerm{} - _t1106.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value544} - _t1104 = _t1106 + var _t1628 *pb.RelTerm + if prediction931 == 0 { + _t1629 := p.parse_specialized_value() + specialized_value932 := _t1629 + _t1630 := &pb.RelTerm{} + _t1630.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value932} + _t1628 = _t1630 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in rel_term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1101 = _t1104 + _t1625 = _t1628 } - return _t1101 + result935 := _t1625 + p.recordSpan(int(span_start934)) + return result935 } func (p *Parser) parse_specialized_value() *pb.Value { + span_start937 := int64(p.spanStart()) p.consumeLiteral("#") - _t1107 := p.parse_value() - value546 := _t1107 - return value546 + _t1631 := p.parse_value() + value936 := _t1631 + result938 := value936 + p.recordSpan(int(span_start937)) + return result938 } func (p *Parser) parse_rel_atom() *pb.RelAtom { + span_start948 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("relatom") - _t1108 := p.parse_name() - name547 := _t1108 - xs548 := []*pb.RelTerm{} - cond549 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond549 { - _t1109 := p.parse_rel_term() - item550 := _t1109 - xs548 = append(xs548, item550) - cond549 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - rel_terms551 := xs548 + p.pushPath(int(3)) + _t1632 := p.parse_name() + name939 := _t1632 + p.popPath() + p.pushPath(int(2)) + xs944 := []*pb.RelTerm{} + cond945 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx946 := 0 + for cond945 { + p.pushPath(int(idx946)) + _t1633 := p.parse_rel_term() + item947 := _t1633 + p.popPath() + xs944 = append(xs944, item947) + idx946 = (idx946 + 1) + cond945 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + rel_terms943 := xs944 + p.popPath() p.consumeLiteral(")") - _t1110 := &pb.RelAtom{Name: name547, Terms: rel_terms551} - return _t1110 + _t1634 := &pb.RelAtom{Name: name939, Terms: rel_terms943} + result949 := _t1634 + p.recordSpan(int(span_start948)) + return result949 } func (p *Parser) parse_cast() *pb.Cast { + span_start952 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("cast") - _t1111 := p.parse_term() - term552 := _t1111 - _t1112 := p.parse_term() - term_3553 := _t1112 + p.pushPath(int(2)) + _t1635 := p.parse_term() + term950 := _t1635 + p.popPath() + p.pushPath(int(3)) + _t1636 := p.parse_term() + term_3951 := _t1636 + p.popPath() p.consumeLiteral(")") - _t1113 := &pb.Cast{Input: term552, Result: term_3553} - return _t1113 + _t1637 := &pb.Cast{Input: term950, Result: term_3951} + result953 := _t1637 + p.recordSpan(int(span_start952)) + return result953 } func (p *Parser) parse_attrs() []*pb.Attribute { + span_start958 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("attrs") - xs554 := []*pb.Attribute{} - cond555 := p.matchLookaheadLiteral("(", 0) - for cond555 { - _t1114 := p.parse_attribute() - item556 := _t1114 - xs554 = append(xs554, item556) - cond555 = p.matchLookaheadLiteral("(", 0) - } - attributes557 := xs554 + xs954 := []*pb.Attribute{} + cond955 := p.matchLookaheadLiteral("(", 0) + for cond955 { + _t1638 := p.parse_attribute() + item956 := _t1638 + xs954 = append(xs954, item956) + cond955 = p.matchLookaheadLiteral("(", 0) + } + attributes957 := xs954 p.consumeLiteral(")") - return attributes557 + result959 := attributes957 + p.recordSpan(int(span_start958)) + return result959 } func (p *Parser) parse_attribute() *pb.Attribute { + span_start969 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("attribute") - _t1115 := p.parse_name() - name558 := _t1115 - xs559 := []*pb.Value{} - cond560 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond560 { - _t1116 := p.parse_value() - item561 := _t1116 - xs559 = append(xs559, item561) - cond560 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - values562 := xs559 + p.pushPath(int(1)) + _t1639 := p.parse_name() + name960 := _t1639 + p.popPath() + p.pushPath(int(2)) + xs965 := []*pb.Value{} + cond966 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx967 := 0 + for cond966 { + p.pushPath(int(idx967)) + _t1640 := p.parse_value() + item968 := _t1640 + p.popPath() + xs965 = append(xs965, item968) + idx967 = (idx967 + 1) + cond966 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + values964 := xs965 + p.popPath() p.consumeLiteral(")") - _t1117 := &pb.Attribute{Name: name558, Args: values562} - return _t1117 + _t1641 := &pb.Attribute{Name: name960, Args: values964} + result970 := _t1641 + p.recordSpan(int(span_start969)) + return result970 } func (p *Parser) parse_algorithm() *pb.Algorithm { + span_start980 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("algorithm") - xs563 := []*pb.RelationId{} - cond564 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - for cond564 { - _t1118 := p.parse_relation_id() - item565 := _t1118 - xs563 = append(xs563, item565) - cond564 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - } - relation_ids566 := xs563 - _t1119 := p.parse_script() - script567 := _t1119 + p.pushPath(int(1)) + xs975 := []*pb.RelationId{} + cond976 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx977 := 0 + for cond976 { + p.pushPath(int(idx977)) + _t1642 := p.parse_relation_id() + item978 := _t1642 + p.popPath() + xs975 = append(xs975, item978) + idx977 = (idx977 + 1) + cond976 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + relation_ids974 := xs975 + p.popPath() + p.pushPath(int(2)) + _t1643 := p.parse_script() + script979 := _t1643 + p.popPath() p.consumeLiteral(")") - _t1120 := &pb.Algorithm{Global: relation_ids566, Body: script567} - return _t1120 + _t1644 := &pb.Algorithm{Global: relation_ids974, Body: script979} + result981 := _t1644 + p.recordSpan(int(span_start980)) + return result981 } func (p *Parser) parse_script() *pb.Script { + span_start990 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("script") - xs568 := []*pb.Construct{} - cond569 := p.matchLookaheadLiteral("(", 0) - for cond569 { - _t1121 := p.parse_construct() - item570 := _t1121 - xs568 = append(xs568, item570) - cond569 = p.matchLookaheadLiteral("(", 0) - } - constructs571 := xs568 + p.pushPath(int(1)) + xs986 := []*pb.Construct{} + cond987 := p.matchLookaheadLiteral("(", 0) + idx988 := 0 + for cond987 { + p.pushPath(int(idx988)) + _t1645 := p.parse_construct() + item989 := _t1645 + p.popPath() + xs986 = append(xs986, item989) + idx988 = (idx988 + 1) + cond987 = p.matchLookaheadLiteral("(", 0) + } + constructs985 := xs986 + p.popPath() p.consumeLiteral(")") - _t1122 := &pb.Script{Constructs: constructs571} - return _t1122 + _t1646 := &pb.Script{Constructs: constructs985} + result991 := _t1646 + p.recordSpan(int(span_start990)) + return result991 } func (p *Parser) parse_construct() *pb.Construct { - var _t1123 int64 + span_start995 := int64(p.spanStart()) + var _t1647 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1124 int64 + var _t1648 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1124 = 1 + _t1648 = 1 } else { - var _t1125 int64 + var _t1649 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1125 = 1 + _t1649 = 1 } else { - var _t1126 int64 + var _t1650 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1126 = 1 + _t1650 = 1 } else { - var _t1127 int64 + var _t1651 int64 if p.matchLookaheadLiteral("loop", 1) { - _t1127 = 0 + _t1651 = 0 } else { - var _t1128 int64 + var _t1652 int64 if p.matchLookaheadLiteral("break", 1) { - _t1128 = 1 + _t1652 = 1 } else { - var _t1129 int64 + var _t1653 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1129 = 1 + _t1653 = 1 } else { - _t1129 = -1 + _t1653 = -1 } - _t1128 = _t1129 + _t1652 = _t1653 } - _t1127 = _t1128 + _t1651 = _t1652 } - _t1126 = _t1127 + _t1650 = _t1651 } - _t1125 = _t1126 + _t1649 = _t1650 } - _t1124 = _t1125 + _t1648 = _t1649 } - _t1123 = _t1124 + _t1647 = _t1648 } else { - _t1123 = -1 - } - prediction572 := _t1123 - var _t1130 *pb.Construct - if prediction572 == 1 { - _t1131 := p.parse_instruction() - instruction574 := _t1131 - _t1132 := &pb.Construct{} - _t1132.ConstructType = &pb.Construct_Instruction{Instruction: instruction574} - _t1130 = _t1132 + _t1647 = -1 + } + prediction992 := _t1647 + var _t1654 *pb.Construct + if prediction992 == 1 { + _t1655 := p.parse_instruction() + instruction994 := _t1655 + _t1656 := &pb.Construct{} + _t1656.ConstructType = &pb.Construct_Instruction{Instruction: instruction994} + _t1654 = _t1656 } else { - var _t1133 *pb.Construct - if prediction572 == 0 { - _t1134 := p.parse_loop() - loop573 := _t1134 - _t1135 := &pb.Construct{} - _t1135.ConstructType = &pb.Construct_Loop{Loop: loop573} - _t1133 = _t1135 + var _t1657 *pb.Construct + if prediction992 == 0 { + _t1658 := p.parse_loop() + loop993 := _t1658 + _t1659 := &pb.Construct{} + _t1659.ConstructType = &pb.Construct_Loop{Loop: loop993} + _t1657 = _t1659 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in construct", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1130 = _t1133 + _t1654 = _t1657 } - return _t1130 + result996 := _t1654 + p.recordSpan(int(span_start995)) + return result996 } func (p *Parser) parse_loop() *pb.Loop { + span_start999 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("loop") - _t1136 := p.parse_init() - init575 := _t1136 - _t1137 := p.parse_script() - script576 := _t1137 + p.pushPath(int(1)) + _t1660 := p.parse_init() + init997 := _t1660 + p.popPath() + p.pushPath(int(2)) + _t1661 := p.parse_script() + script998 := _t1661 + p.popPath() p.consumeLiteral(")") - _t1138 := &pb.Loop{Init: init575, Body: script576} - return _t1138 + _t1662 := &pb.Loop{Init: init997, Body: script998} + result1000 := _t1662 + p.recordSpan(int(span_start999)) + return result1000 } func (p *Parser) parse_init() []*pb.Instruction { + span_start1005 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("init") - xs577 := []*pb.Instruction{} - cond578 := p.matchLookaheadLiteral("(", 0) - for cond578 { - _t1139 := p.parse_instruction() - item579 := _t1139 - xs577 = append(xs577, item579) - cond578 = p.matchLookaheadLiteral("(", 0) - } - instructions580 := xs577 + xs1001 := []*pb.Instruction{} + cond1002 := p.matchLookaheadLiteral("(", 0) + for cond1002 { + _t1663 := p.parse_instruction() + item1003 := _t1663 + xs1001 = append(xs1001, item1003) + cond1002 = p.matchLookaheadLiteral("(", 0) + } + instructions1004 := xs1001 p.consumeLiteral(")") - return instructions580 + result1006 := instructions1004 + p.recordSpan(int(span_start1005)) + return result1006 } func (p *Parser) parse_instruction() *pb.Instruction { - var _t1140 int64 + span_start1013 := int64(p.spanStart()) + var _t1664 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1141 int64 + var _t1665 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1141 = 1 + _t1665 = 1 } else { - var _t1142 int64 + var _t1666 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1142 = 4 + _t1666 = 4 } else { - var _t1143 int64 + var _t1667 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1143 = 3 + _t1667 = 3 } else { - var _t1144 int64 + var _t1668 int64 if p.matchLookaheadLiteral("break", 1) { - _t1144 = 2 + _t1668 = 2 } else { - var _t1145 int64 + var _t1669 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1145 = 0 + _t1669 = 0 } else { - _t1145 = -1 + _t1669 = -1 } - _t1144 = _t1145 + _t1668 = _t1669 } - _t1143 = _t1144 + _t1667 = _t1668 } - _t1142 = _t1143 + _t1666 = _t1667 } - _t1141 = _t1142 + _t1665 = _t1666 } - _t1140 = _t1141 + _t1664 = _t1665 } else { - _t1140 = -1 - } - prediction581 := _t1140 - var _t1146 *pb.Instruction - if prediction581 == 4 { - _t1147 := p.parse_monus_def() - monus_def586 := _t1147 - _t1148 := &pb.Instruction{} - _t1148.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def586} - _t1146 = _t1148 + _t1664 = -1 + } + prediction1007 := _t1664 + var _t1670 *pb.Instruction + if prediction1007 == 4 { + _t1671 := p.parse_monus_def() + monus_def1012 := _t1671 + _t1672 := &pb.Instruction{} + _t1672.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def1012} + _t1670 = _t1672 } else { - var _t1149 *pb.Instruction - if prediction581 == 3 { - _t1150 := p.parse_monoid_def() - monoid_def585 := _t1150 - _t1151 := &pb.Instruction{} - _t1151.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def585} - _t1149 = _t1151 + var _t1673 *pb.Instruction + if prediction1007 == 3 { + _t1674 := p.parse_monoid_def() + monoid_def1011 := _t1674 + _t1675 := &pb.Instruction{} + _t1675.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def1011} + _t1673 = _t1675 } else { - var _t1152 *pb.Instruction - if prediction581 == 2 { - _t1153 := p.parse_break() - break584 := _t1153 - _t1154 := &pb.Instruction{} - _t1154.InstrType = &pb.Instruction_Break{Break: break584} - _t1152 = _t1154 + var _t1676 *pb.Instruction + if prediction1007 == 2 { + _t1677 := p.parse_break() + break1010 := _t1677 + _t1678 := &pb.Instruction{} + _t1678.InstrType = &pb.Instruction_Break{Break: break1010} + _t1676 = _t1678 } else { - var _t1155 *pb.Instruction - if prediction581 == 1 { - _t1156 := p.parse_upsert() - upsert583 := _t1156 - _t1157 := &pb.Instruction{} - _t1157.InstrType = &pb.Instruction_Upsert{Upsert: upsert583} - _t1155 = _t1157 + var _t1679 *pb.Instruction + if prediction1007 == 1 { + _t1680 := p.parse_upsert() + upsert1009 := _t1680 + _t1681 := &pb.Instruction{} + _t1681.InstrType = &pb.Instruction_Upsert{Upsert: upsert1009} + _t1679 = _t1681 } else { - var _t1158 *pb.Instruction - if prediction581 == 0 { - _t1159 := p.parse_assign() - assign582 := _t1159 - _t1160 := &pb.Instruction{} - _t1160.InstrType = &pb.Instruction_Assign{Assign: assign582} - _t1158 = _t1160 + var _t1682 *pb.Instruction + if prediction1007 == 0 { + _t1683 := p.parse_assign() + assign1008 := _t1683 + _t1684 := &pb.Instruction{} + _t1684.InstrType = &pb.Instruction_Assign{Assign: assign1008} + _t1682 = _t1684 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in instruction", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1155 = _t1158 + _t1679 = _t1682 } - _t1152 = _t1155 + _t1676 = _t1679 } - _t1149 = _t1152 + _t1673 = _t1676 } - _t1146 = _t1149 + _t1670 = _t1673 } - return _t1146 + result1014 := _t1670 + p.recordSpan(int(span_start1013)) + return result1014 } func (p *Parser) parse_assign() *pb.Assign { + span_start1018 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("assign") - _t1161 := p.parse_relation_id() - relation_id587 := _t1161 - _t1162 := p.parse_abstraction() - abstraction588 := _t1162 - var _t1163 []*pb.Attribute + p.pushPath(int(1)) + _t1685 := p.parse_relation_id() + relation_id1015 := _t1685 + p.popPath() + p.pushPath(int(2)) + _t1686 := p.parse_abstraction() + abstraction1016 := _t1686 + p.popPath() + p.pushPath(int(3)) + var _t1687 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1164 := p.parse_attrs() - _t1163 = _t1164 + _t1688 := p.parse_attrs() + _t1687 = _t1688 } - attrs589 := _t1163 + attrs1017 := _t1687 + p.popPath() p.consumeLiteral(")") - _t1165 := attrs589 - if attrs589 == nil { - _t1165 = []*pb.Attribute{} + _t1689 := attrs1017 + if attrs1017 == nil { + _t1689 = []*pb.Attribute{} } - _t1166 := &pb.Assign{Name: relation_id587, Body: abstraction588, Attrs: _t1165} - return _t1166 + _t1690 := &pb.Assign{Name: relation_id1015, Body: abstraction1016, Attrs: _t1689} + result1019 := _t1690 + p.recordSpan(int(span_start1018)) + return result1019 } func (p *Parser) parse_upsert() *pb.Upsert { + span_start1023 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("upsert") - _t1167 := p.parse_relation_id() - relation_id590 := _t1167 - _t1168 := p.parse_abstraction_with_arity() - abstraction_with_arity591 := _t1168 - var _t1169 []*pb.Attribute + p.pushPath(int(1)) + _t1691 := p.parse_relation_id() + relation_id1020 := _t1691 + p.popPath() + _t1692 := p.parse_abstraction_with_arity() + abstraction_with_arity1021 := _t1692 + p.pushPath(int(3)) + var _t1693 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1170 := p.parse_attrs() - _t1169 = _t1170 + _t1694 := p.parse_attrs() + _t1693 = _t1694 } - attrs592 := _t1169 + attrs1022 := _t1693 + p.popPath() p.consumeLiteral(")") - _t1171 := attrs592 - if attrs592 == nil { - _t1171 = []*pb.Attribute{} + _t1695 := attrs1022 + if attrs1022 == nil { + _t1695 = []*pb.Attribute{} } - _t1172 := &pb.Upsert{Name: relation_id590, Body: abstraction_with_arity591[0].(*pb.Abstraction), Attrs: _t1171, ValueArity: abstraction_with_arity591[1].(int64)} - return _t1172 + _t1696 := &pb.Upsert{Name: relation_id1020, Body: abstraction_with_arity1021[0].(*pb.Abstraction), Attrs: _t1695, ValueArity: abstraction_with_arity1021[1].(int64)} + result1024 := _t1696 + p.recordSpan(int(span_start1023)) + return result1024 } func (p *Parser) parse_abstraction_with_arity() []interface{} { + span_start1027 := int64(p.spanStart()) p.consumeLiteral("(") - _t1173 := p.parse_bindings() - bindings593 := _t1173 - _t1174 := p.parse_formula() - formula594 := _t1174 + _t1697 := p.parse_bindings() + bindings1025 := _t1697 + _t1698 := p.parse_formula() + formula1026 := _t1698 p.consumeLiteral(")") - _t1175 := &pb.Abstraction{Vars: listConcat(bindings593[0].([]*pb.Binding), bindings593[1].([]*pb.Binding)), Value: formula594} - return []interface{}{_t1175, int64(len(bindings593[1].([]*pb.Binding)))} + _t1699 := &pb.Abstraction{Vars: listConcat(bindings1025[0].([]*pb.Binding), bindings1025[1].([]*pb.Binding)), Value: formula1026} + result1028 := []interface{}{_t1699, int64(len(bindings1025[1].([]*pb.Binding)))} + p.recordSpan(int(span_start1027)) + return result1028 } func (p *Parser) parse_break() *pb.Break { + span_start1032 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("break") - _t1176 := p.parse_relation_id() - relation_id595 := _t1176 - _t1177 := p.parse_abstraction() - abstraction596 := _t1177 - var _t1178 []*pb.Attribute + p.pushPath(int(1)) + _t1700 := p.parse_relation_id() + relation_id1029 := _t1700 + p.popPath() + p.pushPath(int(2)) + _t1701 := p.parse_abstraction() + abstraction1030 := _t1701 + p.popPath() + p.pushPath(int(3)) + var _t1702 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1179 := p.parse_attrs() - _t1178 = _t1179 + _t1703 := p.parse_attrs() + _t1702 = _t1703 } - attrs597 := _t1178 + attrs1031 := _t1702 + p.popPath() p.consumeLiteral(")") - _t1180 := attrs597 - if attrs597 == nil { - _t1180 = []*pb.Attribute{} + _t1704 := attrs1031 + if attrs1031 == nil { + _t1704 = []*pb.Attribute{} } - _t1181 := &pb.Break{Name: relation_id595, Body: abstraction596, Attrs: _t1180} - return _t1181 + _t1705 := &pb.Break{Name: relation_id1029, Body: abstraction1030, Attrs: _t1704} + result1033 := _t1705 + p.recordSpan(int(span_start1032)) + return result1033 } func (p *Parser) parse_monoid_def() *pb.MonoidDef { + span_start1038 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("monoid") - _t1182 := p.parse_monoid() - monoid598 := _t1182 - _t1183 := p.parse_relation_id() - relation_id599 := _t1183 - _t1184 := p.parse_abstraction_with_arity() - abstraction_with_arity600 := _t1184 - var _t1185 []*pb.Attribute + p.pushPath(int(1)) + _t1706 := p.parse_monoid() + monoid1034 := _t1706 + p.popPath() + p.pushPath(int(2)) + _t1707 := p.parse_relation_id() + relation_id1035 := _t1707 + p.popPath() + _t1708 := p.parse_abstraction_with_arity() + abstraction_with_arity1036 := _t1708 + p.pushPath(int(4)) + var _t1709 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1186 := p.parse_attrs() - _t1185 = _t1186 + _t1710 := p.parse_attrs() + _t1709 = _t1710 } - attrs601 := _t1185 + attrs1037 := _t1709 + p.popPath() p.consumeLiteral(")") - _t1187 := attrs601 - if attrs601 == nil { - _t1187 = []*pb.Attribute{} + _t1711 := attrs1037 + if attrs1037 == nil { + _t1711 = []*pb.Attribute{} } - _t1188 := &pb.MonoidDef{Monoid: monoid598, Name: relation_id599, Body: abstraction_with_arity600[0].(*pb.Abstraction), Attrs: _t1187, ValueArity: abstraction_with_arity600[1].(int64)} - return _t1188 + _t1712 := &pb.MonoidDef{Monoid: monoid1034, Name: relation_id1035, Body: abstraction_with_arity1036[0].(*pb.Abstraction), Attrs: _t1711, ValueArity: abstraction_with_arity1036[1].(int64)} + result1039 := _t1712 + p.recordSpan(int(span_start1038)) + return result1039 } func (p *Parser) parse_monoid() *pb.Monoid { - var _t1189 int64 + span_start1045 := int64(p.spanStart()) + var _t1713 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1190 int64 + var _t1714 int64 if p.matchLookaheadLiteral("sum", 1) { - _t1190 = 3 + _t1714 = 3 } else { - var _t1191 int64 + var _t1715 int64 if p.matchLookaheadLiteral("or", 1) { - _t1191 = 0 + _t1715 = 0 } else { - var _t1192 int64 + var _t1716 int64 if p.matchLookaheadLiteral("min", 1) { - _t1192 = 1 + _t1716 = 1 } else { - var _t1193 int64 + var _t1717 int64 if p.matchLookaheadLiteral("max", 1) { - _t1193 = 2 + _t1717 = 2 } else { - _t1193 = -1 + _t1717 = -1 } - _t1192 = _t1193 + _t1716 = _t1717 } - _t1191 = _t1192 + _t1715 = _t1716 } - _t1190 = _t1191 + _t1714 = _t1715 } - _t1189 = _t1190 + _t1713 = _t1714 } else { - _t1189 = -1 - } - prediction602 := _t1189 - var _t1194 *pb.Monoid - if prediction602 == 3 { - _t1195 := p.parse_sum_monoid() - sum_monoid606 := _t1195 - _t1196 := &pb.Monoid{} - _t1196.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid606} - _t1194 = _t1196 + _t1713 = -1 + } + prediction1040 := _t1713 + var _t1718 *pb.Monoid + if prediction1040 == 3 { + _t1719 := p.parse_sum_monoid() + sum_monoid1044 := _t1719 + _t1720 := &pb.Monoid{} + _t1720.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid1044} + _t1718 = _t1720 } else { - var _t1197 *pb.Monoid - if prediction602 == 2 { - _t1198 := p.parse_max_monoid() - max_monoid605 := _t1198 - _t1199 := &pb.Monoid{} - _t1199.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid605} - _t1197 = _t1199 + var _t1721 *pb.Monoid + if prediction1040 == 2 { + _t1722 := p.parse_max_monoid() + max_monoid1043 := _t1722 + _t1723 := &pb.Monoid{} + _t1723.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid1043} + _t1721 = _t1723 } else { - var _t1200 *pb.Monoid - if prediction602 == 1 { - _t1201 := p.parse_min_monoid() - min_monoid604 := _t1201 - _t1202 := &pb.Monoid{} - _t1202.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid604} - _t1200 = _t1202 + var _t1724 *pb.Monoid + if prediction1040 == 1 { + _t1725 := p.parse_min_monoid() + min_monoid1042 := _t1725 + _t1726 := &pb.Monoid{} + _t1726.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid1042} + _t1724 = _t1726 } else { - var _t1203 *pb.Monoid - if prediction602 == 0 { - _t1204 := p.parse_or_monoid() - or_monoid603 := _t1204 - _t1205 := &pb.Monoid{} - _t1205.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid603} - _t1203 = _t1205 + var _t1727 *pb.Monoid + if prediction1040 == 0 { + _t1728 := p.parse_or_monoid() + or_monoid1041 := _t1728 + _t1729 := &pb.Monoid{} + _t1729.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid1041} + _t1727 = _t1729 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in monoid", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1200 = _t1203 + _t1724 = _t1727 } - _t1197 = _t1200 + _t1721 = _t1724 } - _t1194 = _t1197 + _t1718 = _t1721 } - return _t1194 + result1046 := _t1718 + p.recordSpan(int(span_start1045)) + return result1046 } func (p *Parser) parse_or_monoid() *pb.OrMonoid { + span_start1047 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("or") p.consumeLiteral(")") - _t1206 := &pb.OrMonoid{} - return _t1206 + _t1730 := &pb.OrMonoid{} + result1048 := _t1730 + p.recordSpan(int(span_start1047)) + return result1048 } func (p *Parser) parse_min_monoid() *pb.MinMonoid { + span_start1050 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("min") - _t1207 := p.parse_type() - type607 := _t1207 + p.pushPath(int(1)) + _t1731 := p.parse_type() + type1049 := _t1731 + p.popPath() p.consumeLiteral(")") - _t1208 := &pb.MinMonoid{Type: type607} - return _t1208 + _t1732 := &pb.MinMonoid{Type: type1049} + result1051 := _t1732 + p.recordSpan(int(span_start1050)) + return result1051 } func (p *Parser) parse_max_monoid() *pb.MaxMonoid { + span_start1053 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("max") - _t1209 := p.parse_type() - type608 := _t1209 + p.pushPath(int(1)) + _t1733 := p.parse_type() + type1052 := _t1733 + p.popPath() p.consumeLiteral(")") - _t1210 := &pb.MaxMonoid{Type: type608} - return _t1210 + _t1734 := &pb.MaxMonoid{Type: type1052} + result1054 := _t1734 + p.recordSpan(int(span_start1053)) + return result1054 } func (p *Parser) parse_sum_monoid() *pb.SumMonoid { + span_start1056 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("sum") - _t1211 := p.parse_type() - type609 := _t1211 + p.pushPath(int(1)) + _t1735 := p.parse_type() + type1055 := _t1735 + p.popPath() p.consumeLiteral(")") - _t1212 := &pb.SumMonoid{Type: type609} - return _t1212 + _t1736 := &pb.SumMonoid{Type: type1055} + result1057 := _t1736 + p.recordSpan(int(span_start1056)) + return result1057 } func (p *Parser) parse_monus_def() *pb.MonusDef { + span_start1062 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("monus") - _t1213 := p.parse_monoid() - monoid610 := _t1213 - _t1214 := p.parse_relation_id() - relation_id611 := _t1214 - _t1215 := p.parse_abstraction_with_arity() - abstraction_with_arity612 := _t1215 - var _t1216 []*pb.Attribute + p.pushPath(int(1)) + _t1737 := p.parse_monoid() + monoid1058 := _t1737 + p.popPath() + p.pushPath(int(2)) + _t1738 := p.parse_relation_id() + relation_id1059 := _t1738 + p.popPath() + _t1739 := p.parse_abstraction_with_arity() + abstraction_with_arity1060 := _t1739 + p.pushPath(int(4)) + var _t1740 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1217 := p.parse_attrs() - _t1216 = _t1217 + _t1741 := p.parse_attrs() + _t1740 = _t1741 } - attrs613 := _t1216 + attrs1061 := _t1740 + p.popPath() p.consumeLiteral(")") - _t1218 := attrs613 - if attrs613 == nil { - _t1218 = []*pb.Attribute{} + _t1742 := attrs1061 + if attrs1061 == nil { + _t1742 = []*pb.Attribute{} } - _t1219 := &pb.MonusDef{Monoid: monoid610, Name: relation_id611, Body: abstraction_with_arity612[0].(*pb.Abstraction), Attrs: _t1218, ValueArity: abstraction_with_arity612[1].(int64)} - return _t1219 + _t1743 := &pb.MonusDef{Monoid: monoid1058, Name: relation_id1059, Body: abstraction_with_arity1060[0].(*pb.Abstraction), Attrs: _t1742, ValueArity: abstraction_with_arity1060[1].(int64)} + result1063 := _t1743 + p.recordSpan(int(span_start1062)) + return result1063 } func (p *Parser) parse_constraint() *pb.Constraint { + span_start1068 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("functional_dependency") - _t1220 := p.parse_relation_id() - relation_id614 := _t1220 - _t1221 := p.parse_abstraction() - abstraction615 := _t1221 - _t1222 := p.parse_functional_dependency_keys() - functional_dependency_keys616 := _t1222 - _t1223 := p.parse_functional_dependency_values() - functional_dependency_values617 := _t1223 + p.pushPath(int(2)) + _t1744 := p.parse_relation_id() + relation_id1064 := _t1744 + p.popPath() + _t1745 := p.parse_abstraction() + abstraction1065 := _t1745 + _t1746 := p.parse_functional_dependency_keys() + functional_dependency_keys1066 := _t1746 + _t1747 := p.parse_functional_dependency_values() + functional_dependency_values1067 := _t1747 p.consumeLiteral(")") - _t1224 := &pb.FunctionalDependency{Guard: abstraction615, Keys: functional_dependency_keys616, Values: functional_dependency_values617} - _t1225 := &pb.Constraint{Name: relation_id614} - _t1225.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t1224} - return _t1225 + _t1748 := &pb.FunctionalDependency{Guard: abstraction1065, Keys: functional_dependency_keys1066, Values: functional_dependency_values1067} + _t1749 := &pb.Constraint{Name: relation_id1064} + _t1749.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t1748} + result1069 := _t1749 + p.recordSpan(int(span_start1068)) + return result1069 } func (p *Parser) parse_functional_dependency_keys() []*pb.Var { + span_start1074 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("keys") - xs618 := []*pb.Var{} - cond619 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond619 { - _t1226 := p.parse_var() - item620 := _t1226 - xs618 = append(xs618, item620) - cond619 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars621 := xs618 + xs1070 := []*pb.Var{} + cond1071 := p.matchLookaheadTerminal("SYMBOL", 0) + for cond1071 { + _t1750 := p.parse_var() + item1072 := _t1750 + xs1070 = append(xs1070, item1072) + cond1071 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars1073 := xs1070 p.consumeLiteral(")") - return vars621 + result1075 := vars1073 + p.recordSpan(int(span_start1074)) + return result1075 } func (p *Parser) parse_functional_dependency_values() []*pb.Var { + span_start1080 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("values") - xs622 := []*pb.Var{} - cond623 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond623 { - _t1227 := p.parse_var() - item624 := _t1227 - xs622 = append(xs622, item624) - cond623 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars625 := xs622 + xs1076 := []*pb.Var{} + cond1077 := p.matchLookaheadTerminal("SYMBOL", 0) + for cond1077 { + _t1751 := p.parse_var() + item1078 := _t1751 + xs1076 = append(xs1076, item1078) + cond1077 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars1079 := xs1076 p.consumeLiteral(")") - return vars625 + result1081 := vars1079 + p.recordSpan(int(span_start1080)) + return result1081 } func (p *Parser) parse_data() *pb.Data { - var _t1228 int64 + span_start1086 := int64(p.spanStart()) + var _t1752 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1229 int64 + var _t1753 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t1229 = 0 + _t1753 = 0 } else { - var _t1230 int64 + var _t1754 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t1230 = 2 + _t1754 = 2 } else { - var _t1231 int64 + var _t1755 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t1231 = 1 + _t1755 = 1 } else { - _t1231 = -1 + _t1755 = -1 } - _t1230 = _t1231 + _t1754 = _t1755 } - _t1229 = _t1230 + _t1753 = _t1754 } - _t1228 = _t1229 + _t1752 = _t1753 } else { - _t1228 = -1 - } - prediction626 := _t1228 - var _t1232 *pb.Data - if prediction626 == 2 { - _t1233 := p.parse_csv_data() - csv_data629 := _t1233 - _t1234 := &pb.Data{} - _t1234.DataType = &pb.Data_CsvData{CsvData: csv_data629} - _t1232 = _t1234 + _t1752 = -1 + } + prediction1082 := _t1752 + var _t1756 *pb.Data + if prediction1082 == 2 { + _t1757 := p.parse_csv_data() + csv_data1085 := _t1757 + _t1758 := &pb.Data{} + _t1758.DataType = &pb.Data_CsvData{CsvData: csv_data1085} + _t1756 = _t1758 } else { - var _t1235 *pb.Data - if prediction626 == 1 { - _t1236 := p.parse_betree_relation() - betree_relation628 := _t1236 - _t1237 := &pb.Data{} - _t1237.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation628} - _t1235 = _t1237 + var _t1759 *pb.Data + if prediction1082 == 1 { + _t1760 := p.parse_betree_relation() + betree_relation1084 := _t1760 + _t1761 := &pb.Data{} + _t1761.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation1084} + _t1759 = _t1761 } else { - var _t1238 *pb.Data - if prediction626 == 0 { - _t1239 := p.parse_rel_edb() - rel_edb627 := _t1239 - _t1240 := &pb.Data{} - _t1240.DataType = &pb.Data_RelEdb{RelEdb: rel_edb627} - _t1238 = _t1240 + var _t1762 *pb.Data + if prediction1082 == 0 { + _t1763 := p.parse_rel_edb() + rel_edb1083 := _t1763 + _t1764 := &pb.Data{} + _t1764.DataType = &pb.Data_RelEdb{RelEdb: rel_edb1083} + _t1762 = _t1764 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in data", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1235 = _t1238 + _t1759 = _t1762 } - _t1232 = _t1235 + _t1756 = _t1759 } - return _t1232 + result1087 := _t1756 + p.recordSpan(int(span_start1086)) + return result1087 } func (p *Parser) parse_rel_edb() *pb.RelEDB { + span_start1091 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("rel_edb") - _t1241 := p.parse_relation_id() - relation_id630 := _t1241 - _t1242 := p.parse_rel_edb_path() - rel_edb_path631 := _t1242 - _t1243 := p.parse_rel_edb_types() - rel_edb_types632 := _t1243 + p.pushPath(int(1)) + _t1765 := p.parse_relation_id() + relation_id1088 := _t1765 + p.popPath() + p.pushPath(int(2)) + _t1766 := p.parse_rel_edb_path() + rel_edb_path1089 := _t1766 + p.popPath() + p.pushPath(int(3)) + _t1767 := p.parse_rel_edb_types() + rel_edb_types1090 := _t1767 + p.popPath() p.consumeLiteral(")") - _t1244 := &pb.RelEDB{TargetId: relation_id630, Path: rel_edb_path631, Types: rel_edb_types632} - return _t1244 + _t1768 := &pb.RelEDB{TargetId: relation_id1088, Path: rel_edb_path1089, Types: rel_edb_types1090} + result1092 := _t1768 + p.recordSpan(int(span_start1091)) + return result1092 } func (p *Parser) parse_rel_edb_path() []string { + span_start1097 := int64(p.spanStart()) p.consumeLiteral("[") - xs633 := []string{} - cond634 := p.matchLookaheadTerminal("STRING", 0) - for cond634 { - item635 := p.consumeTerminal("STRING").Value.str - xs633 = append(xs633, item635) - cond634 = p.matchLookaheadTerminal("STRING", 0) - } - strings636 := xs633 + xs1093 := []string{} + cond1094 := p.matchLookaheadTerminal("STRING", 0) + for cond1094 { + item1095 := p.consumeTerminal("STRING").Value.str + xs1093 = append(xs1093, item1095) + cond1094 = p.matchLookaheadTerminal("STRING", 0) + } + strings1096 := xs1093 p.consumeLiteral("]") - return strings636 + result1098 := strings1096 + p.recordSpan(int(span_start1097)) + return result1098 } func (p *Parser) parse_rel_edb_types() []*pb.Type { + span_start1103 := int64(p.spanStart()) p.consumeLiteral("[") - xs637 := []*pb.Type{} - cond638 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond638 { - _t1245 := p.parse_type() - item639 := _t1245 - xs637 = append(xs637, item639) - cond638 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types640 := xs637 + xs1099 := []*pb.Type{} + cond1100 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + for cond1100 { + _t1769 := p.parse_type() + item1101 := _t1769 + xs1099 = append(xs1099, item1101) + cond1100 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1102 := xs1099 p.consumeLiteral("]") - return types640 + result1104 := types1102 + p.recordSpan(int(span_start1103)) + return result1104 } func (p *Parser) parse_betree_relation() *pb.BeTreeRelation { + span_start1107 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("betree_relation") - _t1246 := p.parse_relation_id() - relation_id641 := _t1246 - _t1247 := p.parse_betree_info() - betree_info642 := _t1247 + p.pushPath(int(1)) + _t1770 := p.parse_relation_id() + relation_id1105 := _t1770 + p.popPath() + p.pushPath(int(2)) + _t1771 := p.parse_betree_info() + betree_info1106 := _t1771 + p.popPath() p.consumeLiteral(")") - _t1248 := &pb.BeTreeRelation{Name: relation_id641, RelationInfo: betree_info642} - return _t1248 + _t1772 := &pb.BeTreeRelation{Name: relation_id1105, RelationInfo: betree_info1106} + result1108 := _t1772 + p.recordSpan(int(span_start1107)) + return result1108 } func (p *Parser) parse_betree_info() *pb.BeTreeInfo { + span_start1112 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("betree_info") - _t1249 := p.parse_betree_info_key_types() - betree_info_key_types643 := _t1249 - _t1250 := p.parse_betree_info_value_types() - betree_info_value_types644 := _t1250 - _t1251 := p.parse_config_dict() - config_dict645 := _t1251 + _t1773 := p.parse_betree_info_key_types() + betree_info_key_types1109 := _t1773 + _t1774 := p.parse_betree_info_value_types() + betree_info_value_types1110 := _t1774 + _t1775 := p.parse_config_dict() + config_dict1111 := _t1775 p.consumeLiteral(")") - _t1252 := p.construct_betree_info(betree_info_key_types643, betree_info_value_types644, config_dict645) - return _t1252 + _t1776 := p.construct_betree_info(betree_info_key_types1109, betree_info_value_types1110, config_dict1111) + result1113 := _t1776 + p.recordSpan(int(span_start1112)) + return result1113 } func (p *Parser) parse_betree_info_key_types() []*pb.Type { + span_start1118 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("key_types") - xs646 := []*pb.Type{} - cond647 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond647 { - _t1253 := p.parse_type() - item648 := _t1253 - xs646 = append(xs646, item648) - cond647 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types649 := xs646 + xs1114 := []*pb.Type{} + cond1115 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + for cond1115 { + _t1777 := p.parse_type() + item1116 := _t1777 + xs1114 = append(xs1114, item1116) + cond1115 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1117 := xs1114 p.consumeLiteral(")") - return types649 + result1119 := types1117 + p.recordSpan(int(span_start1118)) + return result1119 } func (p *Parser) parse_betree_info_value_types() []*pb.Type { + span_start1124 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("value_types") - xs650 := []*pb.Type{} - cond651 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond651 { - _t1254 := p.parse_type() - item652 := _t1254 - xs650 = append(xs650, item652) - cond651 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types653 := xs650 + xs1120 := []*pb.Type{} + cond1121 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + for cond1121 { + _t1778 := p.parse_type() + item1122 := _t1778 + xs1120 = append(xs1120, item1122) + cond1121 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1123 := xs1120 p.consumeLiteral(")") - return types653 + result1125 := types1123 + p.recordSpan(int(span_start1124)) + return result1125 } func (p *Parser) parse_csv_data() *pb.CSVData { + span_start1130 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_data") - _t1255 := p.parse_csvlocator() - csvlocator654 := _t1255 - _t1256 := p.parse_csv_config() - csv_config655 := _t1256 - _t1257 := p.parse_csv_columns() - csv_columns656 := _t1257 - _t1258 := p.parse_csv_asof() - csv_asof657 := _t1258 + p.pushPath(int(1)) + _t1779 := p.parse_csvlocator() + csvlocator1126 := _t1779 + p.popPath() + p.pushPath(int(2)) + _t1780 := p.parse_csv_config() + csv_config1127 := _t1780 + p.popPath() + p.pushPath(int(3)) + _t1781 := p.parse_csv_columns() + csv_columns1128 := _t1781 + p.popPath() + p.pushPath(int(4)) + _t1782 := p.parse_csv_asof() + csv_asof1129 := _t1782 + p.popPath() p.consumeLiteral(")") - _t1259 := &pb.CSVData{Locator: csvlocator654, Config: csv_config655, Columns: csv_columns656, Asof: csv_asof657} - return _t1259 + _t1783 := &pb.CSVData{Locator: csvlocator1126, Config: csv_config1127, Columns: csv_columns1128, Asof: csv_asof1129} + result1131 := _t1783 + p.recordSpan(int(span_start1130)) + return result1131 } func (p *Parser) parse_csvlocator() *pb.CSVLocator { + span_start1134 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_locator") - var _t1260 []string + p.pushPath(int(1)) + var _t1784 []string if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("paths", 1)) { - _t1261 := p.parse_csv_locator_paths() - _t1260 = _t1261 + _t1785 := p.parse_csv_locator_paths() + _t1784 = _t1785 } - csv_locator_paths658 := _t1260 - var _t1262 *string + csv_locator_paths1132 := _t1784 + p.popPath() + p.pushPath(int(2)) + var _t1786 *string if p.matchLookaheadLiteral("(", 0) { - _t1263 := p.parse_csv_locator_inline_data() - _t1262 = ptr(_t1263) + _t1787 := p.parse_csv_locator_inline_data() + _t1786 = ptr(_t1787) } - csv_locator_inline_data659 := _t1262 + csv_locator_inline_data1133 := _t1786 + p.popPath() p.consumeLiteral(")") - _t1264 := csv_locator_paths658 - if csv_locator_paths658 == nil { - _t1264 = []string{} + _t1788 := csv_locator_paths1132 + if csv_locator_paths1132 == nil { + _t1788 = []string{} } - _t1265 := &pb.CSVLocator{Paths: _t1264, InlineData: []byte(deref(csv_locator_inline_data659, ""))} - return _t1265 + _t1789 := &pb.CSVLocator{Paths: _t1788, InlineData: []byte(deref(csv_locator_inline_data1133, ""))} + result1135 := _t1789 + p.recordSpan(int(span_start1134)) + return result1135 } func (p *Parser) parse_csv_locator_paths() []string { + span_start1140 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("paths") - xs660 := []string{} - cond661 := p.matchLookaheadTerminal("STRING", 0) - for cond661 { - item662 := p.consumeTerminal("STRING").Value.str - xs660 = append(xs660, item662) - cond661 = p.matchLookaheadTerminal("STRING", 0) - } - strings663 := xs660 + xs1136 := []string{} + cond1137 := p.matchLookaheadTerminal("STRING", 0) + for cond1137 { + item1138 := p.consumeTerminal("STRING").Value.str + xs1136 = append(xs1136, item1138) + cond1137 = p.matchLookaheadTerminal("STRING", 0) + } + strings1139 := xs1136 p.consumeLiteral(")") - return strings663 + result1141 := strings1139 + p.recordSpan(int(span_start1140)) + return result1141 } func (p *Parser) parse_csv_locator_inline_data() string { + span_start1143 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("inline_data") - string664 := p.consumeTerminal("STRING").Value.str + string1142 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string664 + result1144 := string1142 + p.recordSpan(int(span_start1143)) + return result1144 } func (p *Parser) parse_csv_config() *pb.CSVConfig { + span_start1146 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_config") - _t1266 := p.parse_config_dict() - config_dict665 := _t1266 + _t1790 := p.parse_config_dict() + config_dict1145 := _t1790 p.consumeLiteral(")") - _t1267 := p.construct_csv_config(config_dict665) - return _t1267 + _t1791 := p.construct_csv_config(config_dict1145) + result1147 := _t1791 + p.recordSpan(int(span_start1146)) + return result1147 } func (p *Parser) parse_csv_columns() []*pb.CSVColumn { + span_start1152 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("columns") - xs666 := []*pb.CSVColumn{} - cond667 := p.matchLookaheadLiteral("(", 0) - for cond667 { - _t1268 := p.parse_csv_column() - item668 := _t1268 - xs666 = append(xs666, item668) - cond667 = p.matchLookaheadLiteral("(", 0) - } - csv_columns669 := xs666 + xs1148 := []*pb.CSVColumn{} + cond1149 := p.matchLookaheadLiteral("(", 0) + for cond1149 { + _t1792 := p.parse_csv_column() + item1150 := _t1792 + xs1148 = append(xs1148, item1150) + cond1149 = p.matchLookaheadLiteral("(", 0) + } + csv_columns1151 := xs1148 p.consumeLiteral(")") - return csv_columns669 + result1153 := csv_columns1151 + p.recordSpan(int(span_start1152)) + return result1153 } func (p *Parser) parse_csv_column() *pb.CSVColumn { + span_start1164 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("column") - string670 := p.consumeTerminal("STRING").Value.str - _t1269 := p.parse_relation_id() - relation_id671 := _t1269 + p.pushPath(int(1)) + string1154 := p.consumeTerminal("STRING").Value.str + p.popPath() + p.pushPath(int(2)) + _t1793 := p.parse_relation_id() + relation_id1155 := _t1793 + p.popPath() p.consumeLiteral("[") - xs672 := []*pb.Type{} - cond673 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond673 { - _t1270 := p.parse_type() - item674 := _t1270 - xs672 = append(xs672, item674) - cond673 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types675 := xs672 + p.pushPath(int(3)) + xs1160 := []*pb.Type{} + cond1161 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx1162 := 0 + for cond1161 { + p.pushPath(int(idx1162)) + _t1794 := p.parse_type() + item1163 := _t1794 + p.popPath() + xs1160 = append(xs1160, item1163) + idx1162 = (idx1162 + 1) + cond1161 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1159 := xs1160 + p.popPath() p.consumeLiteral("]") p.consumeLiteral(")") - _t1271 := &pb.CSVColumn{ColumnName: string670, TargetId: relation_id671, Types: types675} - return _t1271 + _t1795 := &pb.CSVColumn{ColumnName: string1154, TargetId: relation_id1155, Types: types1159} + result1165 := _t1795 + p.recordSpan(int(span_start1164)) + return result1165 } func (p *Parser) parse_csv_asof() string { + span_start1167 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("asof") - string676 := p.consumeTerminal("STRING").Value.str + string1166 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string676 + result1168 := string1166 + p.recordSpan(int(span_start1167)) + return result1168 } func (p *Parser) parse_undefine() *pb.Undefine { + span_start1170 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("undefine") - _t1272 := p.parse_fragment_id() - fragment_id677 := _t1272 + p.pushPath(int(1)) + _t1796 := p.parse_fragment_id() + fragment_id1169 := _t1796 + p.popPath() p.consumeLiteral(")") - _t1273 := &pb.Undefine{FragmentId: fragment_id677} - return _t1273 + _t1797 := &pb.Undefine{FragmentId: fragment_id1169} + result1171 := _t1797 + p.recordSpan(int(span_start1170)) + return result1171 } func (p *Parser) parse_context() *pb.Context { + span_start1180 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("context") - xs678 := []*pb.RelationId{} - cond679 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - for cond679 { - _t1274 := p.parse_relation_id() - item680 := _t1274 - xs678 = append(xs678, item680) - cond679 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - } - relation_ids681 := xs678 + p.pushPath(int(1)) + xs1176 := []*pb.RelationId{} + cond1177 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx1178 := 0 + for cond1177 { + p.pushPath(int(idx1178)) + _t1798 := p.parse_relation_id() + item1179 := _t1798 + p.popPath() + xs1176 = append(xs1176, item1179) + idx1178 = (idx1178 + 1) + cond1177 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + relation_ids1175 := xs1176 + p.popPath() p.consumeLiteral(")") - _t1275 := &pb.Context{Relations: relation_ids681} - return _t1275 + _t1799 := &pb.Context{Relations: relation_ids1175} + result1181 := _t1799 + p.recordSpan(int(span_start1180)) + return result1181 } func (p *Parser) parse_snapshot() *pb.Snapshot { + span_start1184 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("snapshot") - _t1276 := p.parse_rel_edb_path() - rel_edb_path682 := _t1276 - _t1277 := p.parse_relation_id() - relation_id683 := _t1277 + p.pushPath(int(1)) + _t1800 := p.parse_rel_edb_path() + rel_edb_path1182 := _t1800 + p.popPath() + p.pushPath(int(2)) + _t1801 := p.parse_relation_id() + relation_id1183 := _t1801 + p.popPath() p.consumeLiteral(")") - _t1278 := &pb.Snapshot{DestinationPath: rel_edb_path682, SourceRelation: relation_id683} - return _t1278 + _t1802 := &pb.Snapshot{DestinationPath: rel_edb_path1182, SourceRelation: relation_id1183} + result1185 := _t1802 + p.recordSpan(int(span_start1184)) + return result1185 } func (p *Parser) parse_epoch_reads() []*pb.Read { + span_start1190 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("reads") - xs684 := []*pb.Read{} - cond685 := p.matchLookaheadLiteral("(", 0) - for cond685 { - _t1279 := p.parse_read() - item686 := _t1279 - xs684 = append(xs684, item686) - cond685 = p.matchLookaheadLiteral("(", 0) - } - reads687 := xs684 + xs1186 := []*pb.Read{} + cond1187 := p.matchLookaheadLiteral("(", 0) + for cond1187 { + _t1803 := p.parse_read() + item1188 := _t1803 + xs1186 = append(xs1186, item1188) + cond1187 = p.matchLookaheadLiteral("(", 0) + } + reads1189 := xs1186 p.consumeLiteral(")") - return reads687 + result1191 := reads1189 + p.recordSpan(int(span_start1190)) + return result1191 } func (p *Parser) parse_read() *pb.Read { - var _t1280 int64 + span_start1198 := int64(p.spanStart()) + var _t1804 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1281 int64 + var _t1805 int64 if p.matchLookaheadLiteral("what_if", 1) { - _t1281 = 2 + _t1805 = 2 } else { - var _t1282 int64 + var _t1806 int64 if p.matchLookaheadLiteral("output", 1) { - _t1282 = 1 + _t1806 = 1 } else { - var _t1283 int64 + var _t1807 int64 if p.matchLookaheadLiteral("export", 1) { - _t1283 = 4 + _t1807 = 4 } else { - var _t1284 int64 + var _t1808 int64 if p.matchLookaheadLiteral("demand", 1) { - _t1284 = 0 + _t1808 = 0 } else { - var _t1285 int64 + var _t1809 int64 if p.matchLookaheadLiteral("abort", 1) { - _t1285 = 3 + _t1809 = 3 } else { - _t1285 = -1 + _t1809 = -1 } - _t1284 = _t1285 + _t1808 = _t1809 } - _t1283 = _t1284 + _t1807 = _t1808 } - _t1282 = _t1283 + _t1806 = _t1807 } - _t1281 = _t1282 + _t1805 = _t1806 } - _t1280 = _t1281 + _t1804 = _t1805 } else { - _t1280 = -1 - } - prediction688 := _t1280 - var _t1286 *pb.Read - if prediction688 == 4 { - _t1287 := p.parse_export() - export693 := _t1287 - _t1288 := &pb.Read{} - _t1288.ReadType = &pb.Read_Export{Export: export693} - _t1286 = _t1288 + _t1804 = -1 + } + prediction1192 := _t1804 + var _t1810 *pb.Read + if prediction1192 == 4 { + _t1811 := p.parse_export() + export1197 := _t1811 + _t1812 := &pb.Read{} + _t1812.ReadType = &pb.Read_Export{Export: export1197} + _t1810 = _t1812 } else { - var _t1289 *pb.Read - if prediction688 == 3 { - _t1290 := p.parse_abort() - abort692 := _t1290 - _t1291 := &pb.Read{} - _t1291.ReadType = &pb.Read_Abort{Abort: abort692} - _t1289 = _t1291 + var _t1813 *pb.Read + if prediction1192 == 3 { + _t1814 := p.parse_abort() + abort1196 := _t1814 + _t1815 := &pb.Read{} + _t1815.ReadType = &pb.Read_Abort{Abort: abort1196} + _t1813 = _t1815 } else { - var _t1292 *pb.Read - if prediction688 == 2 { - _t1293 := p.parse_what_if() - what_if691 := _t1293 - _t1294 := &pb.Read{} - _t1294.ReadType = &pb.Read_WhatIf{WhatIf: what_if691} - _t1292 = _t1294 + var _t1816 *pb.Read + if prediction1192 == 2 { + _t1817 := p.parse_what_if() + what_if1195 := _t1817 + _t1818 := &pb.Read{} + _t1818.ReadType = &pb.Read_WhatIf{WhatIf: what_if1195} + _t1816 = _t1818 } else { - var _t1295 *pb.Read - if prediction688 == 1 { - _t1296 := p.parse_output() - output690 := _t1296 - _t1297 := &pb.Read{} - _t1297.ReadType = &pb.Read_Output{Output: output690} - _t1295 = _t1297 + var _t1819 *pb.Read + if prediction1192 == 1 { + _t1820 := p.parse_output() + output1194 := _t1820 + _t1821 := &pb.Read{} + _t1821.ReadType = &pb.Read_Output{Output: output1194} + _t1819 = _t1821 } else { - var _t1298 *pb.Read - if prediction688 == 0 { - _t1299 := p.parse_demand() - demand689 := _t1299 - _t1300 := &pb.Read{} - _t1300.ReadType = &pb.Read_Demand{Demand: demand689} - _t1298 = _t1300 + var _t1822 *pb.Read + if prediction1192 == 0 { + _t1823 := p.parse_demand() + demand1193 := _t1823 + _t1824 := &pb.Read{} + _t1824.ReadType = &pb.Read_Demand{Demand: demand1193} + _t1822 = _t1824 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in read", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1295 = _t1298 + _t1819 = _t1822 } - _t1292 = _t1295 + _t1816 = _t1819 } - _t1289 = _t1292 + _t1813 = _t1816 } - _t1286 = _t1289 + _t1810 = _t1813 } - return _t1286 + result1199 := _t1810 + p.recordSpan(int(span_start1198)) + return result1199 } func (p *Parser) parse_demand() *pb.Demand { + span_start1201 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("demand") - _t1301 := p.parse_relation_id() - relation_id694 := _t1301 + p.pushPath(int(1)) + _t1825 := p.parse_relation_id() + relation_id1200 := _t1825 + p.popPath() p.consumeLiteral(")") - _t1302 := &pb.Demand{RelationId: relation_id694} - return _t1302 + _t1826 := &pb.Demand{RelationId: relation_id1200} + result1202 := _t1826 + p.recordSpan(int(span_start1201)) + return result1202 } func (p *Parser) parse_output() *pb.Output { + span_start1205 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("output") - _t1303 := p.parse_name() - name695 := _t1303 - _t1304 := p.parse_relation_id() - relation_id696 := _t1304 + p.pushPath(int(1)) + _t1827 := p.parse_name() + name1203 := _t1827 + p.popPath() + p.pushPath(int(2)) + _t1828 := p.parse_relation_id() + relation_id1204 := _t1828 + p.popPath() p.consumeLiteral(")") - _t1305 := &pb.Output{Name: name695, RelationId: relation_id696} - return _t1305 + _t1829 := &pb.Output{Name: name1203, RelationId: relation_id1204} + result1206 := _t1829 + p.recordSpan(int(span_start1205)) + return result1206 } func (p *Parser) parse_what_if() *pb.WhatIf { + span_start1209 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("what_if") - _t1306 := p.parse_name() - name697 := _t1306 - _t1307 := p.parse_epoch() - epoch698 := _t1307 + p.pushPath(int(1)) + _t1830 := p.parse_name() + name1207 := _t1830 + p.popPath() + p.pushPath(int(2)) + _t1831 := p.parse_epoch() + epoch1208 := _t1831 + p.popPath() p.consumeLiteral(")") - _t1308 := &pb.WhatIf{Branch: name697, Epoch: epoch698} - return _t1308 + _t1832 := &pb.WhatIf{Branch: name1207, Epoch: epoch1208} + result1210 := _t1832 + p.recordSpan(int(span_start1209)) + return result1210 } func (p *Parser) parse_abort() *pb.Abort { + span_start1213 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("abort") - var _t1309 *string + p.pushPath(int(1)) + var _t1833 *string if (p.matchLookaheadLiteral(":", 0) && p.matchLookaheadTerminal("SYMBOL", 1)) { - _t1310 := p.parse_name() - _t1309 = ptr(_t1310) - } - name699 := _t1309 - _t1311 := p.parse_relation_id() - relation_id700 := _t1311 + _t1834 := p.parse_name() + _t1833 = ptr(_t1834) + } + name1211 := _t1833 + p.popPath() + p.pushPath(int(2)) + _t1835 := p.parse_relation_id() + relation_id1212 := _t1835 + p.popPath() p.consumeLiteral(")") - _t1312 := &pb.Abort{Name: deref(name699, "abort"), RelationId: relation_id700} - return _t1312 + _t1836 := &pb.Abort{Name: deref(name1211, "abort"), RelationId: relation_id1212} + result1214 := _t1836 + p.recordSpan(int(span_start1213)) + return result1214 } func (p *Parser) parse_export() *pb.Export { + span_start1216 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("export") - _t1313 := p.parse_export_csv_config() - export_csv_config701 := _t1313 + p.pushPath(int(1)) + _t1837 := p.parse_export_csv_config() + export_csv_config1215 := _t1837 + p.popPath() p.consumeLiteral(")") - _t1314 := &pb.Export{} - _t1314.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config701} - return _t1314 + _t1838 := &pb.Export{} + _t1838.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config1215} + result1217 := _t1838 + p.recordSpan(int(span_start1216)) + return result1217 } func (p *Parser) parse_export_csv_config() *pb.ExportCSVConfig { + span_start1221 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("export_csv_config") - _t1315 := p.parse_export_csv_path() - export_csv_path702 := _t1315 - _t1316 := p.parse_export_csv_columns() - export_csv_columns703 := _t1316 - _t1317 := p.parse_config_dict() - config_dict704 := _t1317 + _t1839 := p.parse_export_csv_path() + export_csv_path1218 := _t1839 + _t1840 := p.parse_export_csv_columns() + export_csv_columns1219 := _t1840 + _t1841 := p.parse_config_dict() + config_dict1220 := _t1841 p.consumeLiteral(")") - _t1318 := p.export_csv_config(export_csv_path702, export_csv_columns703, config_dict704) - return _t1318 + _t1842 := p.export_csv_config(export_csv_path1218, export_csv_columns1219, config_dict1220) + result1222 := _t1842 + p.recordSpan(int(span_start1221)) + return result1222 } func (p *Parser) parse_export_csv_path() string { + span_start1224 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("path") - string705 := p.consumeTerminal("STRING").Value.str + string1223 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string705 + result1225 := string1223 + p.recordSpan(int(span_start1224)) + return result1225 } func (p *Parser) parse_export_csv_columns() []*pb.ExportCSVColumn { + span_start1230 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("columns") - xs706 := []*pb.ExportCSVColumn{} - cond707 := p.matchLookaheadLiteral("(", 0) - for cond707 { - _t1319 := p.parse_export_csv_column() - item708 := _t1319 - xs706 = append(xs706, item708) - cond707 = p.matchLookaheadLiteral("(", 0) - } - export_csv_columns709 := xs706 + xs1226 := []*pb.ExportCSVColumn{} + cond1227 := p.matchLookaheadLiteral("(", 0) + for cond1227 { + _t1843 := p.parse_export_csv_column() + item1228 := _t1843 + xs1226 = append(xs1226, item1228) + cond1227 = p.matchLookaheadLiteral("(", 0) + } + export_csv_columns1229 := xs1226 p.consumeLiteral(")") - return export_csv_columns709 + result1231 := export_csv_columns1229 + p.recordSpan(int(span_start1230)) + return result1231 } func (p *Parser) parse_export_csv_column() *pb.ExportCSVColumn { + span_start1234 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("column") - string710 := p.consumeTerminal("STRING").Value.str - _t1320 := p.parse_relation_id() - relation_id711 := _t1320 + p.pushPath(int(1)) + string1232 := p.consumeTerminal("STRING").Value.str + p.popPath() + p.pushPath(int(2)) + _t1844 := p.parse_relation_id() + relation_id1233 := _t1844 + p.popPath() p.consumeLiteral(")") - _t1321 := &pb.ExportCSVColumn{ColumnName: string710, ColumnData: relation_id711} - return _t1321 + _t1845 := &pb.ExportCSVColumn{ColumnName: string1232, ColumnData: relation_id1233} + result1235 := _t1845 + p.recordSpan(int(span_start1234)) + return result1235 } -// Parse parses the input string and returns the result -func Parse(input string) (result *pb.Transaction, err error) { +// Parse parses the input string and returns (result, provenance, error). +func Parse(input string) (result *pb.Transaction, provenance map[string]Span, err error) { defer func() { if r := recover(); r != nil { if pe, ok := r.(ParseError); ok { @@ -3754,15 +4433,15 @@ func Parse(input string) (result *pb.Transaction, err error) { }() lexer := NewLexer(input) - parser := NewParser(lexer.tokens) + parser := NewParser(lexer.tokens, input) result = parser.parse_transaction() // Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens) { remainingToken := parser.lookahead(0) if remainingToken.Type != "$" { - return nil, ParseError{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)} + return nil, nil, ParseError{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)} } } - return result, nil + return result, parser.Provenance, nil } diff --git a/sdks/go/test/parser_test.go b/sdks/go/test/parser_test.go index 423016c4..954394af 100644 --- a/sdks/go/test/parser_test.go +++ b/sdks/go/test/parser_test.go @@ -20,7 +20,7 @@ func TestBasicParsing(t *testing.T) { (writes) (reads))) ` - result, err := lqp.Parse(input) + result, _, err := lqp.Parse(input) if err != nil { t.Fatalf("Failed to parse basic transaction: %v", err) } @@ -54,7 +54,7 @@ func TestParseLQPFiles(t *testing.T) { t.Fatalf("Failed to read LQP file %s: %v", entry.Name(), err) } - result, err := lqp.Parse(string(content)) + result, _, err := lqp.Parse(string(content)) if err != nil { t.Fatalf("Failed to parse LQP file %s: %v", entry.Name(), err) } diff --git a/sdks/go/test/print_test.go b/sdks/go/test/print_test.go index 28d456c4..af94eb24 100644 --- a/sdks/go/test/print_test.go +++ b/sdks/go/test/print_test.go @@ -127,13 +127,13 @@ func TestRoundtripLQP(t *testing.T) { t.Fatalf("Failed to read LQP file: %v", err) } - parsed, err := lqp.Parse(string(content)) + parsed, _, err := lqp.Parse(string(content)) if err != nil { t.Fatalf("Failed to parse: %v", err) } printed := lqp.ProgramToStr(parsed) - reparsed, err := lqp.Parse(printed) + reparsed, _, err := lqp.Parse(printed) if err != nil { t.Fatalf("Failed to re-parse pretty output: %v", err) } @@ -174,7 +174,7 @@ func TestRoundtripBinary(t *testing.T) { } printed := lqp.ProgramToStr(transaction) - reparsed, err := lqp.Parse(printed) + reparsed, _, err := lqp.Parse(printed) if err != nil { t.Fatalf("Failed to re-parse pretty output: %v", err) } diff --git a/sdks/go/test/provenance_test.go b/sdks/go/test/provenance_test.go new file mode 100644 index 00000000..add6dd0e --- /dev/null +++ b/sdks/go/test/provenance_test.go @@ -0,0 +1,150 @@ +package test + +import ( + "strings" + "testing" + + lqp "github.com/RelationalAI/logical-query-protocol/sdks/go/src" +) + +const simpleInput = `(transaction + (epoch + (writes) + (reads))) +` + +func TestProvenanceRootTransaction(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + span, ok := provenance[""] + if !ok { + t.Fatal("Root path '' not found in provenance") + } + if span.Start.Offset != 0 { + t.Errorf("Expected root start offset 0, got %d", span.Start.Offset) + } + if span.Start.Line != 1 { + t.Errorf("Expected root start line 1, got %d", span.Start.Line) + } + if span.Start.Column != 1 { + t.Errorf("Expected root start column 1, got %d", span.Start.Column) + } +} + +func TestProvenanceEpoch(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + // epochs = field 1, index 0 + span, ok := provenance["1,0"] + if !ok { + t.Fatal("Epoch path '1,0' not found in provenance") + } + if span.Start.Line != 2 { + t.Errorf("Expected epoch start line 2, got %d", span.Start.Line) + } +} + +func TestProvenanceWrites(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + // epochs[0].writes = field 1 within Epoch + span, ok := provenance["1,0,1"] + if !ok { + t.Fatal("Writes path '1,0,1' not found in provenance") + } + if span.Start.Line != 3 { + t.Errorf("Expected writes start line 3, got %d", span.Start.Line) + } +} + +func TestProvenanceReads(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + // epochs[0].reads = field 2 within Epoch + span, ok := provenance["1,0,2"] + if !ok { + t.Fatal("Reads path '1,0,2' not found in provenance") + } + if span.Start.Line != 4 { + t.Errorf("Expected reads start line 4, got %d", span.Start.Line) + } +} + +func TestProvenanceSpanCoversCorrectText(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + // Root transaction starts at offset 0 + rootSpan := provenance[""] + if rootSpan.Start.Offset != 0 { + t.Errorf("Expected root start offset 0, got %d", rootSpan.Start.Offset) + } + + // Epoch span starts at '(' of '(epoch' + epochSpan := provenance["1,0"] + textAtEpoch := simpleInput[epochSpan.Start.Offset:] + if !strings.HasPrefix(textAtEpoch, "(epoch") { + t.Errorf("Expected text at epoch offset to start with '(epoch', got %q", + textAtEpoch[:min(20, len(textAtEpoch))]) + } +} + +func TestProvenanceSpanOrdering(t *testing.T) { + _, provenance, err := lqp.Parse(simpleInput) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + for path, span := range provenance { + if span.Start.Offset > span.End.Offset { + t.Errorf("Bad span at path %q: start %d > end %d", + path, span.Start.Offset, span.End.Offset) + } + if span.Start.Line > span.End.Line { + t.Errorf("Bad line ordering at path %q: start %d > end %d", + path, span.Start.Line, span.End.Line) + } + } +} + +func TestProvenanceMultipleEpochs(t *testing.T) { + input := `(transaction + (epoch + (writes) + (reads)) + (epoch + (writes) + (reads))) +` + _, provenance, err := lqp.Parse(input) + if err != nil { + t.Fatalf("Failed to parse: %v", err) + } + + span0, ok0 := provenance["1,0"] + span1, ok1 := provenance["1,1"] + if !ok0 { + t.Fatal("First epoch path '1,0' not found") + } + if !ok1 { + t.Fatal("Second epoch path '1,1' not found") + } + if span0.Start.Offset >= span1.Start.Offset { + t.Errorf("Expected first epoch before second: %d >= %d", + span0.Start.Offset, span1.Start.Offset) + } +} diff --git a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl index 361e1130..2fde55fd 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl @@ -28,13 +28,26 @@ end Base.showerror(io::IO, e::ParseError) = print(io, "ParseError: ", e.msg) +struct Location + line::Int + column::Int + offset::Int +end + +struct Span + start::Location + var"end"::Location +end + struct Token type::String value::Any - pos::Int + start_pos::Int + end_pos::Int end -Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.pos, ")") +Base.show(io::IO, t::Token) = print(io, "Token(", t.type, ", ", repr(t.value), ", ", t.start_pos, ")") +Base.getproperty(t::Token, s::Symbol) = s === :pos ? getfield(t, :start_pos) : getfield(t, s) mutable struct Lexer @@ -177,31 +190,75 @@ function tokenize!(lexer::Lexer) # Pick the longest match token_type, value, action, end_pos = candidates[argmax([c[4] for c in candidates])] - push!(lexer.tokens, Token(token_type, action(value), lexer.pos)) + push!(lexer.tokens, Token(token_type, action(value), lexer.pos, end_pos)) lexer.pos = end_pos end - push!(lexer.tokens, Token("\$", "", lexer.pos)) + push!(lexer.tokens, Token("\$", "", lexer.pos, lexer.pos)) return nothing end +function _compute_line_starts(text::String)::Vector{Int} + starts = [1] + for i in eachindex(text) + if text[i] == '\n' + push!(starts, nextind(text, i)) + end + end + return starts +end + mutable struct ParserState tokens::Vector{Token} pos::Int id_to_debuginfo::Dict{Vector{UInt8},Vector{Pair{Tuple{UInt64,UInt64},String}}} _current_fragment_id::Union{Nothing,Vector{UInt8}} _relation_id_to_name::Dict{Tuple{UInt64,UInt64},String} + provenance::Dict{Tuple{Vararg{Int}},Span} + _path::Vector{Int} + _line_starts::Vector{Int} - function ParserState(tokens::Vector{Token}) - return new(tokens, 1, Dict(), nothing, Dict()) + function ParserState(tokens::Vector{Token}, input_str::String) + return new(tokens, 1, Dict(), nothing, Dict(), Dict(), Int[], _compute_line_starts(input_str)) end end +function _make_location(parser::ParserState, offset::Int)::Location + line_idx = searchsortedlast(parser._line_starts, offset) + col = offset - parser._line_starts[line_idx] + return Location(line_idx, col + 1, offset) +end + +function push_path!(parser::ParserState, n::Int) + push!(parser._path, n) + return nothing +end + +function pop_path!(parser::ParserState) + pop!(parser._path) + return nothing +end + +function span_start(parser::ParserState)::Int + return lookahead(parser, 0).start_pos +end + +function record_span!(parser::ParserState, start_offset::Int) + if parser.pos > 1 + end_offset = parser.tokens[parser.pos - 1].end_pos + else + end_offset = start_offset + end + s = Span(_make_location(parser, start_offset), _make_location(parser, end_offset)) + parser.provenance[Tuple(parser._path)] = s + return nothing +end + function lookahead(parser::ParserState, k::Int=0)::Token idx = parser.pos + k - return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1) + return idx <= length(parser.tokens) ? parser.tokens[idx] : Token("\$", "", -1, -1) end @@ -305,7 +362,7 @@ function _extract_value_int32(parser::ParserState, value::Union{Nothing, Proto.V if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return Int32(_get_oneof_field(value, :int_value)) else - _t1311 = nothing + _t1835 = nothing end return Int32(default) end @@ -314,7 +371,7 @@ function _extract_value_int64(parser::ParserState, value::Union{Nothing, Proto.V if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return _get_oneof_field(value, :int_value) else - _t1312 = nothing + _t1836 = nothing end return default end @@ -323,7 +380,7 @@ function _extract_value_string(parser::ParserState, value::Union{Nothing, Proto. if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return _get_oneof_field(value, :string_value) else - _t1313 = nothing + _t1837 = nothing end return default end @@ -332,7 +389,7 @@ function _extract_value_boolean(parser::ParserState, value::Union{Nothing, Proto if (!isnothing(value) && _has_proto_field(value, Symbol("boolean_value"))) return _get_oneof_field(value, :boolean_value) else - _t1314 = nothing + _t1838 = nothing end return default end @@ -341,7 +398,7 @@ function _extract_value_string_list(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return String[_get_oneof_field(value, :string_value)] else - _t1315 = nothing + _t1839 = nothing end return default end @@ -350,7 +407,7 @@ function _try_extract_value_int64(parser::ParserState, value::Union{Nothing, Pro if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return _get_oneof_field(value, :int_value) else - _t1316 = nothing + _t1840 = nothing end return nothing end @@ -359,7 +416,7 @@ function _try_extract_value_float64(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("float_value"))) return _get_oneof_field(value, :float_value) else - _t1317 = nothing + _t1841 = nothing end return nothing end @@ -368,7 +425,7 @@ function _try_extract_value_bytes(parser::ParserState, value::Union{Nothing, Pro if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return Vector{UInt8}(_get_oneof_field(value, :string_value)) else - _t1318 = nothing + _t1842 = nothing end return nothing end @@ -377,70 +434,70 @@ function _try_extract_value_uint128(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("uint128_value"))) return _get_oneof_field(value, :uint128_value) else - _t1319 = nothing + _t1843 = nothing end return nothing end function construct_csv_config(parser::ParserState, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.CSVConfig config = Dict(config_dict) - _t1320 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) - header_row = _t1320 - _t1321 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) - skip = _t1321 - _t1322 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") - new_line = _t1322 - _t1323 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") - delimiter = _t1323 - _t1324 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") - quotechar = _t1324 - _t1325 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") - escapechar = _t1325 - _t1326 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") - comment = _t1326 - _t1327 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) - missing_strings = _t1327 - _t1328 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") - decimal_separator = _t1328 - _t1329 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") - encoding = _t1329 - _t1330 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") - compression = _t1330 - _t1331 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1331 + _t1844 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) + header_row = _t1844 + _t1845 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) + skip = _t1845 + _t1846 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") + new_line = _t1846 + _t1847 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") + delimiter = _t1847 + _t1848 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") + quotechar = _t1848 + _t1849 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") + escapechar = _t1849 + _t1850 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") + comment = _t1850 + _t1851 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) + missing_strings = _t1851 + _t1852 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") + decimal_separator = _t1852 + _t1853 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") + encoding = _t1853 + _t1854 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") + compression = _t1854 + _t1855 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1855 end function construct_betree_info(parser::ParserState, key_types::Vector{Proto.var"#Type"}, value_types::Vector{Proto.var"#Type"}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.BeTreeInfo config = Dict(config_dict) - _t1332 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) - epsilon = _t1332 - _t1333 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) - max_pivots = _t1333 - _t1334 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) - max_deltas = _t1334 - _t1335 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) - max_leaf = _t1335 - _t1336 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1336 - _t1337 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) - root_pageid = _t1337 - _t1338 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) - inline_data = _t1338 - _t1339 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) - element_count = _t1339 - _t1340 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) - tree_height = _t1340 - _t1341 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) - relation_locator = _t1341 - _t1342 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1342 + _t1856 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) + epsilon = _t1856 + _t1857 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) + max_pivots = _t1857 + _t1858 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) + max_deltas = _t1858 + _t1859 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) + max_leaf = _t1859 + _t1860 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1860 + _t1861 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) + root_pageid = _t1861 + _t1862 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) + inline_data = _t1862 + _t1863 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) + element_count = _t1863 + _t1864 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) + tree_height = _t1864 + _t1865 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) + relation_locator = _t1865 + _t1866 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1866 end function default_configure(parser::ParserState)::Proto.Configure - _t1343 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1343 - _t1344 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1344 + _t1867 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1867 + _t1868 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1868 end function construct_configure(parser::ParserState, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.Configure @@ -462,2739 +519,3337 @@ function construct_configure(parser::ParserState, config_dict::Vector{Tuple{Stri end end end - _t1345 = Proto.IVMConfig(level=maintenance_level) - ivm_config = _t1345 - _t1346 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) - semantics_version = _t1346 - _t1347 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1347 + _t1869 = Proto.IVMConfig(level=maintenance_level) + ivm_config = _t1869 + _t1870 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) + semantics_version = _t1870 + _t1871 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1871 end function export_csv_config(parser::ParserState, path::String, columns::Vector{Proto.ExportCSVColumn}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.ExportCSVConfig config = Dict(config_dict) - _t1348 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) - partition_size = _t1348 - _t1349 = _extract_value_string(parser, get(config, "compression", nothing), "") - compression = _t1349 - _t1350 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) - syntax_header_row = _t1350 - _t1351 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") - syntax_missing_string = _t1351 - _t1352 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") - syntax_delim = _t1352 - _t1353 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") - syntax_quotechar = _t1353 - _t1354 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") - syntax_escapechar = _t1354 - _t1355 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1355 + _t1872 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) + partition_size = _t1872 + _t1873 = _extract_value_string(parser, get(config, "compression", nothing), "") + compression = _t1873 + _t1874 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) + syntax_header_row = _t1874 + _t1875 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") + syntax_missing_string = _t1875 + _t1876 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") + syntax_delim = _t1876 + _t1877 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") + syntax_quotechar = _t1877 + _t1878 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") + syntax_escapechar = _t1878 + _t1879 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1879 end # --- Parse functions --- function parse_transaction(parser::ParserState)::Proto.Transaction + span_start602 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "transaction") + push_path!(parser, 2) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "configure", 1)) - _t713 = parse_configure(parser) - _t712 = _t713 + _t1237 = parse_configure(parser) + _t1236 = _t1237 else - _t712 = nothing + _t1236 = nothing end - configure356 = _t712 + configure592 = _t1236 + pop_path!(parser) + push_path!(parser, 3) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "sync", 1)) - _t715 = parse_sync(parser) - _t714 = _t715 + _t1239 = parse_sync(parser) + _t1238 = _t1239 else - _t714 = nothing - end - sync357 = _t714 - xs358 = Proto.Epoch[] - cond359 = match_lookahead_literal(parser, "(", 0) - while cond359 - _t716 = parse_epoch(parser) - item360 = _t716 - push!(xs358, item360) - cond359 = match_lookahead_literal(parser, "(", 0) - end - epochs361 = xs358 - consume_literal!(parser, ")") - _t717 = default_configure(parser) - _t718 = Proto.Transaction(epochs=epochs361, configure=(!isnothing(configure356) ? configure356 : _t717), sync=sync357) - return _t718 + _t1238 = nothing + end + sync593 = _t1238 + pop_path!(parser) + push_path!(parser, 1) + xs598 = Proto.Epoch[] + cond599 = match_lookahead_literal(parser, "(", 0) + idx600 = 0 + while cond599 + push_path!(parser, idx600) + _t1240 = parse_epoch(parser) + item601 = _t1240 + pop_path!(parser) + push!(xs598, item601) + idx600 = (idx600 + 1) + cond599 = match_lookahead_literal(parser, "(", 0) + end + epochs597 = xs598 + pop_path!(parser) + consume_literal!(parser, ")") + _t1241 = default_configure(parser) + _t1242 = Proto.Transaction(epochs=epochs597, configure=(!isnothing(configure592) ? configure592 : _t1241), sync=sync593) + result603 = _t1242 + record_span!(parser, span_start602) + return result603 end function parse_configure(parser::ParserState)::Proto.Configure + span_start605 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "configure") - _t719 = parse_config_dict(parser) - config_dict362 = _t719 + _t1243 = parse_config_dict(parser) + config_dict604 = _t1243 consume_literal!(parser, ")") - _t720 = construct_configure(parser, config_dict362) - return _t720 + _t1244 = construct_configure(parser, config_dict604) + result606 = _t1244 + record_span!(parser, span_start605) + return result606 end function parse_config_dict(parser::ParserState)::Vector{Tuple{String, Proto.Value}} + span_start611 = span_start(parser) consume_literal!(parser, "{") - xs363 = Tuple{String, Proto.Value}[] - cond364 = match_lookahead_literal(parser, ":", 0) - while cond364 - _t721 = parse_config_key_value(parser) - item365 = _t721 - push!(xs363, item365) - cond364 = match_lookahead_literal(parser, ":", 0) - end - config_key_values366 = xs363 + xs607 = Tuple{String, Proto.Value}[] + cond608 = match_lookahead_literal(parser, ":", 0) + while cond608 + _t1245 = parse_config_key_value(parser) + item609 = _t1245 + push!(xs607, item609) + cond608 = match_lookahead_literal(parser, ":", 0) + end + config_key_values610 = xs607 consume_literal!(parser, "}") - return config_key_values366 + result612 = config_key_values610 + record_span!(parser, span_start611) + return result612 end function parse_config_key_value(parser::ParserState)::Tuple{String, Proto.Value} + span_start615 = span_start(parser) consume_literal!(parser, ":") - symbol367 = consume_terminal!(parser, "SYMBOL") - _t722 = parse_value(parser) - value368 = _t722 - return (symbol367, value368,) + symbol613 = consume_terminal!(parser, "SYMBOL") + _t1246 = parse_value(parser) + value614 = _t1246 + result616 = (symbol613, value614,) + record_span!(parser, span_start615) + return result616 end function parse_value(parser::ParserState)::Proto.Value + span_start627 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t723 = 9 + _t1247 = 9 else if match_lookahead_literal(parser, "missing", 0) - _t724 = 8 + _t1248 = 8 else if match_lookahead_literal(parser, "false", 0) - _t725 = 9 + _t1249 = 9 else if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "datetime", 1) - _t727 = 1 + _t1251 = 1 else if match_lookahead_literal(parser, "date", 1) - _t728 = 0 + _t1252 = 0 else - _t728 = -1 + _t1252 = -1 end - _t727 = _t728 + _t1251 = _t1252 end - _t726 = _t727 + _t1250 = _t1251 else if match_lookahead_terminal(parser, "UINT128", 0) - _t729 = 5 + _t1253 = 5 else if match_lookahead_terminal(parser, "STRING", 0) - _t730 = 2 + _t1254 = 2 else if match_lookahead_terminal(parser, "INT128", 0) - _t731 = 6 + _t1255 = 6 else if match_lookahead_terminal(parser, "INT", 0) - _t732 = 3 + _t1256 = 3 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t733 = 4 + _t1257 = 4 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t734 = 7 + _t1258 = 7 else - _t734 = -1 + _t1258 = -1 end - _t733 = _t734 + _t1257 = _t1258 end - _t732 = _t733 + _t1256 = _t1257 end - _t731 = _t732 + _t1255 = _t1256 end - _t730 = _t731 + _t1254 = _t1255 end - _t729 = _t730 + _t1253 = _t1254 end - _t726 = _t729 + _t1250 = _t1253 end - _t725 = _t726 + _t1249 = _t1250 end - _t724 = _t725 + _t1248 = _t1249 end - _t723 = _t724 - end - prediction369 = _t723 - if prediction369 == 9 - _t736 = parse_boolean_value(parser) - boolean_value378 = _t736 - _t737 = Proto.Value(value=OneOf(:boolean_value, boolean_value378)) - _t735 = _t737 + _t1247 = _t1248 + end + prediction617 = _t1247 + if prediction617 == 9 + _t1260 = parse_boolean_value(parser) + boolean_value626 = _t1260 + _t1261 = Proto.Value(value=OneOf(:boolean_value, boolean_value626)) + _t1259 = _t1261 else - if prediction369 == 8 + if prediction617 == 8 consume_literal!(parser, "missing") - _t739 = Proto.MissingValue() - _t740 = Proto.Value(value=OneOf(:missing_value, _t739)) - _t738 = _t740 + _t1263 = Proto.MissingValue() + _t1264 = Proto.Value(value=OneOf(:missing_value, _t1263)) + _t1262 = _t1264 else - if prediction369 == 7 - decimal377 = consume_terminal!(parser, "DECIMAL") - _t742 = Proto.Value(value=OneOf(:decimal_value, decimal377)) - _t741 = _t742 + if prediction617 == 7 + decimal625 = consume_terminal!(parser, "DECIMAL") + _t1266 = Proto.Value(value=OneOf(:decimal_value, decimal625)) + _t1265 = _t1266 else - if prediction369 == 6 - int128376 = consume_terminal!(parser, "INT128") - _t744 = Proto.Value(value=OneOf(:int128_value, int128376)) - _t743 = _t744 + if prediction617 == 6 + int128624 = consume_terminal!(parser, "INT128") + _t1268 = Proto.Value(value=OneOf(:int128_value, int128624)) + _t1267 = _t1268 else - if prediction369 == 5 - uint128375 = consume_terminal!(parser, "UINT128") - _t746 = Proto.Value(value=OneOf(:uint128_value, uint128375)) - _t745 = _t746 + if prediction617 == 5 + uint128623 = consume_terminal!(parser, "UINT128") + _t1270 = Proto.Value(value=OneOf(:uint128_value, uint128623)) + _t1269 = _t1270 else - if prediction369 == 4 - float374 = consume_terminal!(parser, "FLOAT") - _t748 = Proto.Value(value=OneOf(:float_value, float374)) - _t747 = _t748 + if prediction617 == 4 + float622 = consume_terminal!(parser, "FLOAT") + _t1272 = Proto.Value(value=OneOf(:float_value, float622)) + _t1271 = _t1272 else - if prediction369 == 3 - int373 = consume_terminal!(parser, "INT") - _t750 = Proto.Value(value=OneOf(:int_value, int373)) - _t749 = _t750 + if prediction617 == 3 + int621 = consume_terminal!(parser, "INT") + _t1274 = Proto.Value(value=OneOf(:int_value, int621)) + _t1273 = _t1274 else - if prediction369 == 2 - string372 = consume_terminal!(parser, "STRING") - _t752 = Proto.Value(value=OneOf(:string_value, string372)) - _t751 = _t752 + if prediction617 == 2 + string620 = consume_terminal!(parser, "STRING") + _t1276 = Proto.Value(value=OneOf(:string_value, string620)) + _t1275 = _t1276 else - if prediction369 == 1 - _t754 = parse_datetime(parser) - datetime371 = _t754 - _t755 = Proto.Value(value=OneOf(:datetime_value, datetime371)) - _t753 = _t755 + if prediction617 == 1 + _t1278 = parse_datetime(parser) + datetime619 = _t1278 + _t1279 = Proto.Value(value=OneOf(:datetime_value, datetime619)) + _t1277 = _t1279 else - if prediction369 == 0 - _t757 = parse_date(parser) - date370 = _t757 - _t758 = Proto.Value(value=OneOf(:date_value, date370)) - _t756 = _t758 + if prediction617 == 0 + _t1281 = parse_date(parser) + date618 = _t1281 + _t1282 = Proto.Value(value=OneOf(:date_value, date618)) + _t1280 = _t1282 else throw(ParseError("Unexpected token in value" * ": " * string(lookahead(parser, 0)))) end - _t753 = _t756 + _t1277 = _t1280 end - _t751 = _t753 + _t1275 = _t1277 end - _t749 = _t751 + _t1273 = _t1275 end - _t747 = _t749 + _t1271 = _t1273 end - _t745 = _t747 + _t1269 = _t1271 end - _t743 = _t745 + _t1267 = _t1269 end - _t741 = _t743 + _t1265 = _t1267 end - _t738 = _t741 + _t1262 = _t1265 end - _t735 = _t738 + _t1259 = _t1262 end - return _t735 + result628 = _t1259 + record_span!(parser, span_start627) + return result628 end function parse_date(parser::ParserState)::Proto.DateValue + span_start632 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "date") - int379 = consume_terminal!(parser, "INT") - int_3380 = consume_terminal!(parser, "INT") - int_4381 = consume_terminal!(parser, "INT") - consume_literal!(parser, ")") - _t759 = Proto.DateValue(year=Int32(int379), month=Int32(int_3380), day=Int32(int_4381)) - return _t759 + push_path!(parser, 1) + int629 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3630 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_4631 = consume_terminal!(parser, "INT") + pop_path!(parser) + consume_literal!(parser, ")") + _t1283 = Proto.DateValue(year=Int32(int629), month=Int32(int_3630), day=Int32(int_4631)) + result633 = _t1283 + record_span!(parser, span_start632) + return result633 end function parse_datetime(parser::ParserState)::Proto.DateTimeValue + span_start641 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "datetime") - int382 = consume_terminal!(parser, "INT") - int_3383 = consume_terminal!(parser, "INT") - int_4384 = consume_terminal!(parser, "INT") - int_5385 = consume_terminal!(parser, "INT") - int_6386 = consume_terminal!(parser, "INT") - int_7387 = consume_terminal!(parser, "INT") + push_path!(parser, 1) + int634 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3635 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_4636 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 4) + int_5637 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 5) + int_6638 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 6) + int_7639 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 7) if match_lookahead_terminal(parser, "INT", 0) - _t760 = consume_terminal!(parser, "INT") + _t1284 = consume_terminal!(parser, "INT") else - _t760 = nothing + _t1284 = nothing end - int_8388 = _t760 + int_8640 = _t1284 + pop_path!(parser) consume_literal!(parser, ")") - _t761 = Proto.DateTimeValue(year=Int32(int382), month=Int32(int_3383), day=Int32(int_4384), hour=Int32(int_5385), minute=Int32(int_6386), second=Int32(int_7387), microsecond=Int32((!isnothing(int_8388) ? int_8388 : 0))) - return _t761 + _t1285 = Proto.DateTimeValue(year=Int32(int634), month=Int32(int_3635), day=Int32(int_4636), hour=Int32(int_5637), minute=Int32(int_6638), second=Int32(int_7639), microsecond=Int32((!isnothing(int_8640) ? int_8640 : 0))) + result642 = _t1285 + record_span!(parser, span_start641) + return result642 end function parse_boolean_value(parser::ParserState)::Bool + span_start644 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t762 = 0 + _t1286 = 0 else if match_lookahead_literal(parser, "false", 0) - _t763 = 1 + _t1287 = 1 else - _t763 = -1 + _t1287 = -1 end - _t762 = _t763 + _t1286 = _t1287 end - prediction389 = _t762 - if prediction389 == 1 + prediction643 = _t1286 + if prediction643 == 1 consume_literal!(parser, "false") - _t764 = false + _t1288 = false else - if prediction389 == 0 + if prediction643 == 0 consume_literal!(parser, "true") - _t765 = true + _t1289 = true else throw(ParseError("Unexpected token in boolean_value" * ": " * string(lookahead(parser, 0)))) end - _t764 = _t765 + _t1288 = _t1289 end - return _t764 + result645 = _t1288 + record_span!(parser, span_start644) + return result645 end function parse_sync(parser::ParserState)::Proto.Sync + span_start654 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sync") - xs390 = Proto.FragmentId[] - cond391 = match_lookahead_literal(parser, ":", 0) - while cond391 - _t766 = parse_fragment_id(parser) - item392 = _t766 - push!(xs390, item392) - cond391 = match_lookahead_literal(parser, ":", 0) + push_path!(parser, 1) + xs650 = Proto.FragmentId[] + cond651 = match_lookahead_literal(parser, ":", 0) + idx652 = 0 + while cond651 + push_path!(parser, idx652) + _t1290 = parse_fragment_id(parser) + item653 = _t1290 + pop_path!(parser) + push!(xs650, item653) + idx652 = (idx652 + 1) + cond651 = match_lookahead_literal(parser, ":", 0) end - fragment_ids393 = xs390 + fragment_ids649 = xs650 + pop_path!(parser) consume_literal!(parser, ")") - _t767 = Proto.Sync(fragments=fragment_ids393) - return _t767 + _t1291 = Proto.Sync(fragments=fragment_ids649) + result655 = _t1291 + record_span!(parser, span_start654) + return result655 end function parse_fragment_id(parser::ParserState)::Proto.FragmentId + span_start657 = span_start(parser) consume_literal!(parser, ":") - symbol394 = consume_terminal!(parser, "SYMBOL") - return Proto.FragmentId(Vector{UInt8}(symbol394)) + symbol656 = consume_terminal!(parser, "SYMBOL") + result658 = Proto.FragmentId(Vector{UInt8}(symbol656)) + record_span!(parser, span_start657) + return result658 end function parse_epoch(parser::ParserState)::Proto.Epoch + span_start661 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "epoch") + push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "writes", 1)) - _t769 = parse_epoch_writes(parser) - _t768 = _t769 + _t1293 = parse_epoch_writes(parser) + _t1292 = _t1293 else - _t768 = nothing + _t1292 = nothing end - epoch_writes395 = _t768 + epoch_writes659 = _t1292 + pop_path!(parser) + push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t771 = parse_epoch_reads(parser) - _t770 = _t771 + _t1295 = parse_epoch_reads(parser) + _t1294 = _t1295 else - _t770 = nothing + _t1294 = nothing end - epoch_reads396 = _t770 + epoch_reads660 = _t1294 + pop_path!(parser) consume_literal!(parser, ")") - _t772 = Proto.Epoch(writes=(!isnothing(epoch_writes395) ? epoch_writes395 : Proto.Write[]), reads=(!isnothing(epoch_reads396) ? epoch_reads396 : Proto.Read[])) - return _t772 + _t1296 = Proto.Epoch(writes=(!isnothing(epoch_writes659) ? epoch_writes659 : Proto.Write[]), reads=(!isnothing(epoch_reads660) ? epoch_reads660 : Proto.Read[])) + result662 = _t1296 + record_span!(parser, span_start661) + return result662 end function parse_epoch_writes(parser::ParserState)::Vector{Proto.Write} + span_start667 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "writes") - xs397 = Proto.Write[] - cond398 = match_lookahead_literal(parser, "(", 0) - while cond398 - _t773 = parse_write(parser) - item399 = _t773 - push!(xs397, item399) - cond398 = match_lookahead_literal(parser, "(", 0) + xs663 = Proto.Write[] + cond664 = match_lookahead_literal(parser, "(", 0) + while cond664 + _t1297 = parse_write(parser) + item665 = _t1297 + push!(xs663, item665) + cond664 = match_lookahead_literal(parser, "(", 0) end - writes400 = xs397 + writes666 = xs663 consume_literal!(parser, ")") - return writes400 + result668 = writes666 + record_span!(parser, span_start667) + return result668 end function parse_write(parser::ParserState)::Proto.Write + span_start674 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "undefine", 1) - _t775 = 1 + _t1299 = 1 else if match_lookahead_literal(parser, "snapshot", 1) - _t776 = 3 + _t1300 = 3 else if match_lookahead_literal(parser, "define", 1) - _t777 = 0 + _t1301 = 0 else if match_lookahead_literal(parser, "context", 1) - _t778 = 2 + _t1302 = 2 else - _t778 = -1 + _t1302 = -1 end - _t777 = _t778 + _t1301 = _t1302 end - _t776 = _t777 + _t1300 = _t1301 end - _t775 = _t776 + _t1299 = _t1300 end - _t774 = _t775 + _t1298 = _t1299 else - _t774 = -1 - end - prediction401 = _t774 - if prediction401 == 3 - _t780 = parse_snapshot(parser) - snapshot405 = _t780 - _t781 = Proto.Write(write_type=OneOf(:snapshot, snapshot405)) - _t779 = _t781 + _t1298 = -1 + end + prediction669 = _t1298 + if prediction669 == 3 + _t1304 = parse_snapshot(parser) + snapshot673 = _t1304 + _t1305 = Proto.Write(write_type=OneOf(:snapshot, snapshot673)) + _t1303 = _t1305 else - if prediction401 == 2 - _t783 = parse_context(parser) - context404 = _t783 - _t784 = Proto.Write(write_type=OneOf(:context, context404)) - _t782 = _t784 + if prediction669 == 2 + _t1307 = parse_context(parser) + context672 = _t1307 + _t1308 = Proto.Write(write_type=OneOf(:context, context672)) + _t1306 = _t1308 else - if prediction401 == 1 - _t786 = parse_undefine(parser) - undefine403 = _t786 - _t787 = Proto.Write(write_type=OneOf(:undefine, undefine403)) - _t785 = _t787 + if prediction669 == 1 + _t1310 = parse_undefine(parser) + undefine671 = _t1310 + _t1311 = Proto.Write(write_type=OneOf(:undefine, undefine671)) + _t1309 = _t1311 else - if prediction401 == 0 - _t789 = parse_define(parser) - define402 = _t789 - _t790 = Proto.Write(write_type=OneOf(:define, define402)) - _t788 = _t790 + if prediction669 == 0 + _t1313 = parse_define(parser) + define670 = _t1313 + _t1314 = Proto.Write(write_type=OneOf(:define, define670)) + _t1312 = _t1314 else throw(ParseError("Unexpected token in write" * ": " * string(lookahead(parser, 0)))) end - _t785 = _t788 + _t1309 = _t1312 end - _t782 = _t785 + _t1306 = _t1309 end - _t779 = _t782 + _t1303 = _t1306 end - return _t779 + result675 = _t1303 + record_span!(parser, span_start674) + return result675 end function parse_define(parser::ParserState)::Proto.Define + span_start677 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "define") - _t791 = parse_fragment(parser) - fragment406 = _t791 + push_path!(parser, 1) + _t1315 = parse_fragment(parser) + fragment676 = _t1315 + pop_path!(parser) consume_literal!(parser, ")") - _t792 = Proto.Define(fragment=fragment406) - return _t792 + _t1316 = Proto.Define(fragment=fragment676) + result678 = _t1316 + record_span!(parser, span_start677) + return result678 end function parse_fragment(parser::ParserState)::Proto.Fragment + span_start684 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "fragment") - _t793 = parse_new_fragment_id(parser) - new_fragment_id407 = _t793 - xs408 = Proto.Declaration[] - cond409 = match_lookahead_literal(parser, "(", 0) - while cond409 - _t794 = parse_declaration(parser) - item410 = _t794 - push!(xs408, item410) - cond409 = match_lookahead_literal(parser, "(", 0) + _t1317 = parse_new_fragment_id(parser) + new_fragment_id679 = _t1317 + xs680 = Proto.Declaration[] + cond681 = match_lookahead_literal(parser, "(", 0) + while cond681 + _t1318 = parse_declaration(parser) + item682 = _t1318 + push!(xs680, item682) + cond681 = match_lookahead_literal(parser, "(", 0) end - declarations411 = xs408 + declarations683 = xs680 consume_literal!(parser, ")") - return construct_fragment(parser, new_fragment_id407, declarations411) + result685 = construct_fragment(parser, new_fragment_id679, declarations683) + record_span!(parser, span_start684) + return result685 end function parse_new_fragment_id(parser::ParserState)::Proto.FragmentId - _t795 = parse_fragment_id(parser) - fragment_id412 = _t795 - start_fragment!(parser, fragment_id412) - return fragment_id412 + span_start687 = span_start(parser) + _t1319 = parse_fragment_id(parser) + fragment_id686 = _t1319 + start_fragment!(parser, fragment_id686) + result688 = fragment_id686 + record_span!(parser, span_start687) + return result688 end function parse_declaration(parser::ParserState)::Proto.Declaration + span_start694 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t797 = 3 + _t1321 = 3 else if match_lookahead_literal(parser, "functional_dependency", 1) - _t798 = 2 + _t1322 = 2 else if match_lookahead_literal(parser, "def", 1) - _t799 = 0 + _t1323 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t800 = 3 + _t1324 = 3 else if match_lookahead_literal(parser, "betree_relation", 1) - _t801 = 3 + _t1325 = 3 else if match_lookahead_literal(parser, "algorithm", 1) - _t802 = 1 + _t1326 = 1 else - _t802 = -1 + _t1326 = -1 end - _t801 = _t802 + _t1325 = _t1326 end - _t800 = _t801 + _t1324 = _t1325 end - _t799 = _t800 + _t1323 = _t1324 end - _t798 = _t799 + _t1322 = _t1323 end - _t797 = _t798 + _t1321 = _t1322 end - _t796 = _t797 + _t1320 = _t1321 else - _t796 = -1 - end - prediction413 = _t796 - if prediction413 == 3 - _t804 = parse_data(parser) - data417 = _t804 - _t805 = Proto.Declaration(declaration_type=OneOf(:data, data417)) - _t803 = _t805 + _t1320 = -1 + end + prediction689 = _t1320 + if prediction689 == 3 + _t1328 = parse_data(parser) + data693 = _t1328 + _t1329 = Proto.Declaration(declaration_type=OneOf(:data, data693)) + _t1327 = _t1329 else - if prediction413 == 2 - _t807 = parse_constraint(parser) - constraint416 = _t807 - _t808 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint416)) - _t806 = _t808 + if prediction689 == 2 + _t1331 = parse_constraint(parser) + constraint692 = _t1331 + _t1332 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint692)) + _t1330 = _t1332 else - if prediction413 == 1 - _t810 = parse_algorithm(parser) - algorithm415 = _t810 - _t811 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm415)) - _t809 = _t811 + if prediction689 == 1 + _t1334 = parse_algorithm(parser) + algorithm691 = _t1334 + _t1335 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm691)) + _t1333 = _t1335 else - if prediction413 == 0 - _t813 = parse_def(parser) - def414 = _t813 - _t814 = Proto.Declaration(declaration_type=OneOf(:def, def414)) - _t812 = _t814 + if prediction689 == 0 + _t1337 = parse_def(parser) + def690 = _t1337 + _t1338 = Proto.Declaration(declaration_type=OneOf(:def, def690)) + _t1336 = _t1338 else throw(ParseError("Unexpected token in declaration" * ": " * string(lookahead(parser, 0)))) end - _t809 = _t812 + _t1333 = _t1336 end - _t806 = _t809 + _t1330 = _t1333 end - _t803 = _t806 + _t1327 = _t1330 end - return _t803 + result695 = _t1327 + record_span!(parser, span_start694) + return result695 end function parse_def(parser::ParserState)::Proto.Def + span_start699 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "def") - _t815 = parse_relation_id(parser) - relation_id418 = _t815 - _t816 = parse_abstraction(parser) - abstraction419 = _t816 + push_path!(parser, 1) + _t1339 = parse_relation_id(parser) + relation_id696 = _t1339 + pop_path!(parser) + push_path!(parser, 2) + _t1340 = parse_abstraction(parser) + abstraction697 = _t1340 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t818 = parse_attrs(parser) - _t817 = _t818 + _t1342 = parse_attrs(parser) + _t1341 = _t1342 else - _t817 = nothing + _t1341 = nothing end - attrs420 = _t817 + attrs698 = _t1341 + pop_path!(parser) consume_literal!(parser, ")") - _t819 = Proto.Def(name=relation_id418, body=abstraction419, attrs=(!isnothing(attrs420) ? attrs420 : Proto.Attribute[])) - return _t819 + _t1343 = Proto.Def(name=relation_id696, body=abstraction697, attrs=(!isnothing(attrs698) ? attrs698 : Proto.Attribute[])) + result700 = _t1343 + record_span!(parser, span_start699) + return result700 end function parse_relation_id(parser::ParserState)::Proto.RelationId + span_start704 = span_start(parser) if match_lookahead_literal(parser, ":", 0) - _t820 = 0 + _t1344 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t821 = 1 + _t1345 = 1 else - _t821 = -1 + _t1345 = -1 end - _t820 = _t821 + _t1344 = _t1345 end - prediction421 = _t820 - if prediction421 == 1 - uint128423 = consume_terminal!(parser, "UINT128") - _t822 = Proto.RelationId(uint128423.low, uint128423.high) + prediction701 = _t1344 + if prediction701 == 1 + uint128703 = consume_terminal!(parser, "UINT128") + _t1346 = Proto.RelationId(uint128703.low, uint128703.high) else - if prediction421 == 0 + if prediction701 == 0 consume_literal!(parser, ":") - symbol422 = consume_terminal!(parser, "SYMBOL") - _t823 = relation_id_from_string(parser, symbol422) + symbol702 = consume_terminal!(parser, "SYMBOL") + _t1347 = relation_id_from_string(parser, symbol702) else throw(ParseError("Unexpected token in relation_id" * ": " * string(lookahead(parser, 0)))) end - _t822 = _t823 + _t1346 = _t1347 end - return _t822 + result705 = _t1346 + record_span!(parser, span_start704) + return result705 end function parse_abstraction(parser::ParserState)::Proto.Abstraction + span_start708 = span_start(parser) consume_literal!(parser, "(") - _t824 = parse_bindings(parser) - bindings424 = _t824 - _t825 = parse_formula(parser) - formula425 = _t825 + _t1348 = parse_bindings(parser) + bindings706 = _t1348 + push_path!(parser, 2) + _t1349 = parse_formula(parser) + formula707 = _t1349 + pop_path!(parser) consume_literal!(parser, ")") - _t826 = Proto.Abstraction(vars=vcat(bindings424[1], !isnothing(bindings424[2]) ? bindings424[2] : []), value=formula425) - return _t826 + _t1350 = Proto.Abstraction(vars=vcat(bindings706[1], !isnothing(bindings706[2]) ? bindings706[2] : []), value=formula707) + result709 = _t1350 + record_span!(parser, span_start708) + return result709 end function parse_bindings(parser::ParserState)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} + span_start715 = span_start(parser) consume_literal!(parser, "[") - xs426 = Proto.Binding[] - cond427 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond427 - _t827 = parse_binding(parser) - item428 = _t827 - push!(xs426, item428) - cond427 = match_lookahead_terminal(parser, "SYMBOL", 0) - end - bindings429 = xs426 + xs710 = Proto.Binding[] + cond711 = match_lookahead_terminal(parser, "SYMBOL", 0) + while cond711 + _t1351 = parse_binding(parser) + item712 = _t1351 + push!(xs710, item712) + cond711 = match_lookahead_terminal(parser, "SYMBOL", 0) + end + bindings713 = xs710 if match_lookahead_literal(parser, "|", 0) - _t829 = parse_value_bindings(parser) - _t828 = _t829 + _t1353 = parse_value_bindings(parser) + _t1352 = _t1353 else - _t828 = nothing + _t1352 = nothing end - value_bindings430 = _t828 + value_bindings714 = _t1352 consume_literal!(parser, "]") - return (bindings429, (!isnothing(value_bindings430) ? value_bindings430 : Proto.Binding[]),) + result716 = (bindings713, (!isnothing(value_bindings714) ? value_bindings714 : Proto.Binding[]),) + record_span!(parser, span_start715) + return result716 end function parse_binding(parser::ParserState)::Proto.Binding - symbol431 = consume_terminal!(parser, "SYMBOL") + span_start719 = span_start(parser) + symbol717 = consume_terminal!(parser, "SYMBOL") consume_literal!(parser, "::") - _t830 = parse_type(parser) - type432 = _t830 - _t831 = Proto.Var(name=symbol431) - _t832 = Proto.Binding(var=_t831, var"#type"=type432) - return _t832 + push_path!(parser, 2) + _t1354 = parse_type(parser) + type718 = _t1354 + pop_path!(parser) + _t1355 = Proto.Var(name=symbol717) + _t1356 = Proto.Binding(var=_t1355, var"#type"=type718) + result720 = _t1356 + record_span!(parser, span_start719) + return result720 end function parse_type(parser::ParserState)::Proto.var"#Type" + span_start733 = span_start(parser) if match_lookahead_literal(parser, "UNKNOWN", 0) - _t833 = 0 + _t1357 = 0 else if match_lookahead_literal(parser, "UINT128", 0) - _t834 = 4 + _t1358 = 4 else if match_lookahead_literal(parser, "STRING", 0) - _t835 = 1 + _t1359 = 1 else if match_lookahead_literal(parser, "MISSING", 0) - _t836 = 8 + _t1360 = 8 else if match_lookahead_literal(parser, "INT128", 0) - _t837 = 5 + _t1361 = 5 else if match_lookahead_literal(parser, "INT", 0) - _t838 = 2 + _t1362 = 2 else if match_lookahead_literal(parser, "FLOAT", 0) - _t839 = 3 + _t1363 = 3 else if match_lookahead_literal(parser, "DATETIME", 0) - _t840 = 7 + _t1364 = 7 else if match_lookahead_literal(parser, "DATE", 0) - _t841 = 6 + _t1365 = 6 else if match_lookahead_literal(parser, "BOOLEAN", 0) - _t842 = 10 + _t1366 = 10 else if match_lookahead_literal(parser, "(", 0) - _t843 = 9 + _t1367 = 9 else - _t843 = -1 + _t1367 = -1 end - _t842 = _t843 + _t1366 = _t1367 end - _t841 = _t842 + _t1365 = _t1366 end - _t840 = _t841 + _t1364 = _t1365 end - _t839 = _t840 + _t1363 = _t1364 end - _t838 = _t839 + _t1362 = _t1363 end - _t837 = _t838 + _t1361 = _t1362 end - _t836 = _t837 + _t1360 = _t1361 end - _t835 = _t836 + _t1359 = _t1360 end - _t834 = _t835 + _t1358 = _t1359 end - _t833 = _t834 - end - prediction433 = _t833 - if prediction433 == 10 - _t845 = parse_boolean_type(parser) - boolean_type444 = _t845 - _t846 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type444)) - _t844 = _t846 + _t1357 = _t1358 + end + prediction721 = _t1357 + if prediction721 == 10 + _t1369 = parse_boolean_type(parser) + boolean_type732 = _t1369 + _t1370 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type732)) + _t1368 = _t1370 else - if prediction433 == 9 - _t848 = parse_decimal_type(parser) - decimal_type443 = _t848 - _t849 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type443)) - _t847 = _t849 + if prediction721 == 9 + _t1372 = parse_decimal_type(parser) + decimal_type731 = _t1372 + _t1373 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type731)) + _t1371 = _t1373 else - if prediction433 == 8 - _t851 = parse_missing_type(parser) - missing_type442 = _t851 - _t852 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type442)) - _t850 = _t852 + if prediction721 == 8 + _t1375 = parse_missing_type(parser) + missing_type730 = _t1375 + _t1376 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type730)) + _t1374 = _t1376 else - if prediction433 == 7 - _t854 = parse_datetime_type(parser) - datetime_type441 = _t854 - _t855 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type441)) - _t853 = _t855 + if prediction721 == 7 + _t1378 = parse_datetime_type(parser) + datetime_type729 = _t1378 + _t1379 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type729)) + _t1377 = _t1379 else - if prediction433 == 6 - _t857 = parse_date_type(parser) - date_type440 = _t857 - _t858 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type440)) - _t856 = _t858 + if prediction721 == 6 + _t1381 = parse_date_type(parser) + date_type728 = _t1381 + _t1382 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type728)) + _t1380 = _t1382 else - if prediction433 == 5 - _t860 = parse_int128_type(parser) - int128_type439 = _t860 - _t861 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type439)) - _t859 = _t861 + if prediction721 == 5 + _t1384 = parse_int128_type(parser) + int128_type727 = _t1384 + _t1385 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type727)) + _t1383 = _t1385 else - if prediction433 == 4 - _t863 = parse_uint128_type(parser) - uint128_type438 = _t863 - _t864 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type438)) - _t862 = _t864 + if prediction721 == 4 + _t1387 = parse_uint128_type(parser) + uint128_type726 = _t1387 + _t1388 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type726)) + _t1386 = _t1388 else - if prediction433 == 3 - _t866 = parse_float_type(parser) - float_type437 = _t866 - _t867 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type437)) - _t865 = _t867 + if prediction721 == 3 + _t1390 = parse_float_type(parser) + float_type725 = _t1390 + _t1391 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type725)) + _t1389 = _t1391 else - if prediction433 == 2 - _t869 = parse_int_type(parser) - int_type436 = _t869 - _t870 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type436)) - _t868 = _t870 + if prediction721 == 2 + _t1393 = parse_int_type(parser) + int_type724 = _t1393 + _t1394 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type724)) + _t1392 = _t1394 else - if prediction433 == 1 - _t872 = parse_string_type(parser) - string_type435 = _t872 - _t873 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type435)) - _t871 = _t873 + if prediction721 == 1 + _t1396 = parse_string_type(parser) + string_type723 = _t1396 + _t1397 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type723)) + _t1395 = _t1397 else - if prediction433 == 0 - _t875 = parse_unspecified_type(parser) - unspecified_type434 = _t875 - _t876 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type434)) - _t874 = _t876 + if prediction721 == 0 + _t1399 = parse_unspecified_type(parser) + unspecified_type722 = _t1399 + _t1400 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type722)) + _t1398 = _t1400 else throw(ParseError("Unexpected token in type" * ": " * string(lookahead(parser, 0)))) end - _t871 = _t874 + _t1395 = _t1398 end - _t868 = _t871 + _t1392 = _t1395 end - _t865 = _t868 + _t1389 = _t1392 end - _t862 = _t865 + _t1386 = _t1389 end - _t859 = _t862 + _t1383 = _t1386 end - _t856 = _t859 + _t1380 = _t1383 end - _t853 = _t856 + _t1377 = _t1380 end - _t850 = _t853 + _t1374 = _t1377 end - _t847 = _t850 + _t1371 = _t1374 end - _t844 = _t847 + _t1368 = _t1371 end - return _t844 + result734 = _t1368 + record_span!(parser, span_start733) + return result734 end function parse_unspecified_type(parser::ParserState)::Proto.UnspecifiedType + span_start735 = span_start(parser) consume_literal!(parser, "UNKNOWN") - _t877 = Proto.UnspecifiedType() - return _t877 + _t1401 = Proto.UnspecifiedType() + result736 = _t1401 + record_span!(parser, span_start735) + return result736 end function parse_string_type(parser::ParserState)::Proto.StringType + span_start737 = span_start(parser) consume_literal!(parser, "STRING") - _t878 = Proto.StringType() - return _t878 + _t1402 = Proto.StringType() + result738 = _t1402 + record_span!(parser, span_start737) + return result738 end function parse_int_type(parser::ParserState)::Proto.IntType + span_start739 = span_start(parser) consume_literal!(parser, "INT") - _t879 = Proto.IntType() - return _t879 + _t1403 = Proto.IntType() + result740 = _t1403 + record_span!(parser, span_start739) + return result740 end function parse_float_type(parser::ParserState)::Proto.FloatType + span_start741 = span_start(parser) consume_literal!(parser, "FLOAT") - _t880 = Proto.FloatType() - return _t880 + _t1404 = Proto.FloatType() + result742 = _t1404 + record_span!(parser, span_start741) + return result742 end function parse_uint128_type(parser::ParserState)::Proto.UInt128Type + span_start743 = span_start(parser) consume_literal!(parser, "UINT128") - _t881 = Proto.UInt128Type() - return _t881 + _t1405 = Proto.UInt128Type() + result744 = _t1405 + record_span!(parser, span_start743) + return result744 end function parse_int128_type(parser::ParserState)::Proto.Int128Type + span_start745 = span_start(parser) consume_literal!(parser, "INT128") - _t882 = Proto.Int128Type() - return _t882 + _t1406 = Proto.Int128Type() + result746 = _t1406 + record_span!(parser, span_start745) + return result746 end function parse_date_type(parser::ParserState)::Proto.DateType + span_start747 = span_start(parser) consume_literal!(parser, "DATE") - _t883 = Proto.DateType() - return _t883 + _t1407 = Proto.DateType() + result748 = _t1407 + record_span!(parser, span_start747) + return result748 end function parse_datetime_type(parser::ParserState)::Proto.DateTimeType + span_start749 = span_start(parser) consume_literal!(parser, "DATETIME") - _t884 = Proto.DateTimeType() - return _t884 + _t1408 = Proto.DateTimeType() + result750 = _t1408 + record_span!(parser, span_start749) + return result750 end function parse_missing_type(parser::ParserState)::Proto.MissingType + span_start751 = span_start(parser) consume_literal!(parser, "MISSING") - _t885 = Proto.MissingType() - return _t885 + _t1409 = Proto.MissingType() + result752 = _t1409 + record_span!(parser, span_start751) + return result752 end function parse_decimal_type(parser::ParserState)::Proto.DecimalType + span_start755 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "DECIMAL") - int445 = consume_terminal!(parser, "INT") - int_3446 = consume_terminal!(parser, "INT") + push_path!(parser, 1) + int753 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3754 = consume_terminal!(parser, "INT") + pop_path!(parser) consume_literal!(parser, ")") - _t886 = Proto.DecimalType(precision=Int32(int445), scale=Int32(int_3446)) - return _t886 + _t1410 = Proto.DecimalType(precision=Int32(int753), scale=Int32(int_3754)) + result756 = _t1410 + record_span!(parser, span_start755) + return result756 end function parse_boolean_type(parser::ParserState)::Proto.BooleanType + span_start757 = span_start(parser) consume_literal!(parser, "BOOLEAN") - _t887 = Proto.BooleanType() - return _t887 + _t1411 = Proto.BooleanType() + result758 = _t1411 + record_span!(parser, span_start757) + return result758 end function parse_value_bindings(parser::ParserState)::Vector{Proto.Binding} + span_start763 = span_start(parser) consume_literal!(parser, "|") - xs447 = Proto.Binding[] - cond448 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond448 - _t888 = parse_binding(parser) - item449 = _t888 - push!(xs447, item449) - cond448 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs759 = Proto.Binding[] + cond760 = match_lookahead_terminal(parser, "SYMBOL", 0) + while cond760 + _t1412 = parse_binding(parser) + item761 = _t1412 + push!(xs759, item761) + cond760 = match_lookahead_terminal(parser, "SYMBOL", 0) end - bindings450 = xs447 - return bindings450 + bindings762 = xs759 + result764 = bindings762 + record_span!(parser, span_start763) + return result764 end function parse_formula(parser::ParserState)::Proto.Formula + span_start779 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "true", 1) - _t890 = 0 + _t1414 = 0 else if match_lookahead_literal(parser, "relatom", 1) - _t891 = 11 + _t1415 = 11 else if match_lookahead_literal(parser, "reduce", 1) - _t892 = 3 + _t1416 = 3 else if match_lookahead_literal(parser, "primitive", 1) - _t893 = 10 + _t1417 = 10 else if match_lookahead_literal(parser, "pragma", 1) - _t894 = 9 + _t1418 = 9 else if match_lookahead_literal(parser, "or", 1) - _t895 = 5 + _t1419 = 5 else if match_lookahead_literal(parser, "not", 1) - _t896 = 6 + _t1420 = 6 else if match_lookahead_literal(parser, "ffi", 1) - _t897 = 7 + _t1421 = 7 else if match_lookahead_literal(parser, "false", 1) - _t898 = 1 + _t1422 = 1 else if match_lookahead_literal(parser, "exists", 1) - _t899 = 2 + _t1423 = 2 else if match_lookahead_literal(parser, "cast", 1) - _t900 = 12 + _t1424 = 12 else if match_lookahead_literal(parser, "atom", 1) - _t901 = 8 + _t1425 = 8 else if match_lookahead_literal(parser, "and", 1) - _t902 = 4 + _t1426 = 4 else if match_lookahead_literal(parser, ">=", 1) - _t903 = 10 + _t1427 = 10 else if match_lookahead_literal(parser, ">", 1) - _t904 = 10 + _t1428 = 10 else if match_lookahead_literal(parser, "=", 1) - _t905 = 10 + _t1429 = 10 else if match_lookahead_literal(parser, "<=", 1) - _t906 = 10 + _t1430 = 10 else if match_lookahead_literal(parser, "<", 1) - _t907 = 10 + _t1431 = 10 else if match_lookahead_literal(parser, "/", 1) - _t908 = 10 + _t1432 = 10 else if match_lookahead_literal(parser, "-", 1) - _t909 = 10 + _t1433 = 10 else if match_lookahead_literal(parser, "+", 1) - _t910 = 10 + _t1434 = 10 else if match_lookahead_literal(parser, "*", 1) - _t911 = 10 + _t1435 = 10 else - _t911 = -1 + _t1435 = -1 end - _t910 = _t911 + _t1434 = _t1435 end - _t909 = _t910 + _t1433 = _t1434 end - _t908 = _t909 + _t1432 = _t1433 end - _t907 = _t908 + _t1431 = _t1432 end - _t906 = _t907 + _t1430 = _t1431 end - _t905 = _t906 + _t1429 = _t1430 end - _t904 = _t905 + _t1428 = _t1429 end - _t903 = _t904 + _t1427 = _t1428 end - _t902 = _t903 + _t1426 = _t1427 end - _t901 = _t902 + _t1425 = _t1426 end - _t900 = _t901 + _t1424 = _t1425 end - _t899 = _t900 + _t1423 = _t1424 end - _t898 = _t899 + _t1422 = _t1423 end - _t897 = _t898 + _t1421 = _t1422 end - _t896 = _t897 + _t1420 = _t1421 end - _t895 = _t896 + _t1419 = _t1420 end - _t894 = _t895 + _t1418 = _t1419 end - _t893 = _t894 + _t1417 = _t1418 end - _t892 = _t893 + _t1416 = _t1417 end - _t891 = _t892 + _t1415 = _t1416 end - _t890 = _t891 + _t1414 = _t1415 end - _t889 = _t890 + _t1413 = _t1414 else - _t889 = -1 - end - prediction451 = _t889 - if prediction451 == 12 - _t913 = parse_cast(parser) - cast464 = _t913 - _t914 = Proto.Formula(formula_type=OneOf(:cast, cast464)) - _t912 = _t914 + _t1413 = -1 + end + prediction765 = _t1413 + if prediction765 == 12 + _t1437 = parse_cast(parser) + cast778 = _t1437 + _t1438 = Proto.Formula(formula_type=OneOf(:cast, cast778)) + _t1436 = _t1438 else - if prediction451 == 11 - _t916 = parse_rel_atom(parser) - rel_atom463 = _t916 - _t917 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom463)) - _t915 = _t917 + if prediction765 == 11 + _t1440 = parse_rel_atom(parser) + rel_atom777 = _t1440 + _t1441 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom777)) + _t1439 = _t1441 else - if prediction451 == 10 - _t919 = parse_primitive(parser) - primitive462 = _t919 - _t920 = Proto.Formula(formula_type=OneOf(:primitive, primitive462)) - _t918 = _t920 + if prediction765 == 10 + _t1443 = parse_primitive(parser) + primitive776 = _t1443 + _t1444 = Proto.Formula(formula_type=OneOf(:primitive, primitive776)) + _t1442 = _t1444 else - if prediction451 == 9 - _t922 = parse_pragma(parser) - pragma461 = _t922 - _t923 = Proto.Formula(formula_type=OneOf(:pragma, pragma461)) - _t921 = _t923 + if prediction765 == 9 + _t1446 = parse_pragma(parser) + pragma775 = _t1446 + _t1447 = Proto.Formula(formula_type=OneOf(:pragma, pragma775)) + _t1445 = _t1447 else - if prediction451 == 8 - _t925 = parse_atom(parser) - atom460 = _t925 - _t926 = Proto.Formula(formula_type=OneOf(:atom, atom460)) - _t924 = _t926 + if prediction765 == 8 + _t1449 = parse_atom(parser) + atom774 = _t1449 + _t1450 = Proto.Formula(formula_type=OneOf(:atom, atom774)) + _t1448 = _t1450 else - if prediction451 == 7 - _t928 = parse_ffi(parser) - ffi459 = _t928 - _t929 = Proto.Formula(formula_type=OneOf(:ffi, ffi459)) - _t927 = _t929 + if prediction765 == 7 + _t1452 = parse_ffi(parser) + ffi773 = _t1452 + _t1453 = Proto.Formula(formula_type=OneOf(:ffi, ffi773)) + _t1451 = _t1453 else - if prediction451 == 6 - _t931 = parse_not(parser) - not458 = _t931 - _t932 = Proto.Formula(formula_type=OneOf(:not, not458)) - _t930 = _t932 + if prediction765 == 6 + _t1455 = parse_not(parser) + not772 = _t1455 + _t1456 = Proto.Formula(formula_type=OneOf(:not, not772)) + _t1454 = _t1456 else - if prediction451 == 5 - _t934 = parse_disjunction(parser) - disjunction457 = _t934 - _t935 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction457)) - _t933 = _t935 + if prediction765 == 5 + _t1458 = parse_disjunction(parser) + disjunction771 = _t1458 + _t1459 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction771)) + _t1457 = _t1459 else - if prediction451 == 4 - _t937 = parse_conjunction(parser) - conjunction456 = _t937 - _t938 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction456)) - _t936 = _t938 + if prediction765 == 4 + _t1461 = parse_conjunction(parser) + conjunction770 = _t1461 + _t1462 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction770)) + _t1460 = _t1462 else - if prediction451 == 3 - _t940 = parse_reduce(parser) - reduce455 = _t940 - _t941 = Proto.Formula(formula_type=OneOf(:reduce, reduce455)) - _t939 = _t941 + if prediction765 == 3 + _t1464 = parse_reduce(parser) + reduce769 = _t1464 + _t1465 = Proto.Formula(formula_type=OneOf(:reduce, reduce769)) + _t1463 = _t1465 else - if prediction451 == 2 - _t943 = parse_exists(parser) - exists454 = _t943 - _t944 = Proto.Formula(formula_type=OneOf(:exists, exists454)) - _t942 = _t944 + if prediction765 == 2 + _t1467 = parse_exists(parser) + exists768 = _t1467 + _t1468 = Proto.Formula(formula_type=OneOf(:exists, exists768)) + _t1466 = _t1468 else - if prediction451 == 1 - _t946 = parse_false(parser) - false453 = _t946 - _t947 = Proto.Formula(formula_type=OneOf(:disjunction, false453)) - _t945 = _t947 + if prediction765 == 1 + _t1470 = parse_false(parser) + false767 = _t1470 + _t1471 = Proto.Formula(formula_type=OneOf(:disjunction, false767)) + _t1469 = _t1471 else - if prediction451 == 0 - _t949 = parse_true(parser) - true452 = _t949 - _t950 = Proto.Formula(formula_type=OneOf(:conjunction, true452)) - _t948 = _t950 + if prediction765 == 0 + _t1473 = parse_true(parser) + true766 = _t1473 + _t1474 = Proto.Formula(formula_type=OneOf(:conjunction, true766)) + _t1472 = _t1474 else throw(ParseError("Unexpected token in formula" * ": " * string(lookahead(parser, 0)))) end - _t945 = _t948 + _t1469 = _t1472 end - _t942 = _t945 + _t1466 = _t1469 end - _t939 = _t942 + _t1463 = _t1466 end - _t936 = _t939 + _t1460 = _t1463 end - _t933 = _t936 + _t1457 = _t1460 end - _t930 = _t933 + _t1454 = _t1457 end - _t927 = _t930 + _t1451 = _t1454 end - _t924 = _t927 + _t1448 = _t1451 end - _t921 = _t924 + _t1445 = _t1448 end - _t918 = _t921 + _t1442 = _t1445 end - _t915 = _t918 + _t1439 = _t1442 end - _t912 = _t915 + _t1436 = _t1439 end - return _t912 + result780 = _t1436 + record_span!(parser, span_start779) + return result780 end function parse_true(parser::ParserState)::Proto.Conjunction + span_start781 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "true") consume_literal!(parser, ")") - _t951 = Proto.Conjunction(args=Proto.Formula[]) - return _t951 + _t1475 = Proto.Conjunction(args=Proto.Formula[]) + result782 = _t1475 + record_span!(parser, span_start781) + return result782 end function parse_false(parser::ParserState)::Proto.Disjunction + span_start783 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "false") consume_literal!(parser, ")") - _t952 = Proto.Disjunction(args=Proto.Formula[]) - return _t952 + _t1476 = Proto.Disjunction(args=Proto.Formula[]) + result784 = _t1476 + record_span!(parser, span_start783) + return result784 end function parse_exists(parser::ParserState)::Proto.Exists + span_start787 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "exists") - _t953 = parse_bindings(parser) - bindings465 = _t953 - _t954 = parse_formula(parser) - formula466 = _t954 + _t1477 = parse_bindings(parser) + bindings785 = _t1477 + _t1478 = parse_formula(parser) + formula786 = _t1478 consume_literal!(parser, ")") - _t955 = Proto.Abstraction(vars=vcat(bindings465[1], !isnothing(bindings465[2]) ? bindings465[2] : []), value=formula466) - _t956 = Proto.Exists(body=_t955) - return _t956 + _t1479 = Proto.Abstraction(vars=vcat(bindings785[1], !isnothing(bindings785[2]) ? bindings785[2] : []), value=formula786) + _t1480 = Proto.Exists(body=_t1479) + result788 = _t1480 + record_span!(parser, span_start787) + return result788 end function parse_reduce(parser::ParserState)::Proto.Reduce + span_start792 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reduce") - _t957 = parse_abstraction(parser) - abstraction467 = _t957 - _t958 = parse_abstraction(parser) - abstraction_3468 = _t958 - _t959 = parse_terms(parser) - terms469 = _t959 - consume_literal!(parser, ")") - _t960 = Proto.Reduce(op=abstraction467, body=abstraction_3468, terms=terms469) - return _t960 + push_path!(parser, 1) + _t1481 = parse_abstraction(parser) + abstraction789 = _t1481 + pop_path!(parser) + push_path!(parser, 2) + _t1482 = parse_abstraction(parser) + abstraction_3790 = _t1482 + pop_path!(parser) + push_path!(parser, 3) + _t1483 = parse_terms(parser) + terms791 = _t1483 + pop_path!(parser) + consume_literal!(parser, ")") + _t1484 = Proto.Reduce(op=abstraction789, body=abstraction_3790, terms=terms791) + result793 = _t1484 + record_span!(parser, span_start792) + return result793 end function parse_terms(parser::ParserState)::Vector{Proto.Term} + span_start798 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "terms") - xs470 = Proto.Term[] - cond471 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond471 - _t961 = parse_term(parser) - item472 = _t961 - push!(xs470, item472) - cond471 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + xs794 = Proto.Term[] + cond795 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + while cond795 + _t1485 = parse_term(parser) + item796 = _t1485 + push!(xs794, item796) + cond795 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms473 = xs470 + terms797 = xs794 consume_literal!(parser, ")") - return terms473 + result799 = terms797 + record_span!(parser, span_start798) + return result799 end function parse_term(parser::ParserState)::Proto.Term + span_start803 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t962 = 1 + _t1486 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t963 = 1 + _t1487 = 1 else if match_lookahead_literal(parser, "false", 0) - _t964 = 1 + _t1488 = 1 else if match_lookahead_literal(parser, "(", 0) - _t965 = 1 + _t1489 = 1 else if match_lookahead_terminal(parser, "UINT128", 0) - _t966 = 1 + _t1490 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t967 = 0 + _t1491 = 0 else if match_lookahead_terminal(parser, "STRING", 0) - _t968 = 1 + _t1492 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t969 = 1 + _t1493 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t970 = 1 + _t1494 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t971 = 1 + _t1495 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t972 = 1 + _t1496 = 1 else - _t972 = -1 + _t1496 = -1 end - _t971 = _t972 + _t1495 = _t1496 end - _t970 = _t971 + _t1494 = _t1495 end - _t969 = _t970 + _t1493 = _t1494 end - _t968 = _t969 + _t1492 = _t1493 end - _t967 = _t968 + _t1491 = _t1492 end - _t966 = _t967 + _t1490 = _t1491 end - _t965 = _t966 + _t1489 = _t1490 end - _t964 = _t965 + _t1488 = _t1489 end - _t963 = _t964 + _t1487 = _t1488 end - _t962 = _t963 - end - prediction474 = _t962 - if prediction474 == 1 - _t974 = parse_constant(parser) - constant476 = _t974 - _t975 = Proto.Term(term_type=OneOf(:constant, constant476)) - _t973 = _t975 + _t1486 = _t1487 + end + prediction800 = _t1486 + if prediction800 == 1 + _t1498 = parse_constant(parser) + constant802 = _t1498 + _t1499 = Proto.Term(term_type=OneOf(:constant, constant802)) + _t1497 = _t1499 else - if prediction474 == 0 - _t977 = parse_var(parser) - var475 = _t977 - _t978 = Proto.Term(term_type=OneOf(:var, var475)) - _t976 = _t978 + if prediction800 == 0 + _t1501 = parse_var(parser) + var801 = _t1501 + _t1502 = Proto.Term(term_type=OneOf(:var, var801)) + _t1500 = _t1502 else throw(ParseError("Unexpected token in term" * ": " * string(lookahead(parser, 0)))) end - _t973 = _t976 + _t1497 = _t1500 end - return _t973 + result804 = _t1497 + record_span!(parser, span_start803) + return result804 end function parse_var(parser::ParserState)::Proto.Var - symbol477 = consume_terminal!(parser, "SYMBOL") - _t979 = Proto.Var(name=symbol477) - return _t979 + span_start806 = span_start(parser) + symbol805 = consume_terminal!(parser, "SYMBOL") + _t1503 = Proto.Var(name=symbol805) + result807 = _t1503 + record_span!(parser, span_start806) + return result807 end function parse_constant(parser::ParserState)::Proto.Value - _t980 = parse_value(parser) - value478 = _t980 - return value478 + span_start809 = span_start(parser) + _t1504 = parse_value(parser) + value808 = _t1504 + result810 = value808 + record_span!(parser, span_start809) + return result810 end function parse_conjunction(parser::ParserState)::Proto.Conjunction + span_start819 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "and") - xs479 = Proto.Formula[] - cond480 = match_lookahead_literal(parser, "(", 0) - while cond480 - _t981 = parse_formula(parser) - item481 = _t981 - push!(xs479, item481) - cond480 = match_lookahead_literal(parser, "(", 0) - end - formulas482 = xs479 - consume_literal!(parser, ")") - _t982 = Proto.Conjunction(args=formulas482) - return _t982 + push_path!(parser, 1) + xs815 = Proto.Formula[] + cond816 = match_lookahead_literal(parser, "(", 0) + idx817 = 0 + while cond816 + push_path!(parser, idx817) + _t1505 = parse_formula(parser) + item818 = _t1505 + pop_path!(parser) + push!(xs815, item818) + idx817 = (idx817 + 1) + cond816 = match_lookahead_literal(parser, "(", 0) + end + formulas814 = xs815 + pop_path!(parser) + consume_literal!(parser, ")") + _t1506 = Proto.Conjunction(args=formulas814) + result820 = _t1506 + record_span!(parser, span_start819) + return result820 end function parse_disjunction(parser::ParserState)::Proto.Disjunction + span_start829 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") - xs483 = Proto.Formula[] - cond484 = match_lookahead_literal(parser, "(", 0) - while cond484 - _t983 = parse_formula(parser) - item485 = _t983 - push!(xs483, item485) - cond484 = match_lookahead_literal(parser, "(", 0) - end - formulas486 = xs483 - consume_literal!(parser, ")") - _t984 = Proto.Disjunction(args=formulas486) - return _t984 + push_path!(parser, 1) + xs825 = Proto.Formula[] + cond826 = match_lookahead_literal(parser, "(", 0) + idx827 = 0 + while cond826 + push_path!(parser, idx827) + _t1507 = parse_formula(parser) + item828 = _t1507 + pop_path!(parser) + push!(xs825, item828) + idx827 = (idx827 + 1) + cond826 = match_lookahead_literal(parser, "(", 0) + end + formulas824 = xs825 + pop_path!(parser) + consume_literal!(parser, ")") + _t1508 = Proto.Disjunction(args=formulas824) + result830 = _t1508 + record_span!(parser, span_start829) + return result830 end function parse_not(parser::ParserState)::Proto.Not + span_start832 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "not") - _t985 = parse_formula(parser) - formula487 = _t985 + push_path!(parser, 1) + _t1509 = parse_formula(parser) + formula831 = _t1509 + pop_path!(parser) consume_literal!(parser, ")") - _t986 = Proto.Not(arg=formula487) - return _t986 + _t1510 = Proto.Not(arg=formula831) + result833 = _t1510 + record_span!(parser, span_start832) + return result833 end function parse_ffi(parser::ParserState)::Proto.FFI + span_start837 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "ffi") - _t987 = parse_name(parser) - name488 = _t987 - _t988 = parse_ffi_args(parser) - ffi_args489 = _t988 - _t989 = parse_terms(parser) - terms490 = _t989 - consume_literal!(parser, ")") - _t990 = Proto.FFI(name=name488, args=ffi_args489, terms=terms490) - return _t990 + push_path!(parser, 1) + _t1511 = parse_name(parser) + name834 = _t1511 + pop_path!(parser) + push_path!(parser, 2) + _t1512 = parse_ffi_args(parser) + ffi_args835 = _t1512 + pop_path!(parser) + push_path!(parser, 3) + _t1513 = parse_terms(parser) + terms836 = _t1513 + pop_path!(parser) + consume_literal!(parser, ")") + _t1514 = Proto.FFI(name=name834, args=ffi_args835, terms=terms836) + result838 = _t1514 + record_span!(parser, span_start837) + return result838 end function parse_name(parser::ParserState)::String + span_start840 = span_start(parser) consume_literal!(parser, ":") - symbol491 = consume_terminal!(parser, "SYMBOL") - return symbol491 + symbol839 = consume_terminal!(parser, "SYMBOL") + result841 = symbol839 + record_span!(parser, span_start840) + return result841 end function parse_ffi_args(parser::ParserState)::Vector{Proto.Abstraction} + span_start846 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "args") - xs492 = Proto.Abstraction[] - cond493 = match_lookahead_literal(parser, "(", 0) - while cond493 - _t991 = parse_abstraction(parser) - item494 = _t991 - push!(xs492, item494) - cond493 = match_lookahead_literal(parser, "(", 0) + xs842 = Proto.Abstraction[] + cond843 = match_lookahead_literal(parser, "(", 0) + while cond843 + _t1515 = parse_abstraction(parser) + item844 = _t1515 + push!(xs842, item844) + cond843 = match_lookahead_literal(parser, "(", 0) end - abstractions495 = xs492 + abstractions845 = xs842 consume_literal!(parser, ")") - return abstractions495 + result847 = abstractions845 + record_span!(parser, span_start846) + return result847 end function parse_atom(parser::ParserState)::Proto.Atom + span_start857 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "atom") - _t992 = parse_relation_id(parser) - relation_id496 = _t992 - xs497 = Proto.Term[] - cond498 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond498 - _t993 = parse_term(parser) - item499 = _t993 - push!(xs497, item499) - cond498 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - end - terms500 = xs497 - consume_literal!(parser, ")") - _t994 = Proto.Atom(name=relation_id496, terms=terms500) - return _t994 + push_path!(parser, 1) + _t1516 = parse_relation_id(parser) + relation_id848 = _t1516 + pop_path!(parser) + push_path!(parser, 2) + xs853 = Proto.Term[] + cond854 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx855 = 0 + while cond854 + push_path!(parser, idx855) + _t1517 = parse_term(parser) + item856 = _t1517 + pop_path!(parser) + push!(xs853, item856) + idx855 = (idx855 + 1) + cond854 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + end + terms852 = xs853 + pop_path!(parser) + consume_literal!(parser, ")") + _t1518 = Proto.Atom(name=relation_id848, terms=terms852) + result858 = _t1518 + record_span!(parser, span_start857) + return result858 end function parse_pragma(parser::ParserState)::Proto.Pragma + span_start868 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "pragma") - _t995 = parse_name(parser) - name501 = _t995 - xs502 = Proto.Term[] - cond503 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond503 - _t996 = parse_term(parser) - item504 = _t996 - push!(xs502, item504) - cond503 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - end - terms505 = xs502 - consume_literal!(parser, ")") - _t997 = Proto.Pragma(name=name501, terms=terms505) - return _t997 + push_path!(parser, 1) + _t1519 = parse_name(parser) + name859 = _t1519 + pop_path!(parser) + push_path!(parser, 2) + xs864 = Proto.Term[] + cond865 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx866 = 0 + while cond865 + push_path!(parser, idx866) + _t1520 = parse_term(parser) + item867 = _t1520 + pop_path!(parser) + push!(xs864, item867) + idx866 = (idx866 + 1) + cond865 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + end + terms863 = xs864 + pop_path!(parser) + consume_literal!(parser, ")") + _t1521 = Proto.Pragma(name=name859, terms=terms863) + result869 = _t1521 + record_span!(parser, span_start868) + return result869 end function parse_primitive(parser::ParserState)::Proto.Primitive + span_start889 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "primitive", 1) - _t999 = 9 + _t1523 = 9 else if match_lookahead_literal(parser, ">=", 1) - _t1000 = 4 + _t1524 = 4 else if match_lookahead_literal(parser, ">", 1) - _t1001 = 3 + _t1525 = 3 else if match_lookahead_literal(parser, "=", 1) - _t1002 = 0 + _t1526 = 0 else if match_lookahead_literal(parser, "<=", 1) - _t1003 = 2 + _t1527 = 2 else if match_lookahead_literal(parser, "<", 1) - _t1004 = 1 + _t1528 = 1 else if match_lookahead_literal(parser, "/", 1) - _t1005 = 8 + _t1529 = 8 else if match_lookahead_literal(parser, "-", 1) - _t1006 = 6 + _t1530 = 6 else if match_lookahead_literal(parser, "+", 1) - _t1007 = 5 + _t1531 = 5 else if match_lookahead_literal(parser, "*", 1) - _t1008 = 7 + _t1532 = 7 else - _t1008 = -1 + _t1532 = -1 end - _t1007 = _t1008 + _t1531 = _t1532 end - _t1006 = _t1007 + _t1530 = _t1531 end - _t1005 = _t1006 + _t1529 = _t1530 end - _t1004 = _t1005 + _t1528 = _t1529 end - _t1003 = _t1004 + _t1527 = _t1528 end - _t1002 = _t1003 + _t1526 = _t1527 end - _t1001 = _t1002 + _t1525 = _t1526 end - _t1000 = _t1001 + _t1524 = _t1525 end - _t999 = _t1000 + _t1523 = _t1524 end - _t998 = _t999 + _t1522 = _t1523 else - _t998 = -1 + _t1522 = -1 end - prediction506 = _t998 - if prediction506 == 9 + prediction870 = _t1522 + if prediction870 == 9 consume_literal!(parser, "(") consume_literal!(parser, "primitive") - _t1010 = parse_name(parser) - name516 = _t1010 - xs517 = Proto.RelTerm[] - cond518 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond518 - _t1011 = parse_rel_term(parser) - item519 = _t1011 - push!(xs517, item519) - cond518 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push_path!(parser, 1) + _t1534 = parse_name(parser) + name880 = _t1534 + pop_path!(parser) + push_path!(parser, 2) + xs885 = Proto.RelTerm[] + cond886 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx887 = 0 + while cond886 + push_path!(parser, idx887) + _t1535 = parse_rel_term(parser) + item888 = _t1535 + pop_path!(parser) + push!(xs885, item888) + idx887 = (idx887 + 1) + cond886 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - rel_terms520 = xs517 + rel_terms884 = xs885 + pop_path!(parser) consume_literal!(parser, ")") - _t1012 = Proto.Primitive(name=name516, terms=rel_terms520) - _t1009 = _t1012 + _t1536 = Proto.Primitive(name=name880, terms=rel_terms884) + _t1533 = _t1536 else - if prediction506 == 8 - _t1014 = parse_divide(parser) - divide515 = _t1014 - _t1013 = divide515 + if prediction870 == 8 + _t1538 = parse_divide(parser) + divide879 = _t1538 + _t1537 = divide879 else - if prediction506 == 7 - _t1016 = parse_multiply(parser) - multiply514 = _t1016 - _t1015 = multiply514 + if prediction870 == 7 + _t1540 = parse_multiply(parser) + multiply878 = _t1540 + _t1539 = multiply878 else - if prediction506 == 6 - _t1018 = parse_minus(parser) - minus513 = _t1018 - _t1017 = minus513 + if prediction870 == 6 + _t1542 = parse_minus(parser) + minus877 = _t1542 + _t1541 = minus877 else - if prediction506 == 5 - _t1020 = parse_add(parser) - add512 = _t1020 - _t1019 = add512 + if prediction870 == 5 + _t1544 = parse_add(parser) + add876 = _t1544 + _t1543 = add876 else - if prediction506 == 4 - _t1022 = parse_gt_eq(parser) - gt_eq511 = _t1022 - _t1021 = gt_eq511 + if prediction870 == 4 + _t1546 = parse_gt_eq(parser) + gt_eq875 = _t1546 + _t1545 = gt_eq875 else - if prediction506 == 3 - _t1024 = parse_gt(parser) - gt510 = _t1024 - _t1023 = gt510 + if prediction870 == 3 + _t1548 = parse_gt(parser) + gt874 = _t1548 + _t1547 = gt874 else - if prediction506 == 2 - _t1026 = parse_lt_eq(parser) - lt_eq509 = _t1026 - _t1025 = lt_eq509 + if prediction870 == 2 + _t1550 = parse_lt_eq(parser) + lt_eq873 = _t1550 + _t1549 = lt_eq873 else - if prediction506 == 1 - _t1028 = parse_lt(parser) - lt508 = _t1028 - _t1027 = lt508 + if prediction870 == 1 + _t1552 = parse_lt(parser) + lt872 = _t1552 + _t1551 = lt872 else - if prediction506 == 0 - _t1030 = parse_eq(parser) - eq507 = _t1030 - _t1029 = eq507 + if prediction870 == 0 + _t1554 = parse_eq(parser) + eq871 = _t1554 + _t1553 = eq871 else throw(ParseError("Unexpected token in primitive" * ": " * string(lookahead(parser, 0)))) end - _t1027 = _t1029 + _t1551 = _t1553 end - _t1025 = _t1027 + _t1549 = _t1551 end - _t1023 = _t1025 + _t1547 = _t1549 end - _t1021 = _t1023 + _t1545 = _t1547 end - _t1019 = _t1021 + _t1543 = _t1545 end - _t1017 = _t1019 + _t1541 = _t1543 end - _t1015 = _t1017 + _t1539 = _t1541 end - _t1013 = _t1015 + _t1537 = _t1539 end - _t1009 = _t1013 + _t1533 = _t1537 end - return _t1009 + result890 = _t1533 + record_span!(parser, span_start889) + return result890 end function parse_eq(parser::ParserState)::Proto.Primitive + span_start893 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "=") - _t1031 = parse_term(parser) - term521 = _t1031 - _t1032 = parse_term(parser) - term_3522 = _t1032 + _t1555 = parse_term(parser) + term891 = _t1555 + _t1556 = parse_term(parser) + term_3892 = _t1556 consume_literal!(parser, ")") - _t1033 = Proto.RelTerm(rel_term_type=OneOf(:term, term521)) - _t1034 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3522)) - _t1035 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t1033, _t1034]) - return _t1035 + _t1557 = Proto.RelTerm(rel_term_type=OneOf(:term, term891)) + _t1558 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3892)) + _t1559 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t1557, _t1558]) + result894 = _t1559 + record_span!(parser, span_start893) + return result894 end function parse_lt(parser::ParserState)::Proto.Primitive + span_start897 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<") - _t1036 = parse_term(parser) - term523 = _t1036 - _t1037 = parse_term(parser) - term_3524 = _t1037 + _t1560 = parse_term(parser) + term895 = _t1560 + _t1561 = parse_term(parser) + term_3896 = _t1561 consume_literal!(parser, ")") - _t1038 = Proto.RelTerm(rel_term_type=OneOf(:term, term523)) - _t1039 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3524)) - _t1040 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t1038, _t1039]) - return _t1040 + _t1562 = Proto.RelTerm(rel_term_type=OneOf(:term, term895)) + _t1563 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3896)) + _t1564 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t1562, _t1563]) + result898 = _t1564 + record_span!(parser, span_start897) + return result898 end function parse_lt_eq(parser::ParserState)::Proto.Primitive + span_start901 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<=") - _t1041 = parse_term(parser) - term525 = _t1041 - _t1042 = parse_term(parser) - term_3526 = _t1042 + _t1565 = parse_term(parser) + term899 = _t1565 + _t1566 = parse_term(parser) + term_3900 = _t1566 consume_literal!(parser, ")") - _t1043 = Proto.RelTerm(rel_term_type=OneOf(:term, term525)) - _t1044 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3526)) - _t1045 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t1043, _t1044]) - return _t1045 + _t1567 = Proto.RelTerm(rel_term_type=OneOf(:term, term899)) + _t1568 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3900)) + _t1569 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t1567, _t1568]) + result902 = _t1569 + record_span!(parser, span_start901) + return result902 end function parse_gt(parser::ParserState)::Proto.Primitive + span_start905 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">") - _t1046 = parse_term(parser) - term527 = _t1046 - _t1047 = parse_term(parser) - term_3528 = _t1047 + _t1570 = parse_term(parser) + term903 = _t1570 + _t1571 = parse_term(parser) + term_3904 = _t1571 consume_literal!(parser, ")") - _t1048 = Proto.RelTerm(rel_term_type=OneOf(:term, term527)) - _t1049 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3528)) - _t1050 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t1048, _t1049]) - return _t1050 + _t1572 = Proto.RelTerm(rel_term_type=OneOf(:term, term903)) + _t1573 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3904)) + _t1574 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t1572, _t1573]) + result906 = _t1574 + record_span!(parser, span_start905) + return result906 end function parse_gt_eq(parser::ParserState)::Proto.Primitive + span_start909 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">=") - _t1051 = parse_term(parser) - term529 = _t1051 - _t1052 = parse_term(parser) - term_3530 = _t1052 + _t1575 = parse_term(parser) + term907 = _t1575 + _t1576 = parse_term(parser) + term_3908 = _t1576 consume_literal!(parser, ")") - _t1053 = Proto.RelTerm(rel_term_type=OneOf(:term, term529)) - _t1054 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3530)) - _t1055 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t1053, _t1054]) - return _t1055 + _t1577 = Proto.RelTerm(rel_term_type=OneOf(:term, term907)) + _t1578 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3908)) + _t1579 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t1577, _t1578]) + result910 = _t1579 + record_span!(parser, span_start909) + return result910 end function parse_add(parser::ParserState)::Proto.Primitive + span_start914 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "+") - _t1056 = parse_term(parser) - term531 = _t1056 - _t1057 = parse_term(parser) - term_3532 = _t1057 - _t1058 = parse_term(parser) - term_4533 = _t1058 - consume_literal!(parser, ")") - _t1059 = Proto.RelTerm(rel_term_type=OneOf(:term, term531)) - _t1060 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3532)) - _t1061 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4533)) - _t1062 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t1059, _t1060, _t1061]) - return _t1062 + _t1580 = parse_term(parser) + term911 = _t1580 + _t1581 = parse_term(parser) + term_3912 = _t1581 + _t1582 = parse_term(parser) + term_4913 = _t1582 + consume_literal!(parser, ")") + _t1583 = Proto.RelTerm(rel_term_type=OneOf(:term, term911)) + _t1584 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3912)) + _t1585 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4913)) + _t1586 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t1583, _t1584, _t1585]) + result915 = _t1586 + record_span!(parser, span_start914) + return result915 end function parse_minus(parser::ParserState)::Proto.Primitive + span_start919 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "-") - _t1063 = parse_term(parser) - term534 = _t1063 - _t1064 = parse_term(parser) - term_3535 = _t1064 - _t1065 = parse_term(parser) - term_4536 = _t1065 - consume_literal!(parser, ")") - _t1066 = Proto.RelTerm(rel_term_type=OneOf(:term, term534)) - _t1067 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3535)) - _t1068 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4536)) - _t1069 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t1066, _t1067, _t1068]) - return _t1069 + _t1587 = parse_term(parser) + term916 = _t1587 + _t1588 = parse_term(parser) + term_3917 = _t1588 + _t1589 = parse_term(parser) + term_4918 = _t1589 + consume_literal!(parser, ")") + _t1590 = Proto.RelTerm(rel_term_type=OneOf(:term, term916)) + _t1591 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3917)) + _t1592 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4918)) + _t1593 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t1590, _t1591, _t1592]) + result920 = _t1593 + record_span!(parser, span_start919) + return result920 end function parse_multiply(parser::ParserState)::Proto.Primitive + span_start924 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "*") - _t1070 = parse_term(parser) - term537 = _t1070 - _t1071 = parse_term(parser) - term_3538 = _t1071 - _t1072 = parse_term(parser) - term_4539 = _t1072 - consume_literal!(parser, ")") - _t1073 = Proto.RelTerm(rel_term_type=OneOf(:term, term537)) - _t1074 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3538)) - _t1075 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4539)) - _t1076 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t1073, _t1074, _t1075]) - return _t1076 + _t1594 = parse_term(parser) + term921 = _t1594 + _t1595 = parse_term(parser) + term_3922 = _t1595 + _t1596 = parse_term(parser) + term_4923 = _t1596 + consume_literal!(parser, ")") + _t1597 = Proto.RelTerm(rel_term_type=OneOf(:term, term921)) + _t1598 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3922)) + _t1599 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4923)) + _t1600 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t1597, _t1598, _t1599]) + result925 = _t1600 + record_span!(parser, span_start924) + return result925 end function parse_divide(parser::ParserState)::Proto.Primitive + span_start929 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "/") - _t1077 = parse_term(parser) - term540 = _t1077 - _t1078 = parse_term(parser) - term_3541 = _t1078 - _t1079 = parse_term(parser) - term_4542 = _t1079 - consume_literal!(parser, ")") - _t1080 = Proto.RelTerm(rel_term_type=OneOf(:term, term540)) - _t1081 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3541)) - _t1082 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4542)) - _t1083 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t1080, _t1081, _t1082]) - return _t1083 + _t1601 = parse_term(parser) + term926 = _t1601 + _t1602 = parse_term(parser) + term_3927 = _t1602 + _t1603 = parse_term(parser) + term_4928 = _t1603 + consume_literal!(parser, ")") + _t1604 = Proto.RelTerm(rel_term_type=OneOf(:term, term926)) + _t1605 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3927)) + _t1606 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4928)) + _t1607 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t1604, _t1605, _t1606]) + result930 = _t1607 + record_span!(parser, span_start929) + return result930 end function parse_rel_term(parser::ParserState)::Proto.RelTerm + span_start934 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1084 = 1 + _t1608 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t1085 = 1 + _t1609 = 1 else if match_lookahead_literal(parser, "false", 0) - _t1086 = 1 + _t1610 = 1 else if match_lookahead_literal(parser, "(", 0) - _t1087 = 1 + _t1611 = 1 else if match_lookahead_literal(parser, "#", 0) - _t1088 = 0 + _t1612 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1089 = 1 + _t1613 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t1090 = 1 + _t1614 = 1 else if match_lookahead_terminal(parser, "STRING", 0) - _t1091 = 1 + _t1615 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t1092 = 1 + _t1616 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t1093 = 1 + _t1617 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t1094 = 1 + _t1618 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t1095 = 1 + _t1619 = 1 else - _t1095 = -1 + _t1619 = -1 end - _t1094 = _t1095 + _t1618 = _t1619 end - _t1093 = _t1094 + _t1617 = _t1618 end - _t1092 = _t1093 + _t1616 = _t1617 end - _t1091 = _t1092 + _t1615 = _t1616 end - _t1090 = _t1091 + _t1614 = _t1615 end - _t1089 = _t1090 + _t1613 = _t1614 end - _t1088 = _t1089 + _t1612 = _t1613 end - _t1087 = _t1088 + _t1611 = _t1612 end - _t1086 = _t1087 + _t1610 = _t1611 end - _t1085 = _t1086 + _t1609 = _t1610 end - _t1084 = _t1085 - end - prediction543 = _t1084 - if prediction543 == 1 - _t1097 = parse_term(parser) - term545 = _t1097 - _t1098 = Proto.RelTerm(rel_term_type=OneOf(:term, term545)) - _t1096 = _t1098 + _t1608 = _t1609 + end + prediction931 = _t1608 + if prediction931 == 1 + _t1621 = parse_term(parser) + term933 = _t1621 + _t1622 = Proto.RelTerm(rel_term_type=OneOf(:term, term933)) + _t1620 = _t1622 else - if prediction543 == 0 - _t1100 = parse_specialized_value(parser) - specialized_value544 = _t1100 - _t1101 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value544)) - _t1099 = _t1101 + if prediction931 == 0 + _t1624 = parse_specialized_value(parser) + specialized_value932 = _t1624 + _t1625 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value932)) + _t1623 = _t1625 else throw(ParseError("Unexpected token in rel_term" * ": " * string(lookahead(parser, 0)))) end - _t1096 = _t1099 + _t1620 = _t1623 end - return _t1096 + result935 = _t1620 + record_span!(parser, span_start934) + return result935 end function parse_specialized_value(parser::ParserState)::Proto.Value + span_start937 = span_start(parser) consume_literal!(parser, "#") - _t1102 = parse_value(parser) - value546 = _t1102 - return value546 + _t1626 = parse_value(parser) + value936 = _t1626 + result938 = value936 + record_span!(parser, span_start937) + return result938 end function parse_rel_atom(parser::ParserState)::Proto.RelAtom + span_start948 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "relatom") - _t1103 = parse_name(parser) - name547 = _t1103 - xs548 = Proto.RelTerm[] - cond549 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond549 - _t1104 = parse_rel_term(parser) - item550 = _t1104 - push!(xs548, item550) - cond549 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - end - rel_terms551 = xs548 - consume_literal!(parser, ")") - _t1105 = Proto.RelAtom(name=name547, terms=rel_terms551) - return _t1105 + push_path!(parser, 3) + _t1627 = parse_name(parser) + name939 = _t1627 + pop_path!(parser) + push_path!(parser, 2) + xs944 = Proto.RelTerm[] + cond945 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx946 = 0 + while cond945 + push_path!(parser, idx946) + _t1628 = parse_rel_term(parser) + item947 = _t1628 + pop_path!(parser) + push!(xs944, item947) + idx946 = (idx946 + 1) + cond945 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + end + rel_terms943 = xs944 + pop_path!(parser) + consume_literal!(parser, ")") + _t1629 = Proto.RelAtom(name=name939, terms=rel_terms943) + result949 = _t1629 + record_span!(parser, span_start948) + return result949 end function parse_cast(parser::ParserState)::Proto.Cast + span_start952 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "cast") - _t1106 = parse_term(parser) - term552 = _t1106 - _t1107 = parse_term(parser) - term_3553 = _t1107 + push_path!(parser, 2) + _t1630 = parse_term(parser) + term950 = _t1630 + pop_path!(parser) + push_path!(parser, 3) + _t1631 = parse_term(parser) + term_3951 = _t1631 + pop_path!(parser) consume_literal!(parser, ")") - _t1108 = Proto.Cast(input=term552, result=term_3553) - return _t1108 + _t1632 = Proto.Cast(input=term950, result=term_3951) + result953 = _t1632 + record_span!(parser, span_start952) + return result953 end function parse_attrs(parser::ParserState)::Vector{Proto.Attribute} + span_start958 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attrs") - xs554 = Proto.Attribute[] - cond555 = match_lookahead_literal(parser, "(", 0) - while cond555 - _t1109 = parse_attribute(parser) - item556 = _t1109 - push!(xs554, item556) - cond555 = match_lookahead_literal(parser, "(", 0) + xs954 = Proto.Attribute[] + cond955 = match_lookahead_literal(parser, "(", 0) + while cond955 + _t1633 = parse_attribute(parser) + item956 = _t1633 + push!(xs954, item956) + cond955 = match_lookahead_literal(parser, "(", 0) end - attributes557 = xs554 + attributes957 = xs954 consume_literal!(parser, ")") - return attributes557 + result959 = attributes957 + record_span!(parser, span_start958) + return result959 end function parse_attribute(parser::ParserState)::Proto.Attribute + span_start969 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attribute") - _t1110 = parse_name(parser) - name558 = _t1110 - xs559 = Proto.Value[] - cond560 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond560 - _t1111 = parse_value(parser) - item561 = _t1111 - push!(xs559, item561) - cond560 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - end - values562 = xs559 - consume_literal!(parser, ")") - _t1112 = Proto.Attribute(name=name558, args=values562) - return _t1112 + push_path!(parser, 1) + _t1634 = parse_name(parser) + name960 = _t1634 + pop_path!(parser) + push_path!(parser, 2) + xs965 = Proto.Value[] + cond966 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx967 = 0 + while cond966 + push_path!(parser, idx967) + _t1635 = parse_value(parser) + item968 = _t1635 + pop_path!(parser) + push!(xs965, item968) + idx967 = (idx967 + 1) + cond966 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + end + values964 = xs965 + pop_path!(parser) + consume_literal!(parser, ")") + _t1636 = Proto.Attribute(name=name960, args=values964) + result970 = _t1636 + record_span!(parser, span_start969) + return result970 end function parse_algorithm(parser::ParserState)::Proto.Algorithm + span_start980 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "algorithm") - xs563 = Proto.RelationId[] - cond564 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond564 - _t1113 = parse_relation_id(parser) - item565 = _t1113 - push!(xs563, item565) - cond564 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - end - relation_ids566 = xs563 - _t1114 = parse_script(parser) - script567 = _t1114 - consume_literal!(parser, ")") - _t1115 = Proto.Algorithm(var"#global"=relation_ids566, body=script567) - return _t1115 + push_path!(parser, 1) + xs975 = Proto.RelationId[] + cond976 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx977 = 0 + while cond976 + push_path!(parser, idx977) + _t1637 = parse_relation_id(parser) + item978 = _t1637 + pop_path!(parser) + push!(xs975, item978) + idx977 = (idx977 + 1) + cond976 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + end + relation_ids974 = xs975 + pop_path!(parser) + push_path!(parser, 2) + _t1638 = parse_script(parser) + script979 = _t1638 + pop_path!(parser) + consume_literal!(parser, ")") + _t1639 = Proto.Algorithm(var"#global"=relation_ids974, body=script979) + result981 = _t1639 + record_span!(parser, span_start980) + return result981 end function parse_script(parser::ParserState)::Proto.Script + span_start990 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "script") - xs568 = Proto.Construct[] - cond569 = match_lookahead_literal(parser, "(", 0) - while cond569 - _t1116 = parse_construct(parser) - item570 = _t1116 - push!(xs568, item570) - cond569 = match_lookahead_literal(parser, "(", 0) - end - constructs571 = xs568 - consume_literal!(parser, ")") - _t1117 = Proto.Script(constructs=constructs571) - return _t1117 + push_path!(parser, 1) + xs986 = Proto.Construct[] + cond987 = match_lookahead_literal(parser, "(", 0) + idx988 = 0 + while cond987 + push_path!(parser, idx988) + _t1640 = parse_construct(parser) + item989 = _t1640 + pop_path!(parser) + push!(xs986, item989) + idx988 = (idx988 + 1) + cond987 = match_lookahead_literal(parser, "(", 0) + end + constructs985 = xs986 + pop_path!(parser) + consume_literal!(parser, ")") + _t1641 = Proto.Script(constructs=constructs985) + result991 = _t1641 + record_span!(parser, span_start990) + return result991 end function parse_construct(parser::ParserState)::Proto.Construct + span_start995 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1119 = 1 + _t1643 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1120 = 1 + _t1644 = 1 else if match_lookahead_literal(parser, "monoid", 1) - _t1121 = 1 + _t1645 = 1 else if match_lookahead_literal(parser, "loop", 1) - _t1122 = 0 + _t1646 = 0 else if match_lookahead_literal(parser, "break", 1) - _t1123 = 1 + _t1647 = 1 else if match_lookahead_literal(parser, "assign", 1) - _t1124 = 1 + _t1648 = 1 else - _t1124 = -1 + _t1648 = -1 end - _t1123 = _t1124 + _t1647 = _t1648 end - _t1122 = _t1123 + _t1646 = _t1647 end - _t1121 = _t1122 + _t1645 = _t1646 end - _t1120 = _t1121 + _t1644 = _t1645 end - _t1119 = _t1120 + _t1643 = _t1644 end - _t1118 = _t1119 + _t1642 = _t1643 else - _t1118 = -1 - end - prediction572 = _t1118 - if prediction572 == 1 - _t1126 = parse_instruction(parser) - instruction574 = _t1126 - _t1127 = Proto.Construct(construct_type=OneOf(:instruction, instruction574)) - _t1125 = _t1127 + _t1642 = -1 + end + prediction992 = _t1642 + if prediction992 == 1 + _t1650 = parse_instruction(parser) + instruction994 = _t1650 + _t1651 = Proto.Construct(construct_type=OneOf(:instruction, instruction994)) + _t1649 = _t1651 else - if prediction572 == 0 - _t1129 = parse_loop(parser) - loop573 = _t1129 - _t1130 = Proto.Construct(construct_type=OneOf(:loop, loop573)) - _t1128 = _t1130 + if prediction992 == 0 + _t1653 = parse_loop(parser) + loop993 = _t1653 + _t1654 = Proto.Construct(construct_type=OneOf(:loop, loop993)) + _t1652 = _t1654 else throw(ParseError("Unexpected token in construct" * ": " * string(lookahead(parser, 0)))) end - _t1125 = _t1128 + _t1649 = _t1652 end - return _t1125 + result996 = _t1649 + record_span!(parser, span_start995) + return result996 end function parse_loop(parser::ParserState)::Proto.Loop + span_start999 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "loop") - _t1131 = parse_init(parser) - init575 = _t1131 - _t1132 = parse_script(parser) - script576 = _t1132 + push_path!(parser, 1) + _t1655 = parse_init(parser) + init997 = _t1655 + pop_path!(parser) + push_path!(parser, 2) + _t1656 = parse_script(parser) + script998 = _t1656 + pop_path!(parser) consume_literal!(parser, ")") - _t1133 = Proto.Loop(init=init575, body=script576) - return _t1133 + _t1657 = Proto.Loop(init=init997, body=script998) + result1000 = _t1657 + record_span!(parser, span_start999) + return result1000 end function parse_init(parser::ParserState)::Vector{Proto.Instruction} + span_start1005 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "init") - xs577 = Proto.Instruction[] - cond578 = match_lookahead_literal(parser, "(", 0) - while cond578 - _t1134 = parse_instruction(parser) - item579 = _t1134 - push!(xs577, item579) - cond578 = match_lookahead_literal(parser, "(", 0) + xs1001 = Proto.Instruction[] + cond1002 = match_lookahead_literal(parser, "(", 0) + while cond1002 + _t1658 = parse_instruction(parser) + item1003 = _t1658 + push!(xs1001, item1003) + cond1002 = match_lookahead_literal(parser, "(", 0) end - instructions580 = xs577 + instructions1004 = xs1001 consume_literal!(parser, ")") - return instructions580 + result1006 = instructions1004 + record_span!(parser, span_start1005) + return result1006 end function parse_instruction(parser::ParserState)::Proto.Instruction + span_start1013 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1136 = 1 + _t1660 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1137 = 4 + _t1661 = 4 else if match_lookahead_literal(parser, "monoid", 1) - _t1138 = 3 + _t1662 = 3 else if match_lookahead_literal(parser, "break", 1) - _t1139 = 2 + _t1663 = 2 else if match_lookahead_literal(parser, "assign", 1) - _t1140 = 0 + _t1664 = 0 else - _t1140 = -1 + _t1664 = -1 end - _t1139 = _t1140 + _t1663 = _t1664 end - _t1138 = _t1139 + _t1662 = _t1663 end - _t1137 = _t1138 + _t1661 = _t1662 end - _t1136 = _t1137 + _t1660 = _t1661 end - _t1135 = _t1136 + _t1659 = _t1660 else - _t1135 = -1 - end - prediction581 = _t1135 - if prediction581 == 4 - _t1142 = parse_monus_def(parser) - monus_def586 = _t1142 - _t1143 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def586)) - _t1141 = _t1143 + _t1659 = -1 + end + prediction1007 = _t1659 + if prediction1007 == 4 + _t1666 = parse_monus_def(parser) + monus_def1012 = _t1666 + _t1667 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def1012)) + _t1665 = _t1667 else - if prediction581 == 3 - _t1145 = parse_monoid_def(parser) - monoid_def585 = _t1145 - _t1146 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def585)) - _t1144 = _t1146 + if prediction1007 == 3 + _t1669 = parse_monoid_def(parser) + monoid_def1011 = _t1669 + _t1670 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def1011)) + _t1668 = _t1670 else - if prediction581 == 2 - _t1148 = parse_break(parser) - break584 = _t1148 - _t1149 = Proto.Instruction(instr_type=OneOf(:var"#break", break584)) - _t1147 = _t1149 + if prediction1007 == 2 + _t1672 = parse_break(parser) + break1010 = _t1672 + _t1673 = Proto.Instruction(instr_type=OneOf(:var"#break", break1010)) + _t1671 = _t1673 else - if prediction581 == 1 - _t1151 = parse_upsert(parser) - upsert583 = _t1151 - _t1152 = Proto.Instruction(instr_type=OneOf(:upsert, upsert583)) - _t1150 = _t1152 + if prediction1007 == 1 + _t1675 = parse_upsert(parser) + upsert1009 = _t1675 + _t1676 = Proto.Instruction(instr_type=OneOf(:upsert, upsert1009)) + _t1674 = _t1676 else - if prediction581 == 0 - _t1154 = parse_assign(parser) - assign582 = _t1154 - _t1155 = Proto.Instruction(instr_type=OneOf(:assign, assign582)) - _t1153 = _t1155 + if prediction1007 == 0 + _t1678 = parse_assign(parser) + assign1008 = _t1678 + _t1679 = Proto.Instruction(instr_type=OneOf(:assign, assign1008)) + _t1677 = _t1679 else throw(ParseError("Unexpected token in instruction" * ": " * string(lookahead(parser, 0)))) end - _t1150 = _t1153 + _t1674 = _t1677 end - _t1147 = _t1150 + _t1671 = _t1674 end - _t1144 = _t1147 + _t1668 = _t1671 end - _t1141 = _t1144 + _t1665 = _t1668 end - return _t1141 + result1014 = _t1665 + record_span!(parser, span_start1013) + return result1014 end function parse_assign(parser::ParserState)::Proto.Assign + span_start1018 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "assign") - _t1156 = parse_relation_id(parser) - relation_id587 = _t1156 - _t1157 = parse_abstraction(parser) - abstraction588 = _t1157 + push_path!(parser, 1) + _t1680 = parse_relation_id(parser) + relation_id1015 = _t1680 + pop_path!(parser) + push_path!(parser, 2) + _t1681 = parse_abstraction(parser) + abstraction1016 = _t1681 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1159 = parse_attrs(parser) - _t1158 = _t1159 + _t1683 = parse_attrs(parser) + _t1682 = _t1683 else - _t1158 = nothing + _t1682 = nothing end - attrs589 = _t1158 + attrs1017 = _t1682 + pop_path!(parser) consume_literal!(parser, ")") - _t1160 = Proto.Assign(name=relation_id587, body=abstraction588, attrs=(!isnothing(attrs589) ? attrs589 : Proto.Attribute[])) - return _t1160 + _t1684 = Proto.Assign(name=relation_id1015, body=abstraction1016, attrs=(!isnothing(attrs1017) ? attrs1017 : Proto.Attribute[])) + result1019 = _t1684 + record_span!(parser, span_start1018) + return result1019 end function parse_upsert(parser::ParserState)::Proto.Upsert + span_start1023 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "upsert") - _t1161 = parse_relation_id(parser) - relation_id590 = _t1161 - _t1162 = parse_abstraction_with_arity(parser) - abstraction_with_arity591 = _t1162 + push_path!(parser, 1) + _t1685 = parse_relation_id(parser) + relation_id1020 = _t1685 + pop_path!(parser) + _t1686 = parse_abstraction_with_arity(parser) + abstraction_with_arity1021 = _t1686 + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1164 = parse_attrs(parser) - _t1163 = _t1164 + _t1688 = parse_attrs(parser) + _t1687 = _t1688 else - _t1163 = nothing + _t1687 = nothing end - attrs592 = _t1163 + attrs1022 = _t1687 + pop_path!(parser) consume_literal!(parser, ")") - _t1165 = Proto.Upsert(name=relation_id590, body=abstraction_with_arity591[1], attrs=(!isnothing(attrs592) ? attrs592 : Proto.Attribute[]), value_arity=abstraction_with_arity591[2]) - return _t1165 + _t1689 = Proto.Upsert(name=relation_id1020, body=abstraction_with_arity1021[1], attrs=(!isnothing(attrs1022) ? attrs1022 : Proto.Attribute[]), value_arity=abstraction_with_arity1021[2]) + result1024 = _t1689 + record_span!(parser, span_start1023) + return result1024 end function parse_abstraction_with_arity(parser::ParserState)::Tuple{Proto.Abstraction, Int64} + span_start1027 = span_start(parser) consume_literal!(parser, "(") - _t1166 = parse_bindings(parser) - bindings593 = _t1166 - _t1167 = parse_formula(parser) - formula594 = _t1167 + _t1690 = parse_bindings(parser) + bindings1025 = _t1690 + _t1691 = parse_formula(parser) + formula1026 = _t1691 consume_literal!(parser, ")") - _t1168 = Proto.Abstraction(vars=vcat(bindings593[1], !isnothing(bindings593[2]) ? bindings593[2] : []), value=formula594) - return (_t1168, length(bindings593[2]),) + _t1692 = Proto.Abstraction(vars=vcat(bindings1025[1], !isnothing(bindings1025[2]) ? bindings1025[2] : []), value=formula1026) + result1028 = (_t1692, length(bindings1025[2]),) + record_span!(parser, span_start1027) + return result1028 end function parse_break(parser::ParserState)::Proto.Break + span_start1032 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "break") - _t1169 = parse_relation_id(parser) - relation_id595 = _t1169 - _t1170 = parse_abstraction(parser) - abstraction596 = _t1170 + push_path!(parser, 1) + _t1693 = parse_relation_id(parser) + relation_id1029 = _t1693 + pop_path!(parser) + push_path!(parser, 2) + _t1694 = parse_abstraction(parser) + abstraction1030 = _t1694 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1172 = parse_attrs(parser) - _t1171 = _t1172 + _t1696 = parse_attrs(parser) + _t1695 = _t1696 else - _t1171 = nothing + _t1695 = nothing end - attrs597 = _t1171 + attrs1031 = _t1695 + pop_path!(parser) consume_literal!(parser, ")") - _t1173 = Proto.Break(name=relation_id595, body=abstraction596, attrs=(!isnothing(attrs597) ? attrs597 : Proto.Attribute[])) - return _t1173 + _t1697 = Proto.Break(name=relation_id1029, body=abstraction1030, attrs=(!isnothing(attrs1031) ? attrs1031 : Proto.Attribute[])) + result1033 = _t1697 + record_span!(parser, span_start1032) + return result1033 end function parse_monoid_def(parser::ParserState)::Proto.MonoidDef + span_start1038 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monoid") - _t1174 = parse_monoid(parser) - monoid598 = _t1174 - _t1175 = parse_relation_id(parser) - relation_id599 = _t1175 - _t1176 = parse_abstraction_with_arity(parser) - abstraction_with_arity600 = _t1176 + push_path!(parser, 1) + _t1698 = parse_monoid(parser) + monoid1034 = _t1698 + pop_path!(parser) + push_path!(parser, 2) + _t1699 = parse_relation_id(parser) + relation_id1035 = _t1699 + pop_path!(parser) + _t1700 = parse_abstraction_with_arity(parser) + abstraction_with_arity1036 = _t1700 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1178 = parse_attrs(parser) - _t1177 = _t1178 + _t1702 = parse_attrs(parser) + _t1701 = _t1702 else - _t1177 = nothing + _t1701 = nothing end - attrs601 = _t1177 + attrs1037 = _t1701 + pop_path!(parser) consume_literal!(parser, ")") - _t1179 = Proto.MonoidDef(monoid=monoid598, name=relation_id599, body=abstraction_with_arity600[1], attrs=(!isnothing(attrs601) ? attrs601 : Proto.Attribute[]), value_arity=abstraction_with_arity600[2]) - return _t1179 + _t1703 = Proto.MonoidDef(monoid=monoid1034, name=relation_id1035, body=abstraction_with_arity1036[1], attrs=(!isnothing(attrs1037) ? attrs1037 : Proto.Attribute[]), value_arity=abstraction_with_arity1036[2]) + result1039 = _t1703 + record_span!(parser, span_start1038) + return result1039 end function parse_monoid(parser::ParserState)::Proto.Monoid + span_start1045 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "sum", 1) - _t1181 = 3 + _t1705 = 3 else if match_lookahead_literal(parser, "or", 1) - _t1182 = 0 + _t1706 = 0 else if match_lookahead_literal(parser, "min", 1) - _t1183 = 1 + _t1707 = 1 else if match_lookahead_literal(parser, "max", 1) - _t1184 = 2 + _t1708 = 2 else - _t1184 = -1 + _t1708 = -1 end - _t1183 = _t1184 + _t1707 = _t1708 end - _t1182 = _t1183 + _t1706 = _t1707 end - _t1181 = _t1182 + _t1705 = _t1706 end - _t1180 = _t1181 + _t1704 = _t1705 else - _t1180 = -1 - end - prediction602 = _t1180 - if prediction602 == 3 - _t1186 = parse_sum_monoid(parser) - sum_monoid606 = _t1186 - _t1187 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid606)) - _t1185 = _t1187 + _t1704 = -1 + end + prediction1040 = _t1704 + if prediction1040 == 3 + _t1710 = parse_sum_monoid(parser) + sum_monoid1044 = _t1710 + _t1711 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid1044)) + _t1709 = _t1711 else - if prediction602 == 2 - _t1189 = parse_max_monoid(parser) - max_monoid605 = _t1189 - _t1190 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid605)) - _t1188 = _t1190 + if prediction1040 == 2 + _t1713 = parse_max_monoid(parser) + max_monoid1043 = _t1713 + _t1714 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid1043)) + _t1712 = _t1714 else - if prediction602 == 1 - _t1192 = parse_min_monoid(parser) - min_monoid604 = _t1192 - _t1193 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid604)) - _t1191 = _t1193 + if prediction1040 == 1 + _t1716 = parse_min_monoid(parser) + min_monoid1042 = _t1716 + _t1717 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid1042)) + _t1715 = _t1717 else - if prediction602 == 0 - _t1195 = parse_or_monoid(parser) - or_monoid603 = _t1195 - _t1196 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid603)) - _t1194 = _t1196 + if prediction1040 == 0 + _t1719 = parse_or_monoid(parser) + or_monoid1041 = _t1719 + _t1720 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid1041)) + _t1718 = _t1720 else throw(ParseError("Unexpected token in monoid" * ": " * string(lookahead(parser, 0)))) end - _t1191 = _t1194 + _t1715 = _t1718 end - _t1188 = _t1191 + _t1712 = _t1715 end - _t1185 = _t1188 + _t1709 = _t1712 end - return _t1185 + result1046 = _t1709 + record_span!(parser, span_start1045) + return result1046 end function parse_or_monoid(parser::ParserState)::Proto.OrMonoid + span_start1047 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") consume_literal!(parser, ")") - _t1197 = Proto.OrMonoid() - return _t1197 + _t1721 = Proto.OrMonoid() + result1048 = _t1721 + record_span!(parser, span_start1047) + return result1048 end function parse_min_monoid(parser::ParserState)::Proto.MinMonoid + span_start1050 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "min") - _t1198 = parse_type(parser) - type607 = _t1198 + push_path!(parser, 1) + _t1722 = parse_type(parser) + type1049 = _t1722 + pop_path!(parser) consume_literal!(parser, ")") - _t1199 = Proto.MinMonoid(var"#type"=type607) - return _t1199 + _t1723 = Proto.MinMonoid(var"#type"=type1049) + result1051 = _t1723 + record_span!(parser, span_start1050) + return result1051 end function parse_max_monoid(parser::ParserState)::Proto.MaxMonoid + span_start1053 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "max") - _t1200 = parse_type(parser) - type608 = _t1200 + push_path!(parser, 1) + _t1724 = parse_type(parser) + type1052 = _t1724 + pop_path!(parser) consume_literal!(parser, ")") - _t1201 = Proto.MaxMonoid(var"#type"=type608) - return _t1201 + _t1725 = Proto.MaxMonoid(var"#type"=type1052) + result1054 = _t1725 + record_span!(parser, span_start1053) + return result1054 end function parse_sum_monoid(parser::ParserState)::Proto.SumMonoid + span_start1056 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sum") - _t1202 = parse_type(parser) - type609 = _t1202 + push_path!(parser, 1) + _t1726 = parse_type(parser) + type1055 = _t1726 + pop_path!(parser) consume_literal!(parser, ")") - _t1203 = Proto.SumMonoid(var"#type"=type609) - return _t1203 + _t1727 = Proto.SumMonoid(var"#type"=type1055) + result1057 = _t1727 + record_span!(parser, span_start1056) + return result1057 end function parse_monus_def(parser::ParserState)::Proto.MonusDef + span_start1062 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monus") - _t1204 = parse_monoid(parser) - monoid610 = _t1204 - _t1205 = parse_relation_id(parser) - relation_id611 = _t1205 - _t1206 = parse_abstraction_with_arity(parser) - abstraction_with_arity612 = _t1206 + push_path!(parser, 1) + _t1728 = parse_monoid(parser) + monoid1058 = _t1728 + pop_path!(parser) + push_path!(parser, 2) + _t1729 = parse_relation_id(parser) + relation_id1059 = _t1729 + pop_path!(parser) + _t1730 = parse_abstraction_with_arity(parser) + abstraction_with_arity1060 = _t1730 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1208 = parse_attrs(parser) - _t1207 = _t1208 + _t1732 = parse_attrs(parser) + _t1731 = _t1732 else - _t1207 = nothing + _t1731 = nothing end - attrs613 = _t1207 + attrs1061 = _t1731 + pop_path!(parser) consume_literal!(parser, ")") - _t1209 = Proto.MonusDef(monoid=monoid610, name=relation_id611, body=abstraction_with_arity612[1], attrs=(!isnothing(attrs613) ? attrs613 : Proto.Attribute[]), value_arity=abstraction_with_arity612[2]) - return _t1209 + _t1733 = Proto.MonusDef(monoid=monoid1058, name=relation_id1059, body=abstraction_with_arity1060[1], attrs=(!isnothing(attrs1061) ? attrs1061 : Proto.Attribute[]), value_arity=abstraction_with_arity1060[2]) + result1063 = _t1733 + record_span!(parser, span_start1062) + return result1063 end function parse_constraint(parser::ParserState)::Proto.Constraint + span_start1068 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "functional_dependency") - _t1210 = parse_relation_id(parser) - relation_id614 = _t1210 - _t1211 = parse_abstraction(parser) - abstraction615 = _t1211 - _t1212 = parse_functional_dependency_keys(parser) - functional_dependency_keys616 = _t1212 - _t1213 = parse_functional_dependency_values(parser) - functional_dependency_values617 = _t1213 - consume_literal!(parser, ")") - _t1214 = Proto.FunctionalDependency(guard=abstraction615, keys=functional_dependency_keys616, values=functional_dependency_values617) - _t1215 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t1214), name=relation_id614) - return _t1215 + push_path!(parser, 2) + _t1734 = parse_relation_id(parser) + relation_id1064 = _t1734 + pop_path!(parser) + _t1735 = parse_abstraction(parser) + abstraction1065 = _t1735 + _t1736 = parse_functional_dependency_keys(parser) + functional_dependency_keys1066 = _t1736 + _t1737 = parse_functional_dependency_values(parser) + functional_dependency_values1067 = _t1737 + consume_literal!(parser, ")") + _t1738 = Proto.FunctionalDependency(guard=abstraction1065, keys=functional_dependency_keys1066, values=functional_dependency_values1067) + _t1739 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t1738), name=relation_id1064) + result1069 = _t1739 + record_span!(parser, span_start1068) + return result1069 end function parse_functional_dependency_keys(parser::ParserState)::Vector{Proto.Var} + span_start1074 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "keys") - xs618 = Proto.Var[] - cond619 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond619 - _t1216 = parse_var(parser) - item620 = _t1216 - push!(xs618, item620) - cond619 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs1070 = Proto.Var[] + cond1071 = match_lookahead_terminal(parser, "SYMBOL", 0) + while cond1071 + _t1740 = parse_var(parser) + item1072 = _t1740 + push!(xs1070, item1072) + cond1071 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars621 = xs618 + vars1073 = xs1070 consume_literal!(parser, ")") - return vars621 + result1075 = vars1073 + record_span!(parser, span_start1074) + return result1075 end function parse_functional_dependency_values(parser::ParserState)::Vector{Proto.Var} + span_start1080 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "values") - xs622 = Proto.Var[] - cond623 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond623 - _t1217 = parse_var(parser) - item624 = _t1217 - push!(xs622, item624) - cond623 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs1076 = Proto.Var[] + cond1077 = match_lookahead_terminal(parser, "SYMBOL", 0) + while cond1077 + _t1741 = parse_var(parser) + item1078 = _t1741 + push!(xs1076, item1078) + cond1077 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars625 = xs622 + vars1079 = xs1076 consume_literal!(parser, ")") - return vars625 + result1081 = vars1079 + record_span!(parser, span_start1080) + return result1081 end function parse_data(parser::ParserState)::Proto.Data + span_start1086 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t1219 = 0 + _t1743 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t1220 = 2 + _t1744 = 2 else if match_lookahead_literal(parser, "betree_relation", 1) - _t1221 = 1 + _t1745 = 1 else - _t1221 = -1 + _t1745 = -1 end - _t1220 = _t1221 + _t1744 = _t1745 end - _t1219 = _t1220 + _t1743 = _t1744 end - _t1218 = _t1219 + _t1742 = _t1743 else - _t1218 = -1 - end - prediction626 = _t1218 - if prediction626 == 2 - _t1223 = parse_csv_data(parser) - csv_data629 = _t1223 - _t1224 = Proto.Data(data_type=OneOf(:csv_data, csv_data629)) - _t1222 = _t1224 + _t1742 = -1 + end + prediction1082 = _t1742 + if prediction1082 == 2 + _t1747 = parse_csv_data(parser) + csv_data1085 = _t1747 + _t1748 = Proto.Data(data_type=OneOf(:csv_data, csv_data1085)) + _t1746 = _t1748 else - if prediction626 == 1 - _t1226 = parse_betree_relation(parser) - betree_relation628 = _t1226 - _t1227 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation628)) - _t1225 = _t1227 + if prediction1082 == 1 + _t1750 = parse_betree_relation(parser) + betree_relation1084 = _t1750 + _t1751 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation1084)) + _t1749 = _t1751 else - if prediction626 == 0 - _t1229 = parse_rel_edb(parser) - rel_edb627 = _t1229 - _t1230 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb627)) - _t1228 = _t1230 + if prediction1082 == 0 + _t1753 = parse_rel_edb(parser) + rel_edb1083 = _t1753 + _t1754 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb1083)) + _t1752 = _t1754 else throw(ParseError("Unexpected token in data" * ": " * string(lookahead(parser, 0)))) end - _t1225 = _t1228 + _t1749 = _t1752 end - _t1222 = _t1225 + _t1746 = _t1749 end - return _t1222 + result1087 = _t1746 + record_span!(parser, span_start1086) + return result1087 end function parse_rel_edb(parser::ParserState)::Proto.RelEDB + span_start1091 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "rel_edb") - _t1231 = parse_relation_id(parser) - relation_id630 = _t1231 - _t1232 = parse_rel_edb_path(parser) - rel_edb_path631 = _t1232 - _t1233 = parse_rel_edb_types(parser) - rel_edb_types632 = _t1233 - consume_literal!(parser, ")") - _t1234 = Proto.RelEDB(target_id=relation_id630, path=rel_edb_path631, types=rel_edb_types632) - return _t1234 + push_path!(parser, 1) + _t1755 = parse_relation_id(parser) + relation_id1088 = _t1755 + pop_path!(parser) + push_path!(parser, 2) + _t1756 = parse_rel_edb_path(parser) + rel_edb_path1089 = _t1756 + pop_path!(parser) + push_path!(parser, 3) + _t1757 = parse_rel_edb_types(parser) + rel_edb_types1090 = _t1757 + pop_path!(parser) + consume_literal!(parser, ")") + _t1758 = Proto.RelEDB(target_id=relation_id1088, path=rel_edb_path1089, types=rel_edb_types1090) + result1092 = _t1758 + record_span!(parser, span_start1091) + return result1092 end function parse_rel_edb_path(parser::ParserState)::Vector{String} + span_start1097 = span_start(parser) consume_literal!(parser, "[") - xs633 = String[] - cond634 = match_lookahead_terminal(parser, "STRING", 0) - while cond634 - item635 = consume_terminal!(parser, "STRING") - push!(xs633, item635) - cond634 = match_lookahead_terminal(parser, "STRING", 0) - end - strings636 = xs633 + xs1093 = String[] + cond1094 = match_lookahead_terminal(parser, "STRING", 0) + while cond1094 + item1095 = consume_terminal!(parser, "STRING") + push!(xs1093, item1095) + cond1094 = match_lookahead_terminal(parser, "STRING", 0) + end + strings1096 = xs1093 consume_literal!(parser, "]") - return strings636 + result1098 = strings1096 + record_span!(parser, span_start1097) + return result1098 end function parse_rel_edb_types(parser::ParserState)::Vector{Proto.var"#Type"} + span_start1103 = span_start(parser) consume_literal!(parser, "[") - xs637 = Proto.var"#Type"[] - cond638 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond638 - _t1235 = parse_type(parser) - item639 = _t1235 - push!(xs637, item639) - cond638 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - end - types640 = xs637 + xs1099 = Proto.var"#Type"[] + cond1100 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + while cond1100 + _t1759 = parse_type(parser) + item1101 = _t1759 + push!(xs1099, item1101) + cond1100 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + end + types1102 = xs1099 consume_literal!(parser, "]") - return types640 + result1104 = types1102 + record_span!(parser, span_start1103) + return result1104 end function parse_betree_relation(parser::ParserState)::Proto.BeTreeRelation + span_start1107 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_relation") - _t1236 = parse_relation_id(parser) - relation_id641 = _t1236 - _t1237 = parse_betree_info(parser) - betree_info642 = _t1237 + push_path!(parser, 1) + _t1760 = parse_relation_id(parser) + relation_id1105 = _t1760 + pop_path!(parser) + push_path!(parser, 2) + _t1761 = parse_betree_info(parser) + betree_info1106 = _t1761 + pop_path!(parser) consume_literal!(parser, ")") - _t1238 = Proto.BeTreeRelation(name=relation_id641, relation_info=betree_info642) - return _t1238 + _t1762 = Proto.BeTreeRelation(name=relation_id1105, relation_info=betree_info1106) + result1108 = _t1762 + record_span!(parser, span_start1107) + return result1108 end function parse_betree_info(parser::ParserState)::Proto.BeTreeInfo + span_start1112 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_info") - _t1239 = parse_betree_info_key_types(parser) - betree_info_key_types643 = _t1239 - _t1240 = parse_betree_info_value_types(parser) - betree_info_value_types644 = _t1240 - _t1241 = parse_config_dict(parser) - config_dict645 = _t1241 + _t1763 = parse_betree_info_key_types(parser) + betree_info_key_types1109 = _t1763 + _t1764 = parse_betree_info_value_types(parser) + betree_info_value_types1110 = _t1764 + _t1765 = parse_config_dict(parser) + config_dict1111 = _t1765 consume_literal!(parser, ")") - _t1242 = construct_betree_info(parser, betree_info_key_types643, betree_info_value_types644, config_dict645) - return _t1242 + _t1766 = construct_betree_info(parser, betree_info_key_types1109, betree_info_value_types1110, config_dict1111) + result1113 = _t1766 + record_span!(parser, span_start1112) + return result1113 end function parse_betree_info_key_types(parser::ParserState)::Vector{Proto.var"#Type"} + span_start1118 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "key_types") - xs646 = Proto.var"#Type"[] - cond647 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond647 - _t1243 = parse_type(parser) - item648 = _t1243 - push!(xs646, item648) - cond647 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs1114 = Proto.var"#Type"[] + cond1115 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + while cond1115 + _t1767 = parse_type(parser) + item1116 = _t1767 + push!(xs1114, item1116) + cond1115 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types649 = xs646 + types1117 = xs1114 consume_literal!(parser, ")") - return types649 + result1119 = types1117 + record_span!(parser, span_start1118) + return result1119 end function parse_betree_info_value_types(parser::ParserState)::Vector{Proto.var"#Type"} + span_start1124 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "value_types") - xs650 = Proto.var"#Type"[] - cond651 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond651 - _t1244 = parse_type(parser) - item652 = _t1244 - push!(xs650, item652) - cond651 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs1120 = Proto.var"#Type"[] + cond1121 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + while cond1121 + _t1768 = parse_type(parser) + item1122 = _t1768 + push!(xs1120, item1122) + cond1121 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types653 = xs650 + types1123 = xs1120 consume_literal!(parser, ")") - return types653 + result1125 = types1123 + record_span!(parser, span_start1124) + return result1125 end function parse_csv_data(parser::ParserState)::Proto.CSVData + span_start1130 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_data") - _t1245 = parse_csvlocator(parser) - csvlocator654 = _t1245 - _t1246 = parse_csv_config(parser) - csv_config655 = _t1246 - _t1247 = parse_csv_columns(parser) - csv_columns656 = _t1247 - _t1248 = parse_csv_asof(parser) - csv_asof657 = _t1248 - consume_literal!(parser, ")") - _t1249 = Proto.CSVData(locator=csvlocator654, config=csv_config655, columns=csv_columns656, asof=csv_asof657) - return _t1249 + push_path!(parser, 1) + _t1769 = parse_csvlocator(parser) + csvlocator1126 = _t1769 + pop_path!(parser) + push_path!(parser, 2) + _t1770 = parse_csv_config(parser) + csv_config1127 = _t1770 + pop_path!(parser) + push_path!(parser, 3) + _t1771 = parse_csv_columns(parser) + csv_columns1128 = _t1771 + pop_path!(parser) + push_path!(parser, 4) + _t1772 = parse_csv_asof(parser) + csv_asof1129 = _t1772 + pop_path!(parser) + consume_literal!(parser, ")") + _t1773 = Proto.CSVData(locator=csvlocator1126, config=csv_config1127, columns=csv_columns1128, asof=csv_asof1129) + result1131 = _t1773 + record_span!(parser, span_start1130) + return result1131 end function parse_csvlocator(parser::ParserState)::Proto.CSVLocator + span_start1134 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_locator") + push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "paths", 1)) - _t1251 = parse_csv_locator_paths(parser) - _t1250 = _t1251 + _t1775 = parse_csv_locator_paths(parser) + _t1774 = _t1775 else - _t1250 = nothing + _t1774 = nothing end - csv_locator_paths658 = _t1250 + csv_locator_paths1132 = _t1774 + pop_path!(parser) + push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t1253 = parse_csv_locator_inline_data(parser) - _t1252 = _t1253 + _t1777 = parse_csv_locator_inline_data(parser) + _t1776 = _t1777 else - _t1252 = nothing + _t1776 = nothing end - csv_locator_inline_data659 = _t1252 + csv_locator_inline_data1133 = _t1776 + pop_path!(parser) consume_literal!(parser, ")") - _t1254 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths658) ? csv_locator_paths658 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data659) ? csv_locator_inline_data659 : ""))) - return _t1254 + _t1778 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths1132) ? csv_locator_paths1132 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data1133) ? csv_locator_inline_data1133 : ""))) + result1135 = _t1778 + record_span!(parser, span_start1134) + return result1135 end function parse_csv_locator_paths(parser::ParserState)::Vector{String} + span_start1140 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "paths") - xs660 = String[] - cond661 = match_lookahead_terminal(parser, "STRING", 0) - while cond661 - item662 = consume_terminal!(parser, "STRING") - push!(xs660, item662) - cond661 = match_lookahead_terminal(parser, "STRING", 0) + xs1136 = String[] + cond1137 = match_lookahead_terminal(parser, "STRING", 0) + while cond1137 + item1138 = consume_terminal!(parser, "STRING") + push!(xs1136, item1138) + cond1137 = match_lookahead_terminal(parser, "STRING", 0) end - strings663 = xs660 + strings1139 = xs1136 consume_literal!(parser, ")") - return strings663 + result1141 = strings1139 + record_span!(parser, span_start1140) + return result1141 end function parse_csv_locator_inline_data(parser::ParserState)::String + span_start1143 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "inline_data") - string664 = consume_terminal!(parser, "STRING") + string1142 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string664 + result1144 = string1142 + record_span!(parser, span_start1143) + return result1144 end function parse_csv_config(parser::ParserState)::Proto.CSVConfig + span_start1146 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_config") - _t1255 = parse_config_dict(parser) - config_dict665 = _t1255 + _t1779 = parse_config_dict(parser) + config_dict1145 = _t1779 consume_literal!(parser, ")") - _t1256 = construct_csv_config(parser, config_dict665) - return _t1256 + _t1780 = construct_csv_config(parser, config_dict1145) + result1147 = _t1780 + record_span!(parser, span_start1146) + return result1147 end function parse_csv_columns(parser::ParserState)::Vector{Proto.CSVColumn} + span_start1152 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs666 = Proto.CSVColumn[] - cond667 = match_lookahead_literal(parser, "(", 0) - while cond667 - _t1257 = parse_csv_column(parser) - item668 = _t1257 - push!(xs666, item668) - cond667 = match_lookahead_literal(parser, "(", 0) + xs1148 = Proto.CSVColumn[] + cond1149 = match_lookahead_literal(parser, "(", 0) + while cond1149 + _t1781 = parse_csv_column(parser) + item1150 = _t1781 + push!(xs1148, item1150) + cond1149 = match_lookahead_literal(parser, "(", 0) end - csv_columns669 = xs666 + csv_columns1151 = xs1148 consume_literal!(parser, ")") - return csv_columns669 + result1153 = csv_columns1151 + record_span!(parser, span_start1152) + return result1153 end function parse_csv_column(parser::ParserState)::Proto.CSVColumn + span_start1164 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") - string670 = consume_terminal!(parser, "STRING") - _t1258 = parse_relation_id(parser) - relation_id671 = _t1258 + push_path!(parser, 1) + string1154 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1782 = parse_relation_id(parser) + relation_id1155 = _t1782 + pop_path!(parser) consume_literal!(parser, "[") - xs672 = Proto.var"#Type"[] - cond673 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond673 - _t1259 = parse_type(parser) - item674 = _t1259 - push!(xs672, item674) - cond673 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - end - types675 = xs672 + push_path!(parser, 3) + xs1160 = Proto.var"#Type"[] + cond1161 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx1162 = 0 + while cond1161 + push_path!(parser, idx1162) + _t1783 = parse_type(parser) + item1163 = _t1783 + pop_path!(parser) + push!(xs1160, item1163) + idx1162 = (idx1162 + 1) + cond1161 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + end + types1159 = xs1160 + pop_path!(parser) consume_literal!(parser, "]") consume_literal!(parser, ")") - _t1260 = Proto.CSVColumn(column_name=string670, target_id=relation_id671, types=types675) - return _t1260 + _t1784 = Proto.CSVColumn(column_name=string1154, target_id=relation_id1155, types=types1159) + result1165 = _t1784 + record_span!(parser, span_start1164) + return result1165 end function parse_csv_asof(parser::ParserState)::String + span_start1167 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "asof") - string676 = consume_terminal!(parser, "STRING") + string1166 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string676 + result1168 = string1166 + record_span!(parser, span_start1167) + return result1168 end function parse_undefine(parser::ParserState)::Proto.Undefine + span_start1170 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "undefine") - _t1261 = parse_fragment_id(parser) - fragment_id677 = _t1261 + push_path!(parser, 1) + _t1785 = parse_fragment_id(parser) + fragment_id1169 = _t1785 + pop_path!(parser) consume_literal!(parser, ")") - _t1262 = Proto.Undefine(fragment_id=fragment_id677) - return _t1262 + _t1786 = Proto.Undefine(fragment_id=fragment_id1169) + result1171 = _t1786 + record_span!(parser, span_start1170) + return result1171 end function parse_context(parser::ParserState)::Proto.Context + span_start1180 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "context") - xs678 = Proto.RelationId[] - cond679 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond679 - _t1263 = parse_relation_id(parser) - item680 = _t1263 - push!(xs678, item680) - cond679 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - end - relation_ids681 = xs678 - consume_literal!(parser, ")") - _t1264 = Proto.Context(relations=relation_ids681) - return _t1264 + push_path!(parser, 1) + xs1176 = Proto.RelationId[] + cond1177 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx1178 = 0 + while cond1177 + push_path!(parser, idx1178) + _t1787 = parse_relation_id(parser) + item1179 = _t1787 + pop_path!(parser) + push!(xs1176, item1179) + idx1178 = (idx1178 + 1) + cond1177 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + end + relation_ids1175 = xs1176 + pop_path!(parser) + consume_literal!(parser, ")") + _t1788 = Proto.Context(relations=relation_ids1175) + result1181 = _t1788 + record_span!(parser, span_start1180) + return result1181 end function parse_snapshot(parser::ParserState)::Proto.Snapshot + span_start1184 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "snapshot") - _t1265 = parse_rel_edb_path(parser) - rel_edb_path682 = _t1265 - _t1266 = parse_relation_id(parser) - relation_id683 = _t1266 + push_path!(parser, 1) + _t1789 = parse_rel_edb_path(parser) + rel_edb_path1182 = _t1789 + pop_path!(parser) + push_path!(parser, 2) + _t1790 = parse_relation_id(parser) + relation_id1183 = _t1790 + pop_path!(parser) consume_literal!(parser, ")") - _t1267 = Proto.Snapshot(destination_path=rel_edb_path682, source_relation=relation_id683) - return _t1267 + _t1791 = Proto.Snapshot(destination_path=rel_edb_path1182, source_relation=relation_id1183) + result1185 = _t1791 + record_span!(parser, span_start1184) + return result1185 end function parse_epoch_reads(parser::ParserState)::Vector{Proto.Read} + span_start1190 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reads") - xs684 = Proto.Read[] - cond685 = match_lookahead_literal(parser, "(", 0) - while cond685 - _t1268 = parse_read(parser) - item686 = _t1268 - push!(xs684, item686) - cond685 = match_lookahead_literal(parser, "(", 0) + xs1186 = Proto.Read[] + cond1187 = match_lookahead_literal(parser, "(", 0) + while cond1187 + _t1792 = parse_read(parser) + item1188 = _t1792 + push!(xs1186, item1188) + cond1187 = match_lookahead_literal(parser, "(", 0) end - reads687 = xs684 + reads1189 = xs1186 consume_literal!(parser, ")") - return reads687 + result1191 = reads1189 + record_span!(parser, span_start1190) + return result1191 end function parse_read(parser::ParserState)::Proto.Read + span_start1198 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "what_if", 1) - _t1270 = 2 + _t1794 = 2 else if match_lookahead_literal(parser, "output", 1) - _t1271 = 1 + _t1795 = 1 else if match_lookahead_literal(parser, "export", 1) - _t1272 = 4 + _t1796 = 4 else if match_lookahead_literal(parser, "demand", 1) - _t1273 = 0 + _t1797 = 0 else if match_lookahead_literal(parser, "abort", 1) - _t1274 = 3 + _t1798 = 3 else - _t1274 = -1 + _t1798 = -1 end - _t1273 = _t1274 + _t1797 = _t1798 end - _t1272 = _t1273 + _t1796 = _t1797 end - _t1271 = _t1272 + _t1795 = _t1796 end - _t1270 = _t1271 + _t1794 = _t1795 end - _t1269 = _t1270 + _t1793 = _t1794 else - _t1269 = -1 - end - prediction688 = _t1269 - if prediction688 == 4 - _t1276 = parse_export(parser) - export693 = _t1276 - _t1277 = Proto.Read(read_type=OneOf(:var"#export", export693)) - _t1275 = _t1277 + _t1793 = -1 + end + prediction1192 = _t1793 + if prediction1192 == 4 + _t1800 = parse_export(parser) + export1197 = _t1800 + _t1801 = Proto.Read(read_type=OneOf(:var"#export", export1197)) + _t1799 = _t1801 else - if prediction688 == 3 - _t1279 = parse_abort(parser) - abort692 = _t1279 - _t1280 = Proto.Read(read_type=OneOf(:abort, abort692)) - _t1278 = _t1280 + if prediction1192 == 3 + _t1803 = parse_abort(parser) + abort1196 = _t1803 + _t1804 = Proto.Read(read_type=OneOf(:abort, abort1196)) + _t1802 = _t1804 else - if prediction688 == 2 - _t1282 = parse_what_if(parser) - what_if691 = _t1282 - _t1283 = Proto.Read(read_type=OneOf(:what_if, what_if691)) - _t1281 = _t1283 + if prediction1192 == 2 + _t1806 = parse_what_if(parser) + what_if1195 = _t1806 + _t1807 = Proto.Read(read_type=OneOf(:what_if, what_if1195)) + _t1805 = _t1807 else - if prediction688 == 1 - _t1285 = parse_output(parser) - output690 = _t1285 - _t1286 = Proto.Read(read_type=OneOf(:output, output690)) - _t1284 = _t1286 + if prediction1192 == 1 + _t1809 = parse_output(parser) + output1194 = _t1809 + _t1810 = Proto.Read(read_type=OneOf(:output, output1194)) + _t1808 = _t1810 else - if prediction688 == 0 - _t1288 = parse_demand(parser) - demand689 = _t1288 - _t1289 = Proto.Read(read_type=OneOf(:demand, demand689)) - _t1287 = _t1289 + if prediction1192 == 0 + _t1812 = parse_demand(parser) + demand1193 = _t1812 + _t1813 = Proto.Read(read_type=OneOf(:demand, demand1193)) + _t1811 = _t1813 else throw(ParseError("Unexpected token in read" * ": " * string(lookahead(parser, 0)))) end - _t1284 = _t1287 + _t1808 = _t1811 end - _t1281 = _t1284 + _t1805 = _t1808 end - _t1278 = _t1281 + _t1802 = _t1805 end - _t1275 = _t1278 + _t1799 = _t1802 end - return _t1275 + result1199 = _t1799 + record_span!(parser, span_start1198) + return result1199 end function parse_demand(parser::ParserState)::Proto.Demand + span_start1201 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "demand") - _t1290 = parse_relation_id(parser) - relation_id694 = _t1290 + push_path!(parser, 1) + _t1814 = parse_relation_id(parser) + relation_id1200 = _t1814 + pop_path!(parser) consume_literal!(parser, ")") - _t1291 = Proto.Demand(relation_id=relation_id694) - return _t1291 + _t1815 = Proto.Demand(relation_id=relation_id1200) + result1202 = _t1815 + record_span!(parser, span_start1201) + return result1202 end function parse_output(parser::ParserState)::Proto.Output + span_start1205 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "output") - _t1292 = parse_name(parser) - name695 = _t1292 - _t1293 = parse_relation_id(parser) - relation_id696 = _t1293 + push_path!(parser, 1) + _t1816 = parse_name(parser) + name1203 = _t1816 + pop_path!(parser) + push_path!(parser, 2) + _t1817 = parse_relation_id(parser) + relation_id1204 = _t1817 + pop_path!(parser) consume_literal!(parser, ")") - _t1294 = Proto.Output(name=name695, relation_id=relation_id696) - return _t1294 + _t1818 = Proto.Output(name=name1203, relation_id=relation_id1204) + result1206 = _t1818 + record_span!(parser, span_start1205) + return result1206 end function parse_what_if(parser::ParserState)::Proto.WhatIf + span_start1209 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "what_if") - _t1295 = parse_name(parser) - name697 = _t1295 - _t1296 = parse_epoch(parser) - epoch698 = _t1296 + push_path!(parser, 1) + _t1819 = parse_name(parser) + name1207 = _t1819 + pop_path!(parser) + push_path!(parser, 2) + _t1820 = parse_epoch(parser) + epoch1208 = _t1820 + pop_path!(parser) consume_literal!(parser, ")") - _t1297 = Proto.WhatIf(branch=name697, epoch=epoch698) - return _t1297 + _t1821 = Proto.WhatIf(branch=name1207, epoch=epoch1208) + result1210 = _t1821 + record_span!(parser, span_start1209) + return result1210 end function parse_abort(parser::ParserState)::Proto.Abort + span_start1213 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "abort") + push_path!(parser, 1) if (match_lookahead_literal(parser, ":", 0) && match_lookahead_terminal(parser, "SYMBOL", 1)) - _t1299 = parse_name(parser) - _t1298 = _t1299 + _t1823 = parse_name(parser) + _t1822 = _t1823 else - _t1298 = nothing + _t1822 = nothing end - name699 = _t1298 - _t1300 = parse_relation_id(parser) - relation_id700 = _t1300 + name1211 = _t1822 + pop_path!(parser) + push_path!(parser, 2) + _t1824 = parse_relation_id(parser) + relation_id1212 = _t1824 + pop_path!(parser) consume_literal!(parser, ")") - _t1301 = Proto.Abort(name=(!isnothing(name699) ? name699 : "abort"), relation_id=relation_id700) - return _t1301 + _t1825 = Proto.Abort(name=(!isnothing(name1211) ? name1211 : "abort"), relation_id=relation_id1212) + result1214 = _t1825 + record_span!(parser, span_start1213) + return result1214 end function parse_export(parser::ParserState)::Proto.Export + span_start1216 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export") - _t1302 = parse_export_csv_config(parser) - export_csv_config701 = _t1302 + push_path!(parser, 1) + _t1826 = parse_export_csv_config(parser) + export_csv_config1215 = _t1826 + pop_path!(parser) consume_literal!(parser, ")") - _t1303 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config701)) - return _t1303 + _t1827 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config1215)) + result1217 = _t1827 + record_span!(parser, span_start1216) + return result1217 end function parse_export_csv_config(parser::ParserState)::Proto.ExportCSVConfig + span_start1221 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export_csv_config") - _t1304 = parse_export_csv_path(parser) - export_csv_path702 = _t1304 - _t1305 = parse_export_csv_columns(parser) - export_csv_columns703 = _t1305 - _t1306 = parse_config_dict(parser) - config_dict704 = _t1306 + _t1828 = parse_export_csv_path(parser) + export_csv_path1218 = _t1828 + _t1829 = parse_export_csv_columns(parser) + export_csv_columns1219 = _t1829 + _t1830 = parse_config_dict(parser) + config_dict1220 = _t1830 consume_literal!(parser, ")") - _t1307 = export_csv_config(parser, export_csv_path702, export_csv_columns703, config_dict704) - return _t1307 + _t1831 = export_csv_config(parser, export_csv_path1218, export_csv_columns1219, config_dict1220) + result1222 = _t1831 + record_span!(parser, span_start1221) + return result1222 end function parse_export_csv_path(parser::ParserState)::String + span_start1224 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "path") - string705 = consume_terminal!(parser, "STRING") + string1223 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string705 + result1225 = string1223 + record_span!(parser, span_start1224) + return result1225 end function parse_export_csv_columns(parser::ParserState)::Vector{Proto.ExportCSVColumn} + span_start1230 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs706 = Proto.ExportCSVColumn[] - cond707 = match_lookahead_literal(parser, "(", 0) - while cond707 - _t1308 = parse_export_csv_column(parser) - item708 = _t1308 - push!(xs706, item708) - cond707 = match_lookahead_literal(parser, "(", 0) + xs1226 = Proto.ExportCSVColumn[] + cond1227 = match_lookahead_literal(parser, "(", 0) + while cond1227 + _t1832 = parse_export_csv_column(parser) + item1228 = _t1832 + push!(xs1226, item1228) + cond1227 = match_lookahead_literal(parser, "(", 0) end - export_csv_columns709 = xs706 + export_csv_columns1229 = xs1226 consume_literal!(parser, ")") - return export_csv_columns709 + result1231 = export_csv_columns1229 + record_span!(parser, span_start1230) + return result1231 end function parse_export_csv_column(parser::ParserState)::Proto.ExportCSVColumn + span_start1234 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") - string710 = consume_terminal!(parser, "STRING") - _t1309 = parse_relation_id(parser) - relation_id711 = _t1309 + push_path!(parser, 1) + string1232 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1833 = parse_relation_id(parser) + relation_id1233 = _t1833 + pop_path!(parser) consume_literal!(parser, ")") - _t1310 = Proto.ExportCSVColumn(column_name=string710, column_data=relation_id711) - return _t1310 + _t1834 = Proto.ExportCSVColumn(column_name=string1232, column_data=relation_id1233) + result1235 = _t1834 + record_span!(parser, span_start1234) + return result1235 end function parse(input::String) lexer = Lexer(input) - parser = ParserState(lexer.tokens) + parser = ParserState(lexer.tokens, input) result = parse_transaction(parser) # Check for unconsumed tokens (except EOF) if parser.pos <= length(parser.tokens) @@ -3203,14 +3858,14 @@ function parse(input::String) throw(ParseError("Unexpected token at end of input: $remaining_token")) end end - return result + return result, parser.provenance end # Export main parse function and error type export parse, ParseError # Export scanner functions for testing export scan_string, scan_int, scan_float, scan_int128, scan_uint128, scan_decimal -# Export Lexer for testing -export Lexer +# Export Lexer and provenance types for testing +export Lexer, Location, Span end # module Parser diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/parser_tests.jl b/sdks/julia/LogicalQueryProtocol.jl/test/parser_tests.jl index 2939db31..3d4a77a8 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/test/parser_tests.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/test/parser_tests.jl @@ -6,7 +6,7 @@ (writes) (reads))) """ - result = Parser.parse(input) + result, _provenance = Parser.parse(input) @test !isnothing(result) @test result isa Proto.Transaction @test length(result.epochs) == 1 @@ -138,7 +138,7 @@ end bin_path = joinpath(bin_files_dir, replace(lqp_file, ".lqp" => ".bin")) content = read(lqp_path, String) - result = Parser.parse(content) + result, _ = Parser.parse(content) @test !isnothing(result) @test result isa Proto.Transaction diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/parser_testsetup.jl b/sdks/julia/LogicalQueryProtocol.jl/test/parser_testsetup.jl index 6e076d9a..39948aea 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/test/parser_testsetup.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/test/parser_testsetup.jl @@ -6,11 +6,11 @@ using LogicalQueryProtocol: Parser # NOTE: We do NOT export `parse` because it conflicts with `Base.parse`. # Tests should use `Parser.parse(...)` instead. using LogicalQueryProtocol.Parser: - ParseError, Lexer, + ParseError, Lexer, Location, Span, scan_string, scan_int, scan_float, scan_int128, scan_uint128, scan_decimal export Proto, Parser, - ParseError, Lexer, + ParseError, Lexer, Location, Span, scan_string, scan_int, scan_float, scan_int128, scan_uint128, scan_decimal end diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/pretty_tests.jl b/sdks/julia/LogicalQueryProtocol.jl/test/pretty_tests.jl index f3231ad6..62cacd8b 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/test/pretty_tests.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/test/pretty_tests.jl @@ -106,10 +106,10 @@ end lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) for lqp_file in lqp_files content = read(joinpath(test_files_dir, lqp_file), String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) narrow = pretty(parsed; max_width=40) - reparsed = Parser.parse(narrow) + reparsed, _ = Parser.parse(narrow) @test reparsed == parsed end end @@ -122,10 +122,10 @@ end lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) for lqp_file in lqp_files content = read(joinpath(test_files_dir, lqp_file), String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) wide = pretty(parsed; max_width=1000) - reparsed = Parser.parse(wide) + reparsed, _ = Parser.parse(wide) @test reparsed == parsed end end @@ -138,7 +138,7 @@ end lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) for lqp_file in lqp_files content = read(joinpath(test_files_dir, lqp_file), String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) narrow = pretty(parsed; max_width=40) default = pretty(parsed) @@ -161,7 +161,7 @@ end lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) for lqp_file in lqp_files content = read(joinpath(test_files_dir, lqp_file), String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) printed = pretty(parsed) # Starts with (transaction @@ -197,7 +197,7 @@ end lqp_path = joinpath(test_files_dir, lqp_file) content = read(lqp_path, String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) @test parsed isa Proto.Transaction printed = pretty(parsed) @@ -222,13 +222,13 @@ end lqp_path = joinpath(test_files_dir, lqp_file) content = read(lqp_path, String) - parsed = Parser.parse(content) + parsed, _ = Parser.parse(content) @test parsed isa Proto.Transaction printed = pretty(parsed) @test !isempty(printed) - reparsed = Parser.parse(printed) + reparsed, _ = Parser.parse(printed) @test reparsed isa Proto.Transaction @test reparsed == parsed @@ -311,7 +311,7 @@ end printed = pretty(txn) @test !isempty(printed) - reparsed = Parser.parse(printed) + reparsed, _ = Parser.parse(printed) @test reparsed isa Proto.Transaction @test reparsed == txn diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl b/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl new file mode 100644 index 00000000..132f64a9 --- /dev/null +++ b/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl @@ -0,0 +1,100 @@ +@testitem "Provenance - root transaction" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + @test haskey(provenance, ()) + span = provenance[()] + @test span.start.offset == 1 # 1-based in Julia + @test span.start.line == 1 + @test span.start.column == 1 +end + +@testitem "Provenance - epoch path" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + # epochs = field 1, index 0 + key = (1, 0) + @test haskey(provenance, key) + span = provenance[key] + @test span.start.line == 2 +end + +@testitem "Provenance - writes path" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + # epochs[0].writes = field 1 within Epoch + key = (1, 0, 1) + @test haskey(provenance, key) + span = provenance[key] + @test span.start.line == 3 +end + +@testitem "Provenance - reads path" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + # epochs[0].reads = field 2 within Epoch + key = (1, 0, 2) + @test haskey(provenance, key) + span = provenance[key] + @test span.start.line == 4 +end + +@testitem "Provenance - span covers correct text" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + # Root starts at offset 1 (1-based in Julia) + root_span = provenance[()] + @test root_span.start.offset == 1 + + # Epoch span starts at '(' of '(epoch' + epoch_span = provenance[(1, 0)] + text_at_epoch = input[epoch_span.start.offset:end] + @test startswith(text_at_epoch, "(epoch") +end + +@testitem "Provenance - span ordering" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + for (path, span) in provenance + @test span.start.offset <= getfield(span, :end).offset + @test span.start.line <= getfield(span, :end).line + end +end + +@testitem "Provenance - multiple epochs" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads))\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + @test haskey(provenance, (1, 0)) + @test haskey(provenance, (1, 1)) + + # First epoch starts before second + @test provenance[(1, 0)].start.offset < provenance[(1, 1)].start.offset +end + +@testitem "Provenance - Location type" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + root_span = provenance[()] + loc = root_span.start + @test loc isa Location + @test loc.line isa Int + @test loc.column isa Int + @test loc.offset isa Int +end + +@testitem "Provenance - Span type" setup=[ParserSetup] begin + input = "(transaction\n (epoch\n (writes)\n (reads)))\n" + _, provenance = Parser.parse(input) + + root_span = provenance[()] + @test root_span isa Span + @test root_span.start isa Location + @test getfield(root_span, :end) isa Location +end diff --git a/sdks/python/src/lqp/cli.py b/sdks/python/src/lqp/cli.py index 767eeea8..73fea2cb 100644 --- a/sdks/python/src/lqp/cli.py +++ b/sdks/python/src/lqp/cli.py @@ -25,7 +25,7 @@ def parse_input(filename: str, validate: bool = True): else: with open(filename) as f: lqp_text = f.read() - txn = parse(lqp_text) + txn, _ = parse(lqp_text) if validate: validate_proto(txn) diff --git a/sdks/python/src/lqp/gen/parser.py b/sdks/python/src/lqp/gen/parser.py index 2c023fb0..d74e9375 100644 --- a/sdks/python/src/lqp/gen/parser.py +++ b/sdks/python/src/lqp/gen/parser.py @@ -10,11 +10,11 @@ """ import ast +import bisect import hashlib import re from collections.abc import Sequence -from typing import List, Optional, Any, Tuple, Callable -from decimal import Decimal +from typing import Any from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -25,16 +25,64 @@ class ParseError(Exception): pass +class Location: + """Source location (1-based line and column, 0-based byte offset).""" + + __slots__ = ("line", "column", "offset") + + def __init__(self, line: int, column: int, offset: int): + self.line = line + self.column = column + self.offset = offset + + def __repr__(self) -> str: + return f"Location({self.line}, {self.column}, {self.offset})" + + def __eq__(self, other) -> bool: + if not isinstance(other, Location): + return NotImplemented + return self.line == other.line and self.column == other.column and self.offset == other.offset + + def __hash__(self) -> int: + return hash((self.line, self.column, self.offset)) + + +class Span: + """Source span from start to end location.""" + + __slots__ = ("start", "end") + + def __init__(self, start: Location, end: Location): + self.start = start + self.end = end + + def __repr__(self) -> str: + return f"Span({self.start}, {self.end})" + + def __eq__(self, other) -> bool: + if not isinstance(other, Span): + return NotImplemented + return self.start == other.start and self.end == other.end + + def __hash__(self) -> int: + return hash((self.start, self.end)) + + class Token: """Token representation.""" - def __init__(self, type: str, value: str, pos: int): + def __init__(self, type: str, value: str, start_pos: int, end_pos: int): self.type = type self.value = value - self.pos = pos + self.start_pos = start_pos + self.end_pos = end_pos + + @property + def pos(self) -> int: + return self.start_pos def __repr__(self) -> str: - return f"Token({self.type}, {self.value!r}, {self.pos})" + return f"Token({self.type}, {self.value!r}, {self.start_pos})" _WHITESPACE_RE = re.compile(r"\s+") @@ -75,7 +123,7 @@ class Lexer: def __init__(self, input_str: str): self.input = input_str self.pos = 0 - self.tokens: List[Token] = [] + self.tokens: list[Token] = [] self._tokenize() def _tokenize(self) -> None: @@ -107,10 +155,10 @@ def _tokenize(self) -> None: # Pick the longest match token_type, value, action, end_pos = max(candidates, key=lambda x: x[3]) - self.tokens.append(Token(token_type, action(value), self.pos)) + self.tokens.append(Token(token_type, action(value), self.pos, end_pos)) self.pos = end_pos - self.tokens.append(Token("$", "", self.pos)) + self.tokens.append(Token("$", "", self.pos, self.pos)) @staticmethod def scan_symbol(s: str) -> str: @@ -179,20 +227,59 @@ def scan_decimal(d: str) -> Any: return logic_pb2.DecimalValue(precision=precision, scale=scale, value=value) +def _compute_line_starts(text: str) -> list[int]: + """Compute byte offsets where each line starts (0-based).""" + starts = [0] + for i, ch in enumerate(text): + if ch == '\n': + starts.append(i + 1) + return starts + + class Parser: """LL(k) recursive-descent parser with backtracking.""" - def __init__(self, tokens: List[Token]): + def __init__(self, tokens: list[Token], input_str: str): self.tokens = tokens self.pos = 0 self.id_to_debuginfo = {} self._current_fragment_id: bytes | None = None self._relation_id_to_name = {} + self.provenance: dict[tuple[int, ...], Span] = {} + self._path: list[int] = [] + self._line_starts = _compute_line_starts(input_str) + + def _make_location(self, offset: int) -> Location: + """Convert byte offset to Location with 1-based line/column.""" + line_idx = bisect.bisect_right(self._line_starts, offset) - 1 + col = offset - self._line_starts[line_idx] + return Location(line_idx + 1, col + 1, offset) + + def push_path(self, n: int) -> None: + """Push a field number onto the provenance path.""" + self._path.append(n) + + def pop_path(self) -> None: + """Pop from the provenance path.""" + self._path.pop() + + def span_start(self) -> int: + """Return the start offset of the current token.""" + return self.lookahead(0).start_pos + + def record_span(self, start_offset: int) -> None: + """Record a span from start_offset to the previous token's end.""" + if self.pos > 0: + end_offset = self.tokens[self.pos - 1].end_pos + else: + end_offset = start_offset + span = Span(self._make_location(start_offset), self._make_location(end_offset)) + self.provenance[tuple(self._path)] = span def lookahead(self, k: int = 0) -> Token: """Get lookahead token at offset k.""" idx = self.pos + k - return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1) + return self.tokens[idx] if idx < len(self.tokens) else Token("$", "", -1, -1) def consume_literal(self, expected: str) -> None: """Consume a literal token.""" @@ -257,7 +344,7 @@ def relation_id_from_string(self, name: str) -> Any: def construct_fragment( self, fragment_id: fragments_pb2.FragmentId, - declarations: List[logic_pb2.Declaration], + declarations: list[logic_pb2.Declaration], ) -> fragments_pb2.Fragment: """Construct Fragment from fragment_id, declarations, and debug info from parser state.""" # Get the debug info for this fragment @@ -295,180 +382,180 @@ def relation_id_to_uint128(self, msg): # --- Helper functions --- - def _extract_value_int32(self, value: Optional[logic_pb2.Value], default: int) -> int: + def _extract_value_int32(self, value: logic_pb2.Value | None, default: int) -> int: if value is not None: assert value is not None - _t1311 = value.HasField("int_value") + _t1835 = value.HasField("int_value") else: - _t1311 = False - if _t1311: + _t1835 = False + if _t1835: assert value is not None return int(value.int_value) else: - _t1312 = None + _t1836 = None return int(default) - def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: + def _extract_value_int64(self, value: logic_pb2.Value | None, default: int) -> int: if value is not None: assert value is not None - _t1313 = value.HasField("int_value") + _t1837 = value.HasField("int_value") else: - _t1313 = False - if _t1313: + _t1837 = False + if _t1837: assert value is not None return value.int_value else: - _t1314 = None + _t1838 = None return default - def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: + def _extract_value_string(self, value: logic_pb2.Value | None, default: str) -> str: if value is not None: assert value is not None - _t1315 = value.HasField("string_value") + _t1839 = value.HasField("string_value") else: - _t1315 = False - if _t1315: + _t1839 = False + if _t1839: assert value is not None return value.string_value else: - _t1316 = None + _t1840 = None return default - def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: + def _extract_value_boolean(self, value: logic_pb2.Value | None, default: bool) -> bool: if value is not None: assert value is not None - _t1317 = value.HasField("boolean_value") + _t1841 = value.HasField("boolean_value") else: - _t1317 = False - if _t1317: + _t1841 = False + if _t1841: assert value is not None return value.boolean_value else: - _t1318 = None + _t1842 = None return default - def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: Sequence[str]) -> Sequence[str]: + def _extract_value_string_list(self, value: logic_pb2.Value | None, default: Sequence[str]) -> Sequence[str]: if value is not None: assert value is not None - _t1319 = value.HasField("string_value") + _t1843 = value.HasField("string_value") else: - _t1319 = False - if _t1319: + _t1843 = False + if _t1843: assert value is not None return [value.string_value] else: - _t1320 = None + _t1844 = None return default - def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: + def _try_extract_value_int64(self, value: logic_pb2.Value | None) -> int | None: if value is not None: assert value is not None - _t1321 = value.HasField("int_value") + _t1845 = value.HasField("int_value") else: - _t1321 = False - if _t1321: + _t1845 = False + if _t1845: assert value is not None return value.int_value else: - _t1322 = None + _t1846 = None return None - def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: + def _try_extract_value_float64(self, value: logic_pb2.Value | None) -> float | None: if value is not None: assert value is not None - _t1323 = value.HasField("float_value") + _t1847 = value.HasField("float_value") else: - _t1323 = False - if _t1323: + _t1847 = False + if _t1847: assert value is not None return value.float_value else: - _t1324 = None + _t1848 = None return None - def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: + def _try_extract_value_bytes(self, value: logic_pb2.Value | None) -> bytes | None: if value is not None: assert value is not None - _t1325 = value.HasField("string_value") + _t1849 = value.HasField("string_value") else: - _t1325 = False - if _t1325: + _t1849 = False + if _t1849: assert value is not None return value.string_value.encode() else: - _t1326 = None + _t1850 = None return None - def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: + def _try_extract_value_uint128(self, value: logic_pb2.Value | None) -> logic_pb2.UInt128Value | None: if value is not None: assert value is not None - _t1327 = value.HasField("uint128_value") + _t1851 = value.HasField("uint128_value") else: - _t1327 = False - if _t1327: + _t1851 = False + if _t1851: assert value is not None return value.uint128_value else: - _t1328 = None + _t1852 = None return None def construct_csv_config(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t1329 = self._extract_value_int32(config.get("csv_header_row"), 1) - header_row = _t1329 - _t1330 = self._extract_value_int64(config.get("csv_skip"), 0) - skip = _t1330 - _t1331 = self._extract_value_string(config.get("csv_new_line"), "") - new_line = _t1331 - _t1332 = self._extract_value_string(config.get("csv_delimiter"), ",") - delimiter = _t1332 - _t1333 = self._extract_value_string(config.get("csv_quotechar"), '"') - quotechar = _t1333 - _t1334 = self._extract_value_string(config.get("csv_escapechar"), '"') - escapechar = _t1334 - _t1335 = self._extract_value_string(config.get("csv_comment"), "") - comment = _t1335 - _t1336 = self._extract_value_string_list(config.get("csv_missing_strings"), []) - missing_strings = _t1336 - _t1337 = self._extract_value_string(config.get("csv_decimal_separator"), ".") - decimal_separator = _t1337 - _t1338 = self._extract_value_string(config.get("csv_encoding"), "utf-8") - encoding = _t1338 - _t1339 = self._extract_value_string(config.get("csv_compression"), "auto") - compression = _t1339 - _t1340 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1340 + _t1853 = self._extract_value_int32(config.get("csv_header_row"), 1) + header_row = _t1853 + _t1854 = self._extract_value_int64(config.get("csv_skip"), 0) + skip = _t1854 + _t1855 = self._extract_value_string(config.get("csv_new_line"), "") + new_line = _t1855 + _t1856 = self._extract_value_string(config.get("csv_delimiter"), ",") + delimiter = _t1856 + _t1857 = self._extract_value_string(config.get("csv_quotechar"), '"') + quotechar = _t1857 + _t1858 = self._extract_value_string(config.get("csv_escapechar"), '"') + escapechar = _t1858 + _t1859 = self._extract_value_string(config.get("csv_comment"), "") + comment = _t1859 + _t1860 = self._extract_value_string_list(config.get("csv_missing_strings"), []) + missing_strings = _t1860 + _t1861 = self._extract_value_string(config.get("csv_decimal_separator"), ".") + decimal_separator = _t1861 + _t1862 = self._extract_value_string(config.get("csv_encoding"), "utf-8") + encoding = _t1862 + _t1863 = self._extract_value_string(config.get("csv_compression"), "auto") + compression = _t1863 + _t1864 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1864 def construct_betree_info(self, key_types: Sequence[logic_pb2.Type], value_types: Sequence[logic_pb2.Type], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t1341 = self._try_extract_value_float64(config.get("betree_config_epsilon")) - epsilon = _t1341 - _t1342 = self._try_extract_value_int64(config.get("betree_config_max_pivots")) - max_pivots = _t1342 - _t1343 = self._try_extract_value_int64(config.get("betree_config_max_deltas")) - max_deltas = _t1343 - _t1344 = self._try_extract_value_int64(config.get("betree_config_max_leaf")) - max_leaf = _t1344 - _t1345 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1345 - _t1346 = self._try_extract_value_uint128(config.get("betree_locator_root_pageid")) - root_pageid = _t1346 - _t1347 = self._try_extract_value_bytes(config.get("betree_locator_inline_data")) - inline_data = _t1347 - _t1348 = self._try_extract_value_int64(config.get("betree_locator_element_count")) - element_count = _t1348 - _t1349 = self._try_extract_value_int64(config.get("betree_locator_tree_height")) - tree_height = _t1349 - _t1350 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1350 - _t1351 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1351 + _t1865 = self._try_extract_value_float64(config.get("betree_config_epsilon")) + epsilon = _t1865 + _t1866 = self._try_extract_value_int64(config.get("betree_config_max_pivots")) + max_pivots = _t1866 + _t1867 = self._try_extract_value_int64(config.get("betree_config_max_deltas")) + max_deltas = _t1867 + _t1868 = self._try_extract_value_int64(config.get("betree_config_max_leaf")) + max_leaf = _t1868 + _t1869 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1869 + _t1870 = self._try_extract_value_uint128(config.get("betree_locator_root_pageid")) + root_pageid = _t1870 + _t1871 = self._try_extract_value_bytes(config.get("betree_locator_inline_data")) + inline_data = _t1871 + _t1872 = self._try_extract_value_int64(config.get("betree_locator_element_count")) + element_count = _t1872 + _t1873 = self._try_extract_value_int64(config.get("betree_locator_tree_height")) + tree_height = _t1873 + _t1874 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1874 + _t1875 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1875 def default_configure(self) -> transactions_pb2.Configure: - _t1352 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1352 - _t1353 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1353 + _t1876 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1876 + _t1877 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1877 def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -485,2378 +572,2976 @@ def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]] maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1354 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1354 - _t1355 = self._extract_value_int64(config.get("semantics_version"), 0) - semantics_version = _t1355 - _t1356 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1356 + _t1878 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1878 + _t1879 = self._extract_value_int64(config.get("semantics_version"), 0) + semantics_version = _t1879 + _t1880 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1880 def export_csv_config(self, path: str, columns: Sequence[transactions_pb2.ExportCSVColumn], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t1357 = self._extract_value_int64(config.get("partition_size"), 0) - partition_size = _t1357 - _t1358 = self._extract_value_string(config.get("compression"), "") - compression = _t1358 - _t1359 = self._extract_value_boolean(config.get("syntax_header_row"), True) - syntax_header_row = _t1359 - _t1360 = self._extract_value_string(config.get("syntax_missing_string"), "") - syntax_missing_string = _t1360 - _t1361 = self._extract_value_string(config.get("syntax_delim"), ",") - syntax_delim = _t1361 - _t1362 = self._extract_value_string(config.get("syntax_quotechar"), '"') - syntax_quotechar = _t1362 - _t1363 = self._extract_value_string(config.get("syntax_escapechar"), "\\") - syntax_escapechar = _t1363 - _t1364 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1364 + _t1881 = self._extract_value_int64(config.get("partition_size"), 0) + partition_size = _t1881 + _t1882 = self._extract_value_string(config.get("compression"), "") + compression = _t1882 + _t1883 = self._extract_value_boolean(config.get("syntax_header_row"), True) + syntax_header_row = _t1883 + _t1884 = self._extract_value_string(config.get("syntax_missing_string"), "") + syntax_missing_string = _t1884 + _t1885 = self._extract_value_string(config.get("syntax_delim"), ",") + syntax_delim = _t1885 + _t1886 = self._extract_value_string(config.get("syntax_quotechar"), '"') + syntax_quotechar = _t1886 + _t1887 = self._extract_value_string(config.get("syntax_escapechar"), "\\") + syntax_escapechar = _t1887 + _t1888 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1888 # --- Parse methods --- def parse_transaction(self) -> transactions_pb2.Transaction: + span_start602 = self.span_start() self.consume_literal("(") self.consume_literal("transaction") + self.push_path(2) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("configure", 1)): - _t713 = self.parse_configure() - _t712 = _t713 + _t1237 = self.parse_configure() + _t1236 = _t1237 else: - _t712 = None - configure356 = _t712 + _t1236 = None + configure592 = _t1236 + self.pop_path() + self.push_path(3) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("sync", 1)): - _t715 = self.parse_sync() - _t714 = _t715 - else: - _t714 = None - sync357 = _t714 - xs358 = [] - cond359 = self.match_lookahead_literal("(", 0) - while cond359: - _t716 = self.parse_epoch() - item360 = _t716 - xs358.append(item360) - cond359 = self.match_lookahead_literal("(", 0) - epochs361 = xs358 - self.consume_literal(")") - _t717 = self.default_configure() - _t718 = transactions_pb2.Transaction(epochs=epochs361, configure=(configure356 if configure356 is not None else _t717), sync=sync357) - return _t718 + _t1239 = self.parse_sync() + _t1238 = _t1239 + else: + _t1238 = None + sync593 = _t1238 + self.pop_path() + self.push_path(1) + xs598 = [] + cond599 = self.match_lookahead_literal("(", 0) + idx600 = 0 + while cond599: + self.push_path(idx600) + _t1240 = self.parse_epoch() + item601 = _t1240 + self.pop_path() + xs598.append(item601) + idx600 = (idx600 + 1) + cond599 = self.match_lookahead_literal("(", 0) + epochs597 = xs598 + self.pop_path() + self.consume_literal(")") + _t1241 = self.default_configure() + _t1242 = transactions_pb2.Transaction(epochs=epochs597, configure=(configure592 if configure592 is not None else _t1241), sync=sync593) + result603 = _t1242 + self.record_span(span_start602) + return result603 def parse_configure(self) -> transactions_pb2.Configure: + span_start605 = self.span_start() self.consume_literal("(") self.consume_literal("configure") - _t719 = self.parse_config_dict() - config_dict362 = _t719 + _t1243 = self.parse_config_dict() + config_dict604 = _t1243 self.consume_literal(")") - _t720 = self.construct_configure(config_dict362) - return _t720 + _t1244 = self.construct_configure(config_dict604) + result606 = _t1244 + self.record_span(span_start605) + return result606 def parse_config_dict(self) -> Sequence[tuple[str, logic_pb2.Value]]: + span_start611 = self.span_start() self.consume_literal("{") - xs363 = [] - cond364 = self.match_lookahead_literal(":", 0) - while cond364: - _t721 = self.parse_config_key_value() - item365 = _t721 - xs363.append(item365) - cond364 = self.match_lookahead_literal(":", 0) - config_key_values366 = xs363 + xs607 = [] + cond608 = self.match_lookahead_literal(":", 0) + while cond608: + _t1245 = self.parse_config_key_value() + item609 = _t1245 + xs607.append(item609) + cond608 = self.match_lookahead_literal(":", 0) + config_key_values610 = xs607 self.consume_literal("}") - return config_key_values366 + result612 = config_key_values610 + self.record_span(span_start611) + return result612 def parse_config_key_value(self) -> tuple[str, logic_pb2.Value]: + span_start615 = self.span_start() self.consume_literal(":") - symbol367 = self.consume_terminal("SYMBOL") - _t722 = self.parse_value() - value368 = _t722 - return (symbol367, value368,) + symbol613 = self.consume_terminal("SYMBOL") + _t1246 = self.parse_value() + value614 = _t1246 + result616 = (symbol613, value614,) + self.record_span(span_start615) + return result616 def parse_value(self) -> logic_pb2.Value: + span_start627 = self.span_start() if self.match_lookahead_literal("true", 0): - _t723 = 9 + _t1247 = 9 else: if self.match_lookahead_literal("missing", 0): - _t724 = 8 + _t1248 = 8 else: if self.match_lookahead_literal("false", 0): - _t725 = 9 + _t1249 = 9 else: if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("datetime", 1): - _t727 = 1 + _t1251 = 1 else: if self.match_lookahead_literal("date", 1): - _t728 = 0 + _t1252 = 0 else: - _t728 = -1 - _t727 = _t728 - _t726 = _t727 + _t1252 = -1 + _t1251 = _t1252 + _t1250 = _t1251 else: if self.match_lookahead_terminal("UINT128", 0): - _t729 = 5 + _t1253 = 5 else: if self.match_lookahead_terminal("STRING", 0): - _t730 = 2 + _t1254 = 2 else: if self.match_lookahead_terminal("INT128", 0): - _t731 = 6 + _t1255 = 6 else: if self.match_lookahead_terminal("INT", 0): - _t732 = 3 + _t1256 = 3 else: if self.match_lookahead_terminal("FLOAT", 0): - _t733 = 4 + _t1257 = 4 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t734 = 7 + _t1258 = 7 else: - _t734 = -1 - _t733 = _t734 - _t732 = _t733 - _t731 = _t732 - _t730 = _t731 - _t729 = _t730 - _t726 = _t729 - _t725 = _t726 - _t724 = _t725 - _t723 = _t724 - prediction369 = _t723 - if prediction369 == 9: - _t736 = self.parse_boolean_value() - boolean_value378 = _t736 - _t737 = logic_pb2.Value(boolean_value=boolean_value378) - _t735 = _t737 - else: - if prediction369 == 8: + _t1258 = -1 + _t1257 = _t1258 + _t1256 = _t1257 + _t1255 = _t1256 + _t1254 = _t1255 + _t1253 = _t1254 + _t1250 = _t1253 + _t1249 = _t1250 + _t1248 = _t1249 + _t1247 = _t1248 + prediction617 = _t1247 + if prediction617 == 9: + _t1260 = self.parse_boolean_value() + boolean_value626 = _t1260 + _t1261 = logic_pb2.Value(boolean_value=boolean_value626) + _t1259 = _t1261 + else: + if prediction617 == 8: self.consume_literal("missing") - _t739 = logic_pb2.MissingValue() - _t740 = logic_pb2.Value(missing_value=_t739) - _t738 = _t740 + _t1263 = logic_pb2.MissingValue() + _t1264 = logic_pb2.Value(missing_value=_t1263) + _t1262 = _t1264 else: - if prediction369 == 7: - decimal377 = self.consume_terminal("DECIMAL") - _t742 = logic_pb2.Value(decimal_value=decimal377) - _t741 = _t742 + if prediction617 == 7: + decimal625 = self.consume_terminal("DECIMAL") + _t1266 = logic_pb2.Value(decimal_value=decimal625) + _t1265 = _t1266 else: - if prediction369 == 6: - int128376 = self.consume_terminal("INT128") - _t744 = logic_pb2.Value(int128_value=int128376) - _t743 = _t744 + if prediction617 == 6: + int128624 = self.consume_terminal("INT128") + _t1268 = logic_pb2.Value(int128_value=int128624) + _t1267 = _t1268 else: - if prediction369 == 5: - uint128375 = self.consume_terminal("UINT128") - _t746 = logic_pb2.Value(uint128_value=uint128375) - _t745 = _t746 + if prediction617 == 5: + uint128623 = self.consume_terminal("UINT128") + _t1270 = logic_pb2.Value(uint128_value=uint128623) + _t1269 = _t1270 else: - if prediction369 == 4: - float374 = self.consume_terminal("FLOAT") - _t748 = logic_pb2.Value(float_value=float374) - _t747 = _t748 + if prediction617 == 4: + float622 = self.consume_terminal("FLOAT") + _t1272 = logic_pb2.Value(float_value=float622) + _t1271 = _t1272 else: - if prediction369 == 3: - int373 = self.consume_terminal("INT") - _t750 = logic_pb2.Value(int_value=int373) - _t749 = _t750 + if prediction617 == 3: + int621 = self.consume_terminal("INT") + _t1274 = logic_pb2.Value(int_value=int621) + _t1273 = _t1274 else: - if prediction369 == 2: - string372 = self.consume_terminal("STRING") - _t752 = logic_pb2.Value(string_value=string372) - _t751 = _t752 + if prediction617 == 2: + string620 = self.consume_terminal("STRING") + _t1276 = logic_pb2.Value(string_value=string620) + _t1275 = _t1276 else: - if prediction369 == 1: - _t754 = self.parse_datetime() - datetime371 = _t754 - _t755 = logic_pb2.Value(datetime_value=datetime371) - _t753 = _t755 + if prediction617 == 1: + _t1278 = self.parse_datetime() + datetime619 = _t1278 + _t1279 = logic_pb2.Value(datetime_value=datetime619) + _t1277 = _t1279 else: - if prediction369 == 0: - _t757 = self.parse_date() - date370 = _t757 - _t758 = logic_pb2.Value(date_value=date370) - _t756 = _t758 + if prediction617 == 0: + _t1281 = self.parse_date() + date618 = _t1281 + _t1282 = logic_pb2.Value(date_value=date618) + _t1280 = _t1282 else: raise ParseError("Unexpected token in value" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t753 = _t756 - _t751 = _t753 - _t749 = _t751 - _t747 = _t749 - _t745 = _t747 - _t743 = _t745 - _t741 = _t743 - _t738 = _t741 - _t735 = _t738 - return _t735 + _t1277 = _t1280 + _t1275 = _t1277 + _t1273 = _t1275 + _t1271 = _t1273 + _t1269 = _t1271 + _t1267 = _t1269 + _t1265 = _t1267 + _t1262 = _t1265 + _t1259 = _t1262 + result628 = _t1259 + self.record_span(span_start627) + return result628 def parse_date(self) -> logic_pb2.DateValue: + span_start632 = self.span_start() self.consume_literal("(") self.consume_literal("date") - int379 = self.consume_terminal("INT") - int_3380 = self.consume_terminal("INT") - int_4381 = self.consume_terminal("INT") - self.consume_literal(")") - _t759 = logic_pb2.DateValue(year=int(int379), month=int(int_3380), day=int(int_4381)) - return _t759 + self.push_path(1) + int629 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3630 = self.consume_terminal("INT") + self.pop_path() + self.push_path(3) + int_4631 = self.consume_terminal("INT") + self.pop_path() + self.consume_literal(")") + _t1283 = logic_pb2.DateValue(year=int(int629), month=int(int_3630), day=int(int_4631)) + result633 = _t1283 + self.record_span(span_start632) + return result633 def parse_datetime(self) -> logic_pb2.DateTimeValue: + span_start641 = self.span_start() self.consume_literal("(") self.consume_literal("datetime") - int382 = self.consume_terminal("INT") - int_3383 = self.consume_terminal("INT") - int_4384 = self.consume_terminal("INT") - int_5385 = self.consume_terminal("INT") - int_6386 = self.consume_terminal("INT") - int_7387 = self.consume_terminal("INT") + self.push_path(1) + int634 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3635 = self.consume_terminal("INT") + self.pop_path() + self.push_path(3) + int_4636 = self.consume_terminal("INT") + self.pop_path() + self.push_path(4) + int_5637 = self.consume_terminal("INT") + self.pop_path() + self.push_path(5) + int_6638 = self.consume_terminal("INT") + self.pop_path() + self.push_path(6) + int_7639 = self.consume_terminal("INT") + self.pop_path() + self.push_path(7) if self.match_lookahead_terminal("INT", 0): - _t760 = self.consume_terminal("INT") + _t1284 = self.consume_terminal("INT") else: - _t760 = None - int_8388 = _t760 + _t1284 = None + int_8640 = _t1284 + self.pop_path() self.consume_literal(")") - _t761 = logic_pb2.DateTimeValue(year=int(int382), month=int(int_3383), day=int(int_4384), hour=int(int_5385), minute=int(int_6386), second=int(int_7387), microsecond=int((int_8388 if int_8388 is not None else 0))) - return _t761 + _t1285 = logic_pb2.DateTimeValue(year=int(int634), month=int(int_3635), day=int(int_4636), hour=int(int_5637), minute=int(int_6638), second=int(int_7639), microsecond=int((int_8640 if int_8640 is not None else 0))) + result642 = _t1285 + self.record_span(span_start641) + return result642 def parse_boolean_value(self) -> bool: + span_start644 = self.span_start() if self.match_lookahead_literal("true", 0): - _t762 = 0 + _t1286 = 0 else: if self.match_lookahead_literal("false", 0): - _t763 = 1 + _t1287 = 1 else: - _t763 = -1 - _t762 = _t763 - prediction389 = _t762 - if prediction389 == 1: + _t1287 = -1 + _t1286 = _t1287 + prediction643 = _t1286 + if prediction643 == 1: self.consume_literal("false") - _t764 = False + _t1288 = False else: - if prediction389 == 0: + if prediction643 == 0: self.consume_literal("true") - _t765 = True + _t1289 = True else: raise ParseError("Unexpected token in boolean_value" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t764 = _t765 - return _t764 + _t1288 = _t1289 + result645 = _t1288 + self.record_span(span_start644) + return result645 def parse_sync(self) -> transactions_pb2.Sync: + span_start654 = self.span_start() self.consume_literal("(") self.consume_literal("sync") - xs390 = [] - cond391 = self.match_lookahead_literal(":", 0) - while cond391: - _t766 = self.parse_fragment_id() - item392 = _t766 - xs390.append(item392) - cond391 = self.match_lookahead_literal(":", 0) - fragment_ids393 = xs390 - self.consume_literal(")") - _t767 = transactions_pb2.Sync(fragments=fragment_ids393) - return _t767 + self.push_path(1) + xs650 = [] + cond651 = self.match_lookahead_literal(":", 0) + idx652 = 0 + while cond651: + self.push_path(idx652) + _t1290 = self.parse_fragment_id() + item653 = _t1290 + self.pop_path() + xs650.append(item653) + idx652 = (idx652 + 1) + cond651 = self.match_lookahead_literal(":", 0) + fragment_ids649 = xs650 + self.pop_path() + self.consume_literal(")") + _t1291 = transactions_pb2.Sync(fragments=fragment_ids649) + result655 = _t1291 + self.record_span(span_start654) + return result655 def parse_fragment_id(self) -> fragments_pb2.FragmentId: + span_start657 = self.span_start() self.consume_literal(":") - symbol394 = self.consume_terminal("SYMBOL") - return fragments_pb2.FragmentId(id=symbol394.encode()) + symbol656 = self.consume_terminal("SYMBOL") + result658 = fragments_pb2.FragmentId(id=symbol656.encode()) + self.record_span(span_start657) + return result658 def parse_epoch(self) -> transactions_pb2.Epoch: + span_start661 = self.span_start() self.consume_literal("(") self.consume_literal("epoch") + self.push_path(1) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("writes", 1)): - _t769 = self.parse_epoch_writes() - _t768 = _t769 + _t1293 = self.parse_epoch_writes() + _t1292 = _t1293 else: - _t768 = None - epoch_writes395 = _t768 + _t1292 = None + epoch_writes659 = _t1292 + self.pop_path() + self.push_path(2) if self.match_lookahead_literal("(", 0): - _t771 = self.parse_epoch_reads() - _t770 = _t771 + _t1295 = self.parse_epoch_reads() + _t1294 = _t1295 else: - _t770 = None - epoch_reads396 = _t770 + _t1294 = None + epoch_reads660 = _t1294 + self.pop_path() self.consume_literal(")") - _t772 = transactions_pb2.Epoch(writes=(epoch_writes395 if epoch_writes395 is not None else []), reads=(epoch_reads396 if epoch_reads396 is not None else [])) - return _t772 + _t1296 = transactions_pb2.Epoch(writes=(epoch_writes659 if epoch_writes659 is not None else []), reads=(epoch_reads660 if epoch_reads660 is not None else [])) + result662 = _t1296 + self.record_span(span_start661) + return result662 def parse_epoch_writes(self) -> Sequence[transactions_pb2.Write]: + span_start667 = self.span_start() self.consume_literal("(") self.consume_literal("writes") - xs397 = [] - cond398 = self.match_lookahead_literal("(", 0) - while cond398: - _t773 = self.parse_write() - item399 = _t773 - xs397.append(item399) - cond398 = self.match_lookahead_literal("(", 0) - writes400 = xs397 - self.consume_literal(")") - return writes400 + xs663 = [] + cond664 = self.match_lookahead_literal("(", 0) + while cond664: + _t1297 = self.parse_write() + item665 = _t1297 + xs663.append(item665) + cond664 = self.match_lookahead_literal("(", 0) + writes666 = xs663 + self.consume_literal(")") + result668 = writes666 + self.record_span(span_start667) + return result668 def parse_write(self) -> transactions_pb2.Write: + span_start674 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("undefine", 1): - _t775 = 1 + _t1299 = 1 else: if self.match_lookahead_literal("snapshot", 1): - _t776 = 3 + _t1300 = 3 else: if self.match_lookahead_literal("define", 1): - _t777 = 0 + _t1301 = 0 else: if self.match_lookahead_literal("context", 1): - _t778 = 2 + _t1302 = 2 else: - _t778 = -1 - _t777 = _t778 - _t776 = _t777 - _t775 = _t776 - _t774 = _t775 - else: - _t774 = -1 - prediction401 = _t774 - if prediction401 == 3: - _t780 = self.parse_snapshot() - snapshot405 = _t780 - _t781 = transactions_pb2.Write(snapshot=snapshot405) - _t779 = _t781 - else: - if prediction401 == 2: - _t783 = self.parse_context() - context404 = _t783 - _t784 = transactions_pb2.Write(context=context404) - _t782 = _t784 + _t1302 = -1 + _t1301 = _t1302 + _t1300 = _t1301 + _t1299 = _t1300 + _t1298 = _t1299 + else: + _t1298 = -1 + prediction669 = _t1298 + if prediction669 == 3: + _t1304 = self.parse_snapshot() + snapshot673 = _t1304 + _t1305 = transactions_pb2.Write(snapshot=snapshot673) + _t1303 = _t1305 + else: + if prediction669 == 2: + _t1307 = self.parse_context() + context672 = _t1307 + _t1308 = transactions_pb2.Write(context=context672) + _t1306 = _t1308 else: - if prediction401 == 1: - _t786 = self.parse_undefine() - undefine403 = _t786 - _t787 = transactions_pb2.Write(undefine=undefine403) - _t785 = _t787 + if prediction669 == 1: + _t1310 = self.parse_undefine() + undefine671 = _t1310 + _t1311 = transactions_pb2.Write(undefine=undefine671) + _t1309 = _t1311 else: - if prediction401 == 0: - _t789 = self.parse_define() - define402 = _t789 - _t790 = transactions_pb2.Write(define=define402) - _t788 = _t790 + if prediction669 == 0: + _t1313 = self.parse_define() + define670 = _t1313 + _t1314 = transactions_pb2.Write(define=define670) + _t1312 = _t1314 else: raise ParseError("Unexpected token in write" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t785 = _t788 - _t782 = _t785 - _t779 = _t782 - return _t779 + _t1309 = _t1312 + _t1306 = _t1309 + _t1303 = _t1306 + result675 = _t1303 + self.record_span(span_start674) + return result675 def parse_define(self) -> transactions_pb2.Define: + span_start677 = self.span_start() self.consume_literal("(") self.consume_literal("define") - _t791 = self.parse_fragment() - fragment406 = _t791 + self.push_path(1) + _t1315 = self.parse_fragment() + fragment676 = _t1315 + self.pop_path() self.consume_literal(")") - _t792 = transactions_pb2.Define(fragment=fragment406) - return _t792 + _t1316 = transactions_pb2.Define(fragment=fragment676) + result678 = _t1316 + self.record_span(span_start677) + return result678 def parse_fragment(self) -> fragments_pb2.Fragment: + span_start684 = self.span_start() self.consume_literal("(") self.consume_literal("fragment") - _t793 = self.parse_new_fragment_id() - new_fragment_id407 = _t793 - xs408 = [] - cond409 = self.match_lookahead_literal("(", 0) - while cond409: - _t794 = self.parse_declaration() - item410 = _t794 - xs408.append(item410) - cond409 = self.match_lookahead_literal("(", 0) - declarations411 = xs408 - self.consume_literal(")") - return self.construct_fragment(new_fragment_id407, declarations411) + _t1317 = self.parse_new_fragment_id() + new_fragment_id679 = _t1317 + xs680 = [] + cond681 = self.match_lookahead_literal("(", 0) + while cond681: + _t1318 = self.parse_declaration() + item682 = _t1318 + xs680.append(item682) + cond681 = self.match_lookahead_literal("(", 0) + declarations683 = xs680 + self.consume_literal(")") + result685 = self.construct_fragment(new_fragment_id679, declarations683) + self.record_span(span_start684) + return result685 def parse_new_fragment_id(self) -> fragments_pb2.FragmentId: - _t795 = self.parse_fragment_id() - fragment_id412 = _t795 - self.start_fragment(fragment_id412) - return fragment_id412 + span_start687 = self.span_start() + _t1319 = self.parse_fragment_id() + fragment_id686 = _t1319 + self.start_fragment(fragment_id686) + result688 = fragment_id686 + self.record_span(span_start687) + return result688 def parse_declaration(self) -> logic_pb2.Declaration: + span_start694 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t797 = 3 + _t1321 = 3 else: if self.match_lookahead_literal("functional_dependency", 1): - _t798 = 2 + _t1322 = 2 else: if self.match_lookahead_literal("def", 1): - _t799 = 0 + _t1323 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t800 = 3 + _t1324 = 3 else: if self.match_lookahead_literal("betree_relation", 1): - _t801 = 3 + _t1325 = 3 else: if self.match_lookahead_literal("algorithm", 1): - _t802 = 1 + _t1326 = 1 else: - _t802 = -1 - _t801 = _t802 - _t800 = _t801 - _t799 = _t800 - _t798 = _t799 - _t797 = _t798 - _t796 = _t797 - else: - _t796 = -1 - prediction413 = _t796 - if prediction413 == 3: - _t804 = self.parse_data() - data417 = _t804 - _t805 = logic_pb2.Declaration(data=data417) - _t803 = _t805 - else: - if prediction413 == 2: - _t807 = self.parse_constraint() - constraint416 = _t807 - _t808 = logic_pb2.Declaration(constraint=constraint416) - _t806 = _t808 + _t1326 = -1 + _t1325 = _t1326 + _t1324 = _t1325 + _t1323 = _t1324 + _t1322 = _t1323 + _t1321 = _t1322 + _t1320 = _t1321 + else: + _t1320 = -1 + prediction689 = _t1320 + if prediction689 == 3: + _t1328 = self.parse_data() + data693 = _t1328 + _t1329 = logic_pb2.Declaration(data=data693) + _t1327 = _t1329 + else: + if prediction689 == 2: + _t1331 = self.parse_constraint() + constraint692 = _t1331 + _t1332 = logic_pb2.Declaration(constraint=constraint692) + _t1330 = _t1332 else: - if prediction413 == 1: - _t810 = self.parse_algorithm() - algorithm415 = _t810 - _t811 = logic_pb2.Declaration(algorithm=algorithm415) - _t809 = _t811 + if prediction689 == 1: + _t1334 = self.parse_algorithm() + algorithm691 = _t1334 + _t1335 = logic_pb2.Declaration(algorithm=algorithm691) + _t1333 = _t1335 else: - if prediction413 == 0: - _t813 = self.parse_def() - def414 = _t813 - _t814 = logic_pb2.Declaration() - getattr(_t814, 'def').CopyFrom(def414) - _t812 = _t814 + if prediction689 == 0: + _t1337 = self.parse_def() + def690 = _t1337 + _t1338 = logic_pb2.Declaration() + getattr(_t1338, 'def').CopyFrom(def690) + _t1336 = _t1338 else: raise ParseError("Unexpected token in declaration" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t809 = _t812 - _t806 = _t809 - _t803 = _t806 - return _t803 + _t1333 = _t1336 + _t1330 = _t1333 + _t1327 = _t1330 + result695 = _t1327 + self.record_span(span_start694) + return result695 def parse_def(self) -> logic_pb2.Def: + span_start699 = self.span_start() self.consume_literal("(") self.consume_literal("def") - _t815 = self.parse_relation_id() - relation_id418 = _t815 - _t816 = self.parse_abstraction() - abstraction419 = _t816 + self.push_path(1) + _t1339 = self.parse_relation_id() + relation_id696 = _t1339 + self.pop_path() + self.push_path(2) + _t1340 = self.parse_abstraction() + abstraction697 = _t1340 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t818 = self.parse_attrs() - _t817 = _t818 + _t1342 = self.parse_attrs() + _t1341 = _t1342 else: - _t817 = None - attrs420 = _t817 + _t1341 = None + attrs698 = _t1341 + self.pop_path() self.consume_literal(")") - _t819 = logic_pb2.Def(name=relation_id418, body=abstraction419, attrs=(attrs420 if attrs420 is not None else [])) - return _t819 + _t1343 = logic_pb2.Def(name=relation_id696, body=abstraction697, attrs=(attrs698 if attrs698 is not None else [])) + result700 = _t1343 + self.record_span(span_start699) + return result700 def parse_relation_id(self) -> logic_pb2.RelationId: + span_start704 = self.span_start() if self.match_lookahead_literal(":", 0): - _t820 = 0 + _t1344 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t821 = 1 + _t1345 = 1 else: - _t821 = -1 - _t820 = _t821 - prediction421 = _t820 - if prediction421 == 1: - uint128423 = self.consume_terminal("UINT128") - _t822 = logic_pb2.RelationId(id_low=uint128423.low, id_high=uint128423.high) - else: - if prediction421 == 0: + _t1345 = -1 + _t1344 = _t1345 + prediction701 = _t1344 + if prediction701 == 1: + uint128703 = self.consume_terminal("UINT128") + _t1346 = logic_pb2.RelationId(id_low=uint128703.low, id_high=uint128703.high) + else: + if prediction701 == 0: self.consume_literal(":") - symbol422 = self.consume_terminal("SYMBOL") - _t823 = self.relation_id_from_string(symbol422) + symbol702 = self.consume_terminal("SYMBOL") + _t1347 = self.relation_id_from_string(symbol702) else: raise ParseError("Unexpected token in relation_id" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t822 = _t823 - return _t822 + _t1346 = _t1347 + result705 = _t1346 + self.record_span(span_start704) + return result705 def parse_abstraction(self) -> logic_pb2.Abstraction: + span_start708 = self.span_start() self.consume_literal("(") - _t824 = self.parse_bindings() - bindings424 = _t824 - _t825 = self.parse_formula() - formula425 = _t825 + _t1348 = self.parse_bindings() + bindings706 = _t1348 + self.push_path(2) + _t1349 = self.parse_formula() + formula707 = _t1349 + self.pop_path() self.consume_literal(")") - _t826 = logic_pb2.Abstraction(vars=(list(bindings424[0]) + list(bindings424[1] if bindings424[1] is not None else [])), value=formula425) - return _t826 + _t1350 = logic_pb2.Abstraction(vars=(list(bindings706[0]) + list(bindings706[1] if bindings706[1] is not None else [])), value=formula707) + result709 = _t1350 + self.record_span(span_start708) + return result709 def parse_bindings(self) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: + span_start715 = self.span_start() self.consume_literal("[") - xs426 = [] - cond427 = self.match_lookahead_terminal("SYMBOL", 0) - while cond427: - _t827 = self.parse_binding() - item428 = _t827 - xs426.append(item428) - cond427 = self.match_lookahead_terminal("SYMBOL", 0) - bindings429 = xs426 + xs710 = [] + cond711 = self.match_lookahead_terminal("SYMBOL", 0) + while cond711: + _t1351 = self.parse_binding() + item712 = _t1351 + xs710.append(item712) + cond711 = self.match_lookahead_terminal("SYMBOL", 0) + bindings713 = xs710 if self.match_lookahead_literal("|", 0): - _t829 = self.parse_value_bindings() - _t828 = _t829 + _t1353 = self.parse_value_bindings() + _t1352 = _t1353 else: - _t828 = None - value_bindings430 = _t828 + _t1352 = None + value_bindings714 = _t1352 self.consume_literal("]") - return (bindings429, (value_bindings430 if value_bindings430 is not None else []),) + result716 = (bindings713, (value_bindings714 if value_bindings714 is not None else []),) + self.record_span(span_start715) + return result716 def parse_binding(self) -> logic_pb2.Binding: - symbol431 = self.consume_terminal("SYMBOL") + span_start719 = self.span_start() + symbol717 = self.consume_terminal("SYMBOL") self.consume_literal("::") - _t830 = self.parse_type() - type432 = _t830 - _t831 = logic_pb2.Var(name=symbol431) - _t832 = logic_pb2.Binding(var=_t831, type=type432) - return _t832 + self.push_path(2) + _t1354 = self.parse_type() + type718 = _t1354 + self.pop_path() + _t1355 = logic_pb2.Var(name=symbol717) + _t1356 = logic_pb2.Binding(var=_t1355, type=type718) + result720 = _t1356 + self.record_span(span_start719) + return result720 def parse_type(self) -> logic_pb2.Type: + span_start733 = self.span_start() if self.match_lookahead_literal("UNKNOWN", 0): - _t833 = 0 + _t1357 = 0 else: if self.match_lookahead_literal("UINT128", 0): - _t834 = 4 + _t1358 = 4 else: if self.match_lookahead_literal("STRING", 0): - _t835 = 1 + _t1359 = 1 else: if self.match_lookahead_literal("MISSING", 0): - _t836 = 8 + _t1360 = 8 else: if self.match_lookahead_literal("INT128", 0): - _t837 = 5 + _t1361 = 5 else: if self.match_lookahead_literal("INT", 0): - _t838 = 2 + _t1362 = 2 else: if self.match_lookahead_literal("FLOAT", 0): - _t839 = 3 + _t1363 = 3 else: if self.match_lookahead_literal("DATETIME", 0): - _t840 = 7 + _t1364 = 7 else: if self.match_lookahead_literal("DATE", 0): - _t841 = 6 + _t1365 = 6 else: if self.match_lookahead_literal("BOOLEAN", 0): - _t842 = 10 + _t1366 = 10 else: if self.match_lookahead_literal("(", 0): - _t843 = 9 + _t1367 = 9 else: - _t843 = -1 - _t842 = _t843 - _t841 = _t842 - _t840 = _t841 - _t839 = _t840 - _t838 = _t839 - _t837 = _t838 - _t836 = _t837 - _t835 = _t836 - _t834 = _t835 - _t833 = _t834 - prediction433 = _t833 - if prediction433 == 10: - _t845 = self.parse_boolean_type() - boolean_type444 = _t845 - _t846 = logic_pb2.Type(boolean_type=boolean_type444) - _t844 = _t846 - else: - if prediction433 == 9: - _t848 = self.parse_decimal_type() - decimal_type443 = _t848 - _t849 = logic_pb2.Type(decimal_type=decimal_type443) - _t847 = _t849 + _t1367 = -1 + _t1366 = _t1367 + _t1365 = _t1366 + _t1364 = _t1365 + _t1363 = _t1364 + _t1362 = _t1363 + _t1361 = _t1362 + _t1360 = _t1361 + _t1359 = _t1360 + _t1358 = _t1359 + _t1357 = _t1358 + prediction721 = _t1357 + if prediction721 == 10: + _t1369 = self.parse_boolean_type() + boolean_type732 = _t1369 + _t1370 = logic_pb2.Type(boolean_type=boolean_type732) + _t1368 = _t1370 + else: + if prediction721 == 9: + _t1372 = self.parse_decimal_type() + decimal_type731 = _t1372 + _t1373 = logic_pb2.Type(decimal_type=decimal_type731) + _t1371 = _t1373 else: - if prediction433 == 8: - _t851 = self.parse_missing_type() - missing_type442 = _t851 - _t852 = logic_pb2.Type(missing_type=missing_type442) - _t850 = _t852 + if prediction721 == 8: + _t1375 = self.parse_missing_type() + missing_type730 = _t1375 + _t1376 = logic_pb2.Type(missing_type=missing_type730) + _t1374 = _t1376 else: - if prediction433 == 7: - _t854 = self.parse_datetime_type() - datetime_type441 = _t854 - _t855 = logic_pb2.Type(datetime_type=datetime_type441) - _t853 = _t855 + if prediction721 == 7: + _t1378 = self.parse_datetime_type() + datetime_type729 = _t1378 + _t1379 = logic_pb2.Type(datetime_type=datetime_type729) + _t1377 = _t1379 else: - if prediction433 == 6: - _t857 = self.parse_date_type() - date_type440 = _t857 - _t858 = logic_pb2.Type(date_type=date_type440) - _t856 = _t858 + if prediction721 == 6: + _t1381 = self.parse_date_type() + date_type728 = _t1381 + _t1382 = logic_pb2.Type(date_type=date_type728) + _t1380 = _t1382 else: - if prediction433 == 5: - _t860 = self.parse_int128_type() - int128_type439 = _t860 - _t861 = logic_pb2.Type(int128_type=int128_type439) - _t859 = _t861 + if prediction721 == 5: + _t1384 = self.parse_int128_type() + int128_type727 = _t1384 + _t1385 = logic_pb2.Type(int128_type=int128_type727) + _t1383 = _t1385 else: - if prediction433 == 4: - _t863 = self.parse_uint128_type() - uint128_type438 = _t863 - _t864 = logic_pb2.Type(uint128_type=uint128_type438) - _t862 = _t864 + if prediction721 == 4: + _t1387 = self.parse_uint128_type() + uint128_type726 = _t1387 + _t1388 = logic_pb2.Type(uint128_type=uint128_type726) + _t1386 = _t1388 else: - if prediction433 == 3: - _t866 = self.parse_float_type() - float_type437 = _t866 - _t867 = logic_pb2.Type(float_type=float_type437) - _t865 = _t867 + if prediction721 == 3: + _t1390 = self.parse_float_type() + float_type725 = _t1390 + _t1391 = logic_pb2.Type(float_type=float_type725) + _t1389 = _t1391 else: - if prediction433 == 2: - _t869 = self.parse_int_type() - int_type436 = _t869 - _t870 = logic_pb2.Type(int_type=int_type436) - _t868 = _t870 + if prediction721 == 2: + _t1393 = self.parse_int_type() + int_type724 = _t1393 + _t1394 = logic_pb2.Type(int_type=int_type724) + _t1392 = _t1394 else: - if prediction433 == 1: - _t872 = self.parse_string_type() - string_type435 = _t872 - _t873 = logic_pb2.Type(string_type=string_type435) - _t871 = _t873 + if prediction721 == 1: + _t1396 = self.parse_string_type() + string_type723 = _t1396 + _t1397 = logic_pb2.Type(string_type=string_type723) + _t1395 = _t1397 else: - if prediction433 == 0: - _t875 = self.parse_unspecified_type() - unspecified_type434 = _t875 - _t876 = logic_pb2.Type(unspecified_type=unspecified_type434) - _t874 = _t876 + if prediction721 == 0: + _t1399 = self.parse_unspecified_type() + unspecified_type722 = _t1399 + _t1400 = logic_pb2.Type(unspecified_type=unspecified_type722) + _t1398 = _t1400 else: raise ParseError("Unexpected token in type" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t871 = _t874 - _t868 = _t871 - _t865 = _t868 - _t862 = _t865 - _t859 = _t862 - _t856 = _t859 - _t853 = _t856 - _t850 = _t853 - _t847 = _t850 - _t844 = _t847 - return _t844 + _t1395 = _t1398 + _t1392 = _t1395 + _t1389 = _t1392 + _t1386 = _t1389 + _t1383 = _t1386 + _t1380 = _t1383 + _t1377 = _t1380 + _t1374 = _t1377 + _t1371 = _t1374 + _t1368 = _t1371 + result734 = _t1368 + self.record_span(span_start733) + return result734 def parse_unspecified_type(self) -> logic_pb2.UnspecifiedType: + span_start735 = self.span_start() self.consume_literal("UNKNOWN") - _t877 = logic_pb2.UnspecifiedType() - return _t877 + _t1401 = logic_pb2.UnspecifiedType() + result736 = _t1401 + self.record_span(span_start735) + return result736 def parse_string_type(self) -> logic_pb2.StringType: + span_start737 = self.span_start() self.consume_literal("STRING") - _t878 = logic_pb2.StringType() - return _t878 + _t1402 = logic_pb2.StringType() + result738 = _t1402 + self.record_span(span_start737) + return result738 def parse_int_type(self) -> logic_pb2.IntType: + span_start739 = self.span_start() self.consume_literal("INT") - _t879 = logic_pb2.IntType() - return _t879 + _t1403 = logic_pb2.IntType() + result740 = _t1403 + self.record_span(span_start739) + return result740 def parse_float_type(self) -> logic_pb2.FloatType: + span_start741 = self.span_start() self.consume_literal("FLOAT") - _t880 = logic_pb2.FloatType() - return _t880 + _t1404 = logic_pb2.FloatType() + result742 = _t1404 + self.record_span(span_start741) + return result742 def parse_uint128_type(self) -> logic_pb2.UInt128Type: + span_start743 = self.span_start() self.consume_literal("UINT128") - _t881 = logic_pb2.UInt128Type() - return _t881 + _t1405 = logic_pb2.UInt128Type() + result744 = _t1405 + self.record_span(span_start743) + return result744 def parse_int128_type(self) -> logic_pb2.Int128Type: + span_start745 = self.span_start() self.consume_literal("INT128") - _t882 = logic_pb2.Int128Type() - return _t882 + _t1406 = logic_pb2.Int128Type() + result746 = _t1406 + self.record_span(span_start745) + return result746 def parse_date_type(self) -> logic_pb2.DateType: + span_start747 = self.span_start() self.consume_literal("DATE") - _t883 = logic_pb2.DateType() - return _t883 + _t1407 = logic_pb2.DateType() + result748 = _t1407 + self.record_span(span_start747) + return result748 def parse_datetime_type(self) -> logic_pb2.DateTimeType: + span_start749 = self.span_start() self.consume_literal("DATETIME") - _t884 = logic_pb2.DateTimeType() - return _t884 + _t1408 = logic_pb2.DateTimeType() + result750 = _t1408 + self.record_span(span_start749) + return result750 def parse_missing_type(self) -> logic_pb2.MissingType: + span_start751 = self.span_start() self.consume_literal("MISSING") - _t885 = logic_pb2.MissingType() - return _t885 + _t1409 = logic_pb2.MissingType() + result752 = _t1409 + self.record_span(span_start751) + return result752 def parse_decimal_type(self) -> logic_pb2.DecimalType: + span_start755 = self.span_start() self.consume_literal("(") self.consume_literal("DECIMAL") - int445 = self.consume_terminal("INT") - int_3446 = self.consume_terminal("INT") - self.consume_literal(")") - _t886 = logic_pb2.DecimalType(precision=int(int445), scale=int(int_3446)) - return _t886 + self.push_path(1) + int753 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3754 = self.consume_terminal("INT") + self.pop_path() + self.consume_literal(")") + _t1410 = logic_pb2.DecimalType(precision=int(int753), scale=int(int_3754)) + result756 = _t1410 + self.record_span(span_start755) + return result756 def parse_boolean_type(self) -> logic_pb2.BooleanType: + span_start757 = self.span_start() self.consume_literal("BOOLEAN") - _t887 = logic_pb2.BooleanType() - return _t887 + _t1411 = logic_pb2.BooleanType() + result758 = _t1411 + self.record_span(span_start757) + return result758 def parse_value_bindings(self) -> Sequence[logic_pb2.Binding]: + span_start763 = self.span_start() self.consume_literal("|") - xs447 = [] - cond448 = self.match_lookahead_terminal("SYMBOL", 0) - while cond448: - _t888 = self.parse_binding() - item449 = _t888 - xs447.append(item449) - cond448 = self.match_lookahead_terminal("SYMBOL", 0) - bindings450 = xs447 - return bindings450 + xs759 = [] + cond760 = self.match_lookahead_terminal("SYMBOL", 0) + while cond760: + _t1412 = self.parse_binding() + item761 = _t1412 + xs759.append(item761) + cond760 = self.match_lookahead_terminal("SYMBOL", 0) + bindings762 = xs759 + result764 = bindings762 + self.record_span(span_start763) + return result764 def parse_formula(self) -> logic_pb2.Formula: + span_start779 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("true", 1): - _t890 = 0 + _t1414 = 0 else: if self.match_lookahead_literal("relatom", 1): - _t891 = 11 + _t1415 = 11 else: if self.match_lookahead_literal("reduce", 1): - _t892 = 3 + _t1416 = 3 else: if self.match_lookahead_literal("primitive", 1): - _t893 = 10 + _t1417 = 10 else: if self.match_lookahead_literal("pragma", 1): - _t894 = 9 + _t1418 = 9 else: if self.match_lookahead_literal("or", 1): - _t895 = 5 + _t1419 = 5 else: if self.match_lookahead_literal("not", 1): - _t896 = 6 + _t1420 = 6 else: if self.match_lookahead_literal("ffi", 1): - _t897 = 7 + _t1421 = 7 else: if self.match_lookahead_literal("false", 1): - _t898 = 1 + _t1422 = 1 else: if self.match_lookahead_literal("exists", 1): - _t899 = 2 + _t1423 = 2 else: if self.match_lookahead_literal("cast", 1): - _t900 = 12 + _t1424 = 12 else: if self.match_lookahead_literal("atom", 1): - _t901 = 8 + _t1425 = 8 else: if self.match_lookahead_literal("and", 1): - _t902 = 4 + _t1426 = 4 else: if self.match_lookahead_literal(">=", 1): - _t903 = 10 + _t1427 = 10 else: if self.match_lookahead_literal(">", 1): - _t904 = 10 + _t1428 = 10 else: if self.match_lookahead_literal("=", 1): - _t905 = 10 + _t1429 = 10 else: if self.match_lookahead_literal("<=", 1): - _t906 = 10 + _t1430 = 10 else: if self.match_lookahead_literal("<", 1): - _t907 = 10 + _t1431 = 10 else: if self.match_lookahead_literal("/", 1): - _t908 = 10 + _t1432 = 10 else: if self.match_lookahead_literal("-", 1): - _t909 = 10 + _t1433 = 10 else: if self.match_lookahead_literal("+", 1): - _t910 = 10 + _t1434 = 10 else: if self.match_lookahead_literal("*", 1): - _t911 = 10 + _t1435 = 10 else: - _t911 = -1 - _t910 = _t911 - _t909 = _t910 - _t908 = _t909 - _t907 = _t908 - _t906 = _t907 - _t905 = _t906 - _t904 = _t905 - _t903 = _t904 - _t902 = _t903 - _t901 = _t902 - _t900 = _t901 - _t899 = _t900 - _t898 = _t899 - _t897 = _t898 - _t896 = _t897 - _t895 = _t896 - _t894 = _t895 - _t893 = _t894 - _t892 = _t893 - _t891 = _t892 - _t890 = _t891 - _t889 = _t890 - else: - _t889 = -1 - prediction451 = _t889 - if prediction451 == 12: - _t913 = self.parse_cast() - cast464 = _t913 - _t914 = logic_pb2.Formula(cast=cast464) - _t912 = _t914 - else: - if prediction451 == 11: - _t916 = self.parse_rel_atom() - rel_atom463 = _t916 - _t917 = logic_pb2.Formula(rel_atom=rel_atom463) - _t915 = _t917 + _t1435 = -1 + _t1434 = _t1435 + _t1433 = _t1434 + _t1432 = _t1433 + _t1431 = _t1432 + _t1430 = _t1431 + _t1429 = _t1430 + _t1428 = _t1429 + _t1427 = _t1428 + _t1426 = _t1427 + _t1425 = _t1426 + _t1424 = _t1425 + _t1423 = _t1424 + _t1422 = _t1423 + _t1421 = _t1422 + _t1420 = _t1421 + _t1419 = _t1420 + _t1418 = _t1419 + _t1417 = _t1418 + _t1416 = _t1417 + _t1415 = _t1416 + _t1414 = _t1415 + _t1413 = _t1414 + else: + _t1413 = -1 + prediction765 = _t1413 + if prediction765 == 12: + _t1437 = self.parse_cast() + cast778 = _t1437 + _t1438 = logic_pb2.Formula(cast=cast778) + _t1436 = _t1438 + else: + if prediction765 == 11: + _t1440 = self.parse_rel_atom() + rel_atom777 = _t1440 + _t1441 = logic_pb2.Formula(rel_atom=rel_atom777) + _t1439 = _t1441 else: - if prediction451 == 10: - _t919 = self.parse_primitive() - primitive462 = _t919 - _t920 = logic_pb2.Formula(primitive=primitive462) - _t918 = _t920 + if prediction765 == 10: + _t1443 = self.parse_primitive() + primitive776 = _t1443 + _t1444 = logic_pb2.Formula(primitive=primitive776) + _t1442 = _t1444 else: - if prediction451 == 9: - _t922 = self.parse_pragma() - pragma461 = _t922 - _t923 = logic_pb2.Formula(pragma=pragma461) - _t921 = _t923 + if prediction765 == 9: + _t1446 = self.parse_pragma() + pragma775 = _t1446 + _t1447 = logic_pb2.Formula(pragma=pragma775) + _t1445 = _t1447 else: - if prediction451 == 8: - _t925 = self.parse_atom() - atom460 = _t925 - _t926 = logic_pb2.Formula(atom=atom460) - _t924 = _t926 + if prediction765 == 8: + _t1449 = self.parse_atom() + atom774 = _t1449 + _t1450 = logic_pb2.Formula(atom=atom774) + _t1448 = _t1450 else: - if prediction451 == 7: - _t928 = self.parse_ffi() - ffi459 = _t928 - _t929 = logic_pb2.Formula(ffi=ffi459) - _t927 = _t929 + if prediction765 == 7: + _t1452 = self.parse_ffi() + ffi773 = _t1452 + _t1453 = logic_pb2.Formula(ffi=ffi773) + _t1451 = _t1453 else: - if prediction451 == 6: - _t931 = self.parse_not() - not458 = _t931 - _t932 = logic_pb2.Formula() - getattr(_t932, 'not').CopyFrom(not458) - _t930 = _t932 + if prediction765 == 6: + _t1455 = self.parse_not() + not772 = _t1455 + _t1456 = logic_pb2.Formula() + getattr(_t1456, 'not').CopyFrom(not772) + _t1454 = _t1456 else: - if prediction451 == 5: - _t934 = self.parse_disjunction() - disjunction457 = _t934 - _t935 = logic_pb2.Formula(disjunction=disjunction457) - _t933 = _t935 + if prediction765 == 5: + _t1458 = self.parse_disjunction() + disjunction771 = _t1458 + _t1459 = logic_pb2.Formula(disjunction=disjunction771) + _t1457 = _t1459 else: - if prediction451 == 4: - _t937 = self.parse_conjunction() - conjunction456 = _t937 - _t938 = logic_pb2.Formula(conjunction=conjunction456) - _t936 = _t938 + if prediction765 == 4: + _t1461 = self.parse_conjunction() + conjunction770 = _t1461 + _t1462 = logic_pb2.Formula(conjunction=conjunction770) + _t1460 = _t1462 else: - if prediction451 == 3: - _t940 = self.parse_reduce() - reduce455 = _t940 - _t941 = logic_pb2.Formula(reduce=reduce455) - _t939 = _t941 + if prediction765 == 3: + _t1464 = self.parse_reduce() + reduce769 = _t1464 + _t1465 = logic_pb2.Formula(reduce=reduce769) + _t1463 = _t1465 else: - if prediction451 == 2: - _t943 = self.parse_exists() - exists454 = _t943 - _t944 = logic_pb2.Formula(exists=exists454) - _t942 = _t944 + if prediction765 == 2: + _t1467 = self.parse_exists() + exists768 = _t1467 + _t1468 = logic_pb2.Formula(exists=exists768) + _t1466 = _t1468 else: - if prediction451 == 1: - _t946 = self.parse_false() - false453 = _t946 - _t947 = logic_pb2.Formula(disjunction=false453) - _t945 = _t947 + if prediction765 == 1: + _t1470 = self.parse_false() + false767 = _t1470 + _t1471 = logic_pb2.Formula(disjunction=false767) + _t1469 = _t1471 else: - if prediction451 == 0: - _t949 = self.parse_true() - true452 = _t949 - _t950 = logic_pb2.Formula(conjunction=true452) - _t948 = _t950 + if prediction765 == 0: + _t1473 = self.parse_true() + true766 = _t1473 + _t1474 = logic_pb2.Formula(conjunction=true766) + _t1472 = _t1474 else: raise ParseError("Unexpected token in formula" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t945 = _t948 - _t942 = _t945 - _t939 = _t942 - _t936 = _t939 - _t933 = _t936 - _t930 = _t933 - _t927 = _t930 - _t924 = _t927 - _t921 = _t924 - _t918 = _t921 - _t915 = _t918 - _t912 = _t915 - return _t912 + _t1469 = _t1472 + _t1466 = _t1469 + _t1463 = _t1466 + _t1460 = _t1463 + _t1457 = _t1460 + _t1454 = _t1457 + _t1451 = _t1454 + _t1448 = _t1451 + _t1445 = _t1448 + _t1442 = _t1445 + _t1439 = _t1442 + _t1436 = _t1439 + result780 = _t1436 + self.record_span(span_start779) + return result780 def parse_true(self) -> logic_pb2.Conjunction: + span_start781 = self.span_start() self.consume_literal("(") self.consume_literal("true") self.consume_literal(")") - _t951 = logic_pb2.Conjunction(args=[]) - return _t951 + _t1475 = logic_pb2.Conjunction(args=[]) + result782 = _t1475 + self.record_span(span_start781) + return result782 def parse_false(self) -> logic_pb2.Disjunction: + span_start783 = self.span_start() self.consume_literal("(") self.consume_literal("false") self.consume_literal(")") - _t952 = logic_pb2.Disjunction(args=[]) - return _t952 + _t1476 = logic_pb2.Disjunction(args=[]) + result784 = _t1476 + self.record_span(span_start783) + return result784 def parse_exists(self) -> logic_pb2.Exists: + span_start787 = self.span_start() self.consume_literal("(") self.consume_literal("exists") - _t953 = self.parse_bindings() - bindings465 = _t953 - _t954 = self.parse_formula() - formula466 = _t954 + _t1477 = self.parse_bindings() + bindings785 = _t1477 + _t1478 = self.parse_formula() + formula786 = _t1478 self.consume_literal(")") - _t955 = logic_pb2.Abstraction(vars=(list(bindings465[0]) + list(bindings465[1] if bindings465[1] is not None else [])), value=formula466) - _t956 = logic_pb2.Exists(body=_t955) - return _t956 + _t1479 = logic_pb2.Abstraction(vars=(list(bindings785[0]) + list(bindings785[1] if bindings785[1] is not None else [])), value=formula786) + _t1480 = logic_pb2.Exists(body=_t1479) + result788 = _t1480 + self.record_span(span_start787) + return result788 def parse_reduce(self) -> logic_pb2.Reduce: + span_start792 = self.span_start() self.consume_literal("(") self.consume_literal("reduce") - _t957 = self.parse_abstraction() - abstraction467 = _t957 - _t958 = self.parse_abstraction() - abstraction_3468 = _t958 - _t959 = self.parse_terms() - terms469 = _t959 - self.consume_literal(")") - _t960 = logic_pb2.Reduce(op=abstraction467, body=abstraction_3468, terms=terms469) - return _t960 + self.push_path(1) + _t1481 = self.parse_abstraction() + abstraction789 = _t1481 + self.pop_path() + self.push_path(2) + _t1482 = self.parse_abstraction() + abstraction_3790 = _t1482 + self.pop_path() + self.push_path(3) + _t1483 = self.parse_terms() + terms791 = _t1483 + self.pop_path() + self.consume_literal(")") + _t1484 = logic_pb2.Reduce(op=abstraction789, body=abstraction_3790, terms=terms791) + result793 = _t1484 + self.record_span(span_start792) + return result793 def parse_terms(self) -> Sequence[logic_pb2.Term]: + span_start798 = self.span_start() self.consume_literal("(") self.consume_literal("terms") - xs470 = [] - cond471 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond471: - _t961 = self.parse_term() - item472 = _t961 - xs470.append(item472) - cond471 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms473 = xs470 - self.consume_literal(")") - return terms473 + xs794 = [] + cond795 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + while cond795: + _t1485 = self.parse_term() + item796 = _t1485 + xs794.append(item796) + cond795 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms797 = xs794 + self.consume_literal(")") + result799 = terms797 + self.record_span(span_start798) + return result799 def parse_term(self) -> logic_pb2.Term: + span_start803 = self.span_start() if self.match_lookahead_literal("true", 0): - _t962 = 1 + _t1486 = 1 else: if self.match_lookahead_literal("missing", 0): - _t963 = 1 + _t1487 = 1 else: if self.match_lookahead_literal("false", 0): - _t964 = 1 + _t1488 = 1 else: if self.match_lookahead_literal("(", 0): - _t965 = 1 + _t1489 = 1 else: if self.match_lookahead_terminal("UINT128", 0): - _t966 = 1 + _t1490 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t967 = 0 + _t1491 = 0 else: if self.match_lookahead_terminal("STRING", 0): - _t968 = 1 + _t1492 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t969 = 1 + _t1493 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t970 = 1 + _t1494 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t971 = 1 + _t1495 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t972 = 1 + _t1496 = 1 else: - _t972 = -1 - _t971 = _t972 - _t970 = _t971 - _t969 = _t970 - _t968 = _t969 - _t967 = _t968 - _t966 = _t967 - _t965 = _t966 - _t964 = _t965 - _t963 = _t964 - _t962 = _t963 - prediction474 = _t962 - if prediction474 == 1: - _t974 = self.parse_constant() - constant476 = _t974 - _t975 = logic_pb2.Term(constant=constant476) - _t973 = _t975 - else: - if prediction474 == 0: - _t977 = self.parse_var() - var475 = _t977 - _t978 = logic_pb2.Term(var=var475) - _t976 = _t978 + _t1496 = -1 + _t1495 = _t1496 + _t1494 = _t1495 + _t1493 = _t1494 + _t1492 = _t1493 + _t1491 = _t1492 + _t1490 = _t1491 + _t1489 = _t1490 + _t1488 = _t1489 + _t1487 = _t1488 + _t1486 = _t1487 + prediction800 = _t1486 + if prediction800 == 1: + _t1498 = self.parse_constant() + constant802 = _t1498 + _t1499 = logic_pb2.Term(constant=constant802) + _t1497 = _t1499 + else: + if prediction800 == 0: + _t1501 = self.parse_var() + var801 = _t1501 + _t1502 = logic_pb2.Term(var=var801) + _t1500 = _t1502 else: raise ParseError("Unexpected token in term" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t973 = _t976 - return _t973 + _t1497 = _t1500 + result804 = _t1497 + self.record_span(span_start803) + return result804 def parse_var(self) -> logic_pb2.Var: - symbol477 = self.consume_terminal("SYMBOL") - _t979 = logic_pb2.Var(name=symbol477) - return _t979 + span_start806 = self.span_start() + symbol805 = self.consume_terminal("SYMBOL") + _t1503 = logic_pb2.Var(name=symbol805) + result807 = _t1503 + self.record_span(span_start806) + return result807 def parse_constant(self) -> logic_pb2.Value: - _t980 = self.parse_value() - value478 = _t980 - return value478 + span_start809 = self.span_start() + _t1504 = self.parse_value() + value808 = _t1504 + result810 = value808 + self.record_span(span_start809) + return result810 def parse_conjunction(self) -> logic_pb2.Conjunction: + span_start819 = self.span_start() self.consume_literal("(") self.consume_literal("and") - xs479 = [] - cond480 = self.match_lookahead_literal("(", 0) - while cond480: - _t981 = self.parse_formula() - item481 = _t981 - xs479.append(item481) - cond480 = self.match_lookahead_literal("(", 0) - formulas482 = xs479 - self.consume_literal(")") - _t982 = logic_pb2.Conjunction(args=formulas482) - return _t982 + self.push_path(1) + xs815 = [] + cond816 = self.match_lookahead_literal("(", 0) + idx817 = 0 + while cond816: + self.push_path(idx817) + _t1505 = self.parse_formula() + item818 = _t1505 + self.pop_path() + xs815.append(item818) + idx817 = (idx817 + 1) + cond816 = self.match_lookahead_literal("(", 0) + formulas814 = xs815 + self.pop_path() + self.consume_literal(")") + _t1506 = logic_pb2.Conjunction(args=formulas814) + result820 = _t1506 + self.record_span(span_start819) + return result820 def parse_disjunction(self) -> logic_pb2.Disjunction: + span_start829 = self.span_start() self.consume_literal("(") self.consume_literal("or") - xs483 = [] - cond484 = self.match_lookahead_literal("(", 0) - while cond484: - _t983 = self.parse_formula() - item485 = _t983 - xs483.append(item485) - cond484 = self.match_lookahead_literal("(", 0) - formulas486 = xs483 - self.consume_literal(")") - _t984 = logic_pb2.Disjunction(args=formulas486) - return _t984 + self.push_path(1) + xs825 = [] + cond826 = self.match_lookahead_literal("(", 0) + idx827 = 0 + while cond826: + self.push_path(idx827) + _t1507 = self.parse_formula() + item828 = _t1507 + self.pop_path() + xs825.append(item828) + idx827 = (idx827 + 1) + cond826 = self.match_lookahead_literal("(", 0) + formulas824 = xs825 + self.pop_path() + self.consume_literal(")") + _t1508 = logic_pb2.Disjunction(args=formulas824) + result830 = _t1508 + self.record_span(span_start829) + return result830 def parse_not(self) -> logic_pb2.Not: + span_start832 = self.span_start() self.consume_literal("(") self.consume_literal("not") - _t985 = self.parse_formula() - formula487 = _t985 + self.push_path(1) + _t1509 = self.parse_formula() + formula831 = _t1509 + self.pop_path() self.consume_literal(")") - _t986 = logic_pb2.Not(arg=formula487) - return _t986 + _t1510 = logic_pb2.Not(arg=formula831) + result833 = _t1510 + self.record_span(span_start832) + return result833 def parse_ffi(self) -> logic_pb2.FFI: + span_start837 = self.span_start() self.consume_literal("(") self.consume_literal("ffi") - _t987 = self.parse_name() - name488 = _t987 - _t988 = self.parse_ffi_args() - ffi_args489 = _t988 - _t989 = self.parse_terms() - terms490 = _t989 - self.consume_literal(")") - _t990 = logic_pb2.FFI(name=name488, args=ffi_args489, terms=terms490) - return _t990 + self.push_path(1) + _t1511 = self.parse_name() + name834 = _t1511 + self.pop_path() + self.push_path(2) + _t1512 = self.parse_ffi_args() + ffi_args835 = _t1512 + self.pop_path() + self.push_path(3) + _t1513 = self.parse_terms() + terms836 = _t1513 + self.pop_path() + self.consume_literal(")") + _t1514 = logic_pb2.FFI(name=name834, args=ffi_args835, terms=terms836) + result838 = _t1514 + self.record_span(span_start837) + return result838 def parse_name(self) -> str: + span_start840 = self.span_start() self.consume_literal(":") - symbol491 = self.consume_terminal("SYMBOL") - return symbol491 + symbol839 = self.consume_terminal("SYMBOL") + result841 = symbol839 + self.record_span(span_start840) + return result841 def parse_ffi_args(self) -> Sequence[logic_pb2.Abstraction]: + span_start846 = self.span_start() self.consume_literal("(") self.consume_literal("args") - xs492 = [] - cond493 = self.match_lookahead_literal("(", 0) - while cond493: - _t991 = self.parse_abstraction() - item494 = _t991 - xs492.append(item494) - cond493 = self.match_lookahead_literal("(", 0) - abstractions495 = xs492 - self.consume_literal(")") - return abstractions495 + xs842 = [] + cond843 = self.match_lookahead_literal("(", 0) + while cond843: + _t1515 = self.parse_abstraction() + item844 = _t1515 + xs842.append(item844) + cond843 = self.match_lookahead_literal("(", 0) + abstractions845 = xs842 + self.consume_literal(")") + result847 = abstractions845 + self.record_span(span_start846) + return result847 def parse_atom(self) -> logic_pb2.Atom: + span_start857 = self.span_start() self.consume_literal("(") self.consume_literal("atom") - _t992 = self.parse_relation_id() - relation_id496 = _t992 - xs497 = [] - cond498 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond498: - _t993 = self.parse_term() - item499 = _t993 - xs497.append(item499) - cond498 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms500 = xs497 - self.consume_literal(")") - _t994 = logic_pb2.Atom(name=relation_id496, terms=terms500) - return _t994 + self.push_path(1) + _t1516 = self.parse_relation_id() + relation_id848 = _t1516 + self.pop_path() + self.push_path(2) + xs853 = [] + cond854 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx855 = 0 + while cond854: + self.push_path(idx855) + _t1517 = self.parse_term() + item856 = _t1517 + self.pop_path() + xs853.append(item856) + idx855 = (idx855 + 1) + cond854 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms852 = xs853 + self.pop_path() + self.consume_literal(")") + _t1518 = logic_pb2.Atom(name=relation_id848, terms=terms852) + result858 = _t1518 + self.record_span(span_start857) + return result858 def parse_pragma(self) -> logic_pb2.Pragma: + span_start868 = self.span_start() self.consume_literal("(") self.consume_literal("pragma") - _t995 = self.parse_name() - name501 = _t995 - xs502 = [] - cond503 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond503: - _t996 = self.parse_term() - item504 = _t996 - xs502.append(item504) - cond503 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms505 = xs502 - self.consume_literal(")") - _t997 = logic_pb2.Pragma(name=name501, terms=terms505) - return _t997 + self.push_path(1) + _t1519 = self.parse_name() + name859 = _t1519 + self.pop_path() + self.push_path(2) + xs864 = [] + cond865 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx866 = 0 + while cond865: + self.push_path(idx866) + _t1520 = self.parse_term() + item867 = _t1520 + self.pop_path() + xs864.append(item867) + idx866 = (idx866 + 1) + cond865 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms863 = xs864 + self.pop_path() + self.consume_literal(")") + _t1521 = logic_pb2.Pragma(name=name859, terms=terms863) + result869 = _t1521 + self.record_span(span_start868) + return result869 def parse_primitive(self) -> logic_pb2.Primitive: + span_start889 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("primitive", 1): - _t999 = 9 + _t1523 = 9 else: if self.match_lookahead_literal(">=", 1): - _t1000 = 4 + _t1524 = 4 else: if self.match_lookahead_literal(">", 1): - _t1001 = 3 + _t1525 = 3 else: if self.match_lookahead_literal("=", 1): - _t1002 = 0 + _t1526 = 0 else: if self.match_lookahead_literal("<=", 1): - _t1003 = 2 + _t1527 = 2 else: if self.match_lookahead_literal("<", 1): - _t1004 = 1 + _t1528 = 1 else: if self.match_lookahead_literal("/", 1): - _t1005 = 8 + _t1529 = 8 else: if self.match_lookahead_literal("-", 1): - _t1006 = 6 + _t1530 = 6 else: if self.match_lookahead_literal("+", 1): - _t1007 = 5 + _t1531 = 5 else: if self.match_lookahead_literal("*", 1): - _t1008 = 7 + _t1532 = 7 else: - _t1008 = -1 - _t1007 = _t1008 - _t1006 = _t1007 - _t1005 = _t1006 - _t1004 = _t1005 - _t1003 = _t1004 - _t1002 = _t1003 - _t1001 = _t1002 - _t1000 = _t1001 - _t999 = _t1000 - _t998 = _t999 - else: - _t998 = -1 - prediction506 = _t998 - if prediction506 == 9: + _t1532 = -1 + _t1531 = _t1532 + _t1530 = _t1531 + _t1529 = _t1530 + _t1528 = _t1529 + _t1527 = _t1528 + _t1526 = _t1527 + _t1525 = _t1526 + _t1524 = _t1525 + _t1523 = _t1524 + _t1522 = _t1523 + else: + _t1522 = -1 + prediction870 = _t1522 + if prediction870 == 9: self.consume_literal("(") self.consume_literal("primitive") - _t1010 = self.parse_name() - name516 = _t1010 - xs517 = [] - cond518 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond518: - _t1011 = self.parse_rel_term() - item519 = _t1011 - xs517.append(item519) - cond518 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - rel_terms520 = xs517 + self.push_path(1) + _t1534 = self.parse_name() + name880 = _t1534 + self.pop_path() + self.push_path(2) + xs885 = [] + cond886 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx887 = 0 + while cond886: + self.push_path(idx887) + _t1535 = self.parse_rel_term() + item888 = _t1535 + self.pop_path() + xs885.append(item888) + idx887 = (idx887 + 1) + cond886 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + rel_terms884 = xs885 + self.pop_path() self.consume_literal(")") - _t1012 = logic_pb2.Primitive(name=name516, terms=rel_terms520) - _t1009 = _t1012 + _t1536 = logic_pb2.Primitive(name=name880, terms=rel_terms884) + _t1533 = _t1536 else: - if prediction506 == 8: - _t1014 = self.parse_divide() - divide515 = _t1014 - _t1013 = divide515 + if prediction870 == 8: + _t1538 = self.parse_divide() + divide879 = _t1538 + _t1537 = divide879 else: - if prediction506 == 7: - _t1016 = self.parse_multiply() - multiply514 = _t1016 - _t1015 = multiply514 + if prediction870 == 7: + _t1540 = self.parse_multiply() + multiply878 = _t1540 + _t1539 = multiply878 else: - if prediction506 == 6: - _t1018 = self.parse_minus() - minus513 = _t1018 - _t1017 = minus513 + if prediction870 == 6: + _t1542 = self.parse_minus() + minus877 = _t1542 + _t1541 = minus877 else: - if prediction506 == 5: - _t1020 = self.parse_add() - add512 = _t1020 - _t1019 = add512 + if prediction870 == 5: + _t1544 = self.parse_add() + add876 = _t1544 + _t1543 = add876 else: - if prediction506 == 4: - _t1022 = self.parse_gt_eq() - gt_eq511 = _t1022 - _t1021 = gt_eq511 + if prediction870 == 4: + _t1546 = self.parse_gt_eq() + gt_eq875 = _t1546 + _t1545 = gt_eq875 else: - if prediction506 == 3: - _t1024 = self.parse_gt() - gt510 = _t1024 - _t1023 = gt510 + if prediction870 == 3: + _t1548 = self.parse_gt() + gt874 = _t1548 + _t1547 = gt874 else: - if prediction506 == 2: - _t1026 = self.parse_lt_eq() - lt_eq509 = _t1026 - _t1025 = lt_eq509 + if prediction870 == 2: + _t1550 = self.parse_lt_eq() + lt_eq873 = _t1550 + _t1549 = lt_eq873 else: - if prediction506 == 1: - _t1028 = self.parse_lt() - lt508 = _t1028 - _t1027 = lt508 + if prediction870 == 1: + _t1552 = self.parse_lt() + lt872 = _t1552 + _t1551 = lt872 else: - if prediction506 == 0: - _t1030 = self.parse_eq() - eq507 = _t1030 - _t1029 = eq507 + if prediction870 == 0: + _t1554 = self.parse_eq() + eq871 = _t1554 + _t1553 = eq871 else: raise ParseError("Unexpected token in primitive" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1027 = _t1029 - _t1025 = _t1027 - _t1023 = _t1025 - _t1021 = _t1023 - _t1019 = _t1021 - _t1017 = _t1019 - _t1015 = _t1017 - _t1013 = _t1015 - _t1009 = _t1013 - return _t1009 + _t1551 = _t1553 + _t1549 = _t1551 + _t1547 = _t1549 + _t1545 = _t1547 + _t1543 = _t1545 + _t1541 = _t1543 + _t1539 = _t1541 + _t1537 = _t1539 + _t1533 = _t1537 + result890 = _t1533 + self.record_span(span_start889) + return result890 def parse_eq(self) -> logic_pb2.Primitive: + span_start893 = self.span_start() self.consume_literal("(") self.consume_literal("=") - _t1031 = self.parse_term() - term521 = _t1031 - _t1032 = self.parse_term() - term_3522 = _t1032 - self.consume_literal(")") - _t1033 = logic_pb2.RelTerm(term=term521) - _t1034 = logic_pb2.RelTerm(term=term_3522) - _t1035 = logic_pb2.Primitive(name="rel_primitive_eq", terms=[_t1033, _t1034]) - return _t1035 + _t1555 = self.parse_term() + term891 = _t1555 + _t1556 = self.parse_term() + term_3892 = _t1556 + self.consume_literal(")") + _t1557 = logic_pb2.RelTerm(term=term891) + _t1558 = logic_pb2.RelTerm(term=term_3892) + _t1559 = logic_pb2.Primitive(name="rel_primitive_eq", terms=[_t1557, _t1558]) + result894 = _t1559 + self.record_span(span_start893) + return result894 def parse_lt(self) -> logic_pb2.Primitive: + span_start897 = self.span_start() self.consume_literal("(") self.consume_literal("<") - _t1036 = self.parse_term() - term523 = _t1036 - _t1037 = self.parse_term() - term_3524 = _t1037 - self.consume_literal(")") - _t1038 = logic_pb2.RelTerm(term=term523) - _t1039 = logic_pb2.RelTerm(term=term_3524) - _t1040 = logic_pb2.Primitive(name="rel_primitive_lt_monotype", terms=[_t1038, _t1039]) - return _t1040 + _t1560 = self.parse_term() + term895 = _t1560 + _t1561 = self.parse_term() + term_3896 = _t1561 + self.consume_literal(")") + _t1562 = logic_pb2.RelTerm(term=term895) + _t1563 = logic_pb2.RelTerm(term=term_3896) + _t1564 = logic_pb2.Primitive(name="rel_primitive_lt_monotype", terms=[_t1562, _t1563]) + result898 = _t1564 + self.record_span(span_start897) + return result898 def parse_lt_eq(self) -> logic_pb2.Primitive: + span_start901 = self.span_start() self.consume_literal("(") self.consume_literal("<=") - _t1041 = self.parse_term() - term525 = _t1041 - _t1042 = self.parse_term() - term_3526 = _t1042 - self.consume_literal(")") - _t1043 = logic_pb2.RelTerm(term=term525) - _t1044 = logic_pb2.RelTerm(term=term_3526) - _t1045 = logic_pb2.Primitive(name="rel_primitive_lt_eq_monotype", terms=[_t1043, _t1044]) - return _t1045 + _t1565 = self.parse_term() + term899 = _t1565 + _t1566 = self.parse_term() + term_3900 = _t1566 + self.consume_literal(")") + _t1567 = logic_pb2.RelTerm(term=term899) + _t1568 = logic_pb2.RelTerm(term=term_3900) + _t1569 = logic_pb2.Primitive(name="rel_primitive_lt_eq_monotype", terms=[_t1567, _t1568]) + result902 = _t1569 + self.record_span(span_start901) + return result902 def parse_gt(self) -> logic_pb2.Primitive: + span_start905 = self.span_start() self.consume_literal("(") self.consume_literal(">") - _t1046 = self.parse_term() - term527 = _t1046 - _t1047 = self.parse_term() - term_3528 = _t1047 - self.consume_literal(")") - _t1048 = logic_pb2.RelTerm(term=term527) - _t1049 = logic_pb2.RelTerm(term=term_3528) - _t1050 = logic_pb2.Primitive(name="rel_primitive_gt_monotype", terms=[_t1048, _t1049]) - return _t1050 + _t1570 = self.parse_term() + term903 = _t1570 + _t1571 = self.parse_term() + term_3904 = _t1571 + self.consume_literal(")") + _t1572 = logic_pb2.RelTerm(term=term903) + _t1573 = logic_pb2.RelTerm(term=term_3904) + _t1574 = logic_pb2.Primitive(name="rel_primitive_gt_monotype", terms=[_t1572, _t1573]) + result906 = _t1574 + self.record_span(span_start905) + return result906 def parse_gt_eq(self) -> logic_pb2.Primitive: + span_start909 = self.span_start() self.consume_literal("(") self.consume_literal(">=") - _t1051 = self.parse_term() - term529 = _t1051 - _t1052 = self.parse_term() - term_3530 = _t1052 - self.consume_literal(")") - _t1053 = logic_pb2.RelTerm(term=term529) - _t1054 = logic_pb2.RelTerm(term=term_3530) - _t1055 = logic_pb2.Primitive(name="rel_primitive_gt_eq_monotype", terms=[_t1053, _t1054]) - return _t1055 + _t1575 = self.parse_term() + term907 = _t1575 + _t1576 = self.parse_term() + term_3908 = _t1576 + self.consume_literal(")") + _t1577 = logic_pb2.RelTerm(term=term907) + _t1578 = logic_pb2.RelTerm(term=term_3908) + _t1579 = logic_pb2.Primitive(name="rel_primitive_gt_eq_monotype", terms=[_t1577, _t1578]) + result910 = _t1579 + self.record_span(span_start909) + return result910 def parse_add(self) -> logic_pb2.Primitive: + span_start914 = self.span_start() self.consume_literal("(") self.consume_literal("+") - _t1056 = self.parse_term() - term531 = _t1056 - _t1057 = self.parse_term() - term_3532 = _t1057 - _t1058 = self.parse_term() - term_4533 = _t1058 - self.consume_literal(")") - _t1059 = logic_pb2.RelTerm(term=term531) - _t1060 = logic_pb2.RelTerm(term=term_3532) - _t1061 = logic_pb2.RelTerm(term=term_4533) - _t1062 = logic_pb2.Primitive(name="rel_primitive_add_monotype", terms=[_t1059, _t1060, _t1061]) - return _t1062 + _t1580 = self.parse_term() + term911 = _t1580 + _t1581 = self.parse_term() + term_3912 = _t1581 + _t1582 = self.parse_term() + term_4913 = _t1582 + self.consume_literal(")") + _t1583 = logic_pb2.RelTerm(term=term911) + _t1584 = logic_pb2.RelTerm(term=term_3912) + _t1585 = logic_pb2.RelTerm(term=term_4913) + _t1586 = logic_pb2.Primitive(name="rel_primitive_add_monotype", terms=[_t1583, _t1584, _t1585]) + result915 = _t1586 + self.record_span(span_start914) + return result915 def parse_minus(self) -> logic_pb2.Primitive: + span_start919 = self.span_start() self.consume_literal("(") self.consume_literal("-") - _t1063 = self.parse_term() - term534 = _t1063 - _t1064 = self.parse_term() - term_3535 = _t1064 - _t1065 = self.parse_term() - term_4536 = _t1065 - self.consume_literal(")") - _t1066 = logic_pb2.RelTerm(term=term534) - _t1067 = logic_pb2.RelTerm(term=term_3535) - _t1068 = logic_pb2.RelTerm(term=term_4536) - _t1069 = logic_pb2.Primitive(name="rel_primitive_subtract_monotype", terms=[_t1066, _t1067, _t1068]) - return _t1069 + _t1587 = self.parse_term() + term916 = _t1587 + _t1588 = self.parse_term() + term_3917 = _t1588 + _t1589 = self.parse_term() + term_4918 = _t1589 + self.consume_literal(")") + _t1590 = logic_pb2.RelTerm(term=term916) + _t1591 = logic_pb2.RelTerm(term=term_3917) + _t1592 = logic_pb2.RelTerm(term=term_4918) + _t1593 = logic_pb2.Primitive(name="rel_primitive_subtract_monotype", terms=[_t1590, _t1591, _t1592]) + result920 = _t1593 + self.record_span(span_start919) + return result920 def parse_multiply(self) -> logic_pb2.Primitive: + span_start924 = self.span_start() self.consume_literal("(") self.consume_literal("*") - _t1070 = self.parse_term() - term537 = _t1070 - _t1071 = self.parse_term() - term_3538 = _t1071 - _t1072 = self.parse_term() - term_4539 = _t1072 - self.consume_literal(")") - _t1073 = logic_pb2.RelTerm(term=term537) - _t1074 = logic_pb2.RelTerm(term=term_3538) - _t1075 = logic_pb2.RelTerm(term=term_4539) - _t1076 = logic_pb2.Primitive(name="rel_primitive_multiply_monotype", terms=[_t1073, _t1074, _t1075]) - return _t1076 + _t1594 = self.parse_term() + term921 = _t1594 + _t1595 = self.parse_term() + term_3922 = _t1595 + _t1596 = self.parse_term() + term_4923 = _t1596 + self.consume_literal(")") + _t1597 = logic_pb2.RelTerm(term=term921) + _t1598 = logic_pb2.RelTerm(term=term_3922) + _t1599 = logic_pb2.RelTerm(term=term_4923) + _t1600 = logic_pb2.Primitive(name="rel_primitive_multiply_monotype", terms=[_t1597, _t1598, _t1599]) + result925 = _t1600 + self.record_span(span_start924) + return result925 def parse_divide(self) -> logic_pb2.Primitive: + span_start929 = self.span_start() self.consume_literal("(") self.consume_literal("/") - _t1077 = self.parse_term() - term540 = _t1077 - _t1078 = self.parse_term() - term_3541 = _t1078 - _t1079 = self.parse_term() - term_4542 = _t1079 - self.consume_literal(")") - _t1080 = logic_pb2.RelTerm(term=term540) - _t1081 = logic_pb2.RelTerm(term=term_3541) - _t1082 = logic_pb2.RelTerm(term=term_4542) - _t1083 = logic_pb2.Primitive(name="rel_primitive_divide_monotype", terms=[_t1080, _t1081, _t1082]) - return _t1083 + _t1601 = self.parse_term() + term926 = _t1601 + _t1602 = self.parse_term() + term_3927 = _t1602 + _t1603 = self.parse_term() + term_4928 = _t1603 + self.consume_literal(")") + _t1604 = logic_pb2.RelTerm(term=term926) + _t1605 = logic_pb2.RelTerm(term=term_3927) + _t1606 = logic_pb2.RelTerm(term=term_4928) + _t1607 = logic_pb2.Primitive(name="rel_primitive_divide_monotype", terms=[_t1604, _t1605, _t1606]) + result930 = _t1607 + self.record_span(span_start929) + return result930 def parse_rel_term(self) -> logic_pb2.RelTerm: + span_start934 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1084 = 1 + _t1608 = 1 else: if self.match_lookahead_literal("missing", 0): - _t1085 = 1 + _t1609 = 1 else: if self.match_lookahead_literal("false", 0): - _t1086 = 1 + _t1610 = 1 else: if self.match_lookahead_literal("(", 0): - _t1087 = 1 + _t1611 = 1 else: if self.match_lookahead_literal("#", 0): - _t1088 = 0 + _t1612 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t1089 = 1 + _t1613 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t1090 = 1 + _t1614 = 1 else: if self.match_lookahead_terminal("STRING", 0): - _t1091 = 1 + _t1615 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t1092 = 1 + _t1616 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t1093 = 1 + _t1617 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t1094 = 1 + _t1618 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t1095 = 1 + _t1619 = 1 else: - _t1095 = -1 - _t1094 = _t1095 - _t1093 = _t1094 - _t1092 = _t1093 - _t1091 = _t1092 - _t1090 = _t1091 - _t1089 = _t1090 - _t1088 = _t1089 - _t1087 = _t1088 - _t1086 = _t1087 - _t1085 = _t1086 - _t1084 = _t1085 - prediction543 = _t1084 - if prediction543 == 1: - _t1097 = self.parse_term() - term545 = _t1097 - _t1098 = logic_pb2.RelTerm(term=term545) - _t1096 = _t1098 - else: - if prediction543 == 0: - _t1100 = self.parse_specialized_value() - specialized_value544 = _t1100 - _t1101 = logic_pb2.RelTerm(specialized_value=specialized_value544) - _t1099 = _t1101 + _t1619 = -1 + _t1618 = _t1619 + _t1617 = _t1618 + _t1616 = _t1617 + _t1615 = _t1616 + _t1614 = _t1615 + _t1613 = _t1614 + _t1612 = _t1613 + _t1611 = _t1612 + _t1610 = _t1611 + _t1609 = _t1610 + _t1608 = _t1609 + prediction931 = _t1608 + if prediction931 == 1: + _t1621 = self.parse_term() + term933 = _t1621 + _t1622 = logic_pb2.RelTerm(term=term933) + _t1620 = _t1622 + else: + if prediction931 == 0: + _t1624 = self.parse_specialized_value() + specialized_value932 = _t1624 + _t1625 = logic_pb2.RelTerm(specialized_value=specialized_value932) + _t1623 = _t1625 else: raise ParseError("Unexpected token in rel_term" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1096 = _t1099 - return _t1096 + _t1620 = _t1623 + result935 = _t1620 + self.record_span(span_start934) + return result935 def parse_specialized_value(self) -> logic_pb2.Value: + span_start937 = self.span_start() self.consume_literal("#") - _t1102 = self.parse_value() - value546 = _t1102 - return value546 + _t1626 = self.parse_value() + value936 = _t1626 + result938 = value936 + self.record_span(span_start937) + return result938 def parse_rel_atom(self) -> logic_pb2.RelAtom: + span_start948 = self.span_start() self.consume_literal("(") self.consume_literal("relatom") - _t1103 = self.parse_name() - name547 = _t1103 - xs548 = [] - cond549 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond549: - _t1104 = self.parse_rel_term() - item550 = _t1104 - xs548.append(item550) - cond549 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - rel_terms551 = xs548 - self.consume_literal(")") - _t1105 = logic_pb2.RelAtom(name=name547, terms=rel_terms551) - return _t1105 + self.push_path(3) + _t1627 = self.parse_name() + name939 = _t1627 + self.pop_path() + self.push_path(2) + xs944 = [] + cond945 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx946 = 0 + while cond945: + self.push_path(idx946) + _t1628 = self.parse_rel_term() + item947 = _t1628 + self.pop_path() + xs944.append(item947) + idx946 = (idx946 + 1) + cond945 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + rel_terms943 = xs944 + self.pop_path() + self.consume_literal(")") + _t1629 = logic_pb2.RelAtom(name=name939, terms=rel_terms943) + result949 = _t1629 + self.record_span(span_start948) + return result949 def parse_cast(self) -> logic_pb2.Cast: + span_start952 = self.span_start() self.consume_literal("(") self.consume_literal("cast") - _t1106 = self.parse_term() - term552 = _t1106 - _t1107 = self.parse_term() - term_3553 = _t1107 - self.consume_literal(")") - _t1108 = logic_pb2.Cast(input=term552, result=term_3553) - return _t1108 + self.push_path(2) + _t1630 = self.parse_term() + term950 = _t1630 + self.pop_path() + self.push_path(3) + _t1631 = self.parse_term() + term_3951 = _t1631 + self.pop_path() + self.consume_literal(")") + _t1632 = logic_pb2.Cast(input=term950, result=term_3951) + result953 = _t1632 + self.record_span(span_start952) + return result953 def parse_attrs(self) -> Sequence[logic_pb2.Attribute]: + span_start958 = self.span_start() self.consume_literal("(") self.consume_literal("attrs") - xs554 = [] - cond555 = self.match_lookahead_literal("(", 0) - while cond555: - _t1109 = self.parse_attribute() - item556 = _t1109 - xs554.append(item556) - cond555 = self.match_lookahead_literal("(", 0) - attributes557 = xs554 - self.consume_literal(")") - return attributes557 + xs954 = [] + cond955 = self.match_lookahead_literal("(", 0) + while cond955: + _t1633 = self.parse_attribute() + item956 = _t1633 + xs954.append(item956) + cond955 = self.match_lookahead_literal("(", 0) + attributes957 = xs954 + self.consume_literal(")") + result959 = attributes957 + self.record_span(span_start958) + return result959 def parse_attribute(self) -> logic_pb2.Attribute: + span_start969 = self.span_start() self.consume_literal("(") self.consume_literal("attribute") - _t1110 = self.parse_name() - name558 = _t1110 - xs559 = [] - cond560 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond560: - _t1111 = self.parse_value() - item561 = _t1111 - xs559.append(item561) - cond560 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) - values562 = xs559 - self.consume_literal(")") - _t1112 = logic_pb2.Attribute(name=name558, args=values562) - return _t1112 + self.push_path(1) + _t1634 = self.parse_name() + name960 = _t1634 + self.pop_path() + self.push_path(2) + xs965 = [] + cond966 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx967 = 0 + while cond966: + self.push_path(idx967) + _t1635 = self.parse_value() + item968 = _t1635 + self.pop_path() + xs965.append(item968) + idx967 = (idx967 + 1) + cond966 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) + values964 = xs965 + self.pop_path() + self.consume_literal(")") + _t1636 = logic_pb2.Attribute(name=name960, args=values964) + result970 = _t1636 + self.record_span(span_start969) + return result970 def parse_algorithm(self) -> logic_pb2.Algorithm: + span_start980 = self.span_start() self.consume_literal("(") self.consume_literal("algorithm") - xs563 = [] - cond564 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - while cond564: - _t1113 = self.parse_relation_id() - item565 = _t1113 - xs563.append(item565) - cond564 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - relation_ids566 = xs563 - _t1114 = self.parse_script() - script567 = _t1114 - self.consume_literal(")") - _t1115 = logic_pb2.Algorithm(body=script567) - getattr(_t1115, 'global').extend(relation_ids566) - return _t1115 + self.push_path(1) + xs975 = [] + cond976 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + idx977 = 0 + while cond976: + self.push_path(idx977) + _t1637 = self.parse_relation_id() + item978 = _t1637 + self.pop_path() + xs975.append(item978) + idx977 = (idx977 + 1) + cond976 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + relation_ids974 = xs975 + self.pop_path() + self.push_path(2) + _t1638 = self.parse_script() + script979 = _t1638 + self.pop_path() + self.consume_literal(")") + _t1639 = logic_pb2.Algorithm(body=script979) + getattr(_t1639, 'global').extend(relation_ids974) + result981 = _t1639 + self.record_span(span_start980) + return result981 def parse_script(self) -> logic_pb2.Script: + span_start990 = self.span_start() self.consume_literal("(") self.consume_literal("script") - xs568 = [] - cond569 = self.match_lookahead_literal("(", 0) - while cond569: - _t1116 = self.parse_construct() - item570 = _t1116 - xs568.append(item570) - cond569 = self.match_lookahead_literal("(", 0) - constructs571 = xs568 - self.consume_literal(")") - _t1117 = logic_pb2.Script(constructs=constructs571) - return _t1117 + self.push_path(1) + xs986 = [] + cond987 = self.match_lookahead_literal("(", 0) + idx988 = 0 + while cond987: + self.push_path(idx988) + _t1640 = self.parse_construct() + item989 = _t1640 + self.pop_path() + xs986.append(item989) + idx988 = (idx988 + 1) + cond987 = self.match_lookahead_literal("(", 0) + constructs985 = xs986 + self.pop_path() + self.consume_literal(")") + _t1641 = logic_pb2.Script(constructs=constructs985) + result991 = _t1641 + self.record_span(span_start990) + return result991 def parse_construct(self) -> logic_pb2.Construct: + span_start995 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1119 = 1 + _t1643 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1120 = 1 + _t1644 = 1 else: if self.match_lookahead_literal("monoid", 1): - _t1121 = 1 + _t1645 = 1 else: if self.match_lookahead_literal("loop", 1): - _t1122 = 0 + _t1646 = 0 else: if self.match_lookahead_literal("break", 1): - _t1123 = 1 + _t1647 = 1 else: if self.match_lookahead_literal("assign", 1): - _t1124 = 1 + _t1648 = 1 else: - _t1124 = -1 - _t1123 = _t1124 - _t1122 = _t1123 - _t1121 = _t1122 - _t1120 = _t1121 - _t1119 = _t1120 - _t1118 = _t1119 - else: - _t1118 = -1 - prediction572 = _t1118 - if prediction572 == 1: - _t1126 = self.parse_instruction() - instruction574 = _t1126 - _t1127 = logic_pb2.Construct(instruction=instruction574) - _t1125 = _t1127 - else: - if prediction572 == 0: - _t1129 = self.parse_loop() - loop573 = _t1129 - _t1130 = logic_pb2.Construct(loop=loop573) - _t1128 = _t1130 + _t1648 = -1 + _t1647 = _t1648 + _t1646 = _t1647 + _t1645 = _t1646 + _t1644 = _t1645 + _t1643 = _t1644 + _t1642 = _t1643 + else: + _t1642 = -1 + prediction992 = _t1642 + if prediction992 == 1: + _t1650 = self.parse_instruction() + instruction994 = _t1650 + _t1651 = logic_pb2.Construct(instruction=instruction994) + _t1649 = _t1651 + else: + if prediction992 == 0: + _t1653 = self.parse_loop() + loop993 = _t1653 + _t1654 = logic_pb2.Construct(loop=loop993) + _t1652 = _t1654 else: raise ParseError("Unexpected token in construct" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1125 = _t1128 - return _t1125 + _t1649 = _t1652 + result996 = _t1649 + self.record_span(span_start995) + return result996 def parse_loop(self) -> logic_pb2.Loop: + span_start999 = self.span_start() self.consume_literal("(") self.consume_literal("loop") - _t1131 = self.parse_init() - init575 = _t1131 - _t1132 = self.parse_script() - script576 = _t1132 - self.consume_literal(")") - _t1133 = logic_pb2.Loop(init=init575, body=script576) - return _t1133 + self.push_path(1) + _t1655 = self.parse_init() + init997 = _t1655 + self.pop_path() + self.push_path(2) + _t1656 = self.parse_script() + script998 = _t1656 + self.pop_path() + self.consume_literal(")") + _t1657 = logic_pb2.Loop(init=init997, body=script998) + result1000 = _t1657 + self.record_span(span_start999) + return result1000 def parse_init(self) -> Sequence[logic_pb2.Instruction]: + span_start1005 = self.span_start() self.consume_literal("(") self.consume_literal("init") - xs577 = [] - cond578 = self.match_lookahead_literal("(", 0) - while cond578: - _t1134 = self.parse_instruction() - item579 = _t1134 - xs577.append(item579) - cond578 = self.match_lookahead_literal("(", 0) - instructions580 = xs577 - self.consume_literal(")") - return instructions580 + xs1001 = [] + cond1002 = self.match_lookahead_literal("(", 0) + while cond1002: + _t1658 = self.parse_instruction() + item1003 = _t1658 + xs1001.append(item1003) + cond1002 = self.match_lookahead_literal("(", 0) + instructions1004 = xs1001 + self.consume_literal(")") + result1006 = instructions1004 + self.record_span(span_start1005) + return result1006 def parse_instruction(self) -> logic_pb2.Instruction: + span_start1013 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1136 = 1 + _t1660 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1137 = 4 + _t1661 = 4 else: if self.match_lookahead_literal("monoid", 1): - _t1138 = 3 + _t1662 = 3 else: if self.match_lookahead_literal("break", 1): - _t1139 = 2 + _t1663 = 2 else: if self.match_lookahead_literal("assign", 1): - _t1140 = 0 + _t1664 = 0 else: - _t1140 = -1 - _t1139 = _t1140 - _t1138 = _t1139 - _t1137 = _t1138 - _t1136 = _t1137 - _t1135 = _t1136 - else: - _t1135 = -1 - prediction581 = _t1135 - if prediction581 == 4: - _t1142 = self.parse_monus_def() - monus_def586 = _t1142 - _t1143 = logic_pb2.Instruction(monus_def=monus_def586) - _t1141 = _t1143 - else: - if prediction581 == 3: - _t1145 = self.parse_monoid_def() - monoid_def585 = _t1145 - _t1146 = logic_pb2.Instruction(monoid_def=monoid_def585) - _t1144 = _t1146 + _t1664 = -1 + _t1663 = _t1664 + _t1662 = _t1663 + _t1661 = _t1662 + _t1660 = _t1661 + _t1659 = _t1660 + else: + _t1659 = -1 + prediction1007 = _t1659 + if prediction1007 == 4: + _t1666 = self.parse_monus_def() + monus_def1012 = _t1666 + _t1667 = logic_pb2.Instruction(monus_def=monus_def1012) + _t1665 = _t1667 + else: + if prediction1007 == 3: + _t1669 = self.parse_monoid_def() + monoid_def1011 = _t1669 + _t1670 = logic_pb2.Instruction(monoid_def=monoid_def1011) + _t1668 = _t1670 else: - if prediction581 == 2: - _t1148 = self.parse_break() - break584 = _t1148 - _t1149 = logic_pb2.Instruction() - getattr(_t1149, 'break').CopyFrom(break584) - _t1147 = _t1149 + if prediction1007 == 2: + _t1672 = self.parse_break() + break1010 = _t1672 + _t1673 = logic_pb2.Instruction() + getattr(_t1673, 'break').CopyFrom(break1010) + _t1671 = _t1673 else: - if prediction581 == 1: - _t1151 = self.parse_upsert() - upsert583 = _t1151 - _t1152 = logic_pb2.Instruction(upsert=upsert583) - _t1150 = _t1152 + if prediction1007 == 1: + _t1675 = self.parse_upsert() + upsert1009 = _t1675 + _t1676 = logic_pb2.Instruction(upsert=upsert1009) + _t1674 = _t1676 else: - if prediction581 == 0: - _t1154 = self.parse_assign() - assign582 = _t1154 - _t1155 = logic_pb2.Instruction(assign=assign582) - _t1153 = _t1155 + if prediction1007 == 0: + _t1678 = self.parse_assign() + assign1008 = _t1678 + _t1679 = logic_pb2.Instruction(assign=assign1008) + _t1677 = _t1679 else: raise ParseError("Unexpected token in instruction" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1150 = _t1153 - _t1147 = _t1150 - _t1144 = _t1147 - _t1141 = _t1144 - return _t1141 + _t1674 = _t1677 + _t1671 = _t1674 + _t1668 = _t1671 + _t1665 = _t1668 + result1014 = _t1665 + self.record_span(span_start1013) + return result1014 def parse_assign(self) -> logic_pb2.Assign: + span_start1018 = self.span_start() self.consume_literal("(") self.consume_literal("assign") - _t1156 = self.parse_relation_id() - relation_id587 = _t1156 - _t1157 = self.parse_abstraction() - abstraction588 = _t1157 + self.push_path(1) + _t1680 = self.parse_relation_id() + relation_id1015 = _t1680 + self.pop_path() + self.push_path(2) + _t1681 = self.parse_abstraction() + abstraction1016 = _t1681 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1159 = self.parse_attrs() - _t1158 = _t1159 + _t1683 = self.parse_attrs() + _t1682 = _t1683 else: - _t1158 = None - attrs589 = _t1158 + _t1682 = None + attrs1017 = _t1682 + self.pop_path() self.consume_literal(")") - _t1160 = logic_pb2.Assign(name=relation_id587, body=abstraction588, attrs=(attrs589 if attrs589 is not None else [])) - return _t1160 + _t1684 = logic_pb2.Assign(name=relation_id1015, body=abstraction1016, attrs=(attrs1017 if attrs1017 is not None else [])) + result1019 = _t1684 + self.record_span(span_start1018) + return result1019 def parse_upsert(self) -> logic_pb2.Upsert: + span_start1023 = self.span_start() self.consume_literal("(") self.consume_literal("upsert") - _t1161 = self.parse_relation_id() - relation_id590 = _t1161 - _t1162 = self.parse_abstraction_with_arity() - abstraction_with_arity591 = _t1162 + self.push_path(1) + _t1685 = self.parse_relation_id() + relation_id1020 = _t1685 + self.pop_path() + _t1686 = self.parse_abstraction_with_arity() + abstraction_with_arity1021 = _t1686 + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1164 = self.parse_attrs() - _t1163 = _t1164 + _t1688 = self.parse_attrs() + _t1687 = _t1688 else: - _t1163 = None - attrs592 = _t1163 + _t1687 = None + attrs1022 = _t1687 + self.pop_path() self.consume_literal(")") - _t1165 = logic_pb2.Upsert(name=relation_id590, body=abstraction_with_arity591[0], attrs=(attrs592 if attrs592 is not None else []), value_arity=abstraction_with_arity591[1]) - return _t1165 + _t1689 = logic_pb2.Upsert(name=relation_id1020, body=abstraction_with_arity1021[0], attrs=(attrs1022 if attrs1022 is not None else []), value_arity=abstraction_with_arity1021[1]) + result1024 = _t1689 + self.record_span(span_start1023) + return result1024 def parse_abstraction_with_arity(self) -> tuple[logic_pb2.Abstraction, int]: + span_start1027 = self.span_start() self.consume_literal("(") - _t1166 = self.parse_bindings() - bindings593 = _t1166 - _t1167 = self.parse_formula() - formula594 = _t1167 + _t1690 = self.parse_bindings() + bindings1025 = _t1690 + _t1691 = self.parse_formula() + formula1026 = _t1691 self.consume_literal(")") - _t1168 = logic_pb2.Abstraction(vars=(list(bindings593[0]) + list(bindings593[1] if bindings593[1] is not None else [])), value=formula594) - return (_t1168, len(bindings593[1]),) + _t1692 = logic_pb2.Abstraction(vars=(list(bindings1025[0]) + list(bindings1025[1] if bindings1025[1] is not None else [])), value=formula1026) + result1028 = (_t1692, len(bindings1025[1]),) + self.record_span(span_start1027) + return result1028 def parse_break(self) -> logic_pb2.Break: + span_start1032 = self.span_start() self.consume_literal("(") self.consume_literal("break") - _t1169 = self.parse_relation_id() - relation_id595 = _t1169 - _t1170 = self.parse_abstraction() - abstraction596 = _t1170 + self.push_path(1) + _t1693 = self.parse_relation_id() + relation_id1029 = _t1693 + self.pop_path() + self.push_path(2) + _t1694 = self.parse_abstraction() + abstraction1030 = _t1694 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1172 = self.parse_attrs() - _t1171 = _t1172 + _t1696 = self.parse_attrs() + _t1695 = _t1696 else: - _t1171 = None - attrs597 = _t1171 + _t1695 = None + attrs1031 = _t1695 + self.pop_path() self.consume_literal(")") - _t1173 = logic_pb2.Break(name=relation_id595, body=abstraction596, attrs=(attrs597 if attrs597 is not None else [])) - return _t1173 + _t1697 = logic_pb2.Break(name=relation_id1029, body=abstraction1030, attrs=(attrs1031 if attrs1031 is not None else [])) + result1033 = _t1697 + self.record_span(span_start1032) + return result1033 def parse_monoid_def(self) -> logic_pb2.MonoidDef: + span_start1038 = self.span_start() self.consume_literal("(") self.consume_literal("monoid") - _t1174 = self.parse_monoid() - monoid598 = _t1174 - _t1175 = self.parse_relation_id() - relation_id599 = _t1175 - _t1176 = self.parse_abstraction_with_arity() - abstraction_with_arity600 = _t1176 + self.push_path(1) + _t1698 = self.parse_monoid() + monoid1034 = _t1698 + self.pop_path() + self.push_path(2) + _t1699 = self.parse_relation_id() + relation_id1035 = _t1699 + self.pop_path() + _t1700 = self.parse_abstraction_with_arity() + abstraction_with_arity1036 = _t1700 + self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1178 = self.parse_attrs() - _t1177 = _t1178 + _t1702 = self.parse_attrs() + _t1701 = _t1702 else: - _t1177 = None - attrs601 = _t1177 + _t1701 = None + attrs1037 = _t1701 + self.pop_path() self.consume_literal(")") - _t1179 = logic_pb2.MonoidDef(monoid=monoid598, name=relation_id599, body=abstraction_with_arity600[0], attrs=(attrs601 if attrs601 is not None else []), value_arity=abstraction_with_arity600[1]) - return _t1179 + _t1703 = logic_pb2.MonoidDef(monoid=monoid1034, name=relation_id1035, body=abstraction_with_arity1036[0], attrs=(attrs1037 if attrs1037 is not None else []), value_arity=abstraction_with_arity1036[1]) + result1039 = _t1703 + self.record_span(span_start1038) + return result1039 def parse_monoid(self) -> logic_pb2.Monoid: + span_start1045 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("sum", 1): - _t1181 = 3 + _t1705 = 3 else: if self.match_lookahead_literal("or", 1): - _t1182 = 0 + _t1706 = 0 else: if self.match_lookahead_literal("min", 1): - _t1183 = 1 + _t1707 = 1 else: if self.match_lookahead_literal("max", 1): - _t1184 = 2 + _t1708 = 2 else: - _t1184 = -1 - _t1183 = _t1184 - _t1182 = _t1183 - _t1181 = _t1182 - _t1180 = _t1181 - else: - _t1180 = -1 - prediction602 = _t1180 - if prediction602 == 3: - _t1186 = self.parse_sum_monoid() - sum_monoid606 = _t1186 - _t1187 = logic_pb2.Monoid(sum_monoid=sum_monoid606) - _t1185 = _t1187 - else: - if prediction602 == 2: - _t1189 = self.parse_max_monoid() - max_monoid605 = _t1189 - _t1190 = logic_pb2.Monoid(max_monoid=max_monoid605) - _t1188 = _t1190 + _t1708 = -1 + _t1707 = _t1708 + _t1706 = _t1707 + _t1705 = _t1706 + _t1704 = _t1705 + else: + _t1704 = -1 + prediction1040 = _t1704 + if prediction1040 == 3: + _t1710 = self.parse_sum_monoid() + sum_monoid1044 = _t1710 + _t1711 = logic_pb2.Monoid(sum_monoid=sum_monoid1044) + _t1709 = _t1711 + else: + if prediction1040 == 2: + _t1713 = self.parse_max_monoid() + max_monoid1043 = _t1713 + _t1714 = logic_pb2.Monoid(max_monoid=max_monoid1043) + _t1712 = _t1714 else: - if prediction602 == 1: - _t1192 = self.parse_min_monoid() - min_monoid604 = _t1192 - _t1193 = logic_pb2.Monoid(min_monoid=min_monoid604) - _t1191 = _t1193 + if prediction1040 == 1: + _t1716 = self.parse_min_monoid() + min_monoid1042 = _t1716 + _t1717 = logic_pb2.Monoid(min_monoid=min_monoid1042) + _t1715 = _t1717 else: - if prediction602 == 0: - _t1195 = self.parse_or_monoid() - or_monoid603 = _t1195 - _t1196 = logic_pb2.Monoid(or_monoid=or_monoid603) - _t1194 = _t1196 + if prediction1040 == 0: + _t1719 = self.parse_or_monoid() + or_monoid1041 = _t1719 + _t1720 = logic_pb2.Monoid(or_monoid=or_monoid1041) + _t1718 = _t1720 else: raise ParseError("Unexpected token in monoid" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1191 = _t1194 - _t1188 = _t1191 - _t1185 = _t1188 - return _t1185 + _t1715 = _t1718 + _t1712 = _t1715 + _t1709 = _t1712 + result1046 = _t1709 + self.record_span(span_start1045) + return result1046 def parse_or_monoid(self) -> logic_pb2.OrMonoid: + span_start1047 = self.span_start() self.consume_literal("(") self.consume_literal("or") self.consume_literal(")") - _t1197 = logic_pb2.OrMonoid() - return _t1197 + _t1721 = logic_pb2.OrMonoid() + result1048 = _t1721 + self.record_span(span_start1047) + return result1048 def parse_min_monoid(self) -> logic_pb2.MinMonoid: + span_start1050 = self.span_start() self.consume_literal("(") self.consume_literal("min") - _t1198 = self.parse_type() - type607 = _t1198 + self.push_path(1) + _t1722 = self.parse_type() + type1049 = _t1722 + self.pop_path() self.consume_literal(")") - _t1199 = logic_pb2.MinMonoid(type=type607) - return _t1199 + _t1723 = logic_pb2.MinMonoid(type=type1049) + result1051 = _t1723 + self.record_span(span_start1050) + return result1051 def parse_max_monoid(self) -> logic_pb2.MaxMonoid: + span_start1053 = self.span_start() self.consume_literal("(") self.consume_literal("max") - _t1200 = self.parse_type() - type608 = _t1200 + self.push_path(1) + _t1724 = self.parse_type() + type1052 = _t1724 + self.pop_path() self.consume_literal(")") - _t1201 = logic_pb2.MaxMonoid(type=type608) - return _t1201 + _t1725 = logic_pb2.MaxMonoid(type=type1052) + result1054 = _t1725 + self.record_span(span_start1053) + return result1054 def parse_sum_monoid(self) -> logic_pb2.SumMonoid: + span_start1056 = self.span_start() self.consume_literal("(") self.consume_literal("sum") - _t1202 = self.parse_type() - type609 = _t1202 + self.push_path(1) + _t1726 = self.parse_type() + type1055 = _t1726 + self.pop_path() self.consume_literal(")") - _t1203 = logic_pb2.SumMonoid(type=type609) - return _t1203 + _t1727 = logic_pb2.SumMonoid(type=type1055) + result1057 = _t1727 + self.record_span(span_start1056) + return result1057 def parse_monus_def(self) -> logic_pb2.MonusDef: + span_start1062 = self.span_start() self.consume_literal("(") self.consume_literal("monus") - _t1204 = self.parse_monoid() - monoid610 = _t1204 - _t1205 = self.parse_relation_id() - relation_id611 = _t1205 - _t1206 = self.parse_abstraction_with_arity() - abstraction_with_arity612 = _t1206 + self.push_path(1) + _t1728 = self.parse_monoid() + monoid1058 = _t1728 + self.pop_path() + self.push_path(2) + _t1729 = self.parse_relation_id() + relation_id1059 = _t1729 + self.pop_path() + _t1730 = self.parse_abstraction_with_arity() + abstraction_with_arity1060 = _t1730 + self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1208 = self.parse_attrs() - _t1207 = _t1208 + _t1732 = self.parse_attrs() + _t1731 = _t1732 else: - _t1207 = None - attrs613 = _t1207 + _t1731 = None + attrs1061 = _t1731 + self.pop_path() self.consume_literal(")") - _t1209 = logic_pb2.MonusDef(monoid=monoid610, name=relation_id611, body=abstraction_with_arity612[0], attrs=(attrs613 if attrs613 is not None else []), value_arity=abstraction_with_arity612[1]) - return _t1209 + _t1733 = logic_pb2.MonusDef(monoid=monoid1058, name=relation_id1059, body=abstraction_with_arity1060[0], attrs=(attrs1061 if attrs1061 is not None else []), value_arity=abstraction_with_arity1060[1]) + result1063 = _t1733 + self.record_span(span_start1062) + return result1063 def parse_constraint(self) -> logic_pb2.Constraint: + span_start1068 = self.span_start() self.consume_literal("(") self.consume_literal("functional_dependency") - _t1210 = self.parse_relation_id() - relation_id614 = _t1210 - _t1211 = self.parse_abstraction() - abstraction615 = _t1211 - _t1212 = self.parse_functional_dependency_keys() - functional_dependency_keys616 = _t1212 - _t1213 = self.parse_functional_dependency_values() - functional_dependency_values617 = _t1213 - self.consume_literal(")") - _t1214 = logic_pb2.FunctionalDependency(guard=abstraction615, keys=functional_dependency_keys616, values=functional_dependency_values617) - _t1215 = logic_pb2.Constraint(name=relation_id614, functional_dependency=_t1214) - return _t1215 + self.push_path(2) + _t1734 = self.parse_relation_id() + relation_id1064 = _t1734 + self.pop_path() + _t1735 = self.parse_abstraction() + abstraction1065 = _t1735 + _t1736 = self.parse_functional_dependency_keys() + functional_dependency_keys1066 = _t1736 + _t1737 = self.parse_functional_dependency_values() + functional_dependency_values1067 = _t1737 + self.consume_literal(")") + _t1738 = logic_pb2.FunctionalDependency(guard=abstraction1065, keys=functional_dependency_keys1066, values=functional_dependency_values1067) + _t1739 = logic_pb2.Constraint(name=relation_id1064, functional_dependency=_t1738) + result1069 = _t1739 + self.record_span(span_start1068) + return result1069 def parse_functional_dependency_keys(self) -> Sequence[logic_pb2.Var]: + span_start1074 = self.span_start() self.consume_literal("(") self.consume_literal("keys") - xs618 = [] - cond619 = self.match_lookahead_terminal("SYMBOL", 0) - while cond619: - _t1216 = self.parse_var() - item620 = _t1216 - xs618.append(item620) - cond619 = self.match_lookahead_terminal("SYMBOL", 0) - vars621 = xs618 - self.consume_literal(")") - return vars621 + xs1070 = [] + cond1071 = self.match_lookahead_terminal("SYMBOL", 0) + while cond1071: + _t1740 = self.parse_var() + item1072 = _t1740 + xs1070.append(item1072) + cond1071 = self.match_lookahead_terminal("SYMBOL", 0) + vars1073 = xs1070 + self.consume_literal(")") + result1075 = vars1073 + self.record_span(span_start1074) + return result1075 def parse_functional_dependency_values(self) -> Sequence[logic_pb2.Var]: + span_start1080 = self.span_start() self.consume_literal("(") self.consume_literal("values") - xs622 = [] - cond623 = self.match_lookahead_terminal("SYMBOL", 0) - while cond623: - _t1217 = self.parse_var() - item624 = _t1217 - xs622.append(item624) - cond623 = self.match_lookahead_terminal("SYMBOL", 0) - vars625 = xs622 - self.consume_literal(")") - return vars625 + xs1076 = [] + cond1077 = self.match_lookahead_terminal("SYMBOL", 0) + while cond1077: + _t1741 = self.parse_var() + item1078 = _t1741 + xs1076.append(item1078) + cond1077 = self.match_lookahead_terminal("SYMBOL", 0) + vars1079 = xs1076 + self.consume_literal(")") + result1081 = vars1079 + self.record_span(span_start1080) + return result1081 def parse_data(self) -> logic_pb2.Data: + span_start1086 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t1219 = 0 + _t1743 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t1220 = 2 + _t1744 = 2 else: if self.match_lookahead_literal("betree_relation", 1): - _t1221 = 1 + _t1745 = 1 else: - _t1221 = -1 - _t1220 = _t1221 - _t1219 = _t1220 - _t1218 = _t1219 - else: - _t1218 = -1 - prediction626 = _t1218 - if prediction626 == 2: - _t1223 = self.parse_csv_data() - csv_data629 = _t1223 - _t1224 = logic_pb2.Data(csv_data=csv_data629) - _t1222 = _t1224 - else: - if prediction626 == 1: - _t1226 = self.parse_betree_relation() - betree_relation628 = _t1226 - _t1227 = logic_pb2.Data(betree_relation=betree_relation628) - _t1225 = _t1227 + _t1745 = -1 + _t1744 = _t1745 + _t1743 = _t1744 + _t1742 = _t1743 + else: + _t1742 = -1 + prediction1082 = _t1742 + if prediction1082 == 2: + _t1747 = self.parse_csv_data() + csv_data1085 = _t1747 + _t1748 = logic_pb2.Data(csv_data=csv_data1085) + _t1746 = _t1748 + else: + if prediction1082 == 1: + _t1750 = self.parse_betree_relation() + betree_relation1084 = _t1750 + _t1751 = logic_pb2.Data(betree_relation=betree_relation1084) + _t1749 = _t1751 else: - if prediction626 == 0: - _t1229 = self.parse_rel_edb() - rel_edb627 = _t1229 - _t1230 = logic_pb2.Data(rel_edb=rel_edb627) - _t1228 = _t1230 + if prediction1082 == 0: + _t1753 = self.parse_rel_edb() + rel_edb1083 = _t1753 + _t1754 = logic_pb2.Data(rel_edb=rel_edb1083) + _t1752 = _t1754 else: raise ParseError("Unexpected token in data" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1225 = _t1228 - _t1222 = _t1225 - return _t1222 + _t1749 = _t1752 + _t1746 = _t1749 + result1087 = _t1746 + self.record_span(span_start1086) + return result1087 def parse_rel_edb(self) -> logic_pb2.RelEDB: + span_start1091 = self.span_start() self.consume_literal("(") self.consume_literal("rel_edb") - _t1231 = self.parse_relation_id() - relation_id630 = _t1231 - _t1232 = self.parse_rel_edb_path() - rel_edb_path631 = _t1232 - _t1233 = self.parse_rel_edb_types() - rel_edb_types632 = _t1233 - self.consume_literal(")") - _t1234 = logic_pb2.RelEDB(target_id=relation_id630, path=rel_edb_path631, types=rel_edb_types632) - return _t1234 + self.push_path(1) + _t1755 = self.parse_relation_id() + relation_id1088 = _t1755 + self.pop_path() + self.push_path(2) + _t1756 = self.parse_rel_edb_path() + rel_edb_path1089 = _t1756 + self.pop_path() + self.push_path(3) + _t1757 = self.parse_rel_edb_types() + rel_edb_types1090 = _t1757 + self.pop_path() + self.consume_literal(")") + _t1758 = logic_pb2.RelEDB(target_id=relation_id1088, path=rel_edb_path1089, types=rel_edb_types1090) + result1092 = _t1758 + self.record_span(span_start1091) + return result1092 def parse_rel_edb_path(self) -> Sequence[str]: + span_start1097 = self.span_start() self.consume_literal("[") - xs633 = [] - cond634 = self.match_lookahead_terminal("STRING", 0) - while cond634: - item635 = self.consume_terminal("STRING") - xs633.append(item635) - cond634 = self.match_lookahead_terminal("STRING", 0) - strings636 = xs633 + xs1093 = [] + cond1094 = self.match_lookahead_terminal("STRING", 0) + while cond1094: + item1095 = self.consume_terminal("STRING") + xs1093.append(item1095) + cond1094 = self.match_lookahead_terminal("STRING", 0) + strings1096 = xs1093 self.consume_literal("]") - return strings636 + result1098 = strings1096 + self.record_span(span_start1097) + return result1098 def parse_rel_edb_types(self) -> Sequence[logic_pb2.Type]: + span_start1103 = self.span_start() self.consume_literal("[") - xs637 = [] - cond638 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond638: - _t1235 = self.parse_type() - item639 = _t1235 - xs637.append(item639) - cond638 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types640 = xs637 + xs1099 = [] + cond1100 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + while cond1100: + _t1759 = self.parse_type() + item1101 = _t1759 + xs1099.append(item1101) + cond1100 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1102 = xs1099 self.consume_literal("]") - return types640 + result1104 = types1102 + self.record_span(span_start1103) + return result1104 def parse_betree_relation(self) -> logic_pb2.BeTreeRelation: + span_start1107 = self.span_start() self.consume_literal("(") self.consume_literal("betree_relation") - _t1236 = self.parse_relation_id() - relation_id641 = _t1236 - _t1237 = self.parse_betree_info() - betree_info642 = _t1237 - self.consume_literal(")") - _t1238 = logic_pb2.BeTreeRelation(name=relation_id641, relation_info=betree_info642) - return _t1238 + self.push_path(1) + _t1760 = self.parse_relation_id() + relation_id1105 = _t1760 + self.pop_path() + self.push_path(2) + _t1761 = self.parse_betree_info() + betree_info1106 = _t1761 + self.pop_path() + self.consume_literal(")") + _t1762 = logic_pb2.BeTreeRelation(name=relation_id1105, relation_info=betree_info1106) + result1108 = _t1762 + self.record_span(span_start1107) + return result1108 def parse_betree_info(self) -> logic_pb2.BeTreeInfo: + span_start1112 = self.span_start() self.consume_literal("(") self.consume_literal("betree_info") - _t1239 = self.parse_betree_info_key_types() - betree_info_key_types643 = _t1239 - _t1240 = self.parse_betree_info_value_types() - betree_info_value_types644 = _t1240 - _t1241 = self.parse_config_dict() - config_dict645 = _t1241 - self.consume_literal(")") - _t1242 = self.construct_betree_info(betree_info_key_types643, betree_info_value_types644, config_dict645) - return _t1242 + _t1763 = self.parse_betree_info_key_types() + betree_info_key_types1109 = _t1763 + _t1764 = self.parse_betree_info_value_types() + betree_info_value_types1110 = _t1764 + _t1765 = self.parse_config_dict() + config_dict1111 = _t1765 + self.consume_literal(")") + _t1766 = self.construct_betree_info(betree_info_key_types1109, betree_info_value_types1110, config_dict1111) + result1113 = _t1766 + self.record_span(span_start1112) + return result1113 def parse_betree_info_key_types(self) -> Sequence[logic_pb2.Type]: + span_start1118 = self.span_start() self.consume_literal("(") self.consume_literal("key_types") - xs646 = [] - cond647 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond647: - _t1243 = self.parse_type() - item648 = _t1243 - xs646.append(item648) - cond647 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types649 = xs646 - self.consume_literal(")") - return types649 + xs1114 = [] + cond1115 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + while cond1115: + _t1767 = self.parse_type() + item1116 = _t1767 + xs1114.append(item1116) + cond1115 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1117 = xs1114 + self.consume_literal(")") + result1119 = types1117 + self.record_span(span_start1118) + return result1119 def parse_betree_info_value_types(self) -> Sequence[logic_pb2.Type]: + span_start1124 = self.span_start() self.consume_literal("(") self.consume_literal("value_types") - xs650 = [] - cond651 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond651: - _t1244 = self.parse_type() - item652 = _t1244 - xs650.append(item652) - cond651 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types653 = xs650 - self.consume_literal(")") - return types653 + xs1120 = [] + cond1121 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + while cond1121: + _t1768 = self.parse_type() + item1122 = _t1768 + xs1120.append(item1122) + cond1121 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1123 = xs1120 + self.consume_literal(")") + result1125 = types1123 + self.record_span(span_start1124) + return result1125 def parse_csv_data(self) -> logic_pb2.CSVData: + span_start1130 = self.span_start() self.consume_literal("(") self.consume_literal("csv_data") - _t1245 = self.parse_csvlocator() - csvlocator654 = _t1245 - _t1246 = self.parse_csv_config() - csv_config655 = _t1246 - _t1247 = self.parse_csv_columns() - csv_columns656 = _t1247 - _t1248 = self.parse_csv_asof() - csv_asof657 = _t1248 - self.consume_literal(")") - _t1249 = logic_pb2.CSVData(locator=csvlocator654, config=csv_config655, columns=csv_columns656, asof=csv_asof657) - return _t1249 + self.push_path(1) + _t1769 = self.parse_csvlocator() + csvlocator1126 = _t1769 + self.pop_path() + self.push_path(2) + _t1770 = self.parse_csv_config() + csv_config1127 = _t1770 + self.pop_path() + self.push_path(3) + _t1771 = self.parse_csv_columns() + csv_columns1128 = _t1771 + self.pop_path() + self.push_path(4) + _t1772 = self.parse_csv_asof() + csv_asof1129 = _t1772 + self.pop_path() + self.consume_literal(")") + _t1773 = logic_pb2.CSVData(locator=csvlocator1126, config=csv_config1127, columns=csv_columns1128, asof=csv_asof1129) + result1131 = _t1773 + self.record_span(span_start1130) + return result1131 def parse_csvlocator(self) -> logic_pb2.CSVLocator: + span_start1134 = self.span_start() self.consume_literal("(") self.consume_literal("csv_locator") + self.push_path(1) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("paths", 1)): - _t1251 = self.parse_csv_locator_paths() - _t1250 = _t1251 + _t1775 = self.parse_csv_locator_paths() + _t1774 = _t1775 else: - _t1250 = None - csv_locator_paths658 = _t1250 + _t1774 = None + csv_locator_paths1132 = _t1774 + self.pop_path() + self.push_path(2) if self.match_lookahead_literal("(", 0): - _t1253 = self.parse_csv_locator_inline_data() - _t1252 = _t1253 + _t1777 = self.parse_csv_locator_inline_data() + _t1776 = _t1777 else: - _t1252 = None - csv_locator_inline_data659 = _t1252 + _t1776 = None + csv_locator_inline_data1133 = _t1776 + self.pop_path() self.consume_literal(")") - _t1254 = logic_pb2.CSVLocator(paths=(csv_locator_paths658 if csv_locator_paths658 is not None else []), inline_data=(csv_locator_inline_data659 if csv_locator_inline_data659 is not None else "").encode()) - return _t1254 + _t1778 = logic_pb2.CSVLocator(paths=(csv_locator_paths1132 if csv_locator_paths1132 is not None else []), inline_data=(csv_locator_inline_data1133 if csv_locator_inline_data1133 is not None else "").encode()) + result1135 = _t1778 + self.record_span(span_start1134) + return result1135 def parse_csv_locator_paths(self) -> Sequence[str]: + span_start1140 = self.span_start() self.consume_literal("(") self.consume_literal("paths") - xs660 = [] - cond661 = self.match_lookahead_terminal("STRING", 0) - while cond661: - item662 = self.consume_terminal("STRING") - xs660.append(item662) - cond661 = self.match_lookahead_terminal("STRING", 0) - strings663 = xs660 - self.consume_literal(")") - return strings663 + xs1136 = [] + cond1137 = self.match_lookahead_terminal("STRING", 0) + while cond1137: + item1138 = self.consume_terminal("STRING") + xs1136.append(item1138) + cond1137 = self.match_lookahead_terminal("STRING", 0) + strings1139 = xs1136 + self.consume_literal(")") + result1141 = strings1139 + self.record_span(span_start1140) + return result1141 def parse_csv_locator_inline_data(self) -> str: + span_start1143 = self.span_start() self.consume_literal("(") self.consume_literal("inline_data") - string664 = self.consume_terminal("STRING") + string1142 = self.consume_terminal("STRING") self.consume_literal(")") - return string664 + result1144 = string1142 + self.record_span(span_start1143) + return result1144 def parse_csv_config(self) -> logic_pb2.CSVConfig: + span_start1146 = self.span_start() self.consume_literal("(") self.consume_literal("csv_config") - _t1255 = self.parse_config_dict() - config_dict665 = _t1255 + _t1779 = self.parse_config_dict() + config_dict1145 = _t1779 self.consume_literal(")") - _t1256 = self.construct_csv_config(config_dict665) - return _t1256 + _t1780 = self.construct_csv_config(config_dict1145) + result1147 = _t1780 + self.record_span(span_start1146) + return result1147 def parse_csv_columns(self) -> Sequence[logic_pb2.CSVColumn]: + span_start1152 = self.span_start() self.consume_literal("(") self.consume_literal("columns") - xs666 = [] - cond667 = self.match_lookahead_literal("(", 0) - while cond667: - _t1257 = self.parse_csv_column() - item668 = _t1257 - xs666.append(item668) - cond667 = self.match_lookahead_literal("(", 0) - csv_columns669 = xs666 - self.consume_literal(")") - return csv_columns669 + xs1148 = [] + cond1149 = self.match_lookahead_literal("(", 0) + while cond1149: + _t1781 = self.parse_csv_column() + item1150 = _t1781 + xs1148.append(item1150) + cond1149 = self.match_lookahead_literal("(", 0) + csv_columns1151 = xs1148 + self.consume_literal(")") + result1153 = csv_columns1151 + self.record_span(span_start1152) + return result1153 def parse_csv_column(self) -> logic_pb2.CSVColumn: + span_start1164 = self.span_start() self.consume_literal("(") self.consume_literal("column") - string670 = self.consume_terminal("STRING") - _t1258 = self.parse_relation_id() - relation_id671 = _t1258 + self.push_path(1) + string1154 = self.consume_terminal("STRING") + self.pop_path() + self.push_path(2) + _t1782 = self.parse_relation_id() + relation_id1155 = _t1782 + self.pop_path() self.consume_literal("[") - xs672 = [] - cond673 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond673: - _t1259 = self.parse_type() - item674 = _t1259 - xs672.append(item674) - cond673 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types675 = xs672 + self.push_path(3) + xs1160 = [] + cond1161 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + idx1162 = 0 + while cond1161: + self.push_path(idx1162) + _t1783 = self.parse_type() + item1163 = _t1783 + self.pop_path() + xs1160.append(item1163) + idx1162 = (idx1162 + 1) + cond1161 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1159 = xs1160 + self.pop_path() self.consume_literal("]") self.consume_literal(")") - _t1260 = logic_pb2.CSVColumn(column_name=string670, target_id=relation_id671, types=types675) - return _t1260 + _t1784 = logic_pb2.CSVColumn(column_name=string1154, target_id=relation_id1155, types=types1159) + result1165 = _t1784 + self.record_span(span_start1164) + return result1165 def parse_csv_asof(self) -> str: + span_start1167 = self.span_start() self.consume_literal("(") self.consume_literal("asof") - string676 = self.consume_terminal("STRING") + string1166 = self.consume_terminal("STRING") self.consume_literal(")") - return string676 + result1168 = string1166 + self.record_span(span_start1167) + return result1168 def parse_undefine(self) -> transactions_pb2.Undefine: + span_start1170 = self.span_start() self.consume_literal("(") self.consume_literal("undefine") - _t1261 = self.parse_fragment_id() - fragment_id677 = _t1261 + self.push_path(1) + _t1785 = self.parse_fragment_id() + fragment_id1169 = _t1785 + self.pop_path() self.consume_literal(")") - _t1262 = transactions_pb2.Undefine(fragment_id=fragment_id677) - return _t1262 + _t1786 = transactions_pb2.Undefine(fragment_id=fragment_id1169) + result1171 = _t1786 + self.record_span(span_start1170) + return result1171 def parse_context(self) -> transactions_pb2.Context: + span_start1180 = self.span_start() self.consume_literal("(") self.consume_literal("context") - xs678 = [] - cond679 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - while cond679: - _t1263 = self.parse_relation_id() - item680 = _t1263 - xs678.append(item680) - cond679 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - relation_ids681 = xs678 - self.consume_literal(")") - _t1264 = transactions_pb2.Context(relations=relation_ids681) - return _t1264 + self.push_path(1) + xs1176 = [] + cond1177 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + idx1178 = 0 + while cond1177: + self.push_path(idx1178) + _t1787 = self.parse_relation_id() + item1179 = _t1787 + self.pop_path() + xs1176.append(item1179) + idx1178 = (idx1178 + 1) + cond1177 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + relation_ids1175 = xs1176 + self.pop_path() + self.consume_literal(")") + _t1788 = transactions_pb2.Context(relations=relation_ids1175) + result1181 = _t1788 + self.record_span(span_start1180) + return result1181 def parse_snapshot(self) -> transactions_pb2.Snapshot: + span_start1184 = self.span_start() self.consume_literal("(") self.consume_literal("snapshot") - _t1265 = self.parse_rel_edb_path() - rel_edb_path682 = _t1265 - _t1266 = self.parse_relation_id() - relation_id683 = _t1266 - self.consume_literal(")") - _t1267 = transactions_pb2.Snapshot(destination_path=rel_edb_path682, source_relation=relation_id683) - return _t1267 + self.push_path(1) + _t1789 = self.parse_rel_edb_path() + rel_edb_path1182 = _t1789 + self.pop_path() + self.push_path(2) + _t1790 = self.parse_relation_id() + relation_id1183 = _t1790 + self.pop_path() + self.consume_literal(")") + _t1791 = transactions_pb2.Snapshot(destination_path=rel_edb_path1182, source_relation=relation_id1183) + result1185 = _t1791 + self.record_span(span_start1184) + return result1185 def parse_epoch_reads(self) -> Sequence[transactions_pb2.Read]: + span_start1190 = self.span_start() self.consume_literal("(") self.consume_literal("reads") - xs684 = [] - cond685 = self.match_lookahead_literal("(", 0) - while cond685: - _t1268 = self.parse_read() - item686 = _t1268 - xs684.append(item686) - cond685 = self.match_lookahead_literal("(", 0) - reads687 = xs684 - self.consume_literal(")") - return reads687 + xs1186 = [] + cond1187 = self.match_lookahead_literal("(", 0) + while cond1187: + _t1792 = self.parse_read() + item1188 = _t1792 + xs1186.append(item1188) + cond1187 = self.match_lookahead_literal("(", 0) + reads1189 = xs1186 + self.consume_literal(")") + result1191 = reads1189 + self.record_span(span_start1190) + return result1191 def parse_read(self) -> transactions_pb2.Read: + span_start1198 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("what_if", 1): - _t1270 = 2 + _t1794 = 2 else: if self.match_lookahead_literal("output", 1): - _t1271 = 1 + _t1795 = 1 else: if self.match_lookahead_literal("export", 1): - _t1272 = 4 + _t1796 = 4 else: if self.match_lookahead_literal("demand", 1): - _t1273 = 0 + _t1797 = 0 else: if self.match_lookahead_literal("abort", 1): - _t1274 = 3 + _t1798 = 3 else: - _t1274 = -1 - _t1273 = _t1274 - _t1272 = _t1273 - _t1271 = _t1272 - _t1270 = _t1271 - _t1269 = _t1270 - else: - _t1269 = -1 - prediction688 = _t1269 - if prediction688 == 4: - _t1276 = self.parse_export() - export693 = _t1276 - _t1277 = transactions_pb2.Read(export=export693) - _t1275 = _t1277 - else: - if prediction688 == 3: - _t1279 = self.parse_abort() - abort692 = _t1279 - _t1280 = transactions_pb2.Read(abort=abort692) - _t1278 = _t1280 + _t1798 = -1 + _t1797 = _t1798 + _t1796 = _t1797 + _t1795 = _t1796 + _t1794 = _t1795 + _t1793 = _t1794 + else: + _t1793 = -1 + prediction1192 = _t1793 + if prediction1192 == 4: + _t1800 = self.parse_export() + export1197 = _t1800 + _t1801 = transactions_pb2.Read(export=export1197) + _t1799 = _t1801 + else: + if prediction1192 == 3: + _t1803 = self.parse_abort() + abort1196 = _t1803 + _t1804 = transactions_pb2.Read(abort=abort1196) + _t1802 = _t1804 else: - if prediction688 == 2: - _t1282 = self.parse_what_if() - what_if691 = _t1282 - _t1283 = transactions_pb2.Read(what_if=what_if691) - _t1281 = _t1283 + if prediction1192 == 2: + _t1806 = self.parse_what_if() + what_if1195 = _t1806 + _t1807 = transactions_pb2.Read(what_if=what_if1195) + _t1805 = _t1807 else: - if prediction688 == 1: - _t1285 = self.parse_output() - output690 = _t1285 - _t1286 = transactions_pb2.Read(output=output690) - _t1284 = _t1286 + if prediction1192 == 1: + _t1809 = self.parse_output() + output1194 = _t1809 + _t1810 = transactions_pb2.Read(output=output1194) + _t1808 = _t1810 else: - if prediction688 == 0: - _t1288 = self.parse_demand() - demand689 = _t1288 - _t1289 = transactions_pb2.Read(demand=demand689) - _t1287 = _t1289 + if prediction1192 == 0: + _t1812 = self.parse_demand() + demand1193 = _t1812 + _t1813 = transactions_pb2.Read(demand=demand1193) + _t1811 = _t1813 else: raise ParseError("Unexpected token in read" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1284 = _t1287 - _t1281 = _t1284 - _t1278 = _t1281 - _t1275 = _t1278 - return _t1275 + _t1808 = _t1811 + _t1805 = _t1808 + _t1802 = _t1805 + _t1799 = _t1802 + result1199 = _t1799 + self.record_span(span_start1198) + return result1199 def parse_demand(self) -> transactions_pb2.Demand: + span_start1201 = self.span_start() self.consume_literal("(") self.consume_literal("demand") - _t1290 = self.parse_relation_id() - relation_id694 = _t1290 + self.push_path(1) + _t1814 = self.parse_relation_id() + relation_id1200 = _t1814 + self.pop_path() self.consume_literal(")") - _t1291 = transactions_pb2.Demand(relation_id=relation_id694) - return _t1291 + _t1815 = transactions_pb2.Demand(relation_id=relation_id1200) + result1202 = _t1815 + self.record_span(span_start1201) + return result1202 def parse_output(self) -> transactions_pb2.Output: + span_start1205 = self.span_start() self.consume_literal("(") self.consume_literal("output") - _t1292 = self.parse_name() - name695 = _t1292 - _t1293 = self.parse_relation_id() - relation_id696 = _t1293 - self.consume_literal(")") - _t1294 = transactions_pb2.Output(name=name695, relation_id=relation_id696) - return _t1294 + self.push_path(1) + _t1816 = self.parse_name() + name1203 = _t1816 + self.pop_path() + self.push_path(2) + _t1817 = self.parse_relation_id() + relation_id1204 = _t1817 + self.pop_path() + self.consume_literal(")") + _t1818 = transactions_pb2.Output(name=name1203, relation_id=relation_id1204) + result1206 = _t1818 + self.record_span(span_start1205) + return result1206 def parse_what_if(self) -> transactions_pb2.WhatIf: + span_start1209 = self.span_start() self.consume_literal("(") self.consume_literal("what_if") - _t1295 = self.parse_name() - name697 = _t1295 - _t1296 = self.parse_epoch() - epoch698 = _t1296 - self.consume_literal(")") - _t1297 = transactions_pb2.WhatIf(branch=name697, epoch=epoch698) - return _t1297 + self.push_path(1) + _t1819 = self.parse_name() + name1207 = _t1819 + self.pop_path() + self.push_path(2) + _t1820 = self.parse_epoch() + epoch1208 = _t1820 + self.pop_path() + self.consume_literal(")") + _t1821 = transactions_pb2.WhatIf(branch=name1207, epoch=epoch1208) + result1210 = _t1821 + self.record_span(span_start1209) + return result1210 def parse_abort(self) -> transactions_pb2.Abort: + span_start1213 = self.span_start() self.consume_literal("(") self.consume_literal("abort") + self.push_path(1) if (self.match_lookahead_literal(":", 0) and self.match_lookahead_terminal("SYMBOL", 1)): - _t1299 = self.parse_name() - _t1298 = _t1299 + _t1823 = self.parse_name() + _t1822 = _t1823 else: - _t1298 = None - name699 = _t1298 - _t1300 = self.parse_relation_id() - relation_id700 = _t1300 - self.consume_literal(")") - _t1301 = transactions_pb2.Abort(name=(name699 if name699 is not None else "abort"), relation_id=relation_id700) - return _t1301 + _t1822 = None + name1211 = _t1822 + self.pop_path() + self.push_path(2) + _t1824 = self.parse_relation_id() + relation_id1212 = _t1824 + self.pop_path() + self.consume_literal(")") + _t1825 = transactions_pb2.Abort(name=(name1211 if name1211 is not None else "abort"), relation_id=relation_id1212) + result1214 = _t1825 + self.record_span(span_start1213) + return result1214 def parse_export(self) -> transactions_pb2.Export: + span_start1216 = self.span_start() self.consume_literal("(") self.consume_literal("export") - _t1302 = self.parse_export_csv_config() - export_csv_config701 = _t1302 + self.push_path(1) + _t1826 = self.parse_export_csv_config() + export_csv_config1215 = _t1826 + self.pop_path() self.consume_literal(")") - _t1303 = transactions_pb2.Export(csv_config=export_csv_config701) - return _t1303 + _t1827 = transactions_pb2.Export(csv_config=export_csv_config1215) + result1217 = _t1827 + self.record_span(span_start1216) + return result1217 def parse_export_csv_config(self) -> transactions_pb2.ExportCSVConfig: + span_start1221 = self.span_start() self.consume_literal("(") self.consume_literal("export_csv_config") - _t1304 = self.parse_export_csv_path() - export_csv_path702 = _t1304 - _t1305 = self.parse_export_csv_columns() - export_csv_columns703 = _t1305 - _t1306 = self.parse_config_dict() - config_dict704 = _t1306 - self.consume_literal(")") - _t1307 = self.export_csv_config(export_csv_path702, export_csv_columns703, config_dict704) - return _t1307 + _t1828 = self.parse_export_csv_path() + export_csv_path1218 = _t1828 + _t1829 = self.parse_export_csv_columns() + export_csv_columns1219 = _t1829 + _t1830 = self.parse_config_dict() + config_dict1220 = _t1830 + self.consume_literal(")") + _t1831 = self.export_csv_config(export_csv_path1218, export_csv_columns1219, config_dict1220) + result1222 = _t1831 + self.record_span(span_start1221) + return result1222 def parse_export_csv_path(self) -> str: + span_start1224 = self.span_start() self.consume_literal("(") self.consume_literal("path") - string705 = self.consume_terminal("STRING") + string1223 = self.consume_terminal("STRING") self.consume_literal(")") - return string705 + result1225 = string1223 + self.record_span(span_start1224) + return result1225 def parse_export_csv_columns(self) -> Sequence[transactions_pb2.ExportCSVColumn]: + span_start1230 = self.span_start() self.consume_literal("(") self.consume_literal("columns") - xs706 = [] - cond707 = self.match_lookahead_literal("(", 0) - while cond707: - _t1308 = self.parse_export_csv_column() - item708 = _t1308 - xs706.append(item708) - cond707 = self.match_lookahead_literal("(", 0) - export_csv_columns709 = xs706 - self.consume_literal(")") - return export_csv_columns709 + xs1226 = [] + cond1227 = self.match_lookahead_literal("(", 0) + while cond1227: + _t1832 = self.parse_export_csv_column() + item1228 = _t1832 + xs1226.append(item1228) + cond1227 = self.match_lookahead_literal("(", 0) + export_csv_columns1229 = xs1226 + self.consume_literal(")") + result1231 = export_csv_columns1229 + self.record_span(span_start1230) + return result1231 def parse_export_csv_column(self) -> transactions_pb2.ExportCSVColumn: + span_start1234 = self.span_start() self.consume_literal("(") self.consume_literal("column") - string710 = self.consume_terminal("STRING") - _t1309 = self.parse_relation_id() - relation_id711 = _t1309 - self.consume_literal(")") - _t1310 = transactions_pb2.ExportCSVColumn(column_name=string710, column_data=relation_id711) - return _t1310 - - -def parse(input_str: str) -> Any: - """Parse input string and return parse tree.""" + self.push_path(1) + string1232 = self.consume_terminal("STRING") + self.pop_path() + self.push_path(2) + _t1833 = self.parse_relation_id() + relation_id1233 = _t1833 + self.pop_path() + self.consume_literal(")") + _t1834 = transactions_pb2.ExportCSVColumn(column_name=string1232, column_data=relation_id1233) + result1235 = _t1834 + self.record_span(span_start1234) + return result1235 + + +def parse(input_str: str) -> tuple[Any, dict[tuple[int, ...], Span]]: + """Parse input string and return (result, provenance) tuple.""" lexer = Lexer(input_str) - parser = Parser(lexer.tokens) + parser = Parser(lexer.tokens, input_str) result = parser.parse_transaction() # Check for unconsumed tokens (except EOF) if parser.pos < len(parser.tokens): remaining_token = parser.lookahead(0) if remaining_token.type != "$": raise ParseError(f"Unexpected token at end of input: {remaining_token}") - return result + return result, parser.provenance diff --git a/sdks/python/src/lqp/gen/pretty.py b/sdks/python/src/lqp/gen/pretty.py index e58dfdd5..d5f68277 100644 --- a/sdks/python/src/lqp/gen/pretty.py +++ b/sdks/python/src/lqp/gen/pretty.py @@ -14,9 +14,9 @@ import sys if sys.version_info >= (3, 11): - from typing import Any, IO, Never, Optional + from typing import Any, IO, Never else: - from typing import Any, IO, NoReturn as Never, Optional + from typing import Any, IO, NoReturn as Never from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 @@ -28,7 +28,7 @@ class ParseError(Exception): class PrettyPrinter: """Pretty printer for protobuf messages.""" - def __init__(self, io: Optional[IO[str]] = None, max_width: int = 92, print_symbolic_relation_ids: bool = True): + def __init__(self, io: IO[str] | None = None, max_width: int = 92, print_symbolic_relation_ids: bool = True): self.io = io if io is not None else StringIO() self.indent_stack: list[int] = [0] self.column = 0 @@ -82,7 +82,7 @@ def dedent(self) -> None: if len(self.indent_stack) > 1: self.indent_stack.pop() - def _try_flat(self, msg: Any, pretty_fn: Any) -> Optional[str]: + def _try_flat(self, msg: Any, pretty_fn: Any) -> str | None: """Try to render msg flat (space-separated). Return flat string if it fits, else None.""" msg_id = id(msg) if msg_id not in self._memo and msg_id not in self._computing: @@ -325,7 +325,7 @@ def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> str: assert name is not None return name - def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: + def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> logic_pb2.UInt128Value | None: name = self.relation_id_to_string(msg) if name is None: return self.relation_id_to_uint128(msg) @@ -4103,7 +4103,7 @@ def pprint_dispatch(self, msg): else: raise ParseError(f"no pretty printer for {type(msg)}") -def pretty(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: +def pretty(msg: Any, io: IO[str] | None = None, max_width: int = 92) -> str: """Pretty print a protobuf message and return the string representation.""" printer = PrettyPrinter(io, max_width=max_width) printer.pretty_transaction(msg) @@ -4111,7 +4111,7 @@ def pretty(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: return printer.get_output() -def pretty_debug(msg: Any, io: Optional[IO[str]] = None, max_width: int = 92) -> str: +def pretty_debug(msg: Any, io: IO[str] | None = None, max_width: int = 92) -> str: """Pretty print a protobuf message with raw relation IDs and debug info appended as comments.""" printer = PrettyPrinter(io, max_width=max_width, print_symbolic_relation_ids=False) printer.pretty_transaction(msg) diff --git a/sdks/python/src/lqp/generated_pretty_printer.py b/sdks/python/src/lqp/generated_pretty_printer.py deleted file mode 100644 index ea98ebf7..00000000 --- a/sdks/python/src/lqp/generated_pretty_printer.py +++ /dev/null @@ -1,4056 +0,0 @@ -""" -Auto-generated pretty printer. - -Generated from protobuf specifications. -Do not modify this file! If you need to modify the pretty printer, edit the generator code -in `python-tools/src/meta` or edit the protobuf specification in `proto/v1`. - - -Command: python -m meta.cli fragments.proto logic.proto transactions.proto --grammar grammar.y --printer python -""" - -from io import StringIO -from typing import Any, IO, Never, Optional - -from lqp.proto.v1 import logic_pb2, fragments_pb2, transactions_pb2 - - -class ParseError(Exception): - pass - - -class PrettyPrinter: - """Pretty printer for protobuf messages.""" - - def __init__(self, io: Optional[IO[str]] = None): - self.io = io if io is not None else StringIO() - self.indent_level = 0 - self.at_line_start = True - self._debug_info: dict[tuple[int, int], str] = {} - - def write(self, s: str) -> None: - """Write a string to the output, with indentation at line start.""" - if self.at_line_start and s.strip(): - self.io.write(' ' * self.indent_level) - self.at_line_start = False - self.io.write(s) - - def newline(self) -> None: - """Write a newline to the output.""" - self.io.write('\n') - self.at_line_start = True - - def indent(self, delta: int = 1) -> None: - """Increase indentation level.""" - self.indent_level += delta - - def dedent(self, delta: int = 1) -> None: - """Decrease indentation level.""" - self.indent_level = max(0, self.indent_level - delta) - - def get_output(self) -> str: - """Get the accumulated output as a string.""" - if isinstance(self.io, StringIO): - return self.io.getvalue() - return "" - - def format_decimal(self, msg: logic_pb2.DecimalValue) -> str: - """Format a DecimalValue as '.d'.""" - int_val: int = (msg.value.high << 64) | msg.value.low - if msg.value.high & (1 << 63): - int_val -= (1 << 128) - sign = "" - if int_val < 0: - sign = "-" - int_val = -int_val - digits = str(int_val) - scale = msg.scale - if scale <= 0: - decimal_str = digits + "." + "0" * (-scale) - elif scale >= len(digits): - decimal_str = "0." + "0" * (scale - len(digits)) + digits - else: - decimal_str = digits[:-scale] + "." + digits[-scale:] - return sign + decimal_str + "d" + str(msg.precision) - - def format_int128(self, msg: logic_pb2.Int128Value) -> str: - """Format an Int128Value protobuf message as a string with i128 suffix.""" - value = (msg.high << 64) | msg.low - if msg.high & (1 << 63): - value -= (1 << 128) - return str(value) + "i128" - - def format_uint128(self, msg: logic_pb2.UInt128Value) -> str: - """Format a UInt128Value protobuf message as a hex string.""" - value = (msg.high << 64) | msg.low - return f"0x{value:x}" - - def fragment_id_to_string(self, msg: fragments_pb2.FragmentId) -> str: - """Convert FragmentId to string representation.""" - return msg.id.decode('utf-8') if msg.id else "" - - def start_pretty_fragment(self, msg: fragments_pb2.Fragment) -> None: - """Extract debug info from Fragment for relation ID lookup.""" - debug_info = msg.debug_info - for rid, name in zip(debug_info.ids, debug_info.orig_names): - self._debug_info[(rid.id_low, rid.id_high)] = name - - def relation_id_to_string(self, msg: logic_pb2.RelationId) -> str: - """Convert RelationId to string representation using debug info.""" - return self._debug_info.get((msg.id_low, msg.id_high), "") - - def relation_id_to_int(self, msg: logic_pb2.RelationId) -> Optional[int]: - """Convert RelationId to int if it fits in signed 64-bit range.""" - value = (msg.id_high << 64) | msg.id_low - if value <= 0x7FFFFFFFFFFFFFFF: - return value - return None - - def relation_id_to_uint128(self, msg: logic_pb2.RelationId) -> logic_pb2.UInt128Value: - """Convert RelationId to UInt128Value representation.""" - return logic_pb2.UInt128Value(low=msg.id_low, high=msg.id_high) - - def format_string_value(self, s: str) -> str: - """Format a string value with double quotes for LQP output.""" - escaped = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t') - return '"' + escaped + '"' - - # --- Helper functions --- - - def _extract_value_int64(self, value: Optional[logic_pb2.Value], default: int) -> int: - assert value is not None - if (value is not None and value.HasField('int_value')): - assert value is not None - return value.int_value - return default - - def _extract_value_float64(self, value: Optional[logic_pb2.Value], default: float) -> float: - assert value is not None - if (value is not None and value.HasField('float_value')): - assert value is not None - return value.float_value - return default - - def _extract_value_string(self, value: Optional[logic_pb2.Value], default: str) -> str: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return value.string_value - return default - - def _extract_value_boolean(self, value: Optional[logic_pb2.Value], default: bool) -> bool: - assert value is not None - if (value is not None and value.HasField('boolean_value')): - assert value is not None - return value.boolean_value - return default - - def _extract_value_bytes(self, value: Optional[logic_pb2.Value], default: bytes) -> bytes: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return value.string_value.encode() - return default - - def _extract_value_uint128(self, value: Optional[logic_pb2.Value], default: logic_pb2.UInt128Value) -> logic_pb2.UInt128Value: - assert value is not None - if (value is not None and value.HasField('uint128_value')): - assert value is not None - return value.uint128_value - return default - - def _extract_value_string_list(self, value: Optional[logic_pb2.Value], default: list[str]) -> list[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return [value.string_value] - return default - - def _try_extract_value_int64(self, value: Optional[logic_pb2.Value]) -> Optional[int]: - assert value is not None - if (value is not None and value.HasField('int_value')): - assert value is not None - return value.int_value - return None - - def _try_extract_value_float64(self, value: Optional[logic_pb2.Value]) -> Optional[float]: - assert value is not None - if (value is not None and value.HasField('float_value')): - assert value is not None - return value.float_value - return None - - def _try_extract_value_string(self, value: Optional[logic_pb2.Value]) -> Optional[str]: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return value.string_value - return None - - def _try_extract_value_bytes(self, value: Optional[logic_pb2.Value]) -> Optional[bytes]: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return value.string_value.encode() - return None - - def _try_extract_value_uint128(self, value: Optional[logic_pb2.Value]) -> Optional[logic_pb2.UInt128Value]: - assert value is not None - if (value is not None and value.HasField('uint128_value')): - assert value is not None - return value.uint128_value - return None - - def _try_extract_value_string_list(self, value: Optional[logic_pb2.Value]) -> Optional[list[str]]: - assert value is not None - if (value is not None and value.HasField('string_value')): - assert value is not None - return [value.string_value] - return None - - def construct_csv_config(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: - config = dict(config_dict) - _t1290 = self._extract_value_int64(config.get('csv_header_row'), 1) - header_row = _t1290 - _t1291 = self._extract_value_int64(config.get('csv_skip'), 0) - skip = _t1291 - _t1292 = self._extract_value_string(config.get('csv_new_line'), '') - new_line = _t1292 - _t1293 = self._extract_value_string(config.get('csv_delimiter'), ',') - delimiter = _t1293 - _t1294 = self._extract_value_string(config.get('csv_quotechar'), '"') - quotechar = _t1294 - _t1295 = self._extract_value_string(config.get('csv_escapechar'), '"') - escapechar = _t1295 - _t1296 = self._extract_value_string(config.get('csv_comment'), '') - comment = _t1296 - _t1297 = self._extract_value_string_list(config.get('csv_missing_strings'), []) - missing_strings = _t1297 - _t1298 = self._extract_value_string(config.get('csv_decimal_separator'), '.') - decimal_separator = _t1298 - _t1299 = self._extract_value_string(config.get('csv_encoding'), 'utf-8') - encoding = _t1299 - _t1300 = self._extract_value_string(config.get('csv_compression'), 'auto') - compression = _t1300 - _t1301 = logic_pb2.CSVConfig(header_row=int(header_row), skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1301 - - def construct_betree_info(self, key_types: list[logic_pb2.Type], value_types: list[logic_pb2.Type], config_dict: list[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: - config = dict(config_dict) - _t1302 = self._try_extract_value_float64(config.get('betree_config_epsilon')) - epsilon = _t1302 - _t1303 = self._try_extract_value_int64(config.get('betree_config_max_pivots')) - max_pivots = _t1303 - _t1304 = self._try_extract_value_int64(config.get('betree_config_max_deltas')) - max_deltas = _t1304 - _t1305 = self._try_extract_value_int64(config.get('betree_config_max_leaf')) - max_leaf = _t1305 - _t1306 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1306 - _t1307 = self._try_extract_value_uint128(config.get('betree_locator_root_pageid')) - root_pageid = _t1307 - _t1308 = self._try_extract_value_bytes(config.get('betree_locator_inline_data')) - inline_data = _t1308 - _t1309 = self._try_extract_value_int64(config.get('betree_locator_element_count')) - element_count = _t1309 - _t1310 = self._try_extract_value_int64(config.get('betree_locator_tree_height')) - tree_height = _t1310 - _t1311 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1311 - _t1312 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1312 - - def default_configure(self) -> transactions_pb2.Configure: - _t1313 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1313 - _t1314 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1314 - - def construct_configure(self, config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: - config = dict(config_dict) - maintenance_level_val = config.get('ivm.maintenance_level') - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - if (maintenance_level_val is not None and maintenance_level_val.HasField('string_value')): - if maintenance_level_val.string_value == 'off': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - else: - if maintenance_level_val.string_value == 'auto': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO - else: - if maintenance_level_val.string_value == 'all': - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL - else: - maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1315 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1315 - _t1316 = self._extract_value_int64(config.get('semantics_version'), 0) - semantics_version = _t1316 - _t1317 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1317 - - def export_csv_config(self, path: str, columns: list[transactions_pb2.ExportCSVColumn], config_dict: list[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: - config = dict(config_dict) - _t1318 = self._extract_value_int64(config.get('partition_size'), 0) - partition_size = _t1318 - _t1319 = self._extract_value_string(config.get('compression'), '') - compression = _t1319 - _t1320 = self._extract_value_boolean(config.get('syntax_header_row'), True) - syntax_header_row = _t1320 - _t1321 = self._extract_value_string(config.get('syntax_missing_string'), '') - syntax_missing_string = _t1321 - _t1322 = self._extract_value_string(config.get('syntax_delim'), ',') - syntax_delim = _t1322 - _t1323 = self._extract_value_string(config.get('syntax_quotechar'), '"') - syntax_quotechar = _t1323 - _t1324 = self._extract_value_string(config.get('syntax_escapechar'), '\\') - syntax_escapechar = _t1324 - _t1325 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1325 - - def _make_value_int64(self, v: int) -> logic_pb2.Value: - _t1326 = logic_pb2.Value(int_value=v) - return _t1326 - - def _make_value_float64(self, v: float) -> logic_pb2.Value: - _t1327 = logic_pb2.Value(float_value=v) - return _t1327 - - def _make_value_string(self, v: str) -> logic_pb2.Value: - _t1328 = logic_pb2.Value(string_value=v) - return _t1328 - - def _make_value_boolean(self, v: bool) -> logic_pb2.Value: - _t1329 = logic_pb2.Value(boolean_value=v) - return _t1329 - - def _make_value_uint128(self, v: logic_pb2.UInt128Value) -> logic_pb2.Value: - _t1330 = logic_pb2.Value(uint128_value=v) - return _t1330 - - def is_default_configure(self, cfg: transactions_pb2.Configure) -> bool: - if cfg.semantics_version != 0: - return False - if cfg.ivm_config.level != transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - return False - return True - - def deconstruct_configure(self, msg: transactions_pb2.Configure) -> list[tuple[str, logic_pb2.Value]]: - result = [] - - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_AUTO: - _t1332 = self._make_value_string('auto') - result.append(('ivm.maintenance_level', _t1332,)) - _t1331 = None - else: - - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL: - _t1334 = self._make_value_string('all') - result.append(('ivm.maintenance_level', _t1334,)) - _t1333 = None - else: - - if msg.ivm_config.level == transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF: - _t1336 = self._make_value_string('off') - result.append(('ivm.maintenance_level', _t1336,)) - _t1335 = None - else: - _t1335 = None - _t1333 = _t1335 - _t1331 = _t1333 - _t1337 = self._make_value_int64(msg.semantics_version) - result.append(('semantics_version', _t1337,)) - return result - - def deconstruct_csv_config(self, msg: logic_pb2.CSVConfig) -> list[tuple[str, logic_pb2.Value]]: - result = [] - - if msg.header_row != 1: - _t1339 = self._make_value_int64(int(msg.header_row)) - result.append(('csv_header_row', _t1339,)) - _t1338 = None - else: - _t1338 = None - - if msg.skip != 0: - _t1341 = self._make_value_int64(msg.skip) - result.append(('csv_skip', _t1341,)) - _t1340 = None - else: - _t1340 = None - - if msg.new_line != '': - _t1343 = self._make_value_string(msg.new_line) - result.append(('csv_new_line', _t1343,)) - _t1342 = None - else: - _t1342 = None - - if msg.delimiter != ',': - _t1345 = self._make_value_string(msg.delimiter) - result.append(('csv_delimiter', _t1345,)) - _t1344 = None - else: - _t1344 = None - - if msg.quotechar != '"': - _t1347 = self._make_value_string(msg.quotechar) - result.append(('csv_quotechar', _t1347,)) - _t1346 = None - else: - _t1346 = None - - if msg.escapechar != '"': - _t1349 = self._make_value_string(msg.escapechar) - result.append(('csv_escapechar', _t1349,)) - _t1348 = None - else: - _t1348 = None - - if msg.comment != '': - _t1351 = self._make_value_string(msg.comment) - result.append(('csv_comment', _t1351,)) - _t1350 = None - else: - _t1350 = None - - if not len(msg.missing_strings) == 0: - _t1353 = self._make_value_string(msg.missing_strings[0]) - result.append(('csv_missing_strings', _t1353,)) - _t1352 = None - else: - _t1352 = None - - if msg.decimal_separator != '.': - _t1355 = self._make_value_string(msg.decimal_separator) - result.append(('csv_decimal_separator', _t1355,)) - _t1354 = None - else: - _t1354 = None - - if msg.encoding != 'utf-8': - _t1357 = self._make_value_string(msg.encoding) - result.append(('csv_encoding', _t1357,)) - _t1356 = None - else: - _t1356 = None - - if msg.compression != 'auto': - _t1359 = self._make_value_string(msg.compression) - result.append(('csv_compression', _t1359,)) - _t1358 = None - else: - _t1358 = None - return result - - def _maybe_push_float64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[float]) -> None: - - if val is not None: - assert val is not None - _t1361 = self._make_value_float64(val) - result.append((key, _t1361,)) - _t1360 = None - else: - _t1360 = None - return None - - def _maybe_push_int64(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[int]) -> None: - - if val is not None: - assert val is not None - _t1363 = self._make_value_int64(val) - result.append((key, _t1363,)) - _t1362 = None - else: - _t1362 = None - return None - - def _maybe_push_uint128(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[logic_pb2.UInt128Value]) -> None: - - if val is not None: - assert val is not None - _t1365 = self._make_value_uint128(val) - result.append((key, _t1365,)) - _t1364 = None - else: - _t1364 = None - return None - - def _maybe_push_bytes_as_string(self, result: list[tuple[str, logic_pb2.Value]], key: str, val: Optional[bytes]) -> None: - - if val is not None: - assert val is not None - _t1367 = self._make_value_string(val.decode('utf-8')) - result.append((key, _t1367,)) - _t1366 = None - else: - _t1366 = None - return None - - def deconstruct_betree_info_config(self, msg: logic_pb2.BeTreeInfo) -> list[tuple[str, logic_pb2.Value]]: - result = [] - _t1368 = self._maybe_push_float64(result, 'betree_config_epsilon', msg.storage_config.epsilon) - _t1369 = self._maybe_push_int64(result, 'betree_config_max_pivots', msg.storage_config.max_pivots) - _t1370 = self._maybe_push_int64(result, 'betree_config_max_deltas', msg.storage_config.max_deltas) - _t1371 = self._maybe_push_int64(result, 'betree_config_max_leaf', msg.storage_config.max_leaf) - - if msg.relation_locator.HasField('root_pageid'): - _t1373 = self._maybe_push_uint128(result, 'betree_locator_root_pageid', msg.relation_locator.root_pageid) - _t1372 = _t1373 - else: - _t1372 = None - - if msg.relation_locator.HasField('inline_data'): - _t1375 = self._maybe_push_bytes_as_string(result, 'betree_locator_inline_data', msg.relation_locator.inline_data) - _t1374 = _t1375 - else: - _t1374 = None - _t1376 = self._maybe_push_int64(result, 'betree_locator_element_count', msg.relation_locator.element_count) - _t1377 = self._maybe_push_int64(result, 'betree_locator_tree_height', msg.relation_locator.tree_height) - return result - - def deconstruct_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> list[tuple[str, logic_pb2.Value]]: - result = [] - assert msg.partition_size is not None - - if (msg.partition_size is not None and msg.partition_size != 0): - assert msg.partition_size is not None - _t1379 = self._make_value_int64(msg.partition_size) - result.append(('partition_size', _t1379,)) - _t1378 = None - else: - _t1378 = None - assert msg.compression is not None - - if (msg.compression is not None and msg.compression != ''): - assert msg.compression is not None - _t1381 = self._make_value_string(msg.compression) - result.append(('compression', _t1381,)) - _t1380 = None - else: - _t1380 = None - - if msg.syntax_header_row is not None: - assert msg.syntax_header_row is not None - _t1383 = self._make_value_boolean(msg.syntax_header_row) - result.append(('syntax_header_row', _t1383,)) - _t1382 = None - else: - _t1382 = None - assert msg.syntax_missing_string is not None - - if (msg.syntax_missing_string is not None and msg.syntax_missing_string != ''): - assert msg.syntax_missing_string is not None - _t1385 = self._make_value_string(msg.syntax_missing_string) - result.append(('syntax_missing_string', _t1385,)) - _t1384 = None - else: - _t1384 = None - assert msg.syntax_delim is not None - - if (msg.syntax_delim is not None and msg.syntax_delim != ','): - assert msg.syntax_delim is not None - _t1387 = self._make_value_string(msg.syntax_delim) - result.append(('syntax_delim', _t1387,)) - _t1386 = None - else: - _t1386 = None - assert msg.syntax_quotechar is not None - - if (msg.syntax_quotechar is not None and msg.syntax_quotechar != '"'): - assert msg.syntax_quotechar is not None - _t1389 = self._make_value_string(msg.syntax_quotechar) - result.append(('syntax_quotechar', _t1389,)) - _t1388 = None - else: - _t1388 = None - assert msg.syntax_escapechar is not None - - if (msg.syntax_escapechar is not None and msg.syntax_escapechar != '\\'): - assert msg.syntax_escapechar is not None - _t1391 = self._make_value_string(msg.syntax_escapechar) - result.append(('syntax_escapechar', _t1391,)) - _t1390 = None - else: - _t1390 = None - return result - - def deconstruct_relation_id_string(self, msg: logic_pb2.RelationId) -> Optional[str]: - name = self.relation_id_to_string(msg) - if name != '': - return name - return None - - def deconstruct_relation_id_uint128(self, msg: logic_pb2.RelationId) -> Optional[logic_pb2.UInt128Value]: - name = self.relation_id_to_string(msg) - if name == '': - return self.relation_id_to_uint128(msg) - return None - - def deconstruct_bindings(self, abs: logic_pb2.Abstraction) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - n = len(abs.vars) - return (abs.vars[0:n], [],) - - def deconstruct_bindings_with_arity(self, abs: logic_pb2.Abstraction, value_arity: int) -> tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]: - n = len(abs.vars) - key_end = (n - value_arity) - return (abs.vars[0:key_end], abs.vars[key_end:n],) - - # --- Pretty-print methods --- - - def pretty_transaction(self, msg: transactions_pb2.Transaction) -> Optional[Never]: - def _t491(_dollar_dollar): - - if _dollar_dollar.HasField('configure'): - _t492 = _dollar_dollar.configure - else: - _t492 = None - - if _dollar_dollar.HasField('sync'): - _t493 = _dollar_dollar.sync - else: - _t493 = None - return (_t492, _t493, _dollar_dollar.epochs,) - _t494 = _t491(msg) - fields0 = _t494 - assert fields0 is not None - unwrapped_fields1 = fields0 - self.write('(') - self.write('transaction') - self.indent() - field2 = unwrapped_fields1[0] - - if field2 is not None: - self.newline() - assert field2 is not None - opt_val3 = field2 - _t496 = self.pretty_configure(opt_val3) - _t495 = _t496 - else: - _t495 = None - field4 = unwrapped_fields1[1] - - if field4 is not None: - self.newline() - assert field4 is not None - opt_val5 = field4 - _t498 = self.pretty_sync(opt_val5) - _t497 = _t498 - else: - _t497 = None - field6 = unwrapped_fields1[2] - if not len(field6) == 0: - self.newline() - for i8, elem7 in enumerate(field6): - - if (i8 > 0): - self.newline() - _t499 = None - else: - _t499 = None - _t500 = self.pretty_epoch(elem7) - self.dedent() - self.write(')') - return None - - def pretty_configure(self, msg: transactions_pb2.Configure) -> Optional[Never]: - def _t501(_dollar_dollar): - _t502 = self.deconstruct_configure(_dollar_dollar) - return _t502 - _t503 = _t501(msg) - fields9 = _t503 - assert fields9 is not None - unwrapped_fields10 = fields9 - self.write('(') - self.write('configure') - self.indent() - self.newline() - _t504 = self.pretty_config_dict(unwrapped_fields10) - self.dedent() - self.write(')') - return None - - def pretty_config_dict(self, msg: list[tuple[str, logic_pb2.Value]]) -> Optional[Never]: - def _t505(_dollar_dollar): - return _dollar_dollar - _t506 = _t505(msg) - fields11 = _t506 - assert fields11 is not None - unwrapped_fields12 = fields11 - self.write('{') - if not len(unwrapped_fields12) == 0: - self.write(' ') - for i14, elem13 in enumerate(unwrapped_fields12): - - if (i14 > 0): - self.newline() - _t507 = None - else: - _t507 = None - _t508 = self.pretty_config_key_value(elem13) - self.write('}') - return None - - def pretty_config_key_value(self, msg: tuple[str, logic_pb2.Value]) -> Optional[Never]: - def _t509(_dollar_dollar): - return (_dollar_dollar[0], _dollar_dollar[1],) - _t510 = _t509(msg) - fields15 = _t510 - assert fields15 is not None - unwrapped_fields16 = fields15 - self.write(':') - field17 = unwrapped_fields16[0] - self.write(field17) - self.write(' ') - field18 = unwrapped_fields16[1] - _t511 = self.pretty_value(field18) - return _t511 - - def pretty_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t512(_dollar_dollar): - - if _dollar_dollar.HasField('date_value'): - _t513 = _dollar_dollar.date_value - else: - _t513 = None - return _t513 - _t514 = _t512(msg) - deconstruct_result29 = _t514 - - if deconstruct_result29 is not None: - _t516 = self.pretty_date(deconstruct_result29) - _t515 = _t516 - else: - def _t517(_dollar_dollar): - - if _dollar_dollar.HasField('datetime_value'): - _t518 = _dollar_dollar.datetime_value - else: - _t518 = None - return _t518 - _t519 = _t517(msg) - deconstruct_result28 = _t519 - - if deconstruct_result28 is not None: - _t521 = self.pretty_datetime(deconstruct_result28) - _t520 = _t521 - else: - def _t522(_dollar_dollar): - - if _dollar_dollar.HasField('string_value'): - _t523 = _dollar_dollar.string_value - else: - _t523 = None - return _t523 - _t524 = _t522(msg) - deconstruct_result27 = _t524 - - if deconstruct_result27 is not None: - self.write(self.format_string_value(deconstruct_result27)) - _t525 = None - else: - def _t526(_dollar_dollar): - - if _dollar_dollar.HasField('int_value'): - _t527 = _dollar_dollar.int_value - else: - _t527 = None - return _t527 - _t528 = _t526(msg) - deconstruct_result26 = _t528 - - if deconstruct_result26 is not None: - self.write(str(deconstruct_result26)) - _t529 = None - else: - def _t530(_dollar_dollar): - - if _dollar_dollar.HasField('float_value'): - _t531 = _dollar_dollar.float_value - else: - _t531 = None - return _t531 - _t532 = _t530(msg) - deconstruct_result25 = _t532 - - if deconstruct_result25 is not None: - self.write(str(deconstruct_result25)) - _t533 = None - else: - def _t534(_dollar_dollar): - - if _dollar_dollar.HasField('uint128_value'): - _t535 = _dollar_dollar.uint128_value - else: - _t535 = None - return _t535 - _t536 = _t534(msg) - deconstruct_result24 = _t536 - - if deconstruct_result24 is not None: - self.write(self.format_uint128(deconstruct_result24)) - _t537 = None - else: - def _t538(_dollar_dollar): - - if _dollar_dollar.HasField('int128_value'): - _t539 = _dollar_dollar.int128_value - else: - _t539 = None - return _t539 - _t540 = _t538(msg) - deconstruct_result23 = _t540 - - if deconstruct_result23 is not None: - self.write(self.format_int128(deconstruct_result23)) - _t541 = None - else: - def _t542(_dollar_dollar): - - if _dollar_dollar.HasField('decimal_value'): - _t543 = _dollar_dollar.decimal_value - else: - _t543 = None - return _t543 - _t544 = _t542(msg) - deconstruct_result22 = _t544 - - if deconstruct_result22 is not None: - self.write(self.format_decimal(deconstruct_result22)) - _t545 = None - else: - def _t546(_dollar_dollar): - - if _dollar_dollar.HasField('boolean_value'): - _t547 = _dollar_dollar.boolean_value - else: - _t547 = None - return _t547 - _t548 = _t546(msg) - deconstruct_result21 = _t548 - - if deconstruct_result21 is not None: - _t550 = self.pretty_boolean_value(deconstruct_result21) - _t549 = _t550 - else: - def _t551(_dollar_dollar): - return _dollar_dollar - _t552 = _t551(msg) - fields19 = _t552 - assert fields19 is not None - unwrapped_fields20 = fields19 - self.write('missing') - _t549 = None - _t545 = _t549 - _t541 = _t545 - _t537 = _t541 - _t533 = _t537 - _t529 = _t533 - _t525 = _t529 - _t520 = _t525 - _t515 = _t520 - return _t515 - - def pretty_date(self, msg: logic_pb2.DateValue) -> Optional[Never]: - def _t553(_dollar_dollar): - return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day),) - _t554 = _t553(msg) - fields30 = _t554 - assert fields30 is not None - unwrapped_fields31 = fields30 - self.write('(') - self.write('date') - self.indent() - self.newline() - field32 = unwrapped_fields31[0] - self.write(str(field32)) - self.newline() - field33 = unwrapped_fields31[1] - self.write(str(field33)) - self.newline() - field34 = unwrapped_fields31[2] - self.write(str(field34)) - self.dedent() - self.write(')') - return None - - def pretty_datetime(self, msg: logic_pb2.DateTimeValue) -> Optional[Never]: - def _t555(_dollar_dollar): - - if _dollar_dollar.microsecond != 0: - _t556 = int(_dollar_dollar.microsecond) - else: - _t556 = None - return (int(_dollar_dollar.year), int(_dollar_dollar.month), int(_dollar_dollar.day), int(_dollar_dollar.hour), int(_dollar_dollar.minute), int(_dollar_dollar.second), _t556,) - _t557 = _t555(msg) - fields35 = _t557 - assert fields35 is not None - unwrapped_fields36 = fields35 - self.write('(') - self.write('datetime') - self.indent() - self.newline() - field37 = unwrapped_fields36[0] - self.write(str(field37)) - self.newline() - field38 = unwrapped_fields36[1] - self.write(str(field38)) - self.newline() - field39 = unwrapped_fields36[2] - self.write(str(field39)) - self.newline() - field40 = unwrapped_fields36[3] - self.write(str(field40)) - self.newline() - field41 = unwrapped_fields36[4] - self.write(str(field41)) - self.newline() - field42 = unwrapped_fields36[5] - self.write(str(field42)) - field43 = unwrapped_fields36[6] - - if field43 is not None: - self.newline() - assert field43 is not None - opt_val44 = field43 - self.write(str(opt_val44)) - _t558 = None - else: - _t558 = None - self.dedent() - self.write(')') - return None - - def pretty_boolean_value(self, msg: bool) -> Optional[Never]: - def _t559(_dollar_dollar): - - if _dollar_dollar: - _t560 = () - else: - _t560 = None - return _t560 - _t561 = _t559(msg) - deconstruct_result47 = _t561 - - if deconstruct_result47 is not None: - self.write('true') - _t562 = None - else: - def _t563(_dollar_dollar): - return _dollar_dollar - _t564 = _t563(msg) - fields45 = _t564 - assert fields45 is not None - unwrapped_fields46 = fields45 - self.write('false') - _t562 = None - return _t562 - - def pretty_sync(self, msg: transactions_pb2.Sync) -> Optional[Never]: - def _t565(_dollar_dollar): - return _dollar_dollar.fragments - _t566 = _t565(msg) - fields48 = _t566 - assert fields48 is not None - unwrapped_fields49 = fields48 - self.write('(') - self.write('sync') - self.indent() - if not len(unwrapped_fields49) == 0: - self.newline() - for i51, elem50 in enumerate(unwrapped_fields49): - - if (i51 > 0): - self.newline() - _t567 = None - else: - _t567 = None - _t568 = self.pretty_fragment_id(elem50) - self.dedent() - self.write(')') - return None - - def pretty_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t569(_dollar_dollar): - return self.fragment_id_to_string(_dollar_dollar) - _t570 = _t569(msg) - fields52 = _t570 - assert fields52 is not None - unwrapped_fields53 = fields52 - self.write(':') - self.write(unwrapped_fields53) - return None - - def pretty_epoch(self, msg: transactions_pb2.Epoch) -> Optional[Never]: - def _t571(_dollar_dollar): - - if not len(_dollar_dollar.writes) == 0: - _t572 = _dollar_dollar.writes - else: - _t572 = None - - if not len(_dollar_dollar.reads) == 0: - _t573 = _dollar_dollar.reads - else: - _t573 = None - return (_t572, _t573,) - _t574 = _t571(msg) - fields54 = _t574 - assert fields54 is not None - unwrapped_fields55 = fields54 - self.write('(') - self.write('epoch') - self.indent() - field56 = unwrapped_fields55[0] - - if field56 is not None: - self.newline() - assert field56 is not None - opt_val57 = field56 - _t576 = self.pretty_epoch_writes(opt_val57) - _t575 = _t576 - else: - _t575 = None - field58 = unwrapped_fields55[1] - - if field58 is not None: - self.newline() - assert field58 is not None - opt_val59 = field58 - _t578 = self.pretty_epoch_reads(opt_val59) - _t577 = _t578 - else: - _t577 = None - self.dedent() - self.write(')') - return None - - def pretty_epoch_writes(self, msg: list[transactions_pb2.Write]) -> Optional[Never]: - def _t579(_dollar_dollar): - return _dollar_dollar - _t580 = _t579(msg) - fields60 = _t580 - assert fields60 is not None - unwrapped_fields61 = fields60 - self.write('(') - self.write('writes') - self.indent() - if not len(unwrapped_fields61) == 0: - self.newline() - for i63, elem62 in enumerate(unwrapped_fields61): - - if (i63 > 0): - self.newline() - _t581 = None - else: - _t581 = None - _t582 = self.pretty_write(elem62) - self.dedent() - self.write(')') - return None - - def pretty_write(self, msg: transactions_pb2.Write) -> Optional[Never]: - def _t583(_dollar_dollar): - - if _dollar_dollar.HasField('define'): - _t584 = _dollar_dollar.define - else: - _t584 = None - return _t584 - _t585 = _t583(msg) - deconstruct_result66 = _t585 - - if deconstruct_result66 is not None: - _t587 = self.pretty_define(deconstruct_result66) - _t586 = _t587 - else: - def _t588(_dollar_dollar): - - if _dollar_dollar.HasField('undefine'): - _t589 = _dollar_dollar.undefine - else: - _t589 = None - return _t589 - _t590 = _t588(msg) - deconstruct_result65 = _t590 - - if deconstruct_result65 is not None: - _t592 = self.pretty_undefine(deconstruct_result65) - _t591 = _t592 - else: - def _t593(_dollar_dollar): - - if _dollar_dollar.HasField('context'): - _t594 = _dollar_dollar.context - else: - _t594 = None - return _t594 - _t595 = _t593(msg) - deconstruct_result64 = _t595 - - if deconstruct_result64 is not None: - _t597 = self.pretty_context(deconstruct_result64) - _t596 = _t597 - else: - raise ParseError('No matching rule for write') - _t591 = _t596 - _t586 = _t591 - return _t586 - - def pretty_define(self, msg: transactions_pb2.Define) -> Optional[Never]: - def _t598(_dollar_dollar): - return _dollar_dollar.fragment - _t599 = _t598(msg) - fields67 = _t599 - assert fields67 is not None - unwrapped_fields68 = fields67 - self.write('(') - self.write('define') - self.indent() - self.newline() - _t600 = self.pretty_fragment(unwrapped_fields68) - self.dedent() - self.write(')') - return None - - def pretty_fragment(self, msg: fragments_pb2.Fragment) -> Optional[Never]: - def _t601(_dollar_dollar): - _t602 = self.start_pretty_fragment(_dollar_dollar) - return (_dollar_dollar.id, _dollar_dollar.declarations,) - _t603 = _t601(msg) - fields69 = _t603 - assert fields69 is not None - unwrapped_fields70 = fields69 - self.write('(') - self.write('fragment') - self.indent() - self.newline() - field71 = unwrapped_fields70[0] - _t604 = self.pretty_new_fragment_id(field71) - field72 = unwrapped_fields70[1] - if not len(field72) == 0: - self.newline() - for i74, elem73 in enumerate(field72): - - if (i74 > 0): - self.newline() - _t605 = None - else: - _t605 = None - _t606 = self.pretty_declaration(elem73) - self.dedent() - self.write(')') - return None - - def pretty_new_fragment_id(self, msg: fragments_pb2.FragmentId) -> Optional[Never]: - def _t607(_dollar_dollar): - return _dollar_dollar - _t608 = _t607(msg) - fields75 = _t608 - assert fields75 is not None - unwrapped_fields76 = fields75 - _t609 = self.pretty_fragment_id(unwrapped_fields76) - return _t609 - - def pretty_declaration(self, msg: logic_pb2.Declaration) -> Optional[Never]: - def _t610(_dollar_dollar): - - if _dollar_dollar.HasField('def'): - _t611 = getattr(_dollar_dollar, 'def') - else: - _t611 = None - return _t611 - _t612 = _t610(msg) - deconstruct_result80 = _t612 - - if deconstruct_result80 is not None: - _t614 = self.pretty_def(deconstruct_result80) - _t613 = _t614 - else: - def _t615(_dollar_dollar): - - if _dollar_dollar.HasField('algorithm'): - _t616 = _dollar_dollar.algorithm - else: - _t616 = None - return _t616 - _t617 = _t615(msg) - deconstruct_result79 = _t617 - - if deconstruct_result79 is not None: - _t619 = self.pretty_algorithm(deconstruct_result79) - _t618 = _t619 - else: - def _t620(_dollar_dollar): - - if _dollar_dollar.HasField('constraint'): - _t621 = _dollar_dollar.constraint - else: - _t621 = None - return _t621 - _t622 = _t620(msg) - deconstruct_result78 = _t622 - - if deconstruct_result78 is not None: - _t624 = self.pretty_constraint(deconstruct_result78) - _t623 = _t624 - else: - def _t625(_dollar_dollar): - - if _dollar_dollar.HasField('data'): - _t626 = _dollar_dollar.data - else: - _t626 = None - return _t626 - _t627 = _t625(msg) - deconstruct_result77 = _t627 - - if deconstruct_result77 is not None: - _t629 = self.pretty_data(deconstruct_result77) - _t628 = _t629 - else: - raise ParseError('No matching rule for declaration') - _t623 = _t628 - _t618 = _t623 - _t613 = _t618 - return _t613 - - def pretty_def(self, msg: logic_pb2.Def) -> Optional[Never]: - def _t630(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t631 = _dollar_dollar.attrs - else: - _t631 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t631,) - _t632 = _t630(msg) - fields81 = _t632 - assert fields81 is not None - unwrapped_fields82 = fields81 - self.write('(') - self.write('def') - self.indent() - self.newline() - field83 = unwrapped_fields82[0] - _t633 = self.pretty_relation_id(field83) - self.newline() - field84 = unwrapped_fields82[1] - _t634 = self.pretty_abstraction(field84) - field85 = unwrapped_fields82[2] - - if field85 is not None: - self.newline() - assert field85 is not None - opt_val86 = field85 - _t636 = self.pretty_attrs(opt_val86) - _t635 = _t636 - else: - _t635 = None - self.dedent() - self.write(')') - return None - - def pretty_relation_id(self, msg: logic_pb2.RelationId) -> Optional[Never]: - def _t637(_dollar_dollar): - _t638 = self.deconstruct_relation_id_string(_dollar_dollar) - return _t638 - _t639 = _t637(msg) - deconstruct_result88 = _t639 - - if deconstruct_result88 is not None: - self.write(':') - self.write(deconstruct_result88) - _t640 = None - else: - def _t641(_dollar_dollar): - _t642 = self.deconstruct_relation_id_uint128(_dollar_dollar) - return _t642 - _t643 = _t641(msg) - deconstruct_result87 = _t643 - - if deconstruct_result87 is not None: - self.write(self.format_uint128(deconstruct_result87)) - _t644 = None - else: - raise ParseError('No matching rule for relation_id') - _t640 = _t644 - return _t640 - - def pretty_abstraction(self, msg: logic_pb2.Abstraction) -> Optional[Never]: - def _t645(_dollar_dollar): - _t646 = self.deconstruct_bindings(_dollar_dollar) - return (_t646, _dollar_dollar.value,) - _t647 = _t645(msg) - fields89 = _t647 - assert fields89 is not None - unwrapped_fields90 = fields89 - self.write('(') - field91 = unwrapped_fields90[0] - _t648 = self.pretty_bindings(field91) - self.write(' ') - field92 = unwrapped_fields90[1] - _t649 = self.pretty_formula(field92) - self.write(')') - return None - - def pretty_bindings(self, msg: tuple[list[logic_pb2.Binding], list[logic_pb2.Binding]]) -> Optional[Never]: - def _t650(_dollar_dollar): - - if not len(_dollar_dollar[1]) == 0: - _t651 = _dollar_dollar[1] - else: - _t651 = None - return (_dollar_dollar[0], _t651,) - _t652 = _t650(msg) - fields93 = _t652 - assert fields93 is not None - unwrapped_fields94 = fields93 - self.write('[') - field95 = unwrapped_fields94[0] - for i97, elem96 in enumerate(field95): - - if (i97 > 0): - self.newline() - _t653 = None - else: - _t653 = None - _t654 = self.pretty_binding(elem96) - field98 = unwrapped_fields94[1] - - if field98 is not None: - self.write(' ') - assert field98 is not None - opt_val99 = field98 - _t656 = self.pretty_value_bindings(opt_val99) - _t655 = _t656 - else: - _t655 = None - self.write(']') - return None - - def pretty_binding(self, msg: logic_pb2.Binding) -> Optional[Never]: - def _t657(_dollar_dollar): - return (_dollar_dollar.var.name, _dollar_dollar.type,) - _t658 = _t657(msg) - fields100 = _t658 - assert fields100 is not None - unwrapped_fields101 = fields100 - field102 = unwrapped_fields101[0] - self.write(field102) - self.write('::') - field103 = unwrapped_fields101[1] - _t659 = self.pretty_type(field103) - return _t659 - - def pretty_type(self, msg: logic_pb2.Type) -> Optional[Never]: - def _t660(_dollar_dollar): - - if _dollar_dollar.HasField('unspecified_type'): - _t661 = _dollar_dollar.unspecified_type - else: - _t661 = None - return _t661 - _t662 = _t660(msg) - deconstruct_result114 = _t662 - - if deconstruct_result114 is not None: - _t664 = self.pretty_unspecified_type(deconstruct_result114) - _t663 = _t664 - else: - def _t665(_dollar_dollar): - - if _dollar_dollar.HasField('string_type'): - _t666 = _dollar_dollar.string_type - else: - _t666 = None - return _t666 - _t667 = _t665(msg) - deconstruct_result113 = _t667 - - if deconstruct_result113 is not None: - _t669 = self.pretty_string_type(deconstruct_result113) - _t668 = _t669 - else: - def _t670(_dollar_dollar): - - if _dollar_dollar.HasField('int_type'): - _t671 = _dollar_dollar.int_type - else: - _t671 = None - return _t671 - _t672 = _t670(msg) - deconstruct_result112 = _t672 - - if deconstruct_result112 is not None: - _t674 = self.pretty_int_type(deconstruct_result112) - _t673 = _t674 - else: - def _t675(_dollar_dollar): - - if _dollar_dollar.HasField('float_type'): - _t676 = _dollar_dollar.float_type - else: - _t676 = None - return _t676 - _t677 = _t675(msg) - deconstruct_result111 = _t677 - - if deconstruct_result111 is not None: - _t679 = self.pretty_float_type(deconstruct_result111) - _t678 = _t679 - else: - def _t680(_dollar_dollar): - - if _dollar_dollar.HasField('uint128_type'): - _t681 = _dollar_dollar.uint128_type - else: - _t681 = None - return _t681 - _t682 = _t680(msg) - deconstruct_result110 = _t682 - - if deconstruct_result110 is not None: - _t684 = self.pretty_uint128_type(deconstruct_result110) - _t683 = _t684 - else: - def _t685(_dollar_dollar): - - if _dollar_dollar.HasField('int128_type'): - _t686 = _dollar_dollar.int128_type - else: - _t686 = None - return _t686 - _t687 = _t685(msg) - deconstruct_result109 = _t687 - - if deconstruct_result109 is not None: - _t689 = self.pretty_int128_type(deconstruct_result109) - _t688 = _t689 - else: - def _t690(_dollar_dollar): - - if _dollar_dollar.HasField('date_type'): - _t691 = _dollar_dollar.date_type - else: - _t691 = None - return _t691 - _t692 = _t690(msg) - deconstruct_result108 = _t692 - - if deconstruct_result108 is not None: - _t694 = self.pretty_date_type(deconstruct_result108) - _t693 = _t694 - else: - def _t695(_dollar_dollar): - - if _dollar_dollar.HasField('datetime_type'): - _t696 = _dollar_dollar.datetime_type - else: - _t696 = None - return _t696 - _t697 = _t695(msg) - deconstruct_result107 = _t697 - - if deconstruct_result107 is not None: - _t699 = self.pretty_datetime_type(deconstruct_result107) - _t698 = _t699 - else: - def _t700(_dollar_dollar): - - if _dollar_dollar.HasField('missing_type'): - _t701 = _dollar_dollar.missing_type - else: - _t701 = None - return _t701 - _t702 = _t700(msg) - deconstruct_result106 = _t702 - - if deconstruct_result106 is not None: - _t704 = self.pretty_missing_type(deconstruct_result106) - _t703 = _t704 - else: - def _t705(_dollar_dollar): - - if _dollar_dollar.HasField('decimal_type'): - _t706 = _dollar_dollar.decimal_type - else: - _t706 = None - return _t706 - _t707 = _t705(msg) - deconstruct_result105 = _t707 - - if deconstruct_result105 is not None: - _t709 = self.pretty_decimal_type(deconstruct_result105) - _t708 = _t709 - else: - def _t710(_dollar_dollar): - - if _dollar_dollar.HasField('boolean_type'): - _t711 = _dollar_dollar.boolean_type - else: - _t711 = None - return _t711 - _t712 = _t710(msg) - deconstruct_result104 = _t712 - - if deconstruct_result104 is not None: - _t714 = self.pretty_boolean_type(deconstruct_result104) - _t713 = _t714 - else: - raise ParseError('No matching rule for type') - _t708 = _t713 - _t703 = _t708 - _t698 = _t703 - _t693 = _t698 - _t688 = _t693 - _t683 = _t688 - _t678 = _t683 - _t673 = _t678 - _t668 = _t673 - _t663 = _t668 - return _t663 - - def pretty_unspecified_type(self, msg: logic_pb2.UnspecifiedType) -> Optional[Never]: - def _t715(_dollar_dollar): - return _dollar_dollar - _t716 = _t715(msg) - fields115 = _t716 - assert fields115 is not None - unwrapped_fields116 = fields115 - self.write('UNKNOWN') - return None - - def pretty_string_type(self, msg: logic_pb2.StringType) -> Optional[Never]: - def _t717(_dollar_dollar): - return _dollar_dollar - _t718 = _t717(msg) - fields117 = _t718 - assert fields117 is not None - unwrapped_fields118 = fields117 - self.write('STRING') - return None - - def pretty_int_type(self, msg: logic_pb2.IntType) -> Optional[Never]: - def _t719(_dollar_dollar): - return _dollar_dollar - _t720 = _t719(msg) - fields119 = _t720 - assert fields119 is not None - unwrapped_fields120 = fields119 - self.write('INT') - return None - - def pretty_float_type(self, msg: logic_pb2.FloatType) -> Optional[Never]: - def _t721(_dollar_dollar): - return _dollar_dollar - _t722 = _t721(msg) - fields121 = _t722 - assert fields121 is not None - unwrapped_fields122 = fields121 - self.write('FLOAT') - return None - - def pretty_uint128_type(self, msg: logic_pb2.UInt128Type) -> Optional[Never]: - def _t723(_dollar_dollar): - return _dollar_dollar - _t724 = _t723(msg) - fields123 = _t724 - assert fields123 is not None - unwrapped_fields124 = fields123 - self.write('UINT128') - return None - - def pretty_int128_type(self, msg: logic_pb2.Int128Type) -> Optional[Never]: - def _t725(_dollar_dollar): - return _dollar_dollar - _t726 = _t725(msg) - fields125 = _t726 - assert fields125 is not None - unwrapped_fields126 = fields125 - self.write('INT128') - return None - - def pretty_date_type(self, msg: logic_pb2.DateType) -> Optional[Never]: - def _t727(_dollar_dollar): - return _dollar_dollar - _t728 = _t727(msg) - fields127 = _t728 - assert fields127 is not None - unwrapped_fields128 = fields127 - self.write('DATE') - return None - - def pretty_datetime_type(self, msg: logic_pb2.DateTimeType) -> Optional[Never]: - def _t729(_dollar_dollar): - return _dollar_dollar - _t730 = _t729(msg) - fields129 = _t730 - assert fields129 is not None - unwrapped_fields130 = fields129 - self.write('DATETIME') - return None - - def pretty_missing_type(self, msg: logic_pb2.MissingType) -> Optional[Never]: - def _t731(_dollar_dollar): - return _dollar_dollar - _t732 = _t731(msg) - fields131 = _t732 - assert fields131 is not None - unwrapped_fields132 = fields131 - self.write('MISSING') - return None - - def pretty_decimal_type(self, msg: logic_pb2.DecimalType) -> Optional[Never]: - def _t733(_dollar_dollar): - return (int(_dollar_dollar.precision), int(_dollar_dollar.scale),) - _t734 = _t733(msg) - fields133 = _t734 - assert fields133 is not None - unwrapped_fields134 = fields133 - self.write('(') - self.write('DECIMAL') - self.indent() - self.newline() - field135 = unwrapped_fields134[0] - self.write(str(field135)) - self.newline() - field136 = unwrapped_fields134[1] - self.write(str(field136)) - self.dedent() - self.write(')') - return None - - def pretty_boolean_type(self, msg: logic_pb2.BooleanType) -> Optional[Never]: - def _t735(_dollar_dollar): - return _dollar_dollar - _t736 = _t735(msg) - fields137 = _t736 - assert fields137 is not None - unwrapped_fields138 = fields137 - self.write('BOOLEAN') - return None - - def pretty_value_bindings(self, msg: list[logic_pb2.Binding]) -> Optional[Never]: - def _t737(_dollar_dollar): - return _dollar_dollar - _t738 = _t737(msg) - fields139 = _t738 - assert fields139 is not None - unwrapped_fields140 = fields139 - self.write('|') - if not len(unwrapped_fields140) == 0: - self.write(' ') - for i142, elem141 in enumerate(unwrapped_fields140): - - if (i142 > 0): - self.newline() - _t739 = None - else: - _t739 = None - _t740 = self.pretty_binding(elem141) - return None - - def pretty_formula(self, msg: logic_pb2.Formula) -> Optional[Never]: - def _t741(_dollar_dollar): - - if (_dollar_dollar.HasField('conjunction') and len(_dollar_dollar.conjunction.args) == 0): - _t742 = _dollar_dollar.conjunction - else: - _t742 = None - return _t742 - _t743 = _t741(msg) - deconstruct_result155 = _t743 - - if deconstruct_result155 is not None: - _t745 = self.pretty_true(deconstruct_result155) - _t744 = _t745 - else: - def _t746(_dollar_dollar): - - if (_dollar_dollar.HasField('disjunction') and len(_dollar_dollar.disjunction.args) == 0): - _t747 = _dollar_dollar.disjunction - else: - _t747 = None - return _t747 - _t748 = _t746(msg) - deconstruct_result154 = _t748 - - if deconstruct_result154 is not None: - _t750 = self.pretty_false(deconstruct_result154) - _t749 = _t750 - else: - def _t751(_dollar_dollar): - - if _dollar_dollar.HasField('exists'): - _t752 = _dollar_dollar.exists - else: - _t752 = None - return _t752 - _t753 = _t751(msg) - deconstruct_result153 = _t753 - - if deconstruct_result153 is not None: - _t755 = self.pretty_exists(deconstruct_result153) - _t754 = _t755 - else: - def _t756(_dollar_dollar): - - if _dollar_dollar.HasField('reduce'): - _t757 = _dollar_dollar.reduce - else: - _t757 = None - return _t757 - _t758 = _t756(msg) - deconstruct_result152 = _t758 - - if deconstruct_result152 is not None: - _t760 = self.pretty_reduce(deconstruct_result152) - _t759 = _t760 - else: - def _t761(_dollar_dollar): - - if (_dollar_dollar.HasField('conjunction') and not len(_dollar_dollar.conjunction.args) == 0): - _t762 = _dollar_dollar.conjunction - else: - _t762 = None - return _t762 - _t763 = _t761(msg) - deconstruct_result151 = _t763 - - if deconstruct_result151 is not None: - _t765 = self.pretty_conjunction(deconstruct_result151) - _t764 = _t765 - else: - def _t766(_dollar_dollar): - - if (_dollar_dollar.HasField('disjunction') and not len(_dollar_dollar.disjunction.args) == 0): - _t767 = _dollar_dollar.disjunction - else: - _t767 = None - return _t767 - _t768 = _t766(msg) - deconstruct_result150 = _t768 - - if deconstruct_result150 is not None: - _t770 = self.pretty_disjunction(deconstruct_result150) - _t769 = _t770 - else: - def _t771(_dollar_dollar): - - if _dollar_dollar.HasField('not'): - _t772 = getattr(_dollar_dollar, 'not') - else: - _t772 = None - return _t772 - _t773 = _t771(msg) - deconstruct_result149 = _t773 - - if deconstruct_result149 is not None: - _t775 = self.pretty_not(deconstruct_result149) - _t774 = _t775 - else: - def _t776(_dollar_dollar): - - if _dollar_dollar.HasField('ffi'): - _t777 = _dollar_dollar.ffi - else: - _t777 = None - return _t777 - _t778 = _t776(msg) - deconstruct_result148 = _t778 - - if deconstruct_result148 is not None: - _t780 = self.pretty_ffi(deconstruct_result148) - _t779 = _t780 - else: - def _t781(_dollar_dollar): - - if _dollar_dollar.HasField('atom'): - _t782 = _dollar_dollar.atom - else: - _t782 = None - return _t782 - _t783 = _t781(msg) - deconstruct_result147 = _t783 - - if deconstruct_result147 is not None: - _t785 = self.pretty_atom(deconstruct_result147) - _t784 = _t785 - else: - def _t786(_dollar_dollar): - - if _dollar_dollar.HasField('pragma'): - _t787 = _dollar_dollar.pragma - else: - _t787 = None - return _t787 - _t788 = _t786(msg) - deconstruct_result146 = _t788 - - if deconstruct_result146 is not None: - _t790 = self.pretty_pragma(deconstruct_result146) - _t789 = _t790 - else: - def _t791(_dollar_dollar): - - if _dollar_dollar.HasField('primitive'): - _t792 = _dollar_dollar.primitive - else: - _t792 = None - return _t792 - _t793 = _t791(msg) - deconstruct_result145 = _t793 - - if deconstruct_result145 is not None: - _t795 = self.pretty_primitive(deconstruct_result145) - _t794 = _t795 - else: - def _t796(_dollar_dollar): - - if _dollar_dollar.HasField('rel_atom'): - _t797 = _dollar_dollar.rel_atom - else: - _t797 = None - return _t797 - _t798 = _t796(msg) - deconstruct_result144 = _t798 - - if deconstruct_result144 is not None: - _t800 = self.pretty_rel_atom(deconstruct_result144) - _t799 = _t800 - else: - def _t801(_dollar_dollar): - - if _dollar_dollar.HasField('cast'): - _t802 = _dollar_dollar.cast - else: - _t802 = None - return _t802 - _t803 = _t801(msg) - deconstruct_result143 = _t803 - - if deconstruct_result143 is not None: - _t805 = self.pretty_cast(deconstruct_result143) - _t804 = _t805 - else: - raise ParseError('No matching rule for formula') - _t799 = _t804 - _t794 = _t799 - _t789 = _t794 - _t784 = _t789 - _t779 = _t784 - _t774 = _t779 - _t769 = _t774 - _t764 = _t769 - _t759 = _t764 - _t754 = _t759 - _t749 = _t754 - _t744 = _t749 - return _t744 - - def pretty_true(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t806(_dollar_dollar): - return _dollar_dollar - _t807 = _t806(msg) - fields156 = _t807 - assert fields156 is not None - unwrapped_fields157 = fields156 - self.write('(') - self.write('true') - self.write(')') - return None - - def pretty_false(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t808(_dollar_dollar): - return _dollar_dollar - _t809 = _t808(msg) - fields158 = _t809 - assert fields158 is not None - unwrapped_fields159 = fields158 - self.write('(') - self.write('false') - self.write(')') - return None - - def pretty_exists(self, msg: logic_pb2.Exists) -> Optional[Never]: - def _t810(_dollar_dollar): - _t811 = self.deconstruct_bindings(_dollar_dollar.body) - return (_t811, _dollar_dollar.body.value,) - _t812 = _t810(msg) - fields160 = _t812 - assert fields160 is not None - unwrapped_fields161 = fields160 - self.write('(') - self.write('exists') - self.indent() - self.newline() - field162 = unwrapped_fields161[0] - _t813 = self.pretty_bindings(field162) - self.newline() - field163 = unwrapped_fields161[1] - _t814 = self.pretty_formula(field163) - self.dedent() - self.write(')') - return None - - def pretty_reduce(self, msg: logic_pb2.Reduce) -> Optional[Never]: - def _t815(_dollar_dollar): - return (_dollar_dollar.op, _dollar_dollar.body, _dollar_dollar.terms,) - _t816 = _t815(msg) - fields164 = _t816 - assert fields164 is not None - unwrapped_fields165 = fields164 - self.write('(') - self.write('reduce') - self.indent() - self.newline() - field166 = unwrapped_fields165[0] - _t817 = self.pretty_abstraction(field166) - self.newline() - field167 = unwrapped_fields165[1] - _t818 = self.pretty_abstraction(field167) - self.newline() - field168 = unwrapped_fields165[2] - _t819 = self.pretty_terms(field168) - self.dedent() - self.write(')') - return None - - def pretty_terms(self, msg: list[logic_pb2.Term]) -> Optional[Never]: - def _t820(_dollar_dollar): - return _dollar_dollar - _t821 = _t820(msg) - fields169 = _t821 - assert fields169 is not None - unwrapped_fields170 = fields169 - self.write('(') - self.write('terms') - self.indent() - if not len(unwrapped_fields170) == 0: - self.newline() - for i172, elem171 in enumerate(unwrapped_fields170): - - if (i172 > 0): - self.newline() - _t822 = None - else: - _t822 = None - _t823 = self.pretty_term(elem171) - self.dedent() - self.write(')') - return None - - def pretty_term(self, msg: logic_pb2.Term) -> Optional[Never]: - def _t824(_dollar_dollar): - - if _dollar_dollar.HasField('var'): - _t825 = _dollar_dollar.var - else: - _t825 = None - return _t825 - _t826 = _t824(msg) - deconstruct_result174 = _t826 - - if deconstruct_result174 is not None: - _t828 = self.pretty_var(deconstruct_result174) - _t827 = _t828 - else: - def _t829(_dollar_dollar): - - if _dollar_dollar.HasField('constant'): - _t830 = _dollar_dollar.constant - else: - _t830 = None - return _t830 - _t831 = _t829(msg) - deconstruct_result173 = _t831 - - if deconstruct_result173 is not None: - _t833 = self.pretty_constant(deconstruct_result173) - _t832 = _t833 - else: - raise ParseError('No matching rule for term') - _t827 = _t832 - return _t827 - - def pretty_var(self, msg: logic_pb2.Var) -> Optional[Never]: - def _t834(_dollar_dollar): - return _dollar_dollar.name - _t835 = _t834(msg) - fields175 = _t835 - assert fields175 is not None - unwrapped_fields176 = fields175 - self.write(unwrapped_fields176) - return None - - def pretty_constant(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t836(_dollar_dollar): - return _dollar_dollar - _t837 = _t836(msg) - fields177 = _t837 - assert fields177 is not None - unwrapped_fields178 = fields177 - _t838 = self.pretty_value(unwrapped_fields178) - return _t838 - - def pretty_conjunction(self, msg: logic_pb2.Conjunction) -> Optional[Never]: - def _t839(_dollar_dollar): - return _dollar_dollar.args - _t840 = _t839(msg) - fields179 = _t840 - assert fields179 is not None - unwrapped_fields180 = fields179 - self.write('(') - self.write('and') - self.indent() - if not len(unwrapped_fields180) == 0: - self.newline() - for i182, elem181 in enumerate(unwrapped_fields180): - - if (i182 > 0): - self.newline() - _t841 = None - else: - _t841 = None - _t842 = self.pretty_formula(elem181) - self.dedent() - self.write(')') - return None - - def pretty_disjunction(self, msg: logic_pb2.Disjunction) -> Optional[Never]: - def _t843(_dollar_dollar): - return _dollar_dollar.args - _t844 = _t843(msg) - fields183 = _t844 - assert fields183 is not None - unwrapped_fields184 = fields183 - self.write('(') - self.write('or') - self.indent() - if not len(unwrapped_fields184) == 0: - self.newline() - for i186, elem185 in enumerate(unwrapped_fields184): - - if (i186 > 0): - self.newline() - _t845 = None - else: - _t845 = None - _t846 = self.pretty_formula(elem185) - self.dedent() - self.write(')') - return None - - def pretty_not(self, msg: logic_pb2.Not) -> Optional[Never]: - def _t847(_dollar_dollar): - return _dollar_dollar.arg - _t848 = _t847(msg) - fields187 = _t848 - assert fields187 is not None - unwrapped_fields188 = fields187 - self.write('(') - self.write('not') - self.indent() - self.newline() - _t849 = self.pretty_formula(unwrapped_fields188) - self.dedent() - self.write(')') - return None - - def pretty_ffi(self, msg: logic_pb2.FFI) -> Optional[Never]: - def _t850(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.args, _dollar_dollar.terms,) - _t851 = _t850(msg) - fields189 = _t851 - assert fields189 is not None - unwrapped_fields190 = fields189 - self.write('(') - self.write('ffi') - self.indent() - self.newline() - field191 = unwrapped_fields190[0] - _t852 = self.pretty_name(field191) - self.newline() - field192 = unwrapped_fields190[1] - _t853 = self.pretty_ffi_args(field192) - self.newline() - field193 = unwrapped_fields190[2] - _t854 = self.pretty_terms(field193) - self.dedent() - self.write(')') - return None - - def pretty_name(self, msg: str) -> Optional[Never]: - def _t855(_dollar_dollar): - return _dollar_dollar - _t856 = _t855(msg) - fields194 = _t856 - assert fields194 is not None - unwrapped_fields195 = fields194 - self.write(':') - self.write(unwrapped_fields195) - return None - - def pretty_ffi_args(self, msg: list[logic_pb2.Abstraction]) -> Optional[Never]: - def _t857(_dollar_dollar): - return _dollar_dollar - _t858 = _t857(msg) - fields196 = _t858 - assert fields196 is not None - unwrapped_fields197 = fields196 - self.write('(') - self.write('args') - self.indent() - if not len(unwrapped_fields197) == 0: - self.newline() - for i199, elem198 in enumerate(unwrapped_fields197): - - if (i199 > 0): - self.newline() - _t859 = None - else: - _t859 = None - _t860 = self.pretty_abstraction(elem198) - self.dedent() - self.write(')') - return None - - def pretty_atom(self, msg: logic_pb2.Atom) -> Optional[Never]: - def _t861(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.terms,) - _t862 = _t861(msg) - fields200 = _t862 - assert fields200 is not None - unwrapped_fields201 = fields200 - self.write('(') - self.write('atom') - self.indent() - self.newline() - field202 = unwrapped_fields201[0] - _t863 = self.pretty_relation_id(field202) - field203 = unwrapped_fields201[1] - if not len(field203) == 0: - self.newline() - for i205, elem204 in enumerate(field203): - - if (i205 > 0): - self.newline() - _t864 = None - else: - _t864 = None - _t865 = self.pretty_term(elem204) - self.dedent() - self.write(')') - return None - - def pretty_pragma(self, msg: logic_pb2.Pragma) -> Optional[Never]: - def _t866(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.terms,) - _t867 = _t866(msg) - fields206 = _t867 - assert fields206 is not None - unwrapped_fields207 = fields206 - self.write('(') - self.write('pragma') - self.indent() - self.newline() - field208 = unwrapped_fields207[0] - _t868 = self.pretty_name(field208) - field209 = unwrapped_fields207[1] - if not len(field209) == 0: - self.newline() - for i211, elem210 in enumerate(field209): - - if (i211 > 0): - self.newline() - _t869 = None - else: - _t869 = None - _t870 = self.pretty_term(elem210) - self.dedent() - self.write(')') - return None - - def pretty_primitive(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t871(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_eq': - _t872 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t872 = None - return _t872 - _t873 = _t871(msg) - guard_result226 = _t873 - - if guard_result226 is not None: - _t875 = self.pretty_eq(msg) - _t874 = _t875 - else: - def _t876(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t877 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t877 = None - return _t877 - _t878 = _t876(msg) - guard_result225 = _t878 - - if guard_result225 is not None: - _t880 = self.pretty_lt(msg) - _t879 = _t880 - else: - def _t881(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t882 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t882 = None - return _t882 - _t883 = _t881(msg) - guard_result224 = _t883 - - if guard_result224 is not None: - _t885 = self.pretty_lt_eq(msg) - _t884 = _t885 - else: - def _t886(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t887 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t887 = None - return _t887 - _t888 = _t886(msg) - guard_result223 = _t888 - - if guard_result223 is not None: - _t890 = self.pretty_gt(msg) - _t889 = _t890 - else: - def _t891(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t892 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t892 = None - return _t892 - _t893 = _t891(msg) - guard_result222 = _t893 - - if guard_result222 is not None: - _t895 = self.pretty_gt_eq(msg) - _t894 = _t895 - else: - def _t896(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t897 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t897 = None - return _t897 - _t898 = _t896(msg) - guard_result221 = _t898 - - if guard_result221 is not None: - _t900 = self.pretty_add(msg) - _t899 = _t900 - else: - def _t901(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t902 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t902 = None - return _t902 - _t903 = _t901(msg) - guard_result220 = _t903 - - if guard_result220 is not None: - _t905 = self.pretty_minus(msg) - _t904 = _t905 - else: - def _t906(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t907 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t907 = None - return _t907 - _t908 = _t906(msg) - guard_result219 = _t908 - - if guard_result219 is not None: - _t910 = self.pretty_multiply(msg) - _t909 = _t910 - else: - def _t911(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t912 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t912 = None - return _t912 - _t913 = _t911(msg) - guard_result218 = _t913 - - if guard_result218 is not None: - _t915 = self.pretty_divide(msg) - _t914 = _t915 - else: - def _t916(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.terms,) - _t917 = _t916(msg) - fields212 = _t917 - assert fields212 is not None - unwrapped_fields213 = fields212 - self.write('(') - self.write('primitive') - self.indent() - self.newline() - field214 = unwrapped_fields213[0] - _t918 = self.pretty_name(field214) - field215 = unwrapped_fields213[1] - if not len(field215) == 0: - self.newline() - for i217, elem216 in enumerate(field215): - - if (i217 > 0): - self.newline() - _t919 = None - else: - _t919 = None - _t920 = self.pretty_rel_term(elem216) - self.dedent() - self.write(')') - _t914 = None - _t909 = _t914 - _t904 = _t909 - _t899 = _t904 - _t894 = _t899 - _t889 = _t894 - _t884 = _t889 - _t879 = _t884 - _t874 = _t879 - return _t874 - - def pretty_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t921(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_eq': - _t922 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t922 = None - return _t922 - _t923 = _t921(msg) - fields227 = _t923 - assert fields227 is not None - unwrapped_fields228 = fields227 - self.write('(') - self.write('=') - self.indent() - self.newline() - field229 = unwrapped_fields228[0] - _t924 = self.pretty_term(field229) - self.newline() - field230 = unwrapped_fields228[1] - _t925 = self.pretty_term(field230) - self.dedent() - self.write(')') - return None - - def pretty_lt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t926(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_lt_monotype': - _t927 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t927 = None - return _t927 - _t928 = _t926(msg) - fields231 = _t928 - assert fields231 is not None - unwrapped_fields232 = fields231 - self.write('(') - self.write('<') - self.indent() - self.newline() - field233 = unwrapped_fields232[0] - _t929 = self.pretty_term(field233) - self.newline() - field234 = unwrapped_fields232[1] - _t930 = self.pretty_term(field234) - self.dedent() - self.write(')') - return None - - def pretty_lt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t931(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_lt_eq_monotype': - _t932 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t932 = None - return _t932 - _t933 = _t931(msg) - fields235 = _t933 - assert fields235 is not None - unwrapped_fields236 = fields235 - self.write('(') - self.write('<=') - self.indent() - self.newline() - field237 = unwrapped_fields236[0] - _t934 = self.pretty_term(field237) - self.newline() - field238 = unwrapped_fields236[1] - _t935 = self.pretty_term(field238) - self.dedent() - self.write(')') - return None - - def pretty_gt(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t936(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_gt_monotype': - _t937 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t937 = None - return _t937 - _t938 = _t936(msg) - fields239 = _t938 - assert fields239 is not None - unwrapped_fields240 = fields239 - self.write('(') - self.write('>') - self.indent() - self.newline() - field241 = unwrapped_fields240[0] - _t939 = self.pretty_term(field241) - self.newline() - field242 = unwrapped_fields240[1] - _t940 = self.pretty_term(field242) - self.dedent() - self.write(')') - return None - - def pretty_gt_eq(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t941(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_gt_eq_monotype': - _t942 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term,) - else: - _t942 = None - return _t942 - _t943 = _t941(msg) - fields243 = _t943 - assert fields243 is not None - unwrapped_fields244 = fields243 - self.write('(') - self.write('>=') - self.indent() - self.newline() - field245 = unwrapped_fields244[0] - _t944 = self.pretty_term(field245) - self.newline() - field246 = unwrapped_fields244[1] - _t945 = self.pretty_term(field246) - self.dedent() - self.write(')') - return None - - def pretty_add(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t946(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_add_monotype': - _t947 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t947 = None - return _t947 - _t948 = _t946(msg) - fields247 = _t948 - assert fields247 is not None - unwrapped_fields248 = fields247 - self.write('(') - self.write('+') - self.indent() - self.newline() - field249 = unwrapped_fields248[0] - _t949 = self.pretty_term(field249) - self.newline() - field250 = unwrapped_fields248[1] - _t950 = self.pretty_term(field250) - self.newline() - field251 = unwrapped_fields248[2] - _t951 = self.pretty_term(field251) - self.dedent() - self.write(')') - return None - - def pretty_minus(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t952(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_subtract_monotype': - _t953 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t953 = None - return _t953 - _t954 = _t952(msg) - fields252 = _t954 - assert fields252 is not None - unwrapped_fields253 = fields252 - self.write('(') - self.write('-') - self.indent() - self.newline() - field254 = unwrapped_fields253[0] - _t955 = self.pretty_term(field254) - self.newline() - field255 = unwrapped_fields253[1] - _t956 = self.pretty_term(field255) - self.newline() - field256 = unwrapped_fields253[2] - _t957 = self.pretty_term(field256) - self.dedent() - self.write(')') - return None - - def pretty_multiply(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t958(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_multiply_monotype': - _t959 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t959 = None - return _t959 - _t960 = _t958(msg) - fields257 = _t960 - assert fields257 is not None - unwrapped_fields258 = fields257 - self.write('(') - self.write('*') - self.indent() - self.newline() - field259 = unwrapped_fields258[0] - _t961 = self.pretty_term(field259) - self.newline() - field260 = unwrapped_fields258[1] - _t962 = self.pretty_term(field260) - self.newline() - field261 = unwrapped_fields258[2] - _t963 = self.pretty_term(field261) - self.dedent() - self.write(')') - return None - - def pretty_divide(self, msg: logic_pb2.Primitive) -> Optional[Never]: - def _t964(_dollar_dollar): - - if _dollar_dollar.name == 'rel_primitive_divide_monotype': - _t965 = (_dollar_dollar.terms[0].term, _dollar_dollar.terms[1].term, _dollar_dollar.terms[2].term,) - else: - _t965 = None - return _t965 - _t966 = _t964(msg) - fields262 = _t966 - assert fields262 is not None - unwrapped_fields263 = fields262 - self.write('(') - self.write('/') - self.indent() - self.newline() - field264 = unwrapped_fields263[0] - _t967 = self.pretty_term(field264) - self.newline() - field265 = unwrapped_fields263[1] - _t968 = self.pretty_term(field265) - self.newline() - field266 = unwrapped_fields263[2] - _t969 = self.pretty_term(field266) - self.dedent() - self.write(')') - return None - - def pretty_rel_term(self, msg: logic_pb2.RelTerm) -> Optional[Never]: - def _t970(_dollar_dollar): - - if _dollar_dollar.HasField('specialized_value'): - _t971 = _dollar_dollar.specialized_value - else: - _t971 = None - return _t971 - _t972 = _t970(msg) - deconstruct_result268 = _t972 - - if deconstruct_result268 is not None: - _t974 = self.pretty_specialized_value(deconstruct_result268) - _t973 = _t974 - else: - def _t975(_dollar_dollar): - - if _dollar_dollar.HasField('term'): - _t976 = _dollar_dollar.term - else: - _t976 = None - return _t976 - _t977 = _t975(msg) - deconstruct_result267 = _t977 - - if deconstruct_result267 is not None: - _t979 = self.pretty_term(deconstruct_result267) - _t978 = _t979 - else: - raise ParseError('No matching rule for rel_term') - _t973 = _t978 - return _t973 - - def pretty_specialized_value(self, msg: logic_pb2.Value) -> Optional[Never]: - def _t980(_dollar_dollar): - return _dollar_dollar - _t981 = _t980(msg) - fields269 = _t981 - assert fields269 is not None - unwrapped_fields270 = fields269 - self.write('#') - _t982 = self.pretty_value(unwrapped_fields270) - return _t982 - - def pretty_rel_atom(self, msg: logic_pb2.RelAtom) -> Optional[Never]: - def _t983(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.terms,) - _t984 = _t983(msg) - fields271 = _t984 - assert fields271 is not None - unwrapped_fields272 = fields271 - self.write('(') - self.write('relatom') - self.indent() - self.newline() - field273 = unwrapped_fields272[0] - _t985 = self.pretty_name(field273) - field274 = unwrapped_fields272[1] - if not len(field274) == 0: - self.newline() - for i276, elem275 in enumerate(field274): - - if (i276 > 0): - self.newline() - _t986 = None - else: - _t986 = None - _t987 = self.pretty_rel_term(elem275) - self.dedent() - self.write(')') - return None - - def pretty_cast(self, msg: logic_pb2.Cast) -> Optional[Never]: - def _t988(_dollar_dollar): - return (_dollar_dollar.input, _dollar_dollar.result,) - _t989 = _t988(msg) - fields277 = _t989 - assert fields277 is not None - unwrapped_fields278 = fields277 - self.write('(') - self.write('cast') - self.indent() - self.newline() - field279 = unwrapped_fields278[0] - _t990 = self.pretty_term(field279) - self.newline() - field280 = unwrapped_fields278[1] - _t991 = self.pretty_term(field280) - self.dedent() - self.write(')') - return None - - def pretty_attrs(self, msg: list[logic_pb2.Attribute]) -> Optional[Never]: - def _t992(_dollar_dollar): - return _dollar_dollar - _t993 = _t992(msg) - fields281 = _t993 - assert fields281 is not None - unwrapped_fields282 = fields281 - self.write('(') - self.write('attrs') - self.indent() - if not len(unwrapped_fields282) == 0: - self.newline() - for i284, elem283 in enumerate(unwrapped_fields282): - - if (i284 > 0): - self.newline() - _t994 = None - else: - _t994 = None - _t995 = self.pretty_attribute(elem283) - self.dedent() - self.write(')') - return None - - def pretty_attribute(self, msg: logic_pb2.Attribute) -> Optional[Never]: - def _t996(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.args,) - _t997 = _t996(msg) - fields285 = _t997 - assert fields285 is not None - unwrapped_fields286 = fields285 - self.write('(') - self.write('attribute') - self.indent() - self.newline() - field287 = unwrapped_fields286[0] - _t998 = self.pretty_name(field287) - field288 = unwrapped_fields286[1] - if not len(field288) == 0: - self.newline() - for i290, elem289 in enumerate(field288): - - if (i290 > 0): - self.newline() - _t999 = None - else: - _t999 = None - _t1000 = self.pretty_value(elem289) - self.dedent() - self.write(')') - return None - - def pretty_algorithm(self, msg: logic_pb2.Algorithm) -> Optional[Never]: - def _t1001(_dollar_dollar): - return (getattr(_dollar_dollar, 'global'), _dollar_dollar.body,) - _t1002 = _t1001(msg) - fields291 = _t1002 - assert fields291 is not None - unwrapped_fields292 = fields291 - self.write('(') - self.write('algorithm') - self.indent() - field293 = unwrapped_fields292[0] - if not len(field293) == 0: - self.newline() - for i295, elem294 in enumerate(field293): - - if (i295 > 0): - self.newline() - _t1003 = None - else: - _t1003 = None - _t1004 = self.pretty_relation_id(elem294) - self.newline() - field296 = unwrapped_fields292[1] - _t1005 = self.pretty_script(field296) - self.dedent() - self.write(')') - return None - - def pretty_script(self, msg: logic_pb2.Script) -> Optional[Never]: - def _t1006(_dollar_dollar): - return _dollar_dollar.constructs - _t1007 = _t1006(msg) - fields297 = _t1007 - assert fields297 is not None - unwrapped_fields298 = fields297 - self.write('(') - self.write('script') - self.indent() - if not len(unwrapped_fields298) == 0: - self.newline() - for i300, elem299 in enumerate(unwrapped_fields298): - - if (i300 > 0): - self.newline() - _t1008 = None - else: - _t1008 = None - _t1009 = self.pretty_construct(elem299) - self.dedent() - self.write(')') - return None - - def pretty_construct(self, msg: logic_pb2.Construct) -> Optional[Never]: - def _t1010(_dollar_dollar): - - if _dollar_dollar.HasField('loop'): - _t1011 = _dollar_dollar.loop - else: - _t1011 = None - return _t1011 - _t1012 = _t1010(msg) - deconstruct_result302 = _t1012 - - if deconstruct_result302 is not None: - _t1014 = self.pretty_loop(deconstruct_result302) - _t1013 = _t1014 - else: - def _t1015(_dollar_dollar): - - if _dollar_dollar.HasField('instruction'): - _t1016 = _dollar_dollar.instruction - else: - _t1016 = None - return _t1016 - _t1017 = _t1015(msg) - deconstruct_result301 = _t1017 - - if deconstruct_result301 is not None: - _t1019 = self.pretty_instruction(deconstruct_result301) - _t1018 = _t1019 - else: - raise ParseError('No matching rule for construct') - _t1013 = _t1018 - return _t1013 - - def pretty_loop(self, msg: logic_pb2.Loop) -> Optional[Never]: - def _t1020(_dollar_dollar): - return (_dollar_dollar.init, _dollar_dollar.body,) - _t1021 = _t1020(msg) - fields303 = _t1021 - assert fields303 is not None - unwrapped_fields304 = fields303 - self.write('(') - self.write('loop') - self.indent() - self.newline() - field305 = unwrapped_fields304[0] - _t1022 = self.pretty_init(field305) - self.newline() - field306 = unwrapped_fields304[1] - _t1023 = self.pretty_script(field306) - self.dedent() - self.write(')') - return None - - def pretty_init(self, msg: list[logic_pb2.Instruction]) -> Optional[Never]: - def _t1024(_dollar_dollar): - return _dollar_dollar - _t1025 = _t1024(msg) - fields307 = _t1025 - assert fields307 is not None - unwrapped_fields308 = fields307 - self.write('(') - self.write('init') - self.indent() - if not len(unwrapped_fields308) == 0: - self.newline() - for i310, elem309 in enumerate(unwrapped_fields308): - - if (i310 > 0): - self.newline() - _t1026 = None - else: - _t1026 = None - _t1027 = self.pretty_instruction(elem309) - self.dedent() - self.write(')') - return None - - def pretty_instruction(self, msg: logic_pb2.Instruction) -> Optional[Never]: - def _t1028(_dollar_dollar): - - if _dollar_dollar.HasField('assign'): - _t1029 = _dollar_dollar.assign - else: - _t1029 = None - return _t1029 - _t1030 = _t1028(msg) - deconstruct_result315 = _t1030 - - if deconstruct_result315 is not None: - _t1032 = self.pretty_assign(deconstruct_result315) - _t1031 = _t1032 - else: - def _t1033(_dollar_dollar): - - if _dollar_dollar.HasField('upsert'): - _t1034 = _dollar_dollar.upsert - else: - _t1034 = None - return _t1034 - _t1035 = _t1033(msg) - deconstruct_result314 = _t1035 - - if deconstruct_result314 is not None: - _t1037 = self.pretty_upsert(deconstruct_result314) - _t1036 = _t1037 - else: - def _t1038(_dollar_dollar): - - if _dollar_dollar.HasField('break'): - _t1039 = getattr(_dollar_dollar, 'break') - else: - _t1039 = None - return _t1039 - _t1040 = _t1038(msg) - deconstruct_result313 = _t1040 - - if deconstruct_result313 is not None: - _t1042 = self.pretty_break(deconstruct_result313) - _t1041 = _t1042 - else: - def _t1043(_dollar_dollar): - - if _dollar_dollar.HasField('monoid_def'): - _t1044 = _dollar_dollar.monoid_def - else: - _t1044 = None - return _t1044 - _t1045 = _t1043(msg) - deconstruct_result312 = _t1045 - - if deconstruct_result312 is not None: - _t1047 = self.pretty_monoid_def(deconstruct_result312) - _t1046 = _t1047 - else: - def _t1048(_dollar_dollar): - - if _dollar_dollar.HasField('monus_def'): - _t1049 = _dollar_dollar.monus_def - else: - _t1049 = None - return _t1049 - _t1050 = _t1048(msg) - deconstruct_result311 = _t1050 - - if deconstruct_result311 is not None: - _t1052 = self.pretty_monus_def(deconstruct_result311) - _t1051 = _t1052 - else: - raise ParseError('No matching rule for instruction') - _t1046 = _t1051 - _t1041 = _t1046 - _t1036 = _t1041 - _t1031 = _t1036 - return _t1031 - - def pretty_assign(self, msg: logic_pb2.Assign) -> Optional[Never]: - def _t1053(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t1054 = _dollar_dollar.attrs - else: - _t1054 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1054,) - _t1055 = _t1053(msg) - fields316 = _t1055 - assert fields316 is not None - unwrapped_fields317 = fields316 - self.write('(') - self.write('assign') - self.indent() - self.newline() - field318 = unwrapped_fields317[0] - _t1056 = self.pretty_relation_id(field318) - self.newline() - field319 = unwrapped_fields317[1] - _t1057 = self.pretty_abstraction(field319) - field320 = unwrapped_fields317[2] - - if field320 is not None: - self.newline() - assert field320 is not None - opt_val321 = field320 - _t1059 = self.pretty_attrs(opt_val321) - _t1058 = _t1059 - else: - _t1058 = None - self.dedent() - self.write(')') - return None - - def pretty_upsert(self, msg: logic_pb2.Upsert) -> Optional[Never]: - def _t1060(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t1061 = _dollar_dollar.attrs - else: - _t1061 = None - return (_dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1061,) - _t1062 = _t1060(msg) - fields322 = _t1062 - assert fields322 is not None - unwrapped_fields323 = fields322 - self.write('(') - self.write('upsert') - self.indent() - self.newline() - field324 = unwrapped_fields323[0] - _t1063 = self.pretty_relation_id(field324) - self.newline() - field325 = unwrapped_fields323[1] - _t1064 = self.pretty_abstraction_with_arity(field325) - field326 = unwrapped_fields323[2] - - if field326 is not None: - self.newline() - assert field326 is not None - opt_val327 = field326 - _t1066 = self.pretty_attrs(opt_val327) - _t1065 = _t1066 - else: - _t1065 = None - self.dedent() - self.write(')') - return None - - def pretty_abstraction_with_arity(self, msg: tuple[logic_pb2.Abstraction, int]) -> Optional[Never]: - def _t1067(_dollar_dollar): - _t1068 = self.deconstruct_bindings_with_arity(_dollar_dollar[0], _dollar_dollar[1]) - return (_t1068, _dollar_dollar[0].value,) - _t1069 = _t1067(msg) - fields328 = _t1069 - assert fields328 is not None - unwrapped_fields329 = fields328 - self.write('(') - field330 = unwrapped_fields329[0] - _t1070 = self.pretty_bindings(field330) - self.write(' ') - field331 = unwrapped_fields329[1] - _t1071 = self.pretty_formula(field331) - self.write(')') - return None - - def pretty_break(self, msg: logic_pb2.Break) -> Optional[Never]: - def _t1072(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t1073 = _dollar_dollar.attrs - else: - _t1073 = None - return (_dollar_dollar.name, _dollar_dollar.body, _t1073,) - _t1074 = _t1072(msg) - fields332 = _t1074 - assert fields332 is not None - unwrapped_fields333 = fields332 - self.write('(') - self.write('break') - self.indent() - self.newline() - field334 = unwrapped_fields333[0] - _t1075 = self.pretty_relation_id(field334) - self.newline() - field335 = unwrapped_fields333[1] - _t1076 = self.pretty_abstraction(field335) - field336 = unwrapped_fields333[2] - - if field336 is not None: - self.newline() - assert field336 is not None - opt_val337 = field336 - _t1078 = self.pretty_attrs(opt_val337) - _t1077 = _t1078 - else: - _t1077 = None - self.dedent() - self.write(')') - return None - - def pretty_monoid_def(self, msg: logic_pb2.MonoidDef) -> Optional[Never]: - def _t1079(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t1080 = _dollar_dollar.attrs - else: - _t1080 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1080,) - _t1081 = _t1079(msg) - fields338 = _t1081 - assert fields338 is not None - unwrapped_fields339 = fields338 - self.write('(') - self.write('monoid') - self.indent() - self.newline() - field340 = unwrapped_fields339[0] - _t1082 = self.pretty_monoid(field340) - self.newline() - field341 = unwrapped_fields339[1] - _t1083 = self.pretty_relation_id(field341) - self.newline() - field342 = unwrapped_fields339[2] - _t1084 = self.pretty_abstraction_with_arity(field342) - field343 = unwrapped_fields339[3] - - if field343 is not None: - self.newline() - assert field343 is not None - opt_val344 = field343 - _t1086 = self.pretty_attrs(opt_val344) - _t1085 = _t1086 - else: - _t1085 = None - self.dedent() - self.write(')') - return None - - def pretty_monoid(self, msg: logic_pb2.Monoid) -> Optional[Never]: - def _t1087(_dollar_dollar): - - if _dollar_dollar.HasField('or_monoid'): - _t1088 = _dollar_dollar.or_monoid - else: - _t1088 = None - return _t1088 - _t1089 = _t1087(msg) - deconstruct_result348 = _t1089 - - if deconstruct_result348 is not None: - _t1091 = self.pretty_or_monoid(deconstruct_result348) - _t1090 = _t1091 - else: - def _t1092(_dollar_dollar): - - if _dollar_dollar.HasField('min_monoid'): - _t1093 = _dollar_dollar.min_monoid - else: - _t1093 = None - return _t1093 - _t1094 = _t1092(msg) - deconstruct_result347 = _t1094 - - if deconstruct_result347 is not None: - _t1096 = self.pretty_min_monoid(deconstruct_result347) - _t1095 = _t1096 - else: - def _t1097(_dollar_dollar): - - if _dollar_dollar.HasField('max_monoid'): - _t1098 = _dollar_dollar.max_monoid - else: - _t1098 = None - return _t1098 - _t1099 = _t1097(msg) - deconstruct_result346 = _t1099 - - if deconstruct_result346 is not None: - _t1101 = self.pretty_max_monoid(deconstruct_result346) - _t1100 = _t1101 - else: - def _t1102(_dollar_dollar): - - if _dollar_dollar.HasField('sum_monoid'): - _t1103 = _dollar_dollar.sum_monoid - else: - _t1103 = None - return _t1103 - _t1104 = _t1102(msg) - deconstruct_result345 = _t1104 - - if deconstruct_result345 is not None: - _t1106 = self.pretty_sum_monoid(deconstruct_result345) - _t1105 = _t1106 - else: - raise ParseError('No matching rule for monoid') - _t1100 = _t1105 - _t1095 = _t1100 - _t1090 = _t1095 - return _t1090 - - def pretty_or_monoid(self, msg: logic_pb2.OrMonoid) -> Optional[Never]: - def _t1107(_dollar_dollar): - return _dollar_dollar - _t1108 = _t1107(msg) - fields349 = _t1108 - assert fields349 is not None - unwrapped_fields350 = fields349 - self.write('(') - self.write('or') - self.write(')') - return None - - def pretty_min_monoid(self, msg: logic_pb2.MinMonoid) -> Optional[Never]: - def _t1109(_dollar_dollar): - return _dollar_dollar.type - _t1110 = _t1109(msg) - fields351 = _t1110 - assert fields351 is not None - unwrapped_fields352 = fields351 - self.write('(') - self.write('min') - self.indent() - self.newline() - _t1111 = self.pretty_type(unwrapped_fields352) - self.dedent() - self.write(')') - return None - - def pretty_max_monoid(self, msg: logic_pb2.MaxMonoid) -> Optional[Never]: - def _t1112(_dollar_dollar): - return _dollar_dollar.type - _t1113 = _t1112(msg) - fields353 = _t1113 - assert fields353 is not None - unwrapped_fields354 = fields353 - self.write('(') - self.write('max') - self.indent() - self.newline() - _t1114 = self.pretty_type(unwrapped_fields354) - self.dedent() - self.write(')') - return None - - def pretty_sum_monoid(self, msg: logic_pb2.SumMonoid) -> Optional[Never]: - def _t1115(_dollar_dollar): - return _dollar_dollar.type - _t1116 = _t1115(msg) - fields355 = _t1116 - assert fields355 is not None - unwrapped_fields356 = fields355 - self.write('(') - self.write('sum') - self.indent() - self.newline() - _t1117 = self.pretty_type(unwrapped_fields356) - self.dedent() - self.write(')') - return None - - def pretty_monus_def(self, msg: logic_pb2.MonusDef) -> Optional[Never]: - def _t1118(_dollar_dollar): - - if not len(_dollar_dollar.attrs) == 0: - _t1119 = _dollar_dollar.attrs - else: - _t1119 = None - return (_dollar_dollar.monoid, _dollar_dollar.name, (_dollar_dollar.body, _dollar_dollar.value_arity,), _t1119,) - _t1120 = _t1118(msg) - fields357 = _t1120 - assert fields357 is not None - unwrapped_fields358 = fields357 - self.write('(') - self.write('monus') - self.indent() - self.newline() - field359 = unwrapped_fields358[0] - _t1121 = self.pretty_monoid(field359) - self.newline() - field360 = unwrapped_fields358[1] - _t1122 = self.pretty_relation_id(field360) - self.newline() - field361 = unwrapped_fields358[2] - _t1123 = self.pretty_abstraction_with_arity(field361) - field362 = unwrapped_fields358[3] - - if field362 is not None: - self.newline() - assert field362 is not None - opt_val363 = field362 - _t1125 = self.pretty_attrs(opt_val363) - _t1124 = _t1125 - else: - _t1124 = None - self.dedent() - self.write(')') - return None - - def pretty_constraint(self, msg: logic_pb2.Constraint) -> Optional[Never]: - def _t1126(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.functional_dependency.guard, _dollar_dollar.functional_dependency.keys, _dollar_dollar.functional_dependency.values,) - _t1127 = _t1126(msg) - fields364 = _t1127 - assert fields364 is not None - unwrapped_fields365 = fields364 - self.write('(') - self.write('functional_dependency') - self.indent() - self.newline() - field366 = unwrapped_fields365[0] - _t1128 = self.pretty_relation_id(field366) - self.newline() - field367 = unwrapped_fields365[1] - _t1129 = self.pretty_abstraction(field367) - self.newline() - field368 = unwrapped_fields365[2] - _t1130 = self.pretty_functional_dependency_keys(field368) - self.newline() - field369 = unwrapped_fields365[3] - _t1131 = self.pretty_functional_dependency_values(field369) - self.dedent() - self.write(')') - return None - - def pretty_functional_dependency_keys(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1132(_dollar_dollar): - return _dollar_dollar - _t1133 = _t1132(msg) - fields370 = _t1133 - assert fields370 is not None - unwrapped_fields371 = fields370 - self.write('(') - self.write('keys') - self.indent() - if not len(unwrapped_fields371) == 0: - self.newline() - for i373, elem372 in enumerate(unwrapped_fields371): - - if (i373 > 0): - self.newline() - _t1134 = None - else: - _t1134 = None - _t1135 = self.pretty_var(elem372) - self.dedent() - self.write(')') - return None - - def pretty_functional_dependency_values(self, msg: list[logic_pb2.Var]) -> Optional[Never]: - def _t1136(_dollar_dollar): - return _dollar_dollar - _t1137 = _t1136(msg) - fields374 = _t1137 - assert fields374 is not None - unwrapped_fields375 = fields374 - self.write('(') - self.write('values') - self.indent() - if not len(unwrapped_fields375) == 0: - self.newline() - for i377, elem376 in enumerate(unwrapped_fields375): - - if (i377 > 0): - self.newline() - _t1138 = None - else: - _t1138 = None - _t1139 = self.pretty_var(elem376) - self.dedent() - self.write(')') - return None - - def pretty_data(self, msg: logic_pb2.Data) -> Optional[Never]: - def _t1140(_dollar_dollar): - - if _dollar_dollar.HasField('rel_edb'): - _t1141 = _dollar_dollar.rel_edb - else: - _t1141 = None - return _t1141 - _t1142 = _t1140(msg) - deconstruct_result380 = _t1142 - - if deconstruct_result380 is not None: - _t1144 = self.pretty_rel_edb(deconstruct_result380) - _t1143 = _t1144 - else: - def _t1145(_dollar_dollar): - - if _dollar_dollar.HasField('betree_relation'): - _t1146 = _dollar_dollar.betree_relation - else: - _t1146 = None - return _t1146 - _t1147 = _t1145(msg) - deconstruct_result379 = _t1147 - - if deconstruct_result379 is not None: - _t1149 = self.pretty_betree_relation(deconstruct_result379) - _t1148 = _t1149 - else: - def _t1150(_dollar_dollar): - - if _dollar_dollar.HasField('csv_data'): - _t1151 = _dollar_dollar.csv_data - else: - _t1151 = None - return _t1151 - _t1152 = _t1150(msg) - deconstruct_result378 = _t1152 - - if deconstruct_result378 is not None: - _t1154 = self.pretty_csv_data(deconstruct_result378) - _t1153 = _t1154 - else: - raise ParseError('No matching rule for data') - _t1148 = _t1153 - _t1143 = _t1148 - return _t1143 - - def pretty_rel_edb(self, msg: logic_pb2.RelEDB) -> Optional[Never]: - def _t1155(_dollar_dollar): - return (_dollar_dollar.target_id, _dollar_dollar.path, _dollar_dollar.types,) - _t1156 = _t1155(msg) - fields381 = _t1156 - assert fields381 is not None - unwrapped_fields382 = fields381 - self.write('(') - self.write('rel_edb') - self.indent() - self.newline() - field383 = unwrapped_fields382[0] - _t1157 = self.pretty_relation_id(field383) - self.newline() - field384 = unwrapped_fields382[1] - _t1158 = self.pretty_rel_edb_path(field384) - self.newline() - field385 = unwrapped_fields382[2] - _t1159 = self.pretty_rel_edb_types(field385) - self.dedent() - self.write(')') - return None - - def pretty_rel_edb_path(self, msg: list[str]) -> Optional[Never]: - def _t1160(_dollar_dollar): - return _dollar_dollar - _t1161 = _t1160(msg) - fields386 = _t1161 - assert fields386 is not None - unwrapped_fields387 = fields386 - self.write('[') - for i389, elem388 in enumerate(unwrapped_fields387): - - if (i389 > 0): - self.newline() - _t1162 = None - else: - _t1162 = None - self.write(self.format_string_value(elem388)) - self.write(']') - return None - - def pretty_rel_edb_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1163(_dollar_dollar): - return _dollar_dollar - _t1164 = _t1163(msg) - fields390 = _t1164 - assert fields390 is not None - unwrapped_fields391 = fields390 - self.write('[') - for i393, elem392 in enumerate(unwrapped_fields391): - - if (i393 > 0): - self.newline() - _t1165 = None - else: - _t1165 = None - _t1166 = self.pretty_type(elem392) - self.write(']') - return None - - def pretty_betree_relation(self, msg: logic_pb2.BeTreeRelation) -> Optional[Never]: - def _t1167(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.relation_info,) - _t1168 = _t1167(msg) - fields394 = _t1168 - assert fields394 is not None - unwrapped_fields395 = fields394 - self.write('(') - self.write('betree_relation') - self.indent() - self.newline() - field396 = unwrapped_fields395[0] - _t1169 = self.pretty_relation_id(field396) - self.newline() - field397 = unwrapped_fields395[1] - _t1170 = self.pretty_betree_info(field397) - self.dedent() - self.write(')') - return None - - def pretty_betree_info(self, msg: logic_pb2.BeTreeInfo) -> Optional[Never]: - def _t1171(_dollar_dollar): - _t1172 = self.deconstruct_betree_info_config(_dollar_dollar) - return (_dollar_dollar.key_types, _dollar_dollar.value_types, _t1172,) - _t1173 = _t1171(msg) - fields398 = _t1173 - assert fields398 is not None - unwrapped_fields399 = fields398 - self.write('(') - self.write('betree_info') - self.indent() - self.newline() - field400 = unwrapped_fields399[0] - _t1174 = self.pretty_betree_info_key_types(field400) - self.newline() - field401 = unwrapped_fields399[1] - _t1175 = self.pretty_betree_info_value_types(field401) - self.newline() - field402 = unwrapped_fields399[2] - _t1176 = self.pretty_config_dict(field402) - self.dedent() - self.write(')') - return None - - def pretty_betree_info_key_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1177(_dollar_dollar): - return _dollar_dollar - _t1178 = _t1177(msg) - fields403 = _t1178 - assert fields403 is not None - unwrapped_fields404 = fields403 - self.write('(') - self.write('key_types') - self.indent() - if not len(unwrapped_fields404) == 0: - self.newline() - for i406, elem405 in enumerate(unwrapped_fields404): - - if (i406 > 0): - self.newline() - _t1179 = None - else: - _t1179 = None - _t1180 = self.pretty_type(elem405) - self.dedent() - self.write(')') - return None - - def pretty_betree_info_value_types(self, msg: list[logic_pb2.Type]) -> Optional[Never]: - def _t1181(_dollar_dollar): - return _dollar_dollar - _t1182 = _t1181(msg) - fields407 = _t1182 - assert fields407 is not None - unwrapped_fields408 = fields407 - self.write('(') - self.write('value_types') - self.indent() - if not len(unwrapped_fields408) == 0: - self.newline() - for i410, elem409 in enumerate(unwrapped_fields408): - - if (i410 > 0): - self.newline() - _t1183 = None - else: - _t1183 = None - _t1184 = self.pretty_type(elem409) - self.dedent() - self.write(')') - return None - - def pretty_csv_data(self, msg: logic_pb2.CSVData) -> Optional[Never]: - def _t1185(_dollar_dollar): - return (_dollar_dollar.locator, _dollar_dollar.config, _dollar_dollar.columns, _dollar_dollar.asof,) - _t1186 = _t1185(msg) - fields411 = _t1186 - assert fields411 is not None - unwrapped_fields412 = fields411 - self.write('(') - self.write('csv_data') - self.indent() - self.newline() - field413 = unwrapped_fields412[0] - _t1187 = self.pretty_csvlocator(field413) - self.newline() - field414 = unwrapped_fields412[1] - _t1188 = self.pretty_csv_config(field414) - self.newline() - field415 = unwrapped_fields412[2] - _t1189 = self.pretty_csv_columns(field415) - self.newline() - field416 = unwrapped_fields412[3] - _t1190 = self.pretty_csv_asof(field416) - self.dedent() - self.write(')') - return None - - def pretty_csvlocator(self, msg: logic_pb2.CSVLocator) -> Optional[Never]: - def _t1191(_dollar_dollar): - - if not len(_dollar_dollar.paths) == 0: - _t1192 = _dollar_dollar.paths - else: - _t1192 = None - - if _dollar_dollar.inline_data.decode('utf-8') != '': - _t1193 = _dollar_dollar.inline_data.decode('utf-8') - else: - _t1193 = None - return (_t1192, _t1193,) - _t1194 = _t1191(msg) - fields417 = _t1194 - assert fields417 is not None - unwrapped_fields418 = fields417 - self.write('(') - self.write('csv_locator') - self.indent() - field419 = unwrapped_fields418[0] - - if field419 is not None: - self.newline() - assert field419 is not None - opt_val420 = field419 - _t1196 = self.pretty_csv_locator_paths(opt_val420) - _t1195 = _t1196 - else: - _t1195 = None - field421 = unwrapped_fields418[1] - - if field421 is not None: - self.newline() - assert field421 is not None - opt_val422 = field421 - _t1198 = self.pretty_csv_locator_inline_data(opt_val422) - _t1197 = _t1198 - else: - _t1197 = None - self.dedent() - self.write(')') - return None - - def pretty_csv_locator_paths(self, msg: list[str]) -> Optional[Never]: - def _t1199(_dollar_dollar): - return _dollar_dollar - _t1200 = _t1199(msg) - fields423 = _t1200 - assert fields423 is not None - unwrapped_fields424 = fields423 - self.write('(') - self.write('paths') - self.indent() - if not len(unwrapped_fields424) == 0: - self.newline() - for i426, elem425 in enumerate(unwrapped_fields424): - - if (i426 > 0): - self.newline() - _t1201 = None - else: - _t1201 = None - self.write(self.format_string_value(elem425)) - self.dedent() - self.write(')') - return None - - def pretty_csv_locator_inline_data(self, msg: str) -> Optional[Never]: - def _t1202(_dollar_dollar): - return _dollar_dollar - _t1203 = _t1202(msg) - fields427 = _t1203 - assert fields427 is not None - unwrapped_fields428 = fields427 - self.write('(') - self.write('inline_data') - self.indent() - self.newline() - self.write(self.format_string_value(unwrapped_fields428)) - self.dedent() - self.write(')') - return None - - def pretty_csv_config(self, msg: logic_pb2.CSVConfig) -> Optional[Never]: - def _t1204(_dollar_dollar): - _t1205 = self.deconstruct_csv_config(_dollar_dollar) - return _t1205 - _t1206 = _t1204(msg) - fields429 = _t1206 - assert fields429 is not None - unwrapped_fields430 = fields429 - self.write('(') - self.write('csv_config') - self.indent() - self.newline() - _t1207 = self.pretty_config_dict(unwrapped_fields430) - self.dedent() - self.write(')') - return None - - def pretty_csv_columns(self, msg: list[logic_pb2.CSVColumn]) -> Optional[Never]: - def _t1208(_dollar_dollar): - return _dollar_dollar - _t1209 = _t1208(msg) - fields431 = _t1209 - assert fields431 is not None - unwrapped_fields432 = fields431 - self.write('(') - self.write('columns') - self.indent() - if not len(unwrapped_fields432) == 0: - self.newline() - for i434, elem433 in enumerate(unwrapped_fields432): - - if (i434 > 0): - self.newline() - _t1210 = None - else: - _t1210 = None - _t1211 = self.pretty_csv_column(elem433) - self.dedent() - self.write(')') - return None - - def pretty_csv_column(self, msg: logic_pb2.CSVColumn) -> Optional[Never]: - def _t1212(_dollar_dollar): - return (_dollar_dollar.column_name, _dollar_dollar.target_id, _dollar_dollar.types,) - _t1213 = _t1212(msg) - fields435 = _t1213 - assert fields435 is not None - unwrapped_fields436 = fields435 - self.write('(') - self.write('column') - self.indent() - self.newline() - field437 = unwrapped_fields436[0] - self.write(self.format_string_value(field437)) - self.newline() - field438 = unwrapped_fields436[1] - _t1214 = self.pretty_relation_id(field438) - self.write('[') - field439 = unwrapped_fields436[2] - if not len(field439) == 0: - self.newline() - for i441, elem440 in enumerate(field439): - - if (i441 > 0): - self.newline() - _t1215 = None - else: - _t1215 = None - _t1216 = self.pretty_type(elem440) - self.write(']') - self.dedent() - self.write(')') - return None - - def pretty_csv_asof(self, msg: str) -> Optional[Never]: - def _t1217(_dollar_dollar): - return _dollar_dollar - _t1218 = _t1217(msg) - fields442 = _t1218 - assert fields442 is not None - unwrapped_fields443 = fields442 - self.write('(') - self.write('asof') - self.indent() - self.newline() - self.write(self.format_string_value(unwrapped_fields443)) - self.dedent() - self.write(')') - return None - - def pretty_undefine(self, msg: transactions_pb2.Undefine) -> Optional[Never]: - def _t1219(_dollar_dollar): - return _dollar_dollar.fragment_id - _t1220 = _t1219(msg) - fields444 = _t1220 - assert fields444 is not None - unwrapped_fields445 = fields444 - self.write('(') - self.write('undefine') - self.indent() - self.newline() - _t1221 = self.pretty_fragment_id(unwrapped_fields445) - self.dedent() - self.write(')') - return None - - def pretty_context(self, msg: transactions_pb2.Context) -> Optional[Never]: - def _t1222(_dollar_dollar): - return _dollar_dollar.relations - _t1223 = _t1222(msg) - fields446 = _t1223 - assert fields446 is not None - unwrapped_fields447 = fields446 - self.write('(') - self.write('context') - self.indent() - if not len(unwrapped_fields447) == 0: - self.newline() - for i449, elem448 in enumerate(unwrapped_fields447): - - if (i449 > 0): - self.newline() - _t1224 = None - else: - _t1224 = None - _t1225 = self.pretty_relation_id(elem448) - self.dedent() - self.write(')') - return None - - def pretty_epoch_reads(self, msg: list[transactions_pb2.Read]) -> Optional[Never]: - def _t1226(_dollar_dollar): - return _dollar_dollar - _t1227 = _t1226(msg) - fields450 = _t1227 - assert fields450 is not None - unwrapped_fields451 = fields450 - self.write('(') - self.write('reads') - self.indent() - if not len(unwrapped_fields451) == 0: - self.newline() - for i453, elem452 in enumerate(unwrapped_fields451): - - if (i453 > 0): - self.newline() - _t1228 = None - else: - _t1228 = None - _t1229 = self.pretty_read(elem452) - self.dedent() - self.write(')') - return None - - def pretty_read(self, msg: transactions_pb2.Read) -> Optional[Never]: - def _t1230(_dollar_dollar): - - if _dollar_dollar.HasField('demand'): - _t1231 = _dollar_dollar.demand - else: - _t1231 = None - return _t1231 - _t1232 = _t1230(msg) - deconstruct_result458 = _t1232 - - if deconstruct_result458 is not None: - _t1234 = self.pretty_demand(deconstruct_result458) - _t1233 = _t1234 - else: - def _t1235(_dollar_dollar): - - if _dollar_dollar.HasField('output'): - _t1236 = _dollar_dollar.output - else: - _t1236 = None - return _t1236 - _t1237 = _t1235(msg) - deconstruct_result457 = _t1237 - - if deconstruct_result457 is not None: - _t1239 = self.pretty_output(deconstruct_result457) - _t1238 = _t1239 - else: - def _t1240(_dollar_dollar): - - if _dollar_dollar.HasField('what_if'): - _t1241 = _dollar_dollar.what_if - else: - _t1241 = None - return _t1241 - _t1242 = _t1240(msg) - deconstruct_result456 = _t1242 - - if deconstruct_result456 is not None: - _t1244 = self.pretty_what_if(deconstruct_result456) - _t1243 = _t1244 - else: - def _t1245(_dollar_dollar): - - if _dollar_dollar.HasField('abort'): - _t1246 = _dollar_dollar.abort - else: - _t1246 = None - return _t1246 - _t1247 = _t1245(msg) - deconstruct_result455 = _t1247 - - if deconstruct_result455 is not None: - _t1249 = self.pretty_abort(deconstruct_result455) - _t1248 = _t1249 - else: - def _t1250(_dollar_dollar): - - if _dollar_dollar.HasField('export'): - _t1251 = _dollar_dollar.export - else: - _t1251 = None - return _t1251 - _t1252 = _t1250(msg) - deconstruct_result454 = _t1252 - - if deconstruct_result454 is not None: - _t1254 = self.pretty_export(deconstruct_result454) - _t1253 = _t1254 - else: - raise ParseError('No matching rule for read') - _t1248 = _t1253 - _t1243 = _t1248 - _t1238 = _t1243 - _t1233 = _t1238 - return _t1233 - - def pretty_demand(self, msg: transactions_pb2.Demand) -> Optional[Never]: - def _t1255(_dollar_dollar): - return _dollar_dollar.relation_id - _t1256 = _t1255(msg) - fields459 = _t1256 - assert fields459 is not None - unwrapped_fields460 = fields459 - self.write('(') - self.write('demand') - self.indent() - self.newline() - _t1257 = self.pretty_relation_id(unwrapped_fields460) - self.dedent() - self.write(')') - return None - - def pretty_output(self, msg: transactions_pb2.Output) -> Optional[Never]: - def _t1258(_dollar_dollar): - return (_dollar_dollar.name, _dollar_dollar.relation_id,) - _t1259 = _t1258(msg) - fields461 = _t1259 - assert fields461 is not None - unwrapped_fields462 = fields461 - self.write('(') - self.write('output') - self.indent() - self.newline() - field463 = unwrapped_fields462[0] - _t1260 = self.pretty_name(field463) - self.newline() - field464 = unwrapped_fields462[1] - _t1261 = self.pretty_relation_id(field464) - self.dedent() - self.write(')') - return None - - def pretty_what_if(self, msg: transactions_pb2.WhatIf) -> Optional[Never]: - def _t1262(_dollar_dollar): - return (_dollar_dollar.branch, _dollar_dollar.epoch,) - _t1263 = _t1262(msg) - fields465 = _t1263 - assert fields465 is not None - unwrapped_fields466 = fields465 - self.write('(') - self.write('what_if') - self.indent() - self.newline() - field467 = unwrapped_fields466[0] - _t1264 = self.pretty_name(field467) - self.newline() - field468 = unwrapped_fields466[1] - _t1265 = self.pretty_epoch(field468) - self.dedent() - self.write(')') - return None - - def pretty_abort(self, msg: transactions_pb2.Abort) -> Optional[Never]: - def _t1266(_dollar_dollar): - - if _dollar_dollar.name != 'abort': - _t1267 = _dollar_dollar.name - else: - _t1267 = None - return (_t1267, _dollar_dollar.relation_id,) - _t1268 = _t1266(msg) - fields469 = _t1268 - assert fields469 is not None - unwrapped_fields470 = fields469 - self.write('(') - self.write('abort') - self.indent() - field471 = unwrapped_fields470[0] - - if field471 is not None: - self.newline() - assert field471 is not None - opt_val472 = field471 - _t1270 = self.pretty_name(opt_val472) - _t1269 = _t1270 - else: - _t1269 = None - self.newline() - field473 = unwrapped_fields470[1] - _t1271 = self.pretty_relation_id(field473) - self.dedent() - self.write(')') - return None - - def pretty_export(self, msg: transactions_pb2.Export) -> Optional[Never]: - def _t1272(_dollar_dollar): - return _dollar_dollar.csv_config - _t1273 = _t1272(msg) - fields474 = _t1273 - assert fields474 is not None - unwrapped_fields475 = fields474 - self.write('(') - self.write('export') - self.indent() - self.newline() - _t1274 = self.pretty_export_csv_config(unwrapped_fields475) - self.dedent() - self.write(')') - return None - - def pretty_export_csv_config(self, msg: transactions_pb2.ExportCSVConfig) -> Optional[Never]: - def _t1275(_dollar_dollar): - _t1276 = self.deconstruct_export_csv_config(_dollar_dollar) - return (_dollar_dollar.path, _dollar_dollar.data_columns, _t1276,) - _t1277 = _t1275(msg) - fields476 = _t1277 - assert fields476 is not None - unwrapped_fields477 = fields476 - self.write('(') - self.write('export_csv_config') - self.indent() - self.newline() - field478 = unwrapped_fields477[0] - _t1278 = self.pretty_export_csv_path(field478) - self.newline() - field479 = unwrapped_fields477[1] - _t1279 = self.pretty_export_csv_columns(field479) - self.newline() - field480 = unwrapped_fields477[2] - _t1280 = self.pretty_config_dict(field480) - self.dedent() - self.write(')') - return None - - def pretty_export_csv_path(self, msg: str) -> Optional[Never]: - def _t1281(_dollar_dollar): - return _dollar_dollar - _t1282 = _t1281(msg) - fields481 = _t1282 - assert fields481 is not None - unwrapped_fields482 = fields481 - self.write('(') - self.write('path') - self.indent() - self.newline() - self.write(self.format_string_value(unwrapped_fields482)) - self.dedent() - self.write(')') - return None - - def pretty_export_csv_columns(self, msg: list[transactions_pb2.ExportCSVColumn]) -> Optional[Never]: - def _t1283(_dollar_dollar): - return _dollar_dollar - _t1284 = _t1283(msg) - fields483 = _t1284 - assert fields483 is not None - unwrapped_fields484 = fields483 - self.write('(') - self.write('columns') - self.indent() - if not len(unwrapped_fields484) == 0: - self.newline() - for i486, elem485 in enumerate(unwrapped_fields484): - - if (i486 > 0): - self.newline() - _t1285 = None - else: - _t1285 = None - _t1286 = self.pretty_export_csv_column(elem485) - self.dedent() - self.write(')') - return None - - def pretty_export_csv_column(self, msg: transactions_pb2.ExportCSVColumn) -> Optional[Never]: - def _t1287(_dollar_dollar): - return (_dollar_dollar.column_name, _dollar_dollar.column_data,) - _t1288 = _t1287(msg) - fields487 = _t1288 - assert fields487 is not None - unwrapped_fields488 = fields487 - self.write('(') - self.write('column') - self.indent() - self.newline() - field489 = unwrapped_fields488[0] - self.write(self.format_string_value(field489)) - self.newline() - field490 = unwrapped_fields488[1] - _t1289 = self.pretty_relation_id(field490) - self.dedent() - self.write(')') - return None - - -def pretty(msg: Any, io: Optional[IO[str]] = None) -> str: - """Pretty print a protobuf message and return the string representation.""" - printer = PrettyPrinter(io) - printer.pretty_transaction(msg) - printer.newline() - return printer.get_output() diff --git a/sdks/python/tests/test_generated_pretty.py b/sdks/python/tests/test_generated_pretty.py index 295d1aac..8f79179a 100644 --- a/sdks/python/tests/test_generated_pretty.py +++ b/sdks/python/tests/test_generated_pretty.py @@ -27,9 +27,9 @@ def test_roundtrip(input_file): """Pretty-printed output must re-parse to the same protobuf.""" with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) printed = pretty(proto) - re_proto = generated_parse(printed) + re_proto, _ = generated_parse(printed) assert proto.SerializeToString() == re_proto.SerializeToString(), ( f"Roundtrip failed for {Path(input_file).name}:\n" f"Original proto:\n{proto}\n" @@ -48,7 +48,7 @@ def test_pretty_snapshot(snapshot, input_file): """Pretty output must match saved snapshots.""" with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) printed = pretty(proto) snapshot.snapshot_dir = str(REPO_ROOT / "tests" / "pretty") snapshot.assert_match(printed, os.path.basename(input_file)) @@ -64,9 +64,9 @@ def test_roundtrip_narrow(input_file): """Roundtrip still works with a very narrow max_width (forces multi-line).""" with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) printed = pretty(proto, max_width=40) - re_proto = generated_parse(printed) + re_proto, _ = generated_parse(printed) assert proto.SerializeToString() == re_proto.SerializeToString() @@ -75,16 +75,16 @@ def test_roundtrip_wide(input_file): """Roundtrip still works with a very wide max_width (forces flat where possible).""" with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) printed = pretty(proto, max_width=1000) - re_proto = generated_parse(printed) + re_proto, _ = generated_parse(printed) assert proto.SerializeToString() == re_proto.SerializeToString() def test_narrow_width_produces_more_lines(): """A narrow width should produce at least as many lines as the default.""" content = Path(TEST_INPUTS_DIR / "arithmetic.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) default_output = pretty(proto) narrow_output = pretty(proto, max_width=40) assert narrow_output.count("\n") >= default_output.count("\n") @@ -93,7 +93,7 @@ def test_narrow_width_produces_more_lines(): def test_wide_width_produces_fewer_lines(): """A very wide width should produce at most as many lines as the default.""" content = Path(TEST_INPUTS_DIR / "arithmetic.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) default_output = pretty(proto) wide_output = pretty(proto, max_width=1000) assert wide_output.count("\n") <= default_output.count("\n") @@ -107,7 +107,7 @@ def test_wide_width_produces_fewer_lines(): def test_pretty_writes_to_provided_io(): """When an IO object is provided, pretty printer writes to it.""" content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) buf = StringIO() result = pretty(proto, io=buf) assert buf.getvalue() == result @@ -117,7 +117,7 @@ def test_pretty_writes_to_provided_io(): def test_pretty_returns_string_without_io(): """Without an IO argument, pretty() returns the output as a string.""" content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) result = pretty(proto) assert isinstance(result, str) assert result.startswith("(transaction") @@ -289,7 +289,7 @@ class TestTryFlat: def test_flat_rendering_short_message(self): """A short conjunction should render flat when it fits.""" content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) wide = pretty(proto, max_width=1000) narrow = pretty(proto, max_width=20) assert narrow.count("\n") >= wide.count("\n") @@ -297,7 +297,7 @@ def test_flat_rendering_short_message(self): def test_memo_caching(self): """Flat representations should be memoized.""" content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) pp = PrettyPrinter(max_width=92) pp.pretty_transaction(proto) # After printing, memo should have entries @@ -326,13 +326,13 @@ def test_get_output_with_custom_io(self): class TestOutputContent: def test_output_starts_with_transaction(self): content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) assert output.strip().startswith("(transaction") def test_output_ends_with_newline(self): content = Path(TEST_INPUTS_DIR / "simple_relatom.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) assert output.endswith("\n") @@ -340,7 +340,7 @@ def test_output_has_balanced_parens(self): for input_file in get_lqp_input_files(): with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) opens = output.count("(") closes = output.count(")") @@ -353,7 +353,7 @@ def test_output_has_balanced_brackets(self): for input_file in get_lqp_input_files(): with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) opens = output.count("[") closes = output.count("]") @@ -364,7 +364,7 @@ def test_output_has_balanced_brackets(self): def test_values_file_contains_expected_keywords(self): content = Path(TEST_INPUTS_DIR / "values.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) for kw in [ "transaction", @@ -380,7 +380,7 @@ def test_values_file_contains_expected_keywords(self): def test_arithmetic_contains_operators(self): content = Path(TEST_INPUTS_DIR / "arithmetic.lqp").read_text() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) for op in ["(+", "(-", "(*", "(/"]: assert op in output, f"Missing operator '{op}' in arithmetic output" @@ -390,7 +390,7 @@ def test_no_trailing_whitespace(self): for input_file in get_lqp_input_files(): with open(input_file) as f: content = f.read() - proto = generated_parse(content) + proto, _ = generated_parse(content) output = pretty(proto) for i, line in enumerate(output.split("\n"), 1): assert line == line.rstrip(), ( @@ -438,7 +438,7 @@ def test_pretty_from_binary_roundtrip(bin_file): txn = transactions_pb2.Transaction() txn.ParseFromString(data) printed = pretty(txn) - re_proto = generated_parse(printed) + re_proto, _ = generated_parse(printed) assert txn.SerializeToString() == re_proto.SerializeToString(), ( f"Binary roundtrip failed for {Path(bin_file).name}" ) diff --git a/sdks/python/tests/test_generated_pretty_printer.py b/sdks/python/tests/test_generated_pretty_printer.py deleted file mode 100644 index a3912753..00000000 --- a/sdks/python/tests/test_generated_pretty_printer.py +++ /dev/null @@ -1,167 +0,0 @@ -"""Tests for the generated pretty printer. - -Three test suites: -1. Roundtrip (idempotency): parse → print → parse → print → compare the two prints. -2. Comparison: generated pretty printer output vs old IR-based pretty printer output. -3. Bin roundtrip: parse .bin → print → re-parse → compare protobuf with original. -""" - -import re -import pytest -from pathlib import Path - -from lqp.parser import parse_lqp -from lqp.emit import ir_to_proto -from lqp.gen.pretty import pretty -from lqp.gen.parser import parse as generated_parse -from lqp.cli import read_bin_to_proto -import lqp.print as lqp_print - -from .utils import get_lqp_input_files, get_all_files, PARENT_DIR - - -BIN_DIR = PARENT_DIR / "test_files" / "bin" - - -def get_bin_input_files(): - """Find all .bin files in the test inputs directory.""" - return get_all_files(BIN_DIR, ".bin") - - -def _stem(path: str) -> str: - return Path(path).stem - - -def _parse_and_pretty(input_file: str) -> str: - """Parse an .lqp file through IR → protobuf → generated pretty printer.""" - with open(input_file, "r") as f: - content = f.read() - ir_node = parse_lqp(input_file, content) - proto = ir_to_proto(ir_node) - return pretty(proto) - - -def _normalize_primitives(s: str) -> str: - """Normalize shorthand primitive syntax to verbose form.""" - # Binary primitives: (= a b) → (primitive :rel_primitive_eq a b) - s = re.sub(r'\(\s*=\s+', '(primitive :rel_primitive_eq ', s) - s = re.sub(r'\(\s*<=\s+', '(primitive :rel_primitive_lt_eq_monotype ', s) - s = re.sub(r'\(\s*>=\s+', '(primitive :rel_primitive_gt_eq_monotype ', s) - s = re.sub(r'\(\s*<\s+', '(primitive :rel_primitive_lt_monotype ', s) - s = re.sub(r'\(\s*>\s+', '(primitive :rel_primitive_gt_monotype ', s) - # Ternary primitives: (+ a b c) → (primitive :rel_primitive_add_monotype a b c) - s = re.sub(r'\(\s*\+\s+', '(primitive :rel_primitive_add_monotype ', s) - s = re.sub(r'\(\s*-\s+', '(primitive :rel_primitive_subtract_monotype ', s) - s = re.sub(r'\(\s*\*\s+', '(primitive :rel_primitive_multiply_monotype ', s) - s = re.sub(r'\(\s*/\s+', '(primitive :rel_primitive_divide_monotype ', s) - return s - - -def _normalize_formulas(s: str) -> str: - """Normalize (true) to (and) and (false) to (or).""" - s = re.sub(r'\(\s*true\s*\)', '(and)', s) - s = re.sub(r'\(\s*false\s*\)', '(or)', s) - return s - - -def _normalize_header_row(s: str) -> str: - """Normalize :syntax_header_row 1 to :syntax_header_row true. - - The proto type is bool, but the old printer formats it as an int. - """ - s = re.sub(r':syntax_header_row\s+1\b', ':syntax_header_row true', s) - s = re.sub(r':syntax_header_row\s+0\b', ':syntax_header_row false', s) - return s - - -def _normalize_ws(s: str) -> str: - """Collapse all whitespace sequences to a single space, strip spaces before closing brackets.""" - s = re.sub(r'\s+', ' ', s).strip() - s = re.sub(r'\s+([)\]}])', r'\1', s) - return s - - -def _clear_debug_info(proto): - """Clear debug_info from all fragments in a Transaction.""" - for epoch in proto.epochs: - for write in epoch.writes: - if write.HasField('define'): - write.define.fragment.ClearField('debug_info') - - -@pytest.mark.parametrize("input_file", get_lqp_input_files()) -def test_roundtrip_idempotent(input_file): - """Parse → print → parse → print, then compare the two printed outputs.""" - stem = _stem(input_file) - - # First pass: .lqp → IR → proto → pretty-print - text1 = _parse_and_pretty(input_file) - - # Second pass: parse printed output → proto → pretty-print again - proto2, _ = generated_parse(text1) - text2 = pretty(proto2) - - assert text1 == text2, ( - f"Pretty printer is not idempotent for {stem}.\n" - f"=== First print ===\n{text1}\n" - f"=== Second print ===\n{text2}" - ) - - -@pytest.mark.parametrize("input_file", get_lqp_input_files()) -def test_matches_old_pretty_printer(input_file): - """Compare generated pretty printer output to old IR-based pretty printer.""" - stem = _stem(input_file) - - with open(input_file, "r") as f: - content = f.read() - - # Generated pretty printer: IR → proto → pretty - ir_node = parse_lqp(input_file, content) - proto = ir_to_proto(ir_node) - generated_output = pretty(proto) - - # Old pretty printer: IR → string (with names, no debug info) - options = lqp_print.ugly_config.copy() - options[str(lqp_print.PrettyOptions.PRINT_NAMES)] = True - options[str(lqp_print.PrettyOptions.PRINT_DEBUG)] = False - old_output = lqp_print.to_string(ir_node, options) - - generated_output = _normalize_primitives(generated_output) - generated_output = _normalize_formulas(generated_output) - old_output = _normalize_primitives(old_output) - old_output = _normalize_formulas(old_output) - old_output = _normalize_header_row(old_output) - - assert _normalize_ws(generated_output) == _normalize_ws(old_output), ( - f"Outputs differ for {stem}.\n" - f"=== Generated ===\n{generated_output}\n" - f"=== Old (PRINT_NAMES) ===\n{old_output}" - ) - - -@pytest.mark.parametrize("input_file", get_bin_input_files()) -def test_bin_roundtrip(input_file): - """Parse .bin → print → re-parse → compare protobuf with original.""" - stem = _stem(input_file) - - # Parse binary protobuf - proto1 = read_bin_to_proto(input_file) - - # Pretty-print → re-parse - text = pretty(proto1) - proto2, _ = generated_parse(text) - - # Clear debug info before comparison since pretty printer - # consumes but does not output debug info - _clear_debug_info(proto1) - _clear_debug_info(proto2) - - # Compare serialized protobufs - binary1 = proto1.SerializeToString() - binary2 = proto2.SerializeToString() - - assert binary1 == binary2, ( - f"Bin roundtrip failed for {stem}.\n" - f"=== Pretty-printed ===\n{text}" - ) diff --git a/sdks/python/tests/test_parser.py b/sdks/python/tests/test_parser.py index de05ea46..54806c8c 100644 --- a/sdks/python/tests/test_parser.py +++ b/sdks/python/tests/test_parser.py @@ -14,7 +14,7 @@ def test_parse_lqp(snapshot: Snapshot, input_file): with open(input_file) as f: content = f.read() - txn = parse(content) + txn, _provenance = parse(content) assert txn is not None, f"Failed to parse {input_file}" binary_output = txn.SerializeToString() snapshot.snapshot_dir = BIN_SNAPSHOTS_DIR diff --git a/sdks/python/tests/test_proto_validator.py b/sdks/python/tests/test_proto_validator.py index 67bec7a6..7f5bb613 100644 --- a/sdks/python/tests/test_proto_validator.py +++ b/sdks/python/tests/test_proto_validator.py @@ -17,7 +17,7 @@ def test_validate_proto_lqp_inputs(input_file): with open(input_file) as f: content = f.read() - txn_proto = parse(content) + txn_proto, _ = parse(content) validate_proto(txn_proto) @@ -29,7 +29,7 @@ def test_valid_proto_validator_files(validator_file): file_path = VALIDATOR_DIR / validator_file with open(file_path) as f: content = f.read() - txn_proto = parse(content) + txn_proto, _ = parse(content) validate_proto(txn_proto) @@ -45,7 +45,7 @@ def test_proto_validator_failure_files(validator_file): return with open(file_path) as f: content = f.read() - txn_proto = parse(content) + txn_proto, _ = parse(content) with pytest.raises(ValidationError) as exc_info: validate_proto(txn_proto) error_message = str(exc_info.value) diff --git a/sdks/python/tests/test_provenance.py b/sdks/python/tests/test_provenance.py new file mode 100644 index 00000000..2c29c05c --- /dev/null +++ b/sdks/python/tests/test_provenance.py @@ -0,0 +1,115 @@ +"""Tests for provenance (source location tracking) in the generated parser.""" + +from lqp.gen.parser import Location, Span, parse + +SIMPLE_INPUT = """\ +(transaction + (epoch + (writes) + (reads))) +""" + + +def test_provenance_root_transaction(): + """The root path () should span the entire input.""" + _, provenance = parse(SIMPLE_INPUT) + assert () in provenance + span = provenance[()] + # Transaction starts at offset 0 (the opening paren) + assert span.start.offset == 0 + assert span.start.line == 1 + assert span.start.column == 1 + + +def test_provenance_epoch(): + """The first epoch should be at path (1, 0).""" + _, provenance = parse(SIMPLE_INPUT) + # epochs = field 1, index 0 + key = (1, 0) + assert key in provenance + span = provenance[key] + # The epoch starts at "(epoch" which is indented on line 2 + assert span.start.line == 2 + + +def test_provenance_writes(): + """Writes section should be at path (1, 0, 1).""" + _, provenance = parse(SIMPLE_INPUT) + # epochs[0].writes = field 1 within Epoch + key = (1, 0, 1) + assert key in provenance + span = provenance[key] + assert span.start.line == 3 + + +def test_provenance_reads(): + """Reads section should be at path (1, 0, 2).""" + _, provenance = parse(SIMPLE_INPUT) + # epochs[0].reads = field 2 within Epoch + key = (1, 0, 2) + assert key in provenance + span = provenance[key] + assert span.start.line == 4 + + +def test_provenance_span_covers_correct_text(): + """Verify that spans map back to the correct substrings.""" + _, provenance = parse(SIMPLE_INPUT) + + # Root transaction span should cover from start + root_span = provenance[()] + assert root_span.start.offset == 0 + + # Epoch span should start at the '(' of '(epoch' + epoch_span = provenance[(1, 0)] + text_at_epoch = SIMPLE_INPUT[epoch_span.start.offset :] + assert text_at_epoch.startswith("(epoch") + + +def test_provenance_span_ordering(): + """Verify start <= end for all spans.""" + _, provenance = parse(SIMPLE_INPUT) + for path, span in provenance.items(): + assert span.start.offset <= span.end.offset, f"Bad span at path {path}" + assert span.start.line <= span.end.line, f"Bad line ordering at path {path}" + + +def test_provenance_multiple_epochs(): + """Multiple epochs should be indexed correctly.""" + input_str = """\ +(transaction + (epoch + (writes) + (reads)) + (epoch + (writes) + (reads))) +""" + _, provenance = parse(input_str) + + # First epoch at (1, 0), second at (1, 1) + assert (1, 0) in provenance + assert (1, 1) in provenance + + # First epoch starts before second + assert provenance[(1, 0)].start.offset < provenance[(1, 1)].start.offset + + +def test_provenance_location_fields(): + """Verify Location has correct line, column, offset fields.""" + _, provenance = parse(SIMPLE_INPUT) + root_span = provenance[()] + loc = root_span.start + assert isinstance(loc, Location) + assert isinstance(loc.line, int) + assert isinstance(loc.column, int) + assert isinstance(loc.offset, int) + + +def test_provenance_span_fields(): + """Verify Span has start and end Location.""" + _, provenance = parse(SIMPLE_INPUT) + root_span = provenance[()] + assert isinstance(root_span, Span) + assert isinstance(root_span.start, Location) + assert isinstance(root_span.end, Location) From 3f3fd263ea1ae770bb29892359785a44be698374 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Wed, 25 Feb 2026 17:37:06 +0100 Subject: [PATCH 24/25] Rename span.end to span.stop --- meta/src/meta/templates/parser.go.template | 6 +- meta/src/meta/templates/parser.jl.template | 2 +- meta/src/meta/templates/parser.py.template | 14 +- sdks/go/src/parser.go | 6 +- sdks/go/test/file_provenance_test.go | 178 ++++++++++++++++++ sdks/go/test/provenance_test.go | 8 +- .../LogicalQueryProtocol.jl/src/parser.jl | 2 +- .../test/file_provenance_tests.jl | 96 ++++++++++ .../test/provenance_tests.jl | 6 +- sdks/python/src/lqp/gen/parser.py | 14 +- sdks/python/tests/test_file_provenance.py | 154 +++++++++++++++ sdks/python/tests/test_provenance.py | 8 +- 12 files changed, 461 insertions(+), 33 deletions(-) create mode 100644 sdks/go/test/file_provenance_test.go create mode 100644 sdks/julia/LogicalQueryProtocol.jl/test/file_provenance_tests.jl create mode 100644 sdks/python/tests/test_file_provenance.py diff --git a/meta/src/meta/templates/parser.go.template b/meta/src/meta/templates/parser.go.template index d1405893..17bc5bc9 100644 --- a/meta/src/meta/templates/parser.go.template +++ b/meta/src/meta/templates/parser.go.template @@ -29,10 +29,10 @@ type Location struct {{ Offset int }} -// Span represents a source span from start to end location. +// Span represents a source span from start to stop location. type Span struct {{ Start Location - End Location + Stop Location }} // ParseError represents a parse error @@ -381,7 +381,7 @@ func (p *Parser) recordSpan(startOffset int) {{ }} s := Span{{ Start: p.makeLocation(startOffset), - End: p.makeLocation(endOffset), + Stop: p.makeLocation(endOffset), }} // Build comma-separated path key key := "" diff --git a/meta/src/meta/templates/parser.jl.template b/meta/src/meta/templates/parser.jl.template index 19ac964f..65506098 100644 --- a/meta/src/meta/templates/parser.jl.template +++ b/meta/src/meta/templates/parser.jl.template @@ -36,7 +36,7 @@ end struct Span start::Location - var"end"::Location + stop::Location end struct Token diff --git a/meta/src/meta/templates/parser.py.template b/meta/src/meta/templates/parser.py.template index 0ca8ebb7..8ca8f78f 100644 --- a/meta/src/meta/templates/parser.py.template +++ b/meta/src/meta/templates/parser.py.template @@ -46,24 +46,24 @@ class Location: class Span: - """Source span from start to end location.""" + """Source span from start to stop location.""" - __slots__ = ("start", "end") + __slots__ = ("start", "stop") - def __init__(self, start: Location, end: Location): + def __init__(self, start: Location, stop: Location): self.start = start - self.end = end + self.stop = stop def __repr__(self) -> str: - return f"Span({{self.start}}, {{self.end}})" + return f"Span({{self.start}}, {{self.stop}})" def __eq__(self, other) -> bool: if not isinstance(other, Span): return NotImplemented - return self.start == other.start and self.end == other.end + return self.start == other.start and self.stop == other.stop def __hash__(self) -> int: - return hash((self.start, self.end)) + return hash((self.start, self.stop)) class Token: diff --git a/sdks/go/src/parser.go b/sdks/go/src/parser.go index a4055c07..0a1d65f8 100644 --- a/sdks/go/src/parser.go +++ b/sdks/go/src/parser.go @@ -29,10 +29,10 @@ type Location struct { Offset int } -// Span represents a source span from start to end location. +// Span represents a source span from start to stop location. type Span struct { Start Location - End Location + Stop Location } // ParseError represents a parse error @@ -407,7 +407,7 @@ func (p *Parser) recordSpan(startOffset int) { } s := Span{ Start: p.makeLocation(startOffset), - End: p.makeLocation(endOffset), + Stop: p.makeLocation(endOffset), } // Build comma-separated path key key := "" diff --git a/sdks/go/test/file_provenance_test.go b/sdks/go/test/file_provenance_test.go new file mode 100644 index 00000000..14649a5a --- /dev/null +++ b/sdks/go/test/file_provenance_test.go @@ -0,0 +1,178 @@ +package test + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + lqp "github.com/RelationalAI/logical-query-protocol/sdks/go/src" +) + +// lqpFiles returns all .lqp files in the tests/lqp directory. +func lqpFiles(t *testing.T) []string { + t.Helper() + root := repoRoot(t) + dir := filepath.Join(root, "tests", "lqp") + entries, err := os.ReadDir(dir) + if err != nil { + t.Fatalf("Failed to read LQP directory: %v", err) + } + var files []string + for _, e := range entries { + if strings.HasSuffix(e.Name(), ".lqp") { + files = append(files, filepath.Join(dir, e.Name())) + } + } + return files +} + +// lineOffsets returns 0-based byte offsets of the start of each 1-based line. +func lineOffsets(content string) []int { + offsets := []int{0} + for i, ch := range content { + if ch == '\n' { + offsets = append(offsets, i+1) + } + } + return offsets +} + +func TestFileProvenanceSpansValid(t *testing.T) { + for _, file := range lqpFiles(t) { + name := filepath.Base(file) + t.Run(name, func(t *testing.T) { + data, err := os.ReadFile(file) + if err != nil { + t.Fatalf("Failed to read %s: %v", name, err) + } + content := string(data) + + _, provenance, err := lqp.Parse(content) + if err != nil { + t.Fatalf("Failed to parse %s: %v", name, err) + } + if len(provenance) == 0 { + t.Fatalf("No provenance entries for %s", name) + } + + for path, span := range provenance { + if span.Start.Offset > span.Stop.Offset { + t.Errorf("%s path %q: start offset %d > end offset %d", + name, path, span.Start.Offset, span.Stop.Offset) + } + if span.Start.Offset < 0 || span.Start.Offset > len(content) { + t.Errorf("%s path %q: start offset %d out of range", + name, path, span.Start.Offset) + } + if span.Stop.Offset < 0 || span.Stop.Offset > len(content) { + t.Errorf("%s path %q: end offset %d out of range", + name, path, span.Stop.Offset) + } + if span.Start.Line < 1 { + t.Errorf("%s path %q: start line %d < 1", + name, path, span.Start.Line) + } + if span.Start.Column < 1 { + t.Errorf("%s path %q: start column %d < 1", + name, path, span.Start.Column) + } + } + }) + } +} + +func TestFileProvenanceRootSpansTransaction(t *testing.T) { + for _, file := range lqpFiles(t) { + name := filepath.Base(file) + t.Run(name, func(t *testing.T) { + data, err := os.ReadFile(file) + if err != nil { + t.Fatalf("Failed to read %s: %v", name, err) + } + content := string(data) + + _, provenance, err := lqp.Parse(content) + if err != nil { + t.Fatalf("Failed to parse %s: %v", name, err) + } + + span, ok := provenance[""] + if !ok { + t.Fatalf("%s: no root provenance entry", name) + } + text := content[span.Start.Offset:span.Stop.Offset] + if !strings.HasPrefix(text, "(transaction") { + t.Errorf("%s: root span text starts with %q, expected '(transaction'", + name, text[:min(30, len(text))]) + } + }) + } +} + +func TestFileProvenanceEpochText(t *testing.T) { + for _, file := range lqpFiles(t) { + name := filepath.Base(file) + t.Run(name, func(t *testing.T) { + data, err := os.ReadFile(file) + if err != nil { + t.Fatalf("Failed to read %s: %v", name, err) + } + content := string(data) + + _, provenance, err := lqp.Parse(content) + if err != nil { + t.Fatalf("Failed to parse %s: %v", name, err) + } + + epochCount := 0 + for idx := 0; ; idx++ { + key := fmt.Sprintf("1,%d", idx) + span, ok := provenance[key] + if !ok { + break + } + text := content[span.Start.Offset:span.Stop.Offset] + if !strings.HasPrefix(text, "(epoch") { + t.Errorf("%s: epoch %d span text starts with %q, expected '(epoch'", + name, idx, text[:min(30, len(text))]) + } + epochCount++ + } + if epochCount == 0 { + t.Errorf("%s: no epoch provenance entries", name) + } + }) + } +} + +func TestFileProvenanceOffsetsMatchLineColumn(t *testing.T) { + for _, file := range lqpFiles(t) { + name := filepath.Base(file) + t.Run(name, func(t *testing.T) { + data, err := os.ReadFile(file) + if err != nil { + t.Fatalf("Failed to read %s: %v", name, err) + } + content := string(data) + offsets := lineOffsets(content) + + _, provenance, err := lqp.Parse(content) + if err != nil { + t.Fatalf("Failed to parse %s: %v", name, err) + } + + for path, span := range provenance { + loc := span.Start + if loc.Line >= 1 && loc.Line <= len(offsets) { + expected := offsets[loc.Line-1] + (loc.Column - 1) + if loc.Offset != expected { + t.Errorf("%s path %q: offset %d != expected %d (line %d, col %d)", + name, path, loc.Offset, expected, loc.Line, loc.Column) + } + } + } + }) + } +} diff --git a/sdks/go/test/provenance_test.go b/sdks/go/test/provenance_test.go index add6dd0e..492fe258 100644 --- a/sdks/go/test/provenance_test.go +++ b/sdks/go/test/provenance_test.go @@ -110,13 +110,13 @@ func TestProvenanceSpanOrdering(t *testing.T) { } for path, span := range provenance { - if span.Start.Offset > span.End.Offset { + if span.Start.Offset > span.Stop.Offset { t.Errorf("Bad span at path %q: start %d > end %d", - path, span.Start.Offset, span.End.Offset) + path, span.Start.Offset, span.Stop.Offset) } - if span.Start.Line > span.End.Line { + if span.Start.Line > span.Stop.Line { t.Errorf("Bad line ordering at path %q: start %d > end %d", - path, span.Start.Line, span.End.Line) + path, span.Start.Line, span.Stop.Line) } } } diff --git a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl index 2fde55fd..46d4cee4 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl @@ -36,7 +36,7 @@ end struct Span start::Location - var"end"::Location + stop::Location end struct Token diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/file_provenance_tests.jl b/sdks/julia/LogicalQueryProtocol.jl/test/file_provenance_tests.jl new file mode 100644 index 00000000..4ee5f6d9 --- /dev/null +++ b/sdks/julia/LogicalQueryProtocol.jl/test/file_provenance_tests.jl @@ -0,0 +1,96 @@ +@testitem "File provenance - spans valid" setup=[ParserSetup] begin + test_files_dir = joinpath(@__DIR__, "lqp") + @test isdir(test_files_dir) + + lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) + @test !isempty(lqp_files) + + for lqp_file in lqp_files + lqp_path = joinpath(test_files_dir, lqp_file) + content = read(lqp_path, String) + _, provenance = Parser.parse(content) + + @test !isempty(provenance) + + for (path, span) in provenance + # start <= end + @test span.start.offset <= span.stop.offset + # offsets in range (1-based byte offsets in Julia) + @test 1 <= span.start.offset <= ncodeunits(content) + 1 + @test 1 <= span.stop.offset <= ncodeunits(content) + 1 + # lines are 1-based + @test span.start.line >= 1 + # columns are 1-based + @test span.start.column >= 1 + end + end +end + +@testitem "File provenance - root spans transaction" setup=[ParserSetup] begin + test_files_dir = joinpath(@__DIR__, "lqp") + lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) + + for lqp_file in lqp_files + lqp_path = joinpath(test_files_dir, lqp_file) + content = read(lqp_path, String) + _, provenance = Parser.parse(content) + + @test haskey(provenance, ()) + root_span = provenance[()] + # Use codeunits for byte-based slicing to handle Unicode correctly + text = String(codeunits(content)[root_span.start.offset:root_span.stop.offset - 1]) + @test startswith(text, "(transaction") + end +end + +@testitem "File provenance - epoch text" setup=[ParserSetup] begin + test_files_dir = joinpath(@__DIR__, "lqp") + lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) + + for lqp_file in lqp_files + lqp_path = joinpath(test_files_dir, lqp_file) + content = read(lqp_path, String) + _, provenance = Parser.parse(content) + + epoch_count = 0 + idx = 0 + while true + key = (1, idx) + haskey(provenance, key) || break + span = provenance[key] + text = String(codeunits(content)[span.start.offset:span.stop.offset - 1]) + @test startswith(text, "(epoch") + epoch_count += 1 + idx += 1 + end + @test epoch_count > 0 + end +end + +@testitem "File provenance - offsets match line and column" setup=[ParserSetup] begin + test_files_dir = joinpath(@__DIR__, "lqp") + lqp_files = sort(filter(f -> endswith(f, ".lqp"), readdir(test_files_dir))) + + for lqp_file in lqp_files + lqp_path = joinpath(test_files_dir, lqp_file) + content = read(lqp_path, String) + _, provenance = Parser.parse(content) + + # Build line offset table (1-based byte offsets for Julia) + bytes = codeunits(content) + line_starts = [1] + for i in 1:length(bytes) + if bytes[i] == UInt8('\n') && i < length(bytes) + push!(line_starts, i + 1) + end + end + + for (path, span) in provenance + loc = span.start + if 1 <= loc.line <= length(line_starts) + expected_offset = line_starts[loc.line] + (loc.column - 1) + @test loc.offset == expected_offset + end + end + end +end diff --git a/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl b/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl index 132f64a9..849f6768 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/test/provenance_tests.jl @@ -61,8 +61,8 @@ end _, provenance = Parser.parse(input) for (path, span) in provenance - @test span.start.offset <= getfield(span, :end).offset - @test span.start.line <= getfield(span, :end).line + @test span.start.offset <= span.stop.offset + @test span.start.line <= span.stop.line end end @@ -96,5 +96,5 @@ end root_span = provenance[()] @test root_span isa Span @test root_span.start isa Location - @test getfield(root_span, :end) isa Location + @test root_span.stop isa Location end diff --git a/sdks/python/src/lqp/gen/parser.py b/sdks/python/src/lqp/gen/parser.py index d74e9375..047413e6 100644 --- a/sdks/python/src/lqp/gen/parser.py +++ b/sdks/python/src/lqp/gen/parser.py @@ -48,24 +48,24 @@ def __hash__(self) -> int: class Span: - """Source span from start to end location.""" + """Source span from start to stop location.""" - __slots__ = ("start", "end") + __slots__ = ("start", "stop") - def __init__(self, start: Location, end: Location): + def __init__(self, start: Location, stop: Location): self.start = start - self.end = end + self.stop = stop def __repr__(self) -> str: - return f"Span({self.start}, {self.end})" + return f"Span({self.start}, {self.stop})" def __eq__(self, other) -> bool: if not isinstance(other, Span): return NotImplemented - return self.start == other.start and self.end == other.end + return self.start == other.start and self.stop == other.stop def __hash__(self) -> int: - return hash((self.start, self.end)) + return hash((self.start, self.stop)) class Token: diff --git a/sdks/python/tests/test_file_provenance.py b/sdks/python/tests/test_file_provenance.py new file mode 100644 index 00000000..d8569d66 --- /dev/null +++ b/sdks/python/tests/test_file_provenance.py @@ -0,0 +1,154 @@ +"""Tests that parse LQP files from disk and verify provenance spans are correct.""" + +import os + +import pytest + +from lqp.gen.parser import parse + +from .utils import get_lqp_input_files + + +def extract_text(content: str, span) -> str: + """Extract the substring of content covered by a span (0-based offsets).""" + return content[span.start.offset : span.stop.offset] + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_provenance_spans_valid(input_file): + """Every provenance span should have valid line/column/offset and start <= end.""" + with open(input_file) as f: + content = f.read() + + _, provenance = parse(content) + assert len(provenance) > 0, f"No provenance entries for {input_file}" + + lines = content.split("\n") + + for path, span in provenance.items(): + # start <= end + assert span.start.offset <= span.stop.offset, ( + f"{os.path.basename(input_file)} path {path}: " + f"start offset {span.start.offset} > end offset {span.stop.offset}" + ) + assert span.start.line <= span.stop.line or ( + span.start.line == span.stop.line and span.start.column <= span.stop.column + ), ( + f"{os.path.basename(input_file)} path {path}: " + f"start {span.start.line}:{span.start.column} > " + f"end {span.stop.line}:{span.stop.column}" + ) + + # offsets in range + assert 0 <= span.start.offset <= len(content), ( + f"{os.path.basename(input_file)} path {path}: " + f"start offset {span.start.offset} out of range" + ) + assert 0 <= span.stop.offset <= len(content), ( + f"{os.path.basename(input_file)} path {path}: " + f"end offset {span.stop.offset} out of range" + ) + + # lines are 1-based and valid + assert 1 <= span.start.line <= len(lines), ( + f"{os.path.basename(input_file)} path {path}: " + f"start line {span.start.line} out of range" + ) + + # columns are 1-based + assert span.start.column >= 1, ( + f"{os.path.basename(input_file)} path {path}: " + f"start column {span.start.column} < 1" + ) + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_provenance_root_spans_file(input_file): + """The root path () should start at the beginning of the transaction.""" + with open(input_file) as f: + content = f.read() + + _, provenance = parse(content) + assert () in provenance, f"No root provenance for {input_file}" + + root_span = provenance[()] + text = extract_text(content, root_span) + assert text.startswith("(transaction"), ( + f"{os.path.basename(input_file)}: root span text starts with " + f"{text[:30]!r}, expected '(transaction'" + ) + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_provenance_epoch_text(input_file): + """Each epoch span should start with '(epoch'.""" + with open(input_file) as f: + content = f.read() + + _, provenance = parse(content) + + idx = 0 + while True: + key = (1, idx) + if key not in provenance: + break + text = extract_text(content, provenance[key]) + assert text.startswith("(epoch"), ( + f"{os.path.basename(input_file)}: epoch {idx} span text starts with " + f"{text[:30]!r}, expected '(epoch'" + ) + idx += 1 + + # Every file should have at least one epoch + assert idx > 0, f"No epoch provenance entries for {input_file}" + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_provenance_writes_text(input_file): + """Each writes span within an epoch should start with '(' (a write action).""" + with open(input_file) as f: + content = f.read() + + _, provenance = parse(content) + + epoch_idx = 0 + while (1, epoch_idx) in provenance: + # writes = field 1 within Epoch, each write is (1, epoch_idx, 1, write_idx) + write_idx = 0 + while True: + key = (1, epoch_idx, 1, write_idx) + if key not in provenance: + break + span = provenance[key] + text = extract_text(content, span) + assert text.startswith("("), ( + f"{os.path.basename(input_file)}: write {write_idx} in epoch " + f"{epoch_idx} span text starts with {text[:30]!r}" + ) + write_idx += 1 + epoch_idx += 1 + + +@pytest.mark.parametrize("input_file", get_lqp_input_files()) +def test_provenance_offsets_match_line_column(input_file): + """Verify that offset is consistent with line and column.""" + with open(input_file) as f: + content = f.read() + + _, provenance = parse(content) + + # Build a map from (line, col) -> offset using 1-based lines and columns + line_offsets = [0] # offset of start of line 1 + for i, ch in enumerate(content): + if ch == "\n": + line_offsets.append(i + 1) + + for path, span in provenance.items(): + loc = span.start + if loc.line <= len(line_offsets): + expected_offset = line_offsets[loc.line - 1] + (loc.column - 1) + assert loc.offset == expected_offset, ( + f"{os.path.basename(input_file)} path {path}: " + f"offset {loc.offset} != expected {expected_offset} " + f"(line {loc.line}, col {loc.column})" + ) diff --git a/sdks/python/tests/test_provenance.py b/sdks/python/tests/test_provenance.py index 2c29c05c..f91a94c6 100644 --- a/sdks/python/tests/test_provenance.py +++ b/sdks/python/tests/test_provenance.py @@ -70,8 +70,8 @@ def test_provenance_span_ordering(): """Verify start <= end for all spans.""" _, provenance = parse(SIMPLE_INPUT) for path, span in provenance.items(): - assert span.start.offset <= span.end.offset, f"Bad span at path {path}" - assert span.start.line <= span.end.line, f"Bad line ordering at path {path}" + assert span.start.offset <= span.stop.offset, f"Bad span at path {path}" + assert span.start.line <= span.stop.line, f"Bad line ordering at path {path}" def test_provenance_multiple_epochs(): @@ -107,9 +107,9 @@ def test_provenance_location_fields(): def test_provenance_span_fields(): - """Verify Span has start and end Location.""" + """Verify Span has start and stop Location.""" _, provenance = parse(SIMPLE_INPUT) root_span = provenance[()] assert isinstance(root_span, Span) assert isinstance(root_span.start, Location) - assert isinstance(root_span.end, Location) + assert isinstance(root_span.stop, Location) From 47bf5b9fcbca05eb8b1678e1b4aaf3ddffe204f6 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Thu, 26 Feb 2026 11:26:47 +0100 Subject: [PATCH 25/25] Use the provenance info in the validator --- meta/src/meta/parser_gen.py | 150 +- sdks/go/src/parser.go | 4750 +++++++++-------- .../LogicalQueryProtocol.jl/src/parser.jl | 4068 +++++++------- sdks/python/src/lqp/cli.py | 5 +- sdks/python/src/lqp/gen/parser.py | 4174 ++++++++------- sdks/python/src/lqp/proto_validator.py | 152 +- sdks/python/tests/test_proto_validator.py | 42 +- 7 files changed, 7036 insertions(+), 6305 deletions(-) diff --git a/meta/src/meta/parser_gen.py b/meta/src/meta/parser_gen.py index 4d07c45c..4479aad7 100644 --- a/meta/src/meta/parser_gen.py +++ b/meta/src/meta/parser_gen.py @@ -90,7 +90,7 @@ Terminal, ) from .grammar_utils import is_epsilon, rhs_elements -from .proto_ast import ProtoMessage +from .proto_ast import ProtoField, ProtoMessage from .target import ( Assign, BaseType, @@ -134,45 +134,82 @@ class AmbiguousGrammarError(Exception): pass -def _build_param_field_numbers( +def _proto_fields_by_name( + proto_messages: dict[tuple[str, str], ProtoMessage] | None, + module: str, + name: str, +) -> dict[str, ProtoField]: + """Return a name->ProtoField map for a proto message, or {} if not found.""" + if proto_messages is None: + return {} + proto_msg = proto_messages.get((module, name)) + if proto_msg is None: + return {} + result: dict[str, ProtoField] = {} + for f in proto_msg.fields: + result[f.name] = f + for oneof in proto_msg.oneofs: + for f in oneof.fields: + result[f.name] = f + return result + + +def _build_param_proto_fields( action: Lambda, proto_messages: dict[tuple[str, str], ProtoMessage] | None, -) -> dict[int, int]: - """Map lambda parameter indices to protobuf field numbers. +) -> dict[int, ProtoField]: + """Map lambda parameter indices to protobuf ProtoField descriptors. Inspects the semantic action's body. When it is a NewMessage, cross-references - field names with proto_messages to find field numbers. + field names with proto_messages to find proto fields. - Returns dict mapping parameter index to proto field number. + As a fallback, when the action's return type is a known proto message, + matches parameter names to proto field names. + + Returns dict mapping parameter index to ProtoField. """ if proto_messages is None: return {} body = action.body - if not isinstance(body, NewMessage): + if isinstance(body, NewMessage): + fields_by_name = _proto_fields_by_name(proto_messages, body.module, body.name) + if not fields_by_name: + return {} + param_names = [p.name for p in action.params] + result: dict[int, ProtoField] = {} + for field_name, field_expr in body.fields: + pf = fields_by_name.get(field_name) + if pf is None: + continue + param_name = _extract_param_name(field_expr, param_names) + if param_name is not None and param_name in param_names: + param_idx = param_names.index(param_name) + result.setdefault(param_idx, pf) + return result + # Fallback: match parameter names against the return type's proto fields. + return _build_param_proto_fields_by_return_type(action, proto_messages) + + +def _build_param_proto_fields_by_return_type( + action: Lambda, + proto_messages: dict[tuple[str, str], ProtoMessage] | None, +) -> dict[int, ProtoField]: + """Fallback: match parameter names to proto fields via the return type.""" + from .target import MessageType + + if proto_messages is None: return {} - key = (body.module, body.name) - proto_msg = proto_messages.get(key) - if proto_msg is None: + rt = action.return_type + if not isinstance(rt, MessageType): return {} - # Build name -> field number map from proto definition - name_to_number: dict[str, int] = {} - for f in proto_msg.fields: - name_to_number[f.name] = f.number - for oneof in proto_msg.oneofs: - for f in oneof.fields: - name_to_number[f.name] = f.number - # Map each message field to the lambda param that provides its value - param_names = [p.name for p in action.params] - result: dict[int, int] = {} - for field_name, field_expr in body.fields: - field_num = name_to_number.get(field_name) - if field_num is None: - continue - # Determine which param provides this field - param_name = _extract_param_name(field_expr, param_names) - if param_name is not None and param_name in param_names: - param_idx = param_names.index(param_name) - result[param_idx] = field_num + fields_by_name = _proto_fields_by_name(proto_messages, rt.module, rt.name) + if not fields_by_name: + return {} + result: dict[int, ProtoField] = {} + for i, param in enumerate(action.params): + pf = fields_by_name.get(param.name) + if pf is not None: + result[i] = pf return result @@ -507,6 +544,15 @@ def _generate_parse_rhs_ir( return Seq([parse_expr, apply_lambda(action, [])]) var_name = gensym(action.params[0].name) var = Var(var_name, rhs.target_type()) + # Wrap with push_path when the action maps this param to a proto + # field (e.g., oneof dispatch: formula -> atom pushes the atom + # field number onto the provenance path). + if proto_messages is not None: + pf = _build_param_proto_fields(action, proto_messages).get(0) + if pf is not None: + stmts = _wrap_with_path(pf.number, var, parse_expr) + stmts.append(apply_lambda(action, [var])) + return Seq(stmts) return Let(var, parse_expr, apply_lambda(action, [var])) return parse_expr elif isinstance(rhs, Option): @@ -561,10 +607,10 @@ def _generate_parse_rhs_ir_sequence( if is_epsilon(rhs): return Lit(None) - # Compute param->field_number mapping for provenance - param_field_numbers: dict[int, int] = {} + # Compute param->proto field mapping for provenance + param_proto_fields: dict[int, ProtoField] = {} if action is not None and proto_messages is not None: - param_field_numbers = _build_param_field_numbers(action, proto_messages) + param_proto_fields = _build_param_proto_fields(action, proto_messages) exprs = [] arg_vars = [] @@ -593,16 +639,23 @@ def _generate_parse_rhs_ir_sequence( ) var_name = gensym("arg") var = Var(var_name, elem.target_type()) - field_num = param_field_numbers.get(non_literal_count) - if field_num is not None and isinstance(elem, Star): - # For repeated fields: push field number around the whole - # Star loop, and push/pop a 0-based index inside the loop + pf = param_proto_fields.get(non_literal_count) + if pf is not None and pf.is_repeated and isinstance(elem, Star): + # Repeated proto field parsed as a Star: push field number + # around the whole loop and push/pop an index per element. + stmts = _wrap_star_with_index_path( + elem, var, grammar, follow_set_i, pf.number, proto_messages + ) + exprs.extend(stmts) + elif isinstance(elem, Star) and proto_messages is not None: + # Star without a repeated proto field (helper rule): still + # push/pop an index per element for provenance. stmts = _wrap_star_with_index_path( - elem, var, grammar, follow_set_i, field_num, proto_messages + elem, var, grammar, follow_set_i, None, proto_messages ) exprs.extend(stmts) - elif field_num is not None: - exprs.extend(_wrap_with_path(field_num, var, elem_ir)) + elif pf is not None: + exprs.extend(_wrap_with_path(pf.number, var, elem_ir)) else: exprs.append(Assign(var, elem_ir)) arg_vars.append(var) @@ -628,11 +681,12 @@ def _wrap_star_with_index_path( result_var: Var, grammar: Grammar, follow_set: TerminalSequenceSet, - field_num: int, + field_num: int | None, proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, ) -> list[TargetExpr]: - """Return statements for a Star loop wrapped with push_path(field_num) - and push_path(index)/pop_path() around each element. + """Return statements for a Star loop with push_path(index)/pop_path() + around each element. When field_num is provided, the entire loop is + also wrapped with push_path(field_num)/pop_path(). Assigns the resulting list to result_var.""" xs = Var(gensym("xs"), ListType(star.rhs.target_type())) cond = Var(gensym("cond"), BaseType("Boolean")) @@ -665,8 +719,10 @@ def _wrap_star_with_index_path( ), ), ) - return [ - Call(make_builtin("push_path"), [Lit(field_num)]), - Assign(result_var, inner), - Call(make_builtin("pop_path"), []), - ] + if field_num is not None: + return [ + Call(make_builtin("push_path"), [Lit(field_num)]), + Assign(result_var, inner), + Call(make_builtin("pop_path"), []), + ] + return [Assign(result_var, inner)] diff --git a/sdks/go/src/parser.go b/sdks/go/src/parser.go index 0a1d65f8..935ba554 100644 --- a/sdks/go/src/parser.go +++ b/sdks/go/src/parser.go @@ -605,150 +605,150 @@ func toPascalCase(s string) string { // --- Helper functions --- func (p *Parser) _extract_value_int32(value *pb.Value, default_ int64) int32 { - var _t1846 interface{} + var _t1922 interface{} if (value != nil && hasProtoField(value, "int_value")) { return int32(value.GetIntValue()) } - _ = _t1846 + _ = _t1922 return int32(default_) } func (p *Parser) _extract_value_int64(value *pb.Value, default_ int64) int64 { - var _t1847 interface{} + var _t1923 interface{} if (value != nil && hasProtoField(value, "int_value")) { return value.GetIntValue() } - _ = _t1847 + _ = _t1923 return default_ } func (p *Parser) _extract_value_string(value *pb.Value, default_ string) string { - var _t1848 interface{} + var _t1924 interface{} if (value != nil && hasProtoField(value, "string_value")) { return value.GetStringValue() } - _ = _t1848 + _ = _t1924 return default_ } func (p *Parser) _extract_value_boolean(value *pb.Value, default_ bool) bool { - var _t1849 interface{} + var _t1925 interface{} if (value != nil && hasProtoField(value, "boolean_value")) { return value.GetBooleanValue() } - _ = _t1849 + _ = _t1925 return default_ } func (p *Parser) _extract_value_string_list(value *pb.Value, default_ []string) []string { - var _t1850 interface{} + var _t1926 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []string{value.GetStringValue()} } - _ = _t1850 + _ = _t1926 return default_ } func (p *Parser) _try_extract_value_int64(value *pb.Value) *int64 { - var _t1851 interface{} + var _t1927 interface{} if (value != nil && hasProtoField(value, "int_value")) { return ptr(value.GetIntValue()) } - _ = _t1851 + _ = _t1927 return nil } func (p *Parser) _try_extract_value_float64(value *pb.Value) *float64 { - var _t1852 interface{} + var _t1928 interface{} if (value != nil && hasProtoField(value, "float_value")) { return ptr(value.GetFloatValue()) } - _ = _t1852 + _ = _t1928 return nil } func (p *Parser) _try_extract_value_bytes(value *pb.Value) []byte { - var _t1853 interface{} + var _t1929 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []byte(value.GetStringValue()) } - _ = _t1853 + _ = _t1929 return nil } func (p *Parser) _try_extract_value_uint128(value *pb.Value) *pb.UInt128Value { - var _t1854 interface{} + var _t1930 interface{} if (value != nil && hasProtoField(value, "uint128_value")) { return value.GetUint128Value() } - _ = _t1854 + _ = _t1930 return nil } func (p *Parser) construct_csv_config(config_dict [][]interface{}) *pb.CSVConfig { config := dictFromList(config_dict) - _t1855 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) - header_row := _t1855 - _t1856 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) - skip := _t1856 - _t1857 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") - new_line := _t1857 - _t1858 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") - delimiter := _t1858 - _t1859 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") - quotechar := _t1859 - _t1860 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") - escapechar := _t1860 - _t1861 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") - comment := _t1861 - _t1862 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) - missing_strings := _t1862 - _t1863 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") - decimal_separator := _t1863 - _t1864 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") - encoding := _t1864 - _t1865 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") - compression := _t1865 - _t1866 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} - return _t1866 + _t1931 := p._extract_value_int32(dictGetValue(config, "csv_header_row"), 1) + header_row := _t1931 + _t1932 := p._extract_value_int64(dictGetValue(config, "csv_skip"), 0) + skip := _t1932 + _t1933 := p._extract_value_string(dictGetValue(config, "csv_new_line"), "") + new_line := _t1933 + _t1934 := p._extract_value_string(dictGetValue(config, "csv_delimiter"), ",") + delimiter := _t1934 + _t1935 := p._extract_value_string(dictGetValue(config, "csv_quotechar"), "\"") + quotechar := _t1935 + _t1936 := p._extract_value_string(dictGetValue(config, "csv_escapechar"), "\"") + escapechar := _t1936 + _t1937 := p._extract_value_string(dictGetValue(config, "csv_comment"), "") + comment := _t1937 + _t1938 := p._extract_value_string_list(dictGetValue(config, "csv_missing_strings"), []string{}) + missing_strings := _t1938 + _t1939 := p._extract_value_string(dictGetValue(config, "csv_decimal_separator"), ".") + decimal_separator := _t1939 + _t1940 := p._extract_value_string(dictGetValue(config, "csv_encoding"), "utf-8") + encoding := _t1940 + _t1941 := p._extract_value_string(dictGetValue(config, "csv_compression"), "auto") + compression := _t1941 + _t1942 := &pb.CSVConfig{HeaderRow: header_row, Skip: skip, NewLine: new_line, Delimiter: delimiter, Quotechar: quotechar, Escapechar: escapechar, Comment: comment, MissingStrings: missing_strings, DecimalSeparator: decimal_separator, Encoding: encoding, Compression: compression} + return _t1942 } func (p *Parser) construct_betree_info(key_types []*pb.Type, value_types []*pb.Type, config_dict [][]interface{}) *pb.BeTreeInfo { config := dictFromList(config_dict) - _t1867 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) - epsilon := _t1867 - _t1868 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) - max_pivots := _t1868 - _t1869 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) - max_deltas := _t1869 - _t1870 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) - max_leaf := _t1870 - _t1871 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} - storage_config := _t1871 - _t1872 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) - root_pageid := _t1872 - _t1873 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) - inline_data := _t1873 - _t1874 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) - element_count := _t1874 - _t1875 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) - tree_height := _t1875 - _t1876 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} + _t1943 := p._try_extract_value_float64(dictGetValue(config, "betree_config_epsilon")) + epsilon := _t1943 + _t1944 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_pivots")) + max_pivots := _t1944 + _t1945 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_deltas")) + max_deltas := _t1945 + _t1946 := p._try_extract_value_int64(dictGetValue(config, "betree_config_max_leaf")) + max_leaf := _t1946 + _t1947 := &pb.BeTreeConfig{Epsilon: deref(epsilon, 0.0), MaxPivots: deref(max_pivots, 0), MaxDeltas: deref(max_deltas, 0), MaxLeaf: deref(max_leaf, 0)} + storage_config := _t1947 + _t1948 := p._try_extract_value_uint128(dictGetValue(config, "betree_locator_root_pageid")) + root_pageid := _t1948 + _t1949 := p._try_extract_value_bytes(dictGetValue(config, "betree_locator_inline_data")) + inline_data := _t1949 + _t1950 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_element_count")) + element_count := _t1950 + _t1951 := p._try_extract_value_int64(dictGetValue(config, "betree_locator_tree_height")) + tree_height := _t1951 + _t1952 := &pb.BeTreeLocator{ElementCount: deref(element_count, 0), TreeHeight: deref(tree_height, 0)} if root_pageid != nil { - _t1876.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} + _t1952.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} } else { - _t1876.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} + _t1952.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} } - relation_locator := _t1876 - _t1877 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} - return _t1877 + relation_locator := _t1952 + _t1953 := &pb.BeTreeInfo{KeyTypes: key_types, ValueTypes: value_types, StorageConfig: storage_config, RelationLocator: relation_locator} + return _t1953 } func (p *Parser) default_configure() *pb.Configure { - _t1878 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} - ivm_config := _t1878 - _t1879 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} - return _t1879 + _t1954 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} + ivm_config := _t1954 + _t1955 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} + return _t1955 } func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure { @@ -770,32 +770,32 @@ func (p *Parser) construct_configure(config_dict [][]interface{}) *pb.Configure } } } - _t1880 := &pb.IVMConfig{Level: maintenance_level} - ivm_config := _t1880 - _t1881 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) - semantics_version := _t1881 - _t1882 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} - return _t1882 + _t1956 := &pb.IVMConfig{Level: maintenance_level} + ivm_config := _t1956 + _t1957 := p._extract_value_int64(dictGetValue(config, "semantics_version"), 0) + semantics_version := _t1957 + _t1958 := &pb.Configure{SemanticsVersion: semantics_version, IvmConfig: ivm_config} + return _t1958 } func (p *Parser) export_csv_config(path string, columns []*pb.ExportCSVColumn, config_dict [][]interface{}) *pb.ExportCSVConfig { config := dictFromList(config_dict) - _t1883 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) - partition_size := _t1883 - _t1884 := p._extract_value_string(dictGetValue(config, "compression"), "") - compression := _t1884 - _t1885 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) - syntax_header_row := _t1885 - _t1886 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") - syntax_missing_string := _t1886 - _t1887 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") - syntax_delim := _t1887 - _t1888 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") - syntax_quotechar := _t1888 - _t1889 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") - syntax_escapechar := _t1889 - _t1890 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} - return _t1890 + _t1959 := p._extract_value_int64(dictGetValue(config, "partition_size"), 0) + partition_size := _t1959 + _t1960 := p._extract_value_string(dictGetValue(config, "compression"), "") + compression := _t1960 + _t1961 := p._extract_value_boolean(dictGetValue(config, "syntax_header_row"), true) + syntax_header_row := _t1961 + _t1962 := p._extract_value_string(dictGetValue(config, "syntax_missing_string"), "") + syntax_missing_string := _t1962 + _t1963 := p._extract_value_string(dictGetValue(config, "syntax_delim"), ",") + syntax_delim := _t1963 + _t1964 := p._extract_value_string(dictGetValue(config, "syntax_quotechar"), "\"") + syntax_quotechar := _t1964 + _t1965 := p._extract_value_string(dictGetValue(config, "syntax_escapechar"), "\\") + syntax_escapechar := _t1965 + _t1966 := &pb.ExportCSVConfig{Path: path, DataColumns: columns, PartitionSize: ptr(partition_size), Compression: ptr(compression), SyntaxHeaderRow: ptr(syntax_header_row), SyntaxMissingString: ptr(syntax_missing_string), SyntaxDelim: ptr(syntax_delim), SyntaxQuotechar: ptr(syntax_quotechar), SyntaxEscapechar: ptr(syntax_escapechar)} + return _t1966 } // --- Parse functions --- @@ -805,20 +805,20 @@ func (p *Parser) parse_transaction() *pb.Transaction { p.consumeLiteral("(") p.consumeLiteral("transaction") p.pushPath(int(2)) - var _t1236 *pb.Configure + var _t1312 *pb.Configure if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("configure", 1)) { - _t1237 := p.parse_configure() - _t1236 = _t1237 + _t1313 := p.parse_configure() + _t1312 = _t1313 } - configure592 := _t1236 + configure592 := _t1312 p.popPath() p.pushPath(int(3)) - var _t1238 *pb.Sync + var _t1314 *pb.Sync if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("sync", 1)) { - _t1239 := p.parse_sync() - _t1238 = _t1239 + _t1315 := p.parse_sync() + _t1314 = _t1315 } - sync593 := _t1238 + sync593 := _t1314 p.popPath() p.pushPath(int(1)) xs598 := []*pb.Epoch{} @@ -826,8 +826,8 @@ func (p *Parser) parse_transaction() *pb.Transaction { idx600 := 0 for cond599 { p.pushPath(int(idx600)) - _t1240 := p.parse_epoch() - item601 := _t1240 + _t1316 := p.parse_epoch() + item601 := _t1316 p.popPath() xs598 = append(xs598, item601) idx600 = (idx600 + 1) @@ -836,13 +836,13 @@ func (p *Parser) parse_transaction() *pb.Transaction { epochs597 := xs598 p.popPath() p.consumeLiteral(")") - _t1241 := p.default_configure() - _t1242 := configure592 + _t1317 := p.default_configure() + _t1318 := configure592 if configure592 == nil { - _t1242 = _t1241 + _t1318 = _t1317 } - _t1243 := &pb.Transaction{Epochs: epochs597, Configure: _t1242, Sync: sync593} - result603 := _t1243 + _t1319 := &pb.Transaction{Epochs: epochs597, Configure: _t1318, Sync: sync593} + result603 := _t1319 p.recordSpan(int(span_start602)) return result603 } @@ -851,3572 +851,3766 @@ func (p *Parser) parse_configure() *pb.Configure { span_start605 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("configure") - _t1244 := p.parse_config_dict() - config_dict604 := _t1244 + _t1320 := p.parse_config_dict() + config_dict604 := _t1320 p.consumeLiteral(")") - _t1245 := p.construct_configure(config_dict604) - result606 := _t1245 + _t1321 := p.construct_configure(config_dict604) + result606 := _t1321 p.recordSpan(int(span_start605)) return result606 } func (p *Parser) parse_config_dict() [][]interface{} { - span_start611 := int64(p.spanStart()) + span_start615 := int64(p.spanStart()) p.consumeLiteral("{") - xs607 := [][]interface{}{} - cond608 := p.matchLookaheadLiteral(":", 0) - for cond608 { - _t1246 := p.parse_config_key_value() - item609 := _t1246 - xs607 = append(xs607, item609) - cond608 = p.matchLookaheadLiteral(":", 0) - } - config_key_values610 := xs607 + xs611 := [][]interface{}{} + cond612 := p.matchLookaheadLiteral(":", 0) + idx613 := 0 + for cond612 { + p.pushPath(int(idx613)) + _t1322 := p.parse_config_key_value() + item614 := _t1322 + p.popPath() + xs611 = append(xs611, item614) + idx613 = (idx613 + 1) + cond612 = p.matchLookaheadLiteral(":", 0) + } + config_key_values610 := xs611 p.consumeLiteral("}") - result612 := config_key_values610 - p.recordSpan(int(span_start611)) - return result612 + result616 := config_key_values610 + p.recordSpan(int(span_start615)) + return result616 } func (p *Parser) parse_config_key_value() []interface{} { - span_start615 := int64(p.spanStart()) + span_start619 := int64(p.spanStart()) p.consumeLiteral(":") - symbol613 := p.consumeTerminal("SYMBOL").Value.str - _t1247 := p.parse_value() - value614 := _t1247 - result616 := []interface{}{symbol613, value614} - p.recordSpan(int(span_start615)) - return result616 + symbol617 := p.consumeTerminal("SYMBOL").Value.str + _t1323 := p.parse_value() + value618 := _t1323 + result620 := []interface{}{symbol617, value618} + p.recordSpan(int(span_start619)) + return result620 } func (p *Parser) parse_value() *pb.Value { - span_start627 := int64(p.spanStart()) - var _t1248 int64 + span_start631 := int64(p.spanStart()) + var _t1324 int64 if p.matchLookaheadLiteral("true", 0) { - _t1248 = 9 + _t1324 = 9 } else { - var _t1249 int64 + var _t1325 int64 if p.matchLookaheadLiteral("missing", 0) { - _t1249 = 8 + _t1325 = 8 } else { - var _t1250 int64 + var _t1326 int64 if p.matchLookaheadLiteral("false", 0) { - _t1250 = 9 + _t1326 = 9 } else { - var _t1251 int64 + var _t1327 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1252 int64 + var _t1328 int64 if p.matchLookaheadLiteral("datetime", 1) { - _t1252 = 1 + _t1328 = 1 } else { - var _t1253 int64 + var _t1329 int64 if p.matchLookaheadLiteral("date", 1) { - _t1253 = 0 + _t1329 = 0 } else { - _t1253 = -1 + _t1329 = -1 } - _t1252 = _t1253 + _t1328 = _t1329 } - _t1251 = _t1252 + _t1327 = _t1328 } else { - var _t1254 int64 + var _t1330 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1254 = 5 + _t1330 = 5 } else { - var _t1255 int64 + var _t1331 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t1255 = 2 + _t1331 = 2 } else { - var _t1256 int64 + var _t1332 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t1256 = 6 + _t1332 = 6 } else { - var _t1257 int64 + var _t1333 int64 if p.matchLookaheadTerminal("INT", 0) { - _t1257 = 3 + _t1333 = 3 } else { - var _t1258 int64 + var _t1334 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t1258 = 4 + _t1334 = 4 } else { - var _t1259 int64 + var _t1335 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t1259 = 7 + _t1335 = 7 } else { - _t1259 = -1 + _t1335 = -1 } - _t1258 = _t1259 + _t1334 = _t1335 } - _t1257 = _t1258 + _t1333 = _t1334 } - _t1256 = _t1257 + _t1332 = _t1333 } - _t1255 = _t1256 + _t1331 = _t1332 } - _t1254 = _t1255 + _t1330 = _t1331 } - _t1251 = _t1254 + _t1327 = _t1330 } - _t1250 = _t1251 + _t1326 = _t1327 } - _t1249 = _t1250 + _t1325 = _t1326 } - _t1248 = _t1249 - } - prediction617 := _t1248 - var _t1260 *pb.Value - if prediction617 == 9 { - _t1261 := p.parse_boolean_value() - boolean_value626 := _t1261 - _t1262 := &pb.Value{} - _t1262.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value626} - _t1260 = _t1262 + _t1324 = _t1325 + } + prediction621 := _t1324 + var _t1336 *pb.Value + if prediction621 == 9 { + p.pushPath(int(10)) + _t1337 := p.parse_boolean_value() + boolean_value630 := _t1337 + p.popPath() + _t1338 := &pb.Value{} + _t1338.Value = &pb.Value_BooleanValue{BooleanValue: boolean_value630} + _t1336 = _t1338 } else { - var _t1263 *pb.Value - if prediction617 == 8 { + var _t1339 *pb.Value + if prediction621 == 8 { p.consumeLiteral("missing") - _t1264 := &pb.MissingValue{} - _t1265 := &pb.Value{} - _t1265.Value = &pb.Value_MissingValue{MissingValue: _t1264} - _t1263 = _t1265 + _t1340 := &pb.MissingValue{} + _t1341 := &pb.Value{} + _t1341.Value = &pb.Value_MissingValue{MissingValue: _t1340} + _t1339 = _t1341 } else { - var _t1266 *pb.Value - if prediction617 == 7 { - decimal625 := p.consumeTerminal("DECIMAL").Value.decimal - _t1267 := &pb.Value{} - _t1267.Value = &pb.Value_DecimalValue{DecimalValue: decimal625} - _t1266 = _t1267 + var _t1342 *pb.Value + if prediction621 == 7 { + decimal629 := p.consumeTerminal("DECIMAL").Value.decimal + _t1343 := &pb.Value{} + _t1343.Value = &pb.Value_DecimalValue{DecimalValue: decimal629} + _t1342 = _t1343 } else { - var _t1268 *pb.Value - if prediction617 == 6 { - int128624 := p.consumeTerminal("INT128").Value.int128 - _t1269 := &pb.Value{} - _t1269.Value = &pb.Value_Int128Value{Int128Value: int128624} - _t1268 = _t1269 + var _t1344 *pb.Value + if prediction621 == 6 { + int128628 := p.consumeTerminal("INT128").Value.int128 + _t1345 := &pb.Value{} + _t1345.Value = &pb.Value_Int128Value{Int128Value: int128628} + _t1344 = _t1345 } else { - var _t1270 *pb.Value - if prediction617 == 5 { - uint128623 := p.consumeTerminal("UINT128").Value.uint128 - _t1271 := &pb.Value{} - _t1271.Value = &pb.Value_Uint128Value{Uint128Value: uint128623} - _t1270 = _t1271 + var _t1346 *pb.Value + if prediction621 == 5 { + uint128627 := p.consumeTerminal("UINT128").Value.uint128 + _t1347 := &pb.Value{} + _t1347.Value = &pb.Value_Uint128Value{Uint128Value: uint128627} + _t1346 = _t1347 } else { - var _t1272 *pb.Value - if prediction617 == 4 { - float622 := p.consumeTerminal("FLOAT").Value.f64 - _t1273 := &pb.Value{} - _t1273.Value = &pb.Value_FloatValue{FloatValue: float622} - _t1272 = _t1273 + var _t1348 *pb.Value + if prediction621 == 4 { + float626 := p.consumeTerminal("FLOAT").Value.f64 + _t1349 := &pb.Value{} + _t1349.Value = &pb.Value_FloatValue{FloatValue: float626} + _t1348 = _t1349 } else { - var _t1274 *pb.Value - if prediction617 == 3 { - int621 := p.consumeTerminal("INT").Value.i64 - _t1275 := &pb.Value{} - _t1275.Value = &pb.Value_IntValue{IntValue: int621} - _t1274 = _t1275 + var _t1350 *pb.Value + if prediction621 == 3 { + int625 := p.consumeTerminal("INT").Value.i64 + _t1351 := &pb.Value{} + _t1351.Value = &pb.Value_IntValue{IntValue: int625} + _t1350 = _t1351 } else { - var _t1276 *pb.Value - if prediction617 == 2 { - string620 := p.consumeTerminal("STRING").Value.str - _t1277 := &pb.Value{} - _t1277.Value = &pb.Value_StringValue{StringValue: string620} - _t1276 = _t1277 + var _t1352 *pb.Value + if prediction621 == 2 { + string624 := p.consumeTerminal("STRING").Value.str + _t1353 := &pb.Value{} + _t1353.Value = &pb.Value_StringValue{StringValue: string624} + _t1352 = _t1353 } else { - var _t1278 *pb.Value - if prediction617 == 1 { - _t1279 := p.parse_datetime() - datetime619 := _t1279 - _t1280 := &pb.Value{} - _t1280.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime619} - _t1278 = _t1280 + var _t1354 *pb.Value + if prediction621 == 1 { + p.pushPath(int(8)) + _t1355 := p.parse_datetime() + datetime623 := _t1355 + p.popPath() + _t1356 := &pb.Value{} + _t1356.Value = &pb.Value_DatetimeValue{DatetimeValue: datetime623} + _t1354 = _t1356 } else { - var _t1281 *pb.Value - if prediction617 == 0 { - _t1282 := p.parse_date() - date618 := _t1282 - _t1283 := &pb.Value{} - _t1283.Value = &pb.Value_DateValue{DateValue: date618} - _t1281 = _t1283 + var _t1357 *pb.Value + if prediction621 == 0 { + p.pushPath(int(7)) + _t1358 := p.parse_date() + date622 := _t1358 + p.popPath() + _t1359 := &pb.Value{} + _t1359.Value = &pb.Value_DateValue{DateValue: date622} + _t1357 = _t1359 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1278 = _t1281 + _t1354 = _t1357 } - _t1276 = _t1278 + _t1352 = _t1354 } - _t1274 = _t1276 + _t1350 = _t1352 } - _t1272 = _t1274 + _t1348 = _t1350 } - _t1270 = _t1272 + _t1346 = _t1348 } - _t1268 = _t1270 + _t1344 = _t1346 } - _t1266 = _t1268 + _t1342 = _t1344 } - _t1263 = _t1266 + _t1339 = _t1342 } - _t1260 = _t1263 + _t1336 = _t1339 } - result628 := _t1260 - p.recordSpan(int(span_start627)) - return result628 + result632 := _t1336 + p.recordSpan(int(span_start631)) + return result632 } func (p *Parser) parse_date() *pb.DateValue { - span_start632 := int64(p.spanStart()) + span_start636 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("date") p.pushPath(int(1)) - int629 := p.consumeTerminal("INT").Value.i64 + int633 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(2)) - int_3630 := p.consumeTerminal("INT").Value.i64 + int_3634 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(3)) - int_4631 := p.consumeTerminal("INT").Value.i64 + int_4635 := p.consumeTerminal("INT").Value.i64 p.popPath() p.consumeLiteral(")") - _t1284 := &pb.DateValue{Year: int32(int629), Month: int32(int_3630), Day: int32(int_4631)} - result633 := _t1284 - p.recordSpan(int(span_start632)) - return result633 + _t1360 := &pb.DateValue{Year: int32(int633), Month: int32(int_3634), Day: int32(int_4635)} + result637 := _t1360 + p.recordSpan(int(span_start636)) + return result637 } func (p *Parser) parse_datetime() *pb.DateTimeValue { - span_start641 := int64(p.spanStart()) + span_start645 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("datetime") p.pushPath(int(1)) - int634 := p.consumeTerminal("INT").Value.i64 + int638 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(2)) - int_3635 := p.consumeTerminal("INT").Value.i64 + int_3639 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(3)) - int_4636 := p.consumeTerminal("INT").Value.i64 + int_4640 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(4)) - int_5637 := p.consumeTerminal("INT").Value.i64 + int_5641 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(5)) - int_6638 := p.consumeTerminal("INT").Value.i64 + int_6642 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(6)) - int_7639 := p.consumeTerminal("INT").Value.i64 + int_7643 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(7)) - var _t1285 *int64 + var _t1361 *int64 if p.matchLookaheadTerminal("INT", 0) { - _t1285 = ptr(p.consumeTerminal("INT").Value.i64) + _t1361 = ptr(p.consumeTerminal("INT").Value.i64) } - int_8640 := _t1285 + int_8644 := _t1361 p.popPath() p.consumeLiteral(")") - _t1286 := &pb.DateTimeValue{Year: int32(int634), Month: int32(int_3635), Day: int32(int_4636), Hour: int32(int_5637), Minute: int32(int_6638), Second: int32(int_7639), Microsecond: int32(deref(int_8640, 0))} - result642 := _t1286 - p.recordSpan(int(span_start641)) - return result642 + _t1362 := &pb.DateTimeValue{Year: int32(int638), Month: int32(int_3639), Day: int32(int_4640), Hour: int32(int_5641), Minute: int32(int_6642), Second: int32(int_7643), Microsecond: int32(deref(int_8644, 0))} + result646 := _t1362 + p.recordSpan(int(span_start645)) + return result646 } func (p *Parser) parse_boolean_value() bool { - span_start644 := int64(p.spanStart()) - var _t1287 int64 + span_start648 := int64(p.spanStart()) + var _t1363 int64 if p.matchLookaheadLiteral("true", 0) { - _t1287 = 0 + _t1363 = 0 } else { - var _t1288 int64 + var _t1364 int64 if p.matchLookaheadLiteral("false", 0) { - _t1288 = 1 + _t1364 = 1 } else { - _t1288 = -1 + _t1364 = -1 } - _t1287 = _t1288 + _t1363 = _t1364 } - prediction643 := _t1287 - var _t1289 bool - if prediction643 == 1 { + prediction647 := _t1363 + var _t1365 bool + if prediction647 == 1 { p.consumeLiteral("false") - _t1289 = false + _t1365 = false } else { - var _t1290 bool - if prediction643 == 0 { + var _t1366 bool + if prediction647 == 0 { p.consumeLiteral("true") - _t1290 = true + _t1366 = true } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in boolean_value", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1289 = _t1290 + _t1365 = _t1366 } - result645 := _t1289 - p.recordSpan(int(span_start644)) - return result645 + result649 := _t1365 + p.recordSpan(int(span_start648)) + return result649 } func (p *Parser) parse_sync() *pb.Sync { - span_start654 := int64(p.spanStart()) + span_start658 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("sync") p.pushPath(int(1)) - xs650 := []*pb.FragmentId{} - cond651 := p.matchLookaheadLiteral(":", 0) - idx652 := 0 - for cond651 { - p.pushPath(int(idx652)) - _t1291 := p.parse_fragment_id() - item653 := _t1291 + xs654 := []*pb.FragmentId{} + cond655 := p.matchLookaheadLiteral(":", 0) + idx656 := 0 + for cond655 { + p.pushPath(int(idx656)) + _t1367 := p.parse_fragment_id() + item657 := _t1367 p.popPath() - xs650 = append(xs650, item653) - idx652 = (idx652 + 1) - cond651 = p.matchLookaheadLiteral(":", 0) + xs654 = append(xs654, item657) + idx656 = (idx656 + 1) + cond655 = p.matchLookaheadLiteral(":", 0) } - fragment_ids649 := xs650 + fragment_ids653 := xs654 p.popPath() p.consumeLiteral(")") - _t1292 := &pb.Sync{Fragments: fragment_ids649} - result655 := _t1292 - p.recordSpan(int(span_start654)) - return result655 + _t1368 := &pb.Sync{Fragments: fragment_ids653} + result659 := _t1368 + p.recordSpan(int(span_start658)) + return result659 } func (p *Parser) parse_fragment_id() *pb.FragmentId { - span_start657 := int64(p.spanStart()) + span_start661 := int64(p.spanStart()) p.consumeLiteral(":") - symbol656 := p.consumeTerminal("SYMBOL").Value.str - result658 := &pb.FragmentId{Id: []byte(symbol656)} - p.recordSpan(int(span_start657)) - return result658 + symbol660 := p.consumeTerminal("SYMBOL").Value.str + result662 := &pb.FragmentId{Id: []byte(symbol660)} + p.recordSpan(int(span_start661)) + return result662 } func (p *Parser) parse_epoch() *pb.Epoch { - span_start661 := int64(p.spanStart()) + span_start665 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("epoch") p.pushPath(int(1)) - var _t1293 []*pb.Write + var _t1369 []*pb.Write if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("writes", 1)) { - _t1294 := p.parse_epoch_writes() - _t1293 = _t1294 + _t1370 := p.parse_epoch_writes() + _t1369 = _t1370 } - epoch_writes659 := _t1293 + epoch_writes663 := _t1369 p.popPath() p.pushPath(int(2)) - var _t1295 []*pb.Read + var _t1371 []*pb.Read if p.matchLookaheadLiteral("(", 0) { - _t1296 := p.parse_epoch_reads() - _t1295 = _t1296 + _t1372 := p.parse_epoch_reads() + _t1371 = _t1372 } - epoch_reads660 := _t1295 + epoch_reads664 := _t1371 p.popPath() p.consumeLiteral(")") - _t1297 := epoch_writes659 - if epoch_writes659 == nil { - _t1297 = []*pb.Write{} + _t1373 := epoch_writes663 + if epoch_writes663 == nil { + _t1373 = []*pb.Write{} } - _t1298 := epoch_reads660 - if epoch_reads660 == nil { - _t1298 = []*pb.Read{} + _t1374 := epoch_reads664 + if epoch_reads664 == nil { + _t1374 = []*pb.Read{} } - _t1299 := &pb.Epoch{Writes: _t1297, Reads: _t1298} - result662 := _t1299 - p.recordSpan(int(span_start661)) - return result662 + _t1375 := &pb.Epoch{Writes: _t1373, Reads: _t1374} + result666 := _t1375 + p.recordSpan(int(span_start665)) + return result666 } func (p *Parser) parse_epoch_writes() []*pb.Write { - span_start667 := int64(p.spanStart()) + span_start675 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("writes") - xs663 := []*pb.Write{} - cond664 := p.matchLookaheadLiteral("(", 0) - for cond664 { - _t1300 := p.parse_write() - item665 := _t1300 - xs663 = append(xs663, item665) - cond664 = p.matchLookaheadLiteral("(", 0) - } - writes666 := xs663 + xs671 := []*pb.Write{} + cond672 := p.matchLookaheadLiteral("(", 0) + idx673 := 0 + for cond672 { + p.pushPath(int(idx673)) + _t1376 := p.parse_write() + item674 := _t1376 + p.popPath() + xs671 = append(xs671, item674) + idx673 = (idx673 + 1) + cond672 = p.matchLookaheadLiteral("(", 0) + } + writes670 := xs671 p.consumeLiteral(")") - result668 := writes666 - p.recordSpan(int(span_start667)) - return result668 + result676 := writes670 + p.recordSpan(int(span_start675)) + return result676 } func (p *Parser) parse_write() *pb.Write { - span_start674 := int64(p.spanStart()) - var _t1301 int64 + span_start682 := int64(p.spanStart()) + var _t1377 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1302 int64 + var _t1378 int64 if p.matchLookaheadLiteral("undefine", 1) { - _t1302 = 1 + _t1378 = 1 } else { - var _t1303 int64 + var _t1379 int64 if p.matchLookaheadLiteral("snapshot", 1) { - _t1303 = 3 + _t1379 = 3 } else { - var _t1304 int64 + var _t1380 int64 if p.matchLookaheadLiteral("define", 1) { - _t1304 = 0 + _t1380 = 0 } else { - var _t1305 int64 + var _t1381 int64 if p.matchLookaheadLiteral("context", 1) { - _t1305 = 2 + _t1381 = 2 } else { - _t1305 = -1 + _t1381 = -1 } - _t1304 = _t1305 + _t1380 = _t1381 } - _t1303 = _t1304 + _t1379 = _t1380 } - _t1302 = _t1303 + _t1378 = _t1379 } - _t1301 = _t1302 + _t1377 = _t1378 } else { - _t1301 = -1 - } - prediction669 := _t1301 - var _t1306 *pb.Write - if prediction669 == 3 { - _t1307 := p.parse_snapshot() - snapshot673 := _t1307 - _t1308 := &pb.Write{} - _t1308.WriteType = &pb.Write_Snapshot{Snapshot: snapshot673} - _t1306 = _t1308 + _t1377 = -1 + } + prediction677 := _t1377 + var _t1382 *pb.Write + if prediction677 == 3 { + p.pushPath(int(5)) + _t1383 := p.parse_snapshot() + snapshot681 := _t1383 + p.popPath() + _t1384 := &pb.Write{} + _t1384.WriteType = &pb.Write_Snapshot{Snapshot: snapshot681} + _t1382 = _t1384 } else { - var _t1309 *pb.Write - if prediction669 == 2 { - _t1310 := p.parse_context() - context672 := _t1310 - _t1311 := &pb.Write{} - _t1311.WriteType = &pb.Write_Context{Context: context672} - _t1309 = _t1311 + var _t1385 *pb.Write + if prediction677 == 2 { + p.pushPath(int(3)) + _t1386 := p.parse_context() + context680 := _t1386 + p.popPath() + _t1387 := &pb.Write{} + _t1387.WriteType = &pb.Write_Context{Context: context680} + _t1385 = _t1387 } else { - var _t1312 *pb.Write - if prediction669 == 1 { - _t1313 := p.parse_undefine() - undefine671 := _t1313 - _t1314 := &pb.Write{} - _t1314.WriteType = &pb.Write_Undefine{Undefine: undefine671} - _t1312 = _t1314 + var _t1388 *pb.Write + if prediction677 == 1 { + p.pushPath(int(2)) + _t1389 := p.parse_undefine() + undefine679 := _t1389 + p.popPath() + _t1390 := &pb.Write{} + _t1390.WriteType = &pb.Write_Undefine{Undefine: undefine679} + _t1388 = _t1390 } else { - var _t1315 *pb.Write - if prediction669 == 0 { - _t1316 := p.parse_define() - define670 := _t1316 - _t1317 := &pb.Write{} - _t1317.WriteType = &pb.Write_Define{Define: define670} - _t1315 = _t1317 + var _t1391 *pb.Write + if prediction677 == 0 { + p.pushPath(int(1)) + _t1392 := p.parse_define() + define678 := _t1392 + p.popPath() + _t1393 := &pb.Write{} + _t1393.WriteType = &pb.Write_Define{Define: define678} + _t1391 = _t1393 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in write", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1312 = _t1315 + _t1388 = _t1391 } - _t1309 = _t1312 + _t1385 = _t1388 } - _t1306 = _t1309 + _t1382 = _t1385 } - result675 := _t1306 - p.recordSpan(int(span_start674)) - return result675 + result683 := _t1382 + p.recordSpan(int(span_start682)) + return result683 } func (p *Parser) parse_define() *pb.Define { - span_start677 := int64(p.spanStart()) + span_start685 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("define") p.pushPath(int(1)) - _t1318 := p.parse_fragment() - fragment676 := _t1318 + _t1394 := p.parse_fragment() + fragment684 := _t1394 p.popPath() p.consumeLiteral(")") - _t1319 := &pb.Define{Fragment: fragment676} - result678 := _t1319 - p.recordSpan(int(span_start677)) - return result678 + _t1395 := &pb.Define{Fragment: fragment684} + result686 := _t1395 + p.recordSpan(int(span_start685)) + return result686 } func (p *Parser) parse_fragment() *pb.Fragment { - span_start684 := int64(p.spanStart()) + span_start696 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("fragment") - _t1320 := p.parse_new_fragment_id() - new_fragment_id679 := _t1320 - xs680 := []*pb.Declaration{} - cond681 := p.matchLookaheadLiteral("(", 0) - for cond681 { - _t1321 := p.parse_declaration() - item682 := _t1321 - xs680 = append(xs680, item682) - cond681 = p.matchLookaheadLiteral("(", 0) - } - declarations683 := xs680 + _t1396 := p.parse_new_fragment_id() + new_fragment_id687 := _t1396 + p.pushPath(int(2)) + xs692 := []*pb.Declaration{} + cond693 := p.matchLookaheadLiteral("(", 0) + idx694 := 0 + for cond693 { + p.pushPath(int(idx694)) + _t1397 := p.parse_declaration() + item695 := _t1397 + p.popPath() + xs692 = append(xs692, item695) + idx694 = (idx694 + 1) + cond693 = p.matchLookaheadLiteral("(", 0) + } + declarations691 := xs692 + p.popPath() p.consumeLiteral(")") - result685 := p.constructFragment(new_fragment_id679, declarations683) - p.recordSpan(int(span_start684)) - return result685 + result697 := p.constructFragment(new_fragment_id687, declarations691) + p.recordSpan(int(span_start696)) + return result697 } func (p *Parser) parse_new_fragment_id() *pb.FragmentId { - span_start687 := int64(p.spanStart()) - _t1322 := p.parse_fragment_id() - fragment_id686 := _t1322 - p.startFragment(fragment_id686) - result688 := fragment_id686 - p.recordSpan(int(span_start687)) - return result688 + span_start699 := int64(p.spanStart()) + _t1398 := p.parse_fragment_id() + fragment_id698 := _t1398 + p.startFragment(fragment_id698) + result700 := fragment_id698 + p.recordSpan(int(span_start699)) + return result700 } func (p *Parser) parse_declaration() *pb.Declaration { - span_start694 := int64(p.spanStart()) - var _t1323 int64 + span_start706 := int64(p.spanStart()) + var _t1399 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1324 int64 + var _t1400 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t1324 = 3 + _t1400 = 3 } else { - var _t1325 int64 + var _t1401 int64 if p.matchLookaheadLiteral("functional_dependency", 1) { - _t1325 = 2 + _t1401 = 2 } else { - var _t1326 int64 + var _t1402 int64 if p.matchLookaheadLiteral("def", 1) { - _t1326 = 0 + _t1402 = 0 } else { - var _t1327 int64 + var _t1403 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t1327 = 3 + _t1403 = 3 } else { - var _t1328 int64 + var _t1404 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t1328 = 3 + _t1404 = 3 } else { - var _t1329 int64 + var _t1405 int64 if p.matchLookaheadLiteral("algorithm", 1) { - _t1329 = 1 + _t1405 = 1 } else { - _t1329 = -1 + _t1405 = -1 } - _t1328 = _t1329 + _t1404 = _t1405 } - _t1327 = _t1328 + _t1403 = _t1404 } - _t1326 = _t1327 + _t1402 = _t1403 } - _t1325 = _t1326 + _t1401 = _t1402 } - _t1324 = _t1325 + _t1400 = _t1401 } - _t1323 = _t1324 + _t1399 = _t1400 } else { - _t1323 = -1 - } - prediction689 := _t1323 - var _t1330 *pb.Declaration - if prediction689 == 3 { - _t1331 := p.parse_data() - data693 := _t1331 - _t1332 := &pb.Declaration{} - _t1332.DeclarationType = &pb.Declaration_Data{Data: data693} - _t1330 = _t1332 + _t1399 = -1 + } + prediction701 := _t1399 + var _t1406 *pb.Declaration + if prediction701 == 3 { + p.pushPath(int(4)) + _t1407 := p.parse_data() + data705 := _t1407 + p.popPath() + _t1408 := &pb.Declaration{} + _t1408.DeclarationType = &pb.Declaration_Data{Data: data705} + _t1406 = _t1408 } else { - var _t1333 *pb.Declaration - if prediction689 == 2 { - _t1334 := p.parse_constraint() - constraint692 := _t1334 - _t1335 := &pb.Declaration{} - _t1335.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint692} - _t1333 = _t1335 + var _t1409 *pb.Declaration + if prediction701 == 2 { + p.pushPath(int(3)) + _t1410 := p.parse_constraint() + constraint704 := _t1410 + p.popPath() + _t1411 := &pb.Declaration{} + _t1411.DeclarationType = &pb.Declaration_Constraint{Constraint: constraint704} + _t1409 = _t1411 } else { - var _t1336 *pb.Declaration - if prediction689 == 1 { - _t1337 := p.parse_algorithm() - algorithm691 := _t1337 - _t1338 := &pb.Declaration{} - _t1338.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm691} - _t1336 = _t1338 + var _t1412 *pb.Declaration + if prediction701 == 1 { + p.pushPath(int(2)) + _t1413 := p.parse_algorithm() + algorithm703 := _t1413 + p.popPath() + _t1414 := &pb.Declaration{} + _t1414.DeclarationType = &pb.Declaration_Algorithm{Algorithm: algorithm703} + _t1412 = _t1414 } else { - var _t1339 *pb.Declaration - if prediction689 == 0 { - _t1340 := p.parse_def() - def690 := _t1340 - _t1341 := &pb.Declaration{} - _t1341.DeclarationType = &pb.Declaration_Def{Def: def690} - _t1339 = _t1341 + var _t1415 *pb.Declaration + if prediction701 == 0 { + p.pushPath(int(1)) + _t1416 := p.parse_def() + def702 := _t1416 + p.popPath() + _t1417 := &pb.Declaration{} + _t1417.DeclarationType = &pb.Declaration_Def{Def: def702} + _t1415 = _t1417 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in declaration", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1336 = _t1339 + _t1412 = _t1415 } - _t1333 = _t1336 + _t1409 = _t1412 } - _t1330 = _t1333 + _t1406 = _t1409 } - result695 := _t1330 - p.recordSpan(int(span_start694)) - return result695 + result707 := _t1406 + p.recordSpan(int(span_start706)) + return result707 } func (p *Parser) parse_def() *pb.Def { - span_start699 := int64(p.spanStart()) + span_start711 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("def") p.pushPath(int(1)) - _t1342 := p.parse_relation_id() - relation_id696 := _t1342 + _t1418 := p.parse_relation_id() + relation_id708 := _t1418 p.popPath() p.pushPath(int(2)) - _t1343 := p.parse_abstraction() - abstraction697 := _t1343 + _t1419 := p.parse_abstraction() + abstraction709 := _t1419 p.popPath() p.pushPath(int(3)) - var _t1344 []*pb.Attribute + var _t1420 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1345 := p.parse_attrs() - _t1344 = _t1345 + _t1421 := p.parse_attrs() + _t1420 = _t1421 } - attrs698 := _t1344 + attrs710 := _t1420 p.popPath() p.consumeLiteral(")") - _t1346 := attrs698 - if attrs698 == nil { - _t1346 = []*pb.Attribute{} + _t1422 := attrs710 + if attrs710 == nil { + _t1422 = []*pb.Attribute{} } - _t1347 := &pb.Def{Name: relation_id696, Body: abstraction697, Attrs: _t1346} - result700 := _t1347 - p.recordSpan(int(span_start699)) - return result700 + _t1423 := &pb.Def{Name: relation_id708, Body: abstraction709, Attrs: _t1422} + result712 := _t1423 + p.recordSpan(int(span_start711)) + return result712 } func (p *Parser) parse_relation_id() *pb.RelationId { - span_start704 := int64(p.spanStart()) - var _t1348 int64 + span_start716 := int64(p.spanStart()) + var _t1424 int64 if p.matchLookaheadLiteral(":", 0) { - _t1348 = 0 + _t1424 = 0 } else { - var _t1349 int64 + var _t1425 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1349 = 1 + _t1425 = 1 } else { - _t1349 = -1 + _t1425 = -1 } - _t1348 = _t1349 - } - prediction701 := _t1348 - var _t1350 *pb.RelationId - if prediction701 == 1 { - uint128703 := p.consumeTerminal("UINT128").Value.uint128 - _ = uint128703 - _t1350 = &pb.RelationId{IdLow: uint128703.Low, IdHigh: uint128703.High} + _t1424 = _t1425 + } + prediction713 := _t1424 + var _t1426 *pb.RelationId + if prediction713 == 1 { + uint128715 := p.consumeTerminal("UINT128").Value.uint128 + _ = uint128715 + _t1426 = &pb.RelationId{IdLow: uint128715.Low, IdHigh: uint128715.High} } else { - var _t1351 *pb.RelationId - if prediction701 == 0 { + var _t1427 *pb.RelationId + if prediction713 == 0 { p.consumeLiteral(":") - symbol702 := p.consumeTerminal("SYMBOL").Value.str - _t1351 = p.relationIdFromString(symbol702) + symbol714 := p.consumeTerminal("SYMBOL").Value.str + _t1427 = p.relationIdFromString(symbol714) } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in relation_id", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1350 = _t1351 + _t1426 = _t1427 } - result705 := _t1350 - p.recordSpan(int(span_start704)) - return result705 + result717 := _t1426 + p.recordSpan(int(span_start716)) + return result717 } func (p *Parser) parse_abstraction() *pb.Abstraction { - span_start708 := int64(p.spanStart()) + span_start720 := int64(p.spanStart()) p.consumeLiteral("(") - _t1352 := p.parse_bindings() - bindings706 := _t1352 + _t1428 := p.parse_bindings() + bindings718 := _t1428 p.pushPath(int(2)) - _t1353 := p.parse_formula() - formula707 := _t1353 + _t1429 := p.parse_formula() + formula719 := _t1429 p.popPath() p.consumeLiteral(")") - _t1354 := &pb.Abstraction{Vars: listConcat(bindings706[0].([]*pb.Binding), bindings706[1].([]*pb.Binding)), Value: formula707} - result709 := _t1354 - p.recordSpan(int(span_start708)) - return result709 + _t1430 := &pb.Abstraction{Vars: listConcat(bindings718[0].([]*pb.Binding), bindings718[1].([]*pb.Binding)), Value: formula719} + result721 := _t1430 + p.recordSpan(int(span_start720)) + return result721 } func (p *Parser) parse_bindings() []interface{} { - span_start715 := int64(p.spanStart()) + span_start731 := int64(p.spanStart()) p.consumeLiteral("[") - xs710 := []*pb.Binding{} - cond711 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond711 { - _t1355 := p.parse_binding() - item712 := _t1355 - xs710 = append(xs710, item712) - cond711 = p.matchLookaheadTerminal("SYMBOL", 0) - } - bindings713 := xs710 - var _t1356 []*pb.Binding + xs726 := []*pb.Binding{} + cond727 := p.matchLookaheadTerminal("SYMBOL", 0) + idx728 := 0 + for cond727 { + p.pushPath(int(idx728)) + _t1431 := p.parse_binding() + item729 := _t1431 + p.popPath() + xs726 = append(xs726, item729) + idx728 = (idx728 + 1) + cond727 = p.matchLookaheadTerminal("SYMBOL", 0) + } + bindings725 := xs726 + var _t1432 []*pb.Binding if p.matchLookaheadLiteral("|", 0) { - _t1357 := p.parse_value_bindings() - _t1356 = _t1357 + _t1433 := p.parse_value_bindings() + _t1432 = _t1433 } - value_bindings714 := _t1356 + value_bindings730 := _t1432 p.consumeLiteral("]") - _t1358 := value_bindings714 - if value_bindings714 == nil { - _t1358 = []*pb.Binding{} + _t1434 := value_bindings730 + if value_bindings730 == nil { + _t1434 = []*pb.Binding{} } - result716 := []interface{}{bindings713, _t1358} - p.recordSpan(int(span_start715)) - return result716 + result732 := []interface{}{bindings725, _t1434} + p.recordSpan(int(span_start731)) + return result732 } func (p *Parser) parse_binding() *pb.Binding { - span_start719 := int64(p.spanStart()) - symbol717 := p.consumeTerminal("SYMBOL").Value.str + span_start735 := int64(p.spanStart()) + symbol733 := p.consumeTerminal("SYMBOL").Value.str p.consumeLiteral("::") p.pushPath(int(2)) - _t1359 := p.parse_type() - type718 := _t1359 + _t1435 := p.parse_type() + type734 := _t1435 p.popPath() - _t1360 := &pb.Var{Name: symbol717} - _t1361 := &pb.Binding{Var: _t1360, Type: type718} - result720 := _t1361 - p.recordSpan(int(span_start719)) - return result720 + _t1436 := &pb.Var{Name: symbol733} + _t1437 := &pb.Binding{Var: _t1436, Type: type734} + result736 := _t1437 + p.recordSpan(int(span_start735)) + return result736 } func (p *Parser) parse_type() *pb.Type { - span_start733 := int64(p.spanStart()) - var _t1362 int64 + span_start749 := int64(p.spanStart()) + var _t1438 int64 if p.matchLookaheadLiteral("UNKNOWN", 0) { - _t1362 = 0 + _t1438 = 0 } else { - var _t1363 int64 + var _t1439 int64 if p.matchLookaheadLiteral("UINT128", 0) { - _t1363 = 4 + _t1439 = 4 } else { - var _t1364 int64 + var _t1440 int64 if p.matchLookaheadLiteral("STRING", 0) { - _t1364 = 1 + _t1440 = 1 } else { - var _t1365 int64 + var _t1441 int64 if p.matchLookaheadLiteral("MISSING", 0) { - _t1365 = 8 + _t1441 = 8 } else { - var _t1366 int64 + var _t1442 int64 if p.matchLookaheadLiteral("INT128", 0) { - _t1366 = 5 + _t1442 = 5 } else { - var _t1367 int64 + var _t1443 int64 if p.matchLookaheadLiteral("INT", 0) { - _t1367 = 2 + _t1443 = 2 } else { - var _t1368 int64 + var _t1444 int64 if p.matchLookaheadLiteral("FLOAT", 0) { - _t1368 = 3 + _t1444 = 3 } else { - var _t1369 int64 + var _t1445 int64 if p.matchLookaheadLiteral("DATETIME", 0) { - _t1369 = 7 + _t1445 = 7 } else { - var _t1370 int64 + var _t1446 int64 if p.matchLookaheadLiteral("DATE", 0) { - _t1370 = 6 + _t1446 = 6 } else { - var _t1371 int64 + var _t1447 int64 if p.matchLookaheadLiteral("BOOLEAN", 0) { - _t1371 = 10 + _t1447 = 10 } else { - var _t1372 int64 + var _t1448 int64 if p.matchLookaheadLiteral("(", 0) { - _t1372 = 9 + _t1448 = 9 } else { - _t1372 = -1 + _t1448 = -1 } - _t1371 = _t1372 + _t1447 = _t1448 } - _t1370 = _t1371 + _t1446 = _t1447 } - _t1369 = _t1370 + _t1445 = _t1446 } - _t1368 = _t1369 + _t1444 = _t1445 } - _t1367 = _t1368 + _t1443 = _t1444 } - _t1366 = _t1367 + _t1442 = _t1443 } - _t1365 = _t1366 + _t1441 = _t1442 } - _t1364 = _t1365 + _t1440 = _t1441 } - _t1363 = _t1364 + _t1439 = _t1440 } - _t1362 = _t1363 - } - prediction721 := _t1362 - var _t1373 *pb.Type - if prediction721 == 10 { - _t1374 := p.parse_boolean_type() - boolean_type732 := _t1374 - _t1375 := &pb.Type{} - _t1375.Type = &pb.Type_BooleanType{BooleanType: boolean_type732} - _t1373 = _t1375 + _t1438 = _t1439 + } + prediction737 := _t1438 + var _t1449 *pb.Type + if prediction737 == 10 { + p.pushPath(int(11)) + _t1450 := p.parse_boolean_type() + boolean_type748 := _t1450 + p.popPath() + _t1451 := &pb.Type{} + _t1451.Type = &pb.Type_BooleanType{BooleanType: boolean_type748} + _t1449 = _t1451 } else { - var _t1376 *pb.Type - if prediction721 == 9 { - _t1377 := p.parse_decimal_type() - decimal_type731 := _t1377 - _t1378 := &pb.Type{} - _t1378.Type = &pb.Type_DecimalType{DecimalType: decimal_type731} - _t1376 = _t1378 + var _t1452 *pb.Type + if prediction737 == 9 { + p.pushPath(int(10)) + _t1453 := p.parse_decimal_type() + decimal_type747 := _t1453 + p.popPath() + _t1454 := &pb.Type{} + _t1454.Type = &pb.Type_DecimalType{DecimalType: decimal_type747} + _t1452 = _t1454 } else { - var _t1379 *pb.Type - if prediction721 == 8 { - _t1380 := p.parse_missing_type() - missing_type730 := _t1380 - _t1381 := &pb.Type{} - _t1381.Type = &pb.Type_MissingType{MissingType: missing_type730} - _t1379 = _t1381 + var _t1455 *pb.Type + if prediction737 == 8 { + p.pushPath(int(9)) + _t1456 := p.parse_missing_type() + missing_type746 := _t1456 + p.popPath() + _t1457 := &pb.Type{} + _t1457.Type = &pb.Type_MissingType{MissingType: missing_type746} + _t1455 = _t1457 } else { - var _t1382 *pb.Type - if prediction721 == 7 { - _t1383 := p.parse_datetime_type() - datetime_type729 := _t1383 - _t1384 := &pb.Type{} - _t1384.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type729} - _t1382 = _t1384 + var _t1458 *pb.Type + if prediction737 == 7 { + p.pushPath(int(8)) + _t1459 := p.parse_datetime_type() + datetime_type745 := _t1459 + p.popPath() + _t1460 := &pb.Type{} + _t1460.Type = &pb.Type_DatetimeType{DatetimeType: datetime_type745} + _t1458 = _t1460 } else { - var _t1385 *pb.Type - if prediction721 == 6 { - _t1386 := p.parse_date_type() - date_type728 := _t1386 - _t1387 := &pb.Type{} - _t1387.Type = &pb.Type_DateType{DateType: date_type728} - _t1385 = _t1387 + var _t1461 *pb.Type + if prediction737 == 6 { + p.pushPath(int(7)) + _t1462 := p.parse_date_type() + date_type744 := _t1462 + p.popPath() + _t1463 := &pb.Type{} + _t1463.Type = &pb.Type_DateType{DateType: date_type744} + _t1461 = _t1463 } else { - var _t1388 *pb.Type - if prediction721 == 5 { - _t1389 := p.parse_int128_type() - int128_type727 := _t1389 - _t1390 := &pb.Type{} - _t1390.Type = &pb.Type_Int128Type{Int128Type: int128_type727} - _t1388 = _t1390 + var _t1464 *pb.Type + if prediction737 == 5 { + p.pushPath(int(6)) + _t1465 := p.parse_int128_type() + int128_type743 := _t1465 + p.popPath() + _t1466 := &pb.Type{} + _t1466.Type = &pb.Type_Int128Type{Int128Type: int128_type743} + _t1464 = _t1466 } else { - var _t1391 *pb.Type - if prediction721 == 4 { - _t1392 := p.parse_uint128_type() - uint128_type726 := _t1392 - _t1393 := &pb.Type{} - _t1393.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type726} - _t1391 = _t1393 + var _t1467 *pb.Type + if prediction737 == 4 { + p.pushPath(int(5)) + _t1468 := p.parse_uint128_type() + uint128_type742 := _t1468 + p.popPath() + _t1469 := &pb.Type{} + _t1469.Type = &pb.Type_Uint128Type{Uint128Type: uint128_type742} + _t1467 = _t1469 } else { - var _t1394 *pb.Type - if prediction721 == 3 { - _t1395 := p.parse_float_type() - float_type725 := _t1395 - _t1396 := &pb.Type{} - _t1396.Type = &pb.Type_FloatType{FloatType: float_type725} - _t1394 = _t1396 + var _t1470 *pb.Type + if prediction737 == 3 { + p.pushPath(int(4)) + _t1471 := p.parse_float_type() + float_type741 := _t1471 + p.popPath() + _t1472 := &pb.Type{} + _t1472.Type = &pb.Type_FloatType{FloatType: float_type741} + _t1470 = _t1472 } else { - var _t1397 *pb.Type - if prediction721 == 2 { - _t1398 := p.parse_int_type() - int_type724 := _t1398 - _t1399 := &pb.Type{} - _t1399.Type = &pb.Type_IntType{IntType: int_type724} - _t1397 = _t1399 + var _t1473 *pb.Type + if prediction737 == 2 { + p.pushPath(int(3)) + _t1474 := p.parse_int_type() + int_type740 := _t1474 + p.popPath() + _t1475 := &pb.Type{} + _t1475.Type = &pb.Type_IntType{IntType: int_type740} + _t1473 = _t1475 } else { - var _t1400 *pb.Type - if prediction721 == 1 { - _t1401 := p.parse_string_type() - string_type723 := _t1401 - _t1402 := &pb.Type{} - _t1402.Type = &pb.Type_StringType{StringType: string_type723} - _t1400 = _t1402 + var _t1476 *pb.Type + if prediction737 == 1 { + p.pushPath(int(2)) + _t1477 := p.parse_string_type() + string_type739 := _t1477 + p.popPath() + _t1478 := &pb.Type{} + _t1478.Type = &pb.Type_StringType{StringType: string_type739} + _t1476 = _t1478 } else { - var _t1403 *pb.Type - if prediction721 == 0 { - _t1404 := p.parse_unspecified_type() - unspecified_type722 := _t1404 - _t1405 := &pb.Type{} - _t1405.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type722} - _t1403 = _t1405 + var _t1479 *pb.Type + if prediction737 == 0 { + p.pushPath(int(1)) + _t1480 := p.parse_unspecified_type() + unspecified_type738 := _t1480 + p.popPath() + _t1481 := &pb.Type{} + _t1481.Type = &pb.Type_UnspecifiedType{UnspecifiedType: unspecified_type738} + _t1479 = _t1481 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in type", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1400 = _t1403 + _t1476 = _t1479 } - _t1397 = _t1400 + _t1473 = _t1476 } - _t1394 = _t1397 + _t1470 = _t1473 } - _t1391 = _t1394 + _t1467 = _t1470 } - _t1388 = _t1391 + _t1464 = _t1467 } - _t1385 = _t1388 + _t1461 = _t1464 } - _t1382 = _t1385 + _t1458 = _t1461 } - _t1379 = _t1382 + _t1455 = _t1458 } - _t1376 = _t1379 + _t1452 = _t1455 } - _t1373 = _t1376 + _t1449 = _t1452 } - result734 := _t1373 - p.recordSpan(int(span_start733)) - return result734 + result750 := _t1449 + p.recordSpan(int(span_start749)) + return result750 } func (p *Parser) parse_unspecified_type() *pb.UnspecifiedType { - span_start735 := int64(p.spanStart()) + span_start751 := int64(p.spanStart()) p.consumeLiteral("UNKNOWN") - _t1406 := &pb.UnspecifiedType{} - result736 := _t1406 - p.recordSpan(int(span_start735)) - return result736 + _t1482 := &pb.UnspecifiedType{} + result752 := _t1482 + p.recordSpan(int(span_start751)) + return result752 } func (p *Parser) parse_string_type() *pb.StringType { - span_start737 := int64(p.spanStart()) + span_start753 := int64(p.spanStart()) p.consumeLiteral("STRING") - _t1407 := &pb.StringType{} - result738 := _t1407 - p.recordSpan(int(span_start737)) - return result738 + _t1483 := &pb.StringType{} + result754 := _t1483 + p.recordSpan(int(span_start753)) + return result754 } func (p *Parser) parse_int_type() *pb.IntType { - span_start739 := int64(p.spanStart()) + span_start755 := int64(p.spanStart()) p.consumeLiteral("INT") - _t1408 := &pb.IntType{} - result740 := _t1408 - p.recordSpan(int(span_start739)) - return result740 + _t1484 := &pb.IntType{} + result756 := _t1484 + p.recordSpan(int(span_start755)) + return result756 } func (p *Parser) parse_float_type() *pb.FloatType { - span_start741 := int64(p.spanStart()) + span_start757 := int64(p.spanStart()) p.consumeLiteral("FLOAT") - _t1409 := &pb.FloatType{} - result742 := _t1409 - p.recordSpan(int(span_start741)) - return result742 + _t1485 := &pb.FloatType{} + result758 := _t1485 + p.recordSpan(int(span_start757)) + return result758 } func (p *Parser) parse_uint128_type() *pb.UInt128Type { - span_start743 := int64(p.spanStart()) + span_start759 := int64(p.spanStart()) p.consumeLiteral("UINT128") - _t1410 := &pb.UInt128Type{} - result744 := _t1410 - p.recordSpan(int(span_start743)) - return result744 + _t1486 := &pb.UInt128Type{} + result760 := _t1486 + p.recordSpan(int(span_start759)) + return result760 } func (p *Parser) parse_int128_type() *pb.Int128Type { - span_start745 := int64(p.spanStart()) + span_start761 := int64(p.spanStart()) p.consumeLiteral("INT128") - _t1411 := &pb.Int128Type{} - result746 := _t1411 - p.recordSpan(int(span_start745)) - return result746 + _t1487 := &pb.Int128Type{} + result762 := _t1487 + p.recordSpan(int(span_start761)) + return result762 } func (p *Parser) parse_date_type() *pb.DateType { - span_start747 := int64(p.spanStart()) + span_start763 := int64(p.spanStart()) p.consumeLiteral("DATE") - _t1412 := &pb.DateType{} - result748 := _t1412 - p.recordSpan(int(span_start747)) - return result748 + _t1488 := &pb.DateType{} + result764 := _t1488 + p.recordSpan(int(span_start763)) + return result764 } func (p *Parser) parse_datetime_type() *pb.DateTimeType { - span_start749 := int64(p.spanStart()) + span_start765 := int64(p.spanStart()) p.consumeLiteral("DATETIME") - _t1413 := &pb.DateTimeType{} - result750 := _t1413 - p.recordSpan(int(span_start749)) - return result750 + _t1489 := &pb.DateTimeType{} + result766 := _t1489 + p.recordSpan(int(span_start765)) + return result766 } func (p *Parser) parse_missing_type() *pb.MissingType { - span_start751 := int64(p.spanStart()) + span_start767 := int64(p.spanStart()) p.consumeLiteral("MISSING") - _t1414 := &pb.MissingType{} - result752 := _t1414 - p.recordSpan(int(span_start751)) - return result752 + _t1490 := &pb.MissingType{} + result768 := _t1490 + p.recordSpan(int(span_start767)) + return result768 } func (p *Parser) parse_decimal_type() *pb.DecimalType { - span_start755 := int64(p.spanStart()) + span_start771 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("DECIMAL") p.pushPath(int(1)) - int753 := p.consumeTerminal("INT").Value.i64 + int769 := p.consumeTerminal("INT").Value.i64 p.popPath() p.pushPath(int(2)) - int_3754 := p.consumeTerminal("INT").Value.i64 + int_3770 := p.consumeTerminal("INT").Value.i64 p.popPath() p.consumeLiteral(")") - _t1415 := &pb.DecimalType{Precision: int32(int753), Scale: int32(int_3754)} - result756 := _t1415 - p.recordSpan(int(span_start755)) - return result756 + _t1491 := &pb.DecimalType{Precision: int32(int769), Scale: int32(int_3770)} + result772 := _t1491 + p.recordSpan(int(span_start771)) + return result772 } func (p *Parser) parse_boolean_type() *pb.BooleanType { - span_start757 := int64(p.spanStart()) + span_start773 := int64(p.spanStart()) p.consumeLiteral("BOOLEAN") - _t1416 := &pb.BooleanType{} - result758 := _t1416 - p.recordSpan(int(span_start757)) - return result758 + _t1492 := &pb.BooleanType{} + result774 := _t1492 + p.recordSpan(int(span_start773)) + return result774 } func (p *Parser) parse_value_bindings() []*pb.Binding { - span_start763 := int64(p.spanStart()) + span_start783 := int64(p.spanStart()) p.consumeLiteral("|") - xs759 := []*pb.Binding{} - cond760 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond760 { - _t1417 := p.parse_binding() - item761 := _t1417 - xs759 = append(xs759, item761) - cond760 = p.matchLookaheadTerminal("SYMBOL", 0) - } - bindings762 := xs759 - result764 := bindings762 - p.recordSpan(int(span_start763)) - return result764 + xs779 := []*pb.Binding{} + cond780 := p.matchLookaheadTerminal("SYMBOL", 0) + idx781 := 0 + for cond780 { + p.pushPath(int(idx781)) + _t1493 := p.parse_binding() + item782 := _t1493 + p.popPath() + xs779 = append(xs779, item782) + idx781 = (idx781 + 1) + cond780 = p.matchLookaheadTerminal("SYMBOL", 0) + } + bindings778 := xs779 + result784 := bindings778 + p.recordSpan(int(span_start783)) + return result784 } func (p *Parser) parse_formula() *pb.Formula { - span_start779 := int64(p.spanStart()) - var _t1418 int64 + span_start799 := int64(p.spanStart()) + var _t1494 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1419 int64 + var _t1495 int64 if p.matchLookaheadLiteral("true", 1) { - _t1419 = 0 + _t1495 = 0 } else { - var _t1420 int64 + var _t1496 int64 if p.matchLookaheadLiteral("relatom", 1) { - _t1420 = 11 + _t1496 = 11 } else { - var _t1421 int64 + var _t1497 int64 if p.matchLookaheadLiteral("reduce", 1) { - _t1421 = 3 + _t1497 = 3 } else { - var _t1422 int64 + var _t1498 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t1422 = 10 + _t1498 = 10 } else { - var _t1423 int64 + var _t1499 int64 if p.matchLookaheadLiteral("pragma", 1) { - _t1423 = 9 + _t1499 = 9 } else { - var _t1424 int64 + var _t1500 int64 if p.matchLookaheadLiteral("or", 1) { - _t1424 = 5 + _t1500 = 5 } else { - var _t1425 int64 + var _t1501 int64 if p.matchLookaheadLiteral("not", 1) { - _t1425 = 6 + _t1501 = 6 } else { - var _t1426 int64 + var _t1502 int64 if p.matchLookaheadLiteral("ffi", 1) { - _t1426 = 7 + _t1502 = 7 } else { - var _t1427 int64 + var _t1503 int64 if p.matchLookaheadLiteral("false", 1) { - _t1427 = 1 + _t1503 = 1 } else { - var _t1428 int64 + var _t1504 int64 if p.matchLookaheadLiteral("exists", 1) { - _t1428 = 2 + _t1504 = 2 } else { - var _t1429 int64 + var _t1505 int64 if p.matchLookaheadLiteral("cast", 1) { - _t1429 = 12 + _t1505 = 12 } else { - var _t1430 int64 + var _t1506 int64 if p.matchLookaheadLiteral("atom", 1) { - _t1430 = 8 + _t1506 = 8 } else { - var _t1431 int64 + var _t1507 int64 if p.matchLookaheadLiteral("and", 1) { - _t1431 = 4 + _t1507 = 4 } else { - var _t1432 int64 + var _t1508 int64 if p.matchLookaheadLiteral(">=", 1) { - _t1432 = 10 + _t1508 = 10 } else { - var _t1433 int64 + var _t1509 int64 if p.matchLookaheadLiteral(">", 1) { - _t1433 = 10 + _t1509 = 10 } else { - var _t1434 int64 + var _t1510 int64 if p.matchLookaheadLiteral("=", 1) { - _t1434 = 10 + _t1510 = 10 } else { - var _t1435 int64 + var _t1511 int64 if p.matchLookaheadLiteral("<=", 1) { - _t1435 = 10 + _t1511 = 10 } else { - var _t1436 int64 + var _t1512 int64 if p.matchLookaheadLiteral("<", 1) { - _t1436 = 10 + _t1512 = 10 } else { - var _t1437 int64 + var _t1513 int64 if p.matchLookaheadLiteral("/", 1) { - _t1437 = 10 + _t1513 = 10 } else { - var _t1438 int64 + var _t1514 int64 if p.matchLookaheadLiteral("-", 1) { - _t1438 = 10 + _t1514 = 10 } else { - var _t1439 int64 + var _t1515 int64 if p.matchLookaheadLiteral("+", 1) { - _t1439 = 10 + _t1515 = 10 } else { - var _t1440 int64 + var _t1516 int64 if p.matchLookaheadLiteral("*", 1) { - _t1440 = 10 + _t1516 = 10 } else { - _t1440 = -1 + _t1516 = -1 } - _t1439 = _t1440 + _t1515 = _t1516 } - _t1438 = _t1439 + _t1514 = _t1515 } - _t1437 = _t1438 + _t1513 = _t1514 } - _t1436 = _t1437 + _t1512 = _t1513 } - _t1435 = _t1436 + _t1511 = _t1512 } - _t1434 = _t1435 + _t1510 = _t1511 } - _t1433 = _t1434 + _t1509 = _t1510 } - _t1432 = _t1433 + _t1508 = _t1509 } - _t1431 = _t1432 + _t1507 = _t1508 } - _t1430 = _t1431 + _t1506 = _t1507 } - _t1429 = _t1430 + _t1505 = _t1506 } - _t1428 = _t1429 + _t1504 = _t1505 } - _t1427 = _t1428 + _t1503 = _t1504 } - _t1426 = _t1427 + _t1502 = _t1503 } - _t1425 = _t1426 + _t1501 = _t1502 } - _t1424 = _t1425 + _t1500 = _t1501 } - _t1423 = _t1424 + _t1499 = _t1500 } - _t1422 = _t1423 + _t1498 = _t1499 } - _t1421 = _t1422 + _t1497 = _t1498 } - _t1420 = _t1421 + _t1496 = _t1497 } - _t1419 = _t1420 + _t1495 = _t1496 } - _t1418 = _t1419 + _t1494 = _t1495 } else { - _t1418 = -1 - } - prediction765 := _t1418 - var _t1441 *pb.Formula - if prediction765 == 12 { - _t1442 := p.parse_cast() - cast778 := _t1442 - _t1443 := &pb.Formula{} - _t1443.FormulaType = &pb.Formula_Cast{Cast: cast778} - _t1441 = _t1443 + _t1494 = -1 + } + prediction785 := _t1494 + var _t1517 *pb.Formula + if prediction785 == 12 { + p.pushPath(int(11)) + _t1518 := p.parse_cast() + cast798 := _t1518 + p.popPath() + _t1519 := &pb.Formula{} + _t1519.FormulaType = &pb.Formula_Cast{Cast: cast798} + _t1517 = _t1519 } else { - var _t1444 *pb.Formula - if prediction765 == 11 { - _t1445 := p.parse_rel_atom() - rel_atom777 := _t1445 - _t1446 := &pb.Formula{} - _t1446.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom777} - _t1444 = _t1446 + var _t1520 *pb.Formula + if prediction785 == 11 { + p.pushPath(int(10)) + _t1521 := p.parse_rel_atom() + rel_atom797 := _t1521 + p.popPath() + _t1522 := &pb.Formula{} + _t1522.FormulaType = &pb.Formula_RelAtom{RelAtom: rel_atom797} + _t1520 = _t1522 } else { - var _t1447 *pb.Formula - if prediction765 == 10 { - _t1448 := p.parse_primitive() - primitive776 := _t1448 - _t1449 := &pb.Formula{} - _t1449.FormulaType = &pb.Formula_Primitive{Primitive: primitive776} - _t1447 = _t1449 + var _t1523 *pb.Formula + if prediction785 == 10 { + p.pushPath(int(9)) + _t1524 := p.parse_primitive() + primitive796 := _t1524 + p.popPath() + _t1525 := &pb.Formula{} + _t1525.FormulaType = &pb.Formula_Primitive{Primitive: primitive796} + _t1523 = _t1525 } else { - var _t1450 *pb.Formula - if prediction765 == 9 { - _t1451 := p.parse_pragma() - pragma775 := _t1451 - _t1452 := &pb.Formula{} - _t1452.FormulaType = &pb.Formula_Pragma{Pragma: pragma775} - _t1450 = _t1452 + var _t1526 *pb.Formula + if prediction785 == 9 { + p.pushPath(int(8)) + _t1527 := p.parse_pragma() + pragma795 := _t1527 + p.popPath() + _t1528 := &pb.Formula{} + _t1528.FormulaType = &pb.Formula_Pragma{Pragma: pragma795} + _t1526 = _t1528 } else { - var _t1453 *pb.Formula - if prediction765 == 8 { - _t1454 := p.parse_atom() - atom774 := _t1454 - _t1455 := &pb.Formula{} - _t1455.FormulaType = &pb.Formula_Atom{Atom: atom774} - _t1453 = _t1455 + var _t1529 *pb.Formula + if prediction785 == 8 { + p.pushPath(int(7)) + _t1530 := p.parse_atom() + atom794 := _t1530 + p.popPath() + _t1531 := &pb.Formula{} + _t1531.FormulaType = &pb.Formula_Atom{Atom: atom794} + _t1529 = _t1531 } else { - var _t1456 *pb.Formula - if prediction765 == 7 { - _t1457 := p.parse_ffi() - ffi773 := _t1457 - _t1458 := &pb.Formula{} - _t1458.FormulaType = &pb.Formula_Ffi{Ffi: ffi773} - _t1456 = _t1458 + var _t1532 *pb.Formula + if prediction785 == 7 { + p.pushPath(int(6)) + _t1533 := p.parse_ffi() + ffi793 := _t1533 + p.popPath() + _t1534 := &pb.Formula{} + _t1534.FormulaType = &pb.Formula_Ffi{Ffi: ffi793} + _t1532 = _t1534 } else { - var _t1459 *pb.Formula - if prediction765 == 6 { - _t1460 := p.parse_not() - not772 := _t1460 - _t1461 := &pb.Formula{} - _t1461.FormulaType = &pb.Formula_Not{Not: not772} - _t1459 = _t1461 + var _t1535 *pb.Formula + if prediction785 == 6 { + p.pushPath(int(5)) + _t1536 := p.parse_not() + not792 := _t1536 + p.popPath() + _t1537 := &pb.Formula{} + _t1537.FormulaType = &pb.Formula_Not{Not: not792} + _t1535 = _t1537 } else { - var _t1462 *pb.Formula - if prediction765 == 5 { - _t1463 := p.parse_disjunction() - disjunction771 := _t1463 - _t1464 := &pb.Formula{} - _t1464.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction771} - _t1462 = _t1464 + var _t1538 *pb.Formula + if prediction785 == 5 { + p.pushPath(int(4)) + _t1539 := p.parse_disjunction() + disjunction791 := _t1539 + p.popPath() + _t1540 := &pb.Formula{} + _t1540.FormulaType = &pb.Formula_Disjunction{Disjunction: disjunction791} + _t1538 = _t1540 } else { - var _t1465 *pb.Formula - if prediction765 == 4 { - _t1466 := p.parse_conjunction() - conjunction770 := _t1466 - _t1467 := &pb.Formula{} - _t1467.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction770} - _t1465 = _t1467 + var _t1541 *pb.Formula + if prediction785 == 4 { + p.pushPath(int(3)) + _t1542 := p.parse_conjunction() + conjunction790 := _t1542 + p.popPath() + _t1543 := &pb.Formula{} + _t1543.FormulaType = &pb.Formula_Conjunction{Conjunction: conjunction790} + _t1541 = _t1543 } else { - var _t1468 *pb.Formula - if prediction765 == 3 { - _t1469 := p.parse_reduce() - reduce769 := _t1469 - _t1470 := &pb.Formula{} - _t1470.FormulaType = &pb.Formula_Reduce{Reduce: reduce769} - _t1468 = _t1470 + var _t1544 *pb.Formula + if prediction785 == 3 { + p.pushPath(int(2)) + _t1545 := p.parse_reduce() + reduce789 := _t1545 + p.popPath() + _t1546 := &pb.Formula{} + _t1546.FormulaType = &pb.Formula_Reduce{Reduce: reduce789} + _t1544 = _t1546 } else { - var _t1471 *pb.Formula - if prediction765 == 2 { - _t1472 := p.parse_exists() - exists768 := _t1472 - _t1473 := &pb.Formula{} - _t1473.FormulaType = &pb.Formula_Exists{Exists: exists768} - _t1471 = _t1473 + var _t1547 *pb.Formula + if prediction785 == 2 { + p.pushPath(int(1)) + _t1548 := p.parse_exists() + exists788 := _t1548 + p.popPath() + _t1549 := &pb.Formula{} + _t1549.FormulaType = &pb.Formula_Exists{Exists: exists788} + _t1547 = _t1549 } else { - var _t1474 *pb.Formula - if prediction765 == 1 { - _t1475 := p.parse_false() - false767 := _t1475 - _t1476 := &pb.Formula{} - _t1476.FormulaType = &pb.Formula_Disjunction{Disjunction: false767} - _t1474 = _t1476 + var _t1550 *pb.Formula + if prediction785 == 1 { + p.pushPath(int(4)) + _t1551 := p.parse_false() + false787 := _t1551 + p.popPath() + _t1552 := &pb.Formula{} + _t1552.FormulaType = &pb.Formula_Disjunction{Disjunction: false787} + _t1550 = _t1552 } else { - var _t1477 *pb.Formula - if prediction765 == 0 { - _t1478 := p.parse_true() - true766 := _t1478 - _t1479 := &pb.Formula{} - _t1479.FormulaType = &pb.Formula_Conjunction{Conjunction: true766} - _t1477 = _t1479 + var _t1553 *pb.Formula + if prediction785 == 0 { + p.pushPath(int(3)) + _t1554 := p.parse_true() + true786 := _t1554 + p.popPath() + _t1555 := &pb.Formula{} + _t1555.FormulaType = &pb.Formula_Conjunction{Conjunction: true786} + _t1553 = _t1555 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in formula", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1474 = _t1477 + _t1550 = _t1553 } - _t1471 = _t1474 + _t1547 = _t1550 } - _t1468 = _t1471 + _t1544 = _t1547 } - _t1465 = _t1468 + _t1541 = _t1544 } - _t1462 = _t1465 + _t1538 = _t1541 } - _t1459 = _t1462 + _t1535 = _t1538 } - _t1456 = _t1459 + _t1532 = _t1535 } - _t1453 = _t1456 + _t1529 = _t1532 } - _t1450 = _t1453 + _t1526 = _t1529 } - _t1447 = _t1450 + _t1523 = _t1526 } - _t1444 = _t1447 + _t1520 = _t1523 } - _t1441 = _t1444 + _t1517 = _t1520 } - result780 := _t1441 - p.recordSpan(int(span_start779)) - return result780 + result800 := _t1517 + p.recordSpan(int(span_start799)) + return result800 } func (p *Parser) parse_true() *pb.Conjunction { - span_start781 := int64(p.spanStart()) + span_start801 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("true") p.consumeLiteral(")") - _t1480 := &pb.Conjunction{Args: []*pb.Formula{}} - result782 := _t1480 - p.recordSpan(int(span_start781)) - return result782 + _t1556 := &pb.Conjunction{Args: []*pb.Formula{}} + result802 := _t1556 + p.recordSpan(int(span_start801)) + return result802 } func (p *Parser) parse_false() *pb.Disjunction { - span_start783 := int64(p.spanStart()) + span_start803 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("false") p.consumeLiteral(")") - _t1481 := &pb.Disjunction{Args: []*pb.Formula{}} - result784 := _t1481 - p.recordSpan(int(span_start783)) - return result784 + _t1557 := &pb.Disjunction{Args: []*pb.Formula{}} + result804 := _t1557 + p.recordSpan(int(span_start803)) + return result804 } func (p *Parser) parse_exists() *pb.Exists { - span_start787 := int64(p.spanStart()) + span_start807 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("exists") - _t1482 := p.parse_bindings() - bindings785 := _t1482 - _t1483 := p.parse_formula() - formula786 := _t1483 + _t1558 := p.parse_bindings() + bindings805 := _t1558 + _t1559 := p.parse_formula() + formula806 := _t1559 p.consumeLiteral(")") - _t1484 := &pb.Abstraction{Vars: listConcat(bindings785[0].([]*pb.Binding), bindings785[1].([]*pb.Binding)), Value: formula786} - _t1485 := &pb.Exists{Body: _t1484} - result788 := _t1485 - p.recordSpan(int(span_start787)) - return result788 + _t1560 := &pb.Abstraction{Vars: listConcat(bindings805[0].([]*pb.Binding), bindings805[1].([]*pb.Binding)), Value: formula806} + _t1561 := &pb.Exists{Body: _t1560} + result808 := _t1561 + p.recordSpan(int(span_start807)) + return result808 } func (p *Parser) parse_reduce() *pb.Reduce { - span_start792 := int64(p.spanStart()) + span_start812 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("reduce") p.pushPath(int(1)) - _t1486 := p.parse_abstraction() - abstraction789 := _t1486 + _t1562 := p.parse_abstraction() + abstraction809 := _t1562 p.popPath() p.pushPath(int(2)) - _t1487 := p.parse_abstraction() - abstraction_3790 := _t1487 + _t1563 := p.parse_abstraction() + abstraction_3810 := _t1563 p.popPath() p.pushPath(int(3)) - _t1488 := p.parse_terms() - terms791 := _t1488 + _t1564 := p.parse_terms() + terms811 := _t1564 p.popPath() p.consumeLiteral(")") - _t1489 := &pb.Reduce{Op: abstraction789, Body: abstraction_3790, Terms: terms791} - result793 := _t1489 - p.recordSpan(int(span_start792)) - return result793 + _t1565 := &pb.Reduce{Op: abstraction809, Body: abstraction_3810, Terms: terms811} + result813 := _t1565 + p.recordSpan(int(span_start812)) + return result813 } func (p *Parser) parse_terms() []*pb.Term { - span_start798 := int64(p.spanStart()) + span_start822 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("terms") - xs794 := []*pb.Term{} - cond795 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - for cond795 { - _t1490 := p.parse_term() - item796 := _t1490 - xs794 = append(xs794, item796) - cond795 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - } - terms797 := xs794 + xs818 := []*pb.Term{} + cond819 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx820 := 0 + for cond819 { + p.pushPath(int(idx820)) + _t1566 := p.parse_term() + item821 := _t1566 + p.popPath() + xs818 = append(xs818, item821) + idx820 = (idx820 + 1) + cond819 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + } + terms817 := xs818 p.consumeLiteral(")") - result799 := terms797 - p.recordSpan(int(span_start798)) - return result799 + result823 := terms817 + p.recordSpan(int(span_start822)) + return result823 } func (p *Parser) parse_term() *pb.Term { - span_start803 := int64(p.spanStart()) - var _t1491 int64 + span_start827 := int64(p.spanStart()) + var _t1567 int64 if p.matchLookaheadLiteral("true", 0) { - _t1491 = 1 + _t1567 = 1 } else { - var _t1492 int64 + var _t1568 int64 if p.matchLookaheadLiteral("missing", 0) { - _t1492 = 1 + _t1568 = 1 } else { - var _t1493 int64 + var _t1569 int64 if p.matchLookaheadLiteral("false", 0) { - _t1493 = 1 + _t1569 = 1 } else { - var _t1494 int64 + var _t1570 int64 if p.matchLookaheadLiteral("(", 0) { - _t1494 = 1 + _t1570 = 1 } else { - var _t1495 int64 + var _t1571 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1495 = 1 + _t1571 = 1 } else { - var _t1496 int64 + var _t1572 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t1496 = 0 + _t1572 = 0 } else { - var _t1497 int64 + var _t1573 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t1497 = 1 + _t1573 = 1 } else { - var _t1498 int64 + var _t1574 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t1498 = 1 + _t1574 = 1 } else { - var _t1499 int64 + var _t1575 int64 if p.matchLookaheadTerminal("INT", 0) { - _t1499 = 1 + _t1575 = 1 } else { - var _t1500 int64 + var _t1576 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t1500 = 1 + _t1576 = 1 } else { - var _t1501 int64 + var _t1577 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t1501 = 1 + _t1577 = 1 } else { - _t1501 = -1 + _t1577 = -1 } - _t1500 = _t1501 + _t1576 = _t1577 } - _t1499 = _t1500 + _t1575 = _t1576 } - _t1498 = _t1499 + _t1574 = _t1575 } - _t1497 = _t1498 + _t1573 = _t1574 } - _t1496 = _t1497 + _t1572 = _t1573 } - _t1495 = _t1496 + _t1571 = _t1572 } - _t1494 = _t1495 + _t1570 = _t1571 } - _t1493 = _t1494 + _t1569 = _t1570 } - _t1492 = _t1493 + _t1568 = _t1569 } - _t1491 = _t1492 - } - prediction800 := _t1491 - var _t1502 *pb.Term - if prediction800 == 1 { - _t1503 := p.parse_constant() - constant802 := _t1503 - _t1504 := &pb.Term{} - _t1504.TermType = &pb.Term_Constant{Constant: constant802} - _t1502 = _t1504 + _t1567 = _t1568 + } + prediction824 := _t1567 + var _t1578 *pb.Term + if prediction824 == 1 { + p.pushPath(int(2)) + _t1579 := p.parse_constant() + constant826 := _t1579 + p.popPath() + _t1580 := &pb.Term{} + _t1580.TermType = &pb.Term_Constant{Constant: constant826} + _t1578 = _t1580 } else { - var _t1505 *pb.Term - if prediction800 == 0 { - _t1506 := p.parse_var() - var801 := _t1506 - _t1507 := &pb.Term{} - _t1507.TermType = &pb.Term_Var{Var: var801} - _t1505 = _t1507 + var _t1581 *pb.Term + if prediction824 == 0 { + p.pushPath(int(1)) + _t1582 := p.parse_var() + var825 := _t1582 + p.popPath() + _t1583 := &pb.Term{} + _t1583.TermType = &pb.Term_Var{Var: var825} + _t1581 = _t1583 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1502 = _t1505 + _t1578 = _t1581 } - result804 := _t1502 - p.recordSpan(int(span_start803)) - return result804 + result828 := _t1578 + p.recordSpan(int(span_start827)) + return result828 } func (p *Parser) parse_var() *pb.Var { - span_start806 := int64(p.spanStart()) - symbol805 := p.consumeTerminal("SYMBOL").Value.str - _t1508 := &pb.Var{Name: symbol805} - result807 := _t1508 - p.recordSpan(int(span_start806)) - return result807 + span_start830 := int64(p.spanStart()) + symbol829 := p.consumeTerminal("SYMBOL").Value.str + _t1584 := &pb.Var{Name: symbol829} + result831 := _t1584 + p.recordSpan(int(span_start830)) + return result831 } func (p *Parser) parse_constant() *pb.Value { - span_start809 := int64(p.spanStart()) - _t1509 := p.parse_value() - value808 := _t1509 - result810 := value808 - p.recordSpan(int(span_start809)) - return result810 + span_start833 := int64(p.spanStart()) + _t1585 := p.parse_value() + value832 := _t1585 + result834 := value832 + p.recordSpan(int(span_start833)) + return result834 } func (p *Parser) parse_conjunction() *pb.Conjunction { - span_start819 := int64(p.spanStart()) + span_start843 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("and") p.pushPath(int(1)) - xs815 := []*pb.Formula{} - cond816 := p.matchLookaheadLiteral("(", 0) - idx817 := 0 - for cond816 { - p.pushPath(int(idx817)) - _t1510 := p.parse_formula() - item818 := _t1510 + xs839 := []*pb.Formula{} + cond840 := p.matchLookaheadLiteral("(", 0) + idx841 := 0 + for cond840 { + p.pushPath(int(idx841)) + _t1586 := p.parse_formula() + item842 := _t1586 p.popPath() - xs815 = append(xs815, item818) - idx817 = (idx817 + 1) - cond816 = p.matchLookaheadLiteral("(", 0) + xs839 = append(xs839, item842) + idx841 = (idx841 + 1) + cond840 = p.matchLookaheadLiteral("(", 0) } - formulas814 := xs815 + formulas838 := xs839 p.popPath() p.consumeLiteral(")") - _t1511 := &pb.Conjunction{Args: formulas814} - result820 := _t1511 - p.recordSpan(int(span_start819)) - return result820 + _t1587 := &pb.Conjunction{Args: formulas838} + result844 := _t1587 + p.recordSpan(int(span_start843)) + return result844 } func (p *Parser) parse_disjunction() *pb.Disjunction { - span_start829 := int64(p.spanStart()) + span_start853 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("or") p.pushPath(int(1)) - xs825 := []*pb.Formula{} - cond826 := p.matchLookaheadLiteral("(", 0) - idx827 := 0 - for cond826 { - p.pushPath(int(idx827)) - _t1512 := p.parse_formula() - item828 := _t1512 + xs849 := []*pb.Formula{} + cond850 := p.matchLookaheadLiteral("(", 0) + idx851 := 0 + for cond850 { + p.pushPath(int(idx851)) + _t1588 := p.parse_formula() + item852 := _t1588 p.popPath() - xs825 = append(xs825, item828) - idx827 = (idx827 + 1) - cond826 = p.matchLookaheadLiteral("(", 0) + xs849 = append(xs849, item852) + idx851 = (idx851 + 1) + cond850 = p.matchLookaheadLiteral("(", 0) } - formulas824 := xs825 + formulas848 := xs849 p.popPath() p.consumeLiteral(")") - _t1513 := &pb.Disjunction{Args: formulas824} - result830 := _t1513 - p.recordSpan(int(span_start829)) - return result830 + _t1589 := &pb.Disjunction{Args: formulas848} + result854 := _t1589 + p.recordSpan(int(span_start853)) + return result854 } func (p *Parser) parse_not() *pb.Not { - span_start832 := int64(p.spanStart()) + span_start856 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("not") p.pushPath(int(1)) - _t1514 := p.parse_formula() - formula831 := _t1514 + _t1590 := p.parse_formula() + formula855 := _t1590 p.popPath() p.consumeLiteral(")") - _t1515 := &pb.Not{Arg: formula831} - result833 := _t1515 - p.recordSpan(int(span_start832)) - return result833 + _t1591 := &pb.Not{Arg: formula855} + result857 := _t1591 + p.recordSpan(int(span_start856)) + return result857 } func (p *Parser) parse_ffi() *pb.FFI { - span_start837 := int64(p.spanStart()) + span_start861 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("ffi") p.pushPath(int(1)) - _t1516 := p.parse_name() - name834 := _t1516 + _t1592 := p.parse_name() + name858 := _t1592 p.popPath() p.pushPath(int(2)) - _t1517 := p.parse_ffi_args() - ffi_args835 := _t1517 + _t1593 := p.parse_ffi_args() + ffi_args859 := _t1593 p.popPath() p.pushPath(int(3)) - _t1518 := p.parse_terms() - terms836 := _t1518 + _t1594 := p.parse_terms() + terms860 := _t1594 p.popPath() p.consumeLiteral(")") - _t1519 := &pb.FFI{Name: name834, Args: ffi_args835, Terms: terms836} - result838 := _t1519 - p.recordSpan(int(span_start837)) - return result838 + _t1595 := &pb.FFI{Name: name858, Args: ffi_args859, Terms: terms860} + result862 := _t1595 + p.recordSpan(int(span_start861)) + return result862 } func (p *Parser) parse_name() string { - span_start840 := int64(p.spanStart()) + span_start864 := int64(p.spanStart()) p.consumeLiteral(":") - symbol839 := p.consumeTerminal("SYMBOL").Value.str - result841 := symbol839 - p.recordSpan(int(span_start840)) - return result841 + symbol863 := p.consumeTerminal("SYMBOL").Value.str + result865 := symbol863 + p.recordSpan(int(span_start864)) + return result865 } func (p *Parser) parse_ffi_args() []*pb.Abstraction { - span_start846 := int64(p.spanStart()) + span_start874 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("args") - xs842 := []*pb.Abstraction{} - cond843 := p.matchLookaheadLiteral("(", 0) - for cond843 { - _t1520 := p.parse_abstraction() - item844 := _t1520 - xs842 = append(xs842, item844) - cond843 = p.matchLookaheadLiteral("(", 0) - } - abstractions845 := xs842 + xs870 := []*pb.Abstraction{} + cond871 := p.matchLookaheadLiteral("(", 0) + idx872 := 0 + for cond871 { + p.pushPath(int(idx872)) + _t1596 := p.parse_abstraction() + item873 := _t1596 + p.popPath() + xs870 = append(xs870, item873) + idx872 = (idx872 + 1) + cond871 = p.matchLookaheadLiteral("(", 0) + } + abstractions869 := xs870 p.consumeLiteral(")") - result847 := abstractions845 - p.recordSpan(int(span_start846)) - return result847 + result875 := abstractions869 + p.recordSpan(int(span_start874)) + return result875 } func (p *Parser) parse_atom() *pb.Atom { - span_start857 := int64(p.spanStart()) + span_start885 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("atom") p.pushPath(int(1)) - _t1521 := p.parse_relation_id() - relation_id848 := _t1521 + _t1597 := p.parse_relation_id() + relation_id876 := _t1597 p.popPath() p.pushPath(int(2)) - xs853 := []*pb.Term{} - cond854 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - idx855 := 0 - for cond854 { - p.pushPath(int(idx855)) - _t1522 := p.parse_term() - item856 := _t1522 + xs881 := []*pb.Term{} + cond882 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx883 := 0 + for cond882 { + p.pushPath(int(idx883)) + _t1598 := p.parse_term() + item884 := _t1598 p.popPath() - xs853 = append(xs853, item856) - idx855 = (idx855 + 1) - cond854 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + xs881 = append(xs881, item884) + idx883 = (idx883 + 1) + cond882 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - terms852 := xs853 + terms880 := xs881 p.popPath() p.consumeLiteral(")") - _t1523 := &pb.Atom{Name: relation_id848, Terms: terms852} - result858 := _t1523 - p.recordSpan(int(span_start857)) - return result858 + _t1599 := &pb.Atom{Name: relation_id876, Terms: terms880} + result886 := _t1599 + p.recordSpan(int(span_start885)) + return result886 } func (p *Parser) parse_pragma() *pb.Pragma { - span_start868 := int64(p.spanStart()) + span_start896 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("pragma") p.pushPath(int(1)) - _t1524 := p.parse_name() - name859 := _t1524 + _t1600 := p.parse_name() + name887 := _t1600 p.popPath() p.pushPath(int(2)) - xs864 := []*pb.Term{} - cond865 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - idx866 := 0 - for cond865 { - p.pushPath(int(idx866)) - _t1525 := p.parse_term() - item867 := _t1525 + xs892 := []*pb.Term{} + cond893 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx894 := 0 + for cond893 { + p.pushPath(int(idx894)) + _t1601 := p.parse_term() + item895 := _t1601 p.popPath() - xs864 = append(xs864, item867) - idx866 = (idx866 + 1) - cond865 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + xs892 = append(xs892, item895) + idx894 = (idx894 + 1) + cond893 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - terms863 := xs864 + terms891 := xs892 p.popPath() p.consumeLiteral(")") - _t1526 := &pb.Pragma{Name: name859, Terms: terms863} - result869 := _t1526 - p.recordSpan(int(span_start868)) - return result869 + _t1602 := &pb.Pragma{Name: name887, Terms: terms891} + result897 := _t1602 + p.recordSpan(int(span_start896)) + return result897 } func (p *Parser) parse_primitive() *pb.Primitive { - span_start889 := int64(p.spanStart()) - var _t1527 int64 + span_start917 := int64(p.spanStart()) + var _t1603 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1528 int64 + var _t1604 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t1528 = 9 + _t1604 = 9 } else { - var _t1529 int64 + var _t1605 int64 if p.matchLookaheadLiteral(">=", 1) { - _t1529 = 4 + _t1605 = 4 } else { - var _t1530 int64 + var _t1606 int64 if p.matchLookaheadLiteral(">", 1) { - _t1530 = 3 + _t1606 = 3 } else { - var _t1531 int64 + var _t1607 int64 if p.matchLookaheadLiteral("=", 1) { - _t1531 = 0 + _t1607 = 0 } else { - var _t1532 int64 + var _t1608 int64 if p.matchLookaheadLiteral("<=", 1) { - _t1532 = 2 + _t1608 = 2 } else { - var _t1533 int64 + var _t1609 int64 if p.matchLookaheadLiteral("<", 1) { - _t1533 = 1 + _t1609 = 1 } else { - var _t1534 int64 + var _t1610 int64 if p.matchLookaheadLiteral("/", 1) { - _t1534 = 8 + _t1610 = 8 } else { - var _t1535 int64 + var _t1611 int64 if p.matchLookaheadLiteral("-", 1) { - _t1535 = 6 + _t1611 = 6 } else { - var _t1536 int64 + var _t1612 int64 if p.matchLookaheadLiteral("+", 1) { - _t1536 = 5 + _t1612 = 5 } else { - var _t1537 int64 + var _t1613 int64 if p.matchLookaheadLiteral("*", 1) { - _t1537 = 7 + _t1613 = 7 } else { - _t1537 = -1 + _t1613 = -1 } - _t1536 = _t1537 + _t1612 = _t1613 } - _t1535 = _t1536 + _t1611 = _t1612 } - _t1534 = _t1535 + _t1610 = _t1611 } - _t1533 = _t1534 + _t1609 = _t1610 } - _t1532 = _t1533 + _t1608 = _t1609 } - _t1531 = _t1532 + _t1607 = _t1608 } - _t1530 = _t1531 + _t1606 = _t1607 } - _t1529 = _t1530 + _t1605 = _t1606 } - _t1528 = _t1529 + _t1604 = _t1605 } - _t1527 = _t1528 + _t1603 = _t1604 } else { - _t1527 = -1 + _t1603 = -1 } - prediction870 := _t1527 - var _t1538 *pb.Primitive - if prediction870 == 9 { + prediction898 := _t1603 + var _t1614 *pb.Primitive + if prediction898 == 9 { p.consumeLiteral("(") p.consumeLiteral("primitive") p.pushPath(int(1)) - _t1539 := p.parse_name() - name880 := _t1539 + _t1615 := p.parse_name() + name908 := _t1615 p.popPath() p.pushPath(int(2)) - xs885 := []*pb.RelTerm{} - cond886 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - idx887 := 0 - for cond886 { - p.pushPath(int(idx887)) - _t1540 := p.parse_rel_term() - item888 := _t1540 + xs913 := []*pb.RelTerm{} + cond914 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx915 := 0 + for cond914 { + p.pushPath(int(idx915)) + _t1616 := p.parse_rel_term() + item916 := _t1616 p.popPath() - xs885 = append(xs885, item888) - idx887 = (idx887 + 1) - cond886 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + xs913 = append(xs913, item916) + idx915 = (idx915 + 1) + cond914 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - rel_terms884 := xs885 + rel_terms912 := xs913 p.popPath() p.consumeLiteral(")") - _t1541 := &pb.Primitive{Name: name880, Terms: rel_terms884} - _t1538 = _t1541 + _t1617 := &pb.Primitive{Name: name908, Terms: rel_terms912} + _t1614 = _t1617 } else { - var _t1542 *pb.Primitive - if prediction870 == 8 { - _t1543 := p.parse_divide() - divide879 := _t1543 - _t1542 = divide879 + var _t1618 *pb.Primitive + if prediction898 == 8 { + _t1619 := p.parse_divide() + divide907 := _t1619 + _t1618 = divide907 } else { - var _t1544 *pb.Primitive - if prediction870 == 7 { - _t1545 := p.parse_multiply() - multiply878 := _t1545 - _t1544 = multiply878 + var _t1620 *pb.Primitive + if prediction898 == 7 { + _t1621 := p.parse_multiply() + multiply906 := _t1621 + _t1620 = multiply906 } else { - var _t1546 *pb.Primitive - if prediction870 == 6 { - _t1547 := p.parse_minus() - minus877 := _t1547 - _t1546 = minus877 + var _t1622 *pb.Primitive + if prediction898 == 6 { + _t1623 := p.parse_minus() + minus905 := _t1623 + _t1622 = minus905 } else { - var _t1548 *pb.Primitive - if prediction870 == 5 { - _t1549 := p.parse_add() - add876 := _t1549 - _t1548 = add876 + var _t1624 *pb.Primitive + if prediction898 == 5 { + _t1625 := p.parse_add() + add904 := _t1625 + _t1624 = add904 } else { - var _t1550 *pb.Primitive - if prediction870 == 4 { - _t1551 := p.parse_gt_eq() - gt_eq875 := _t1551 - _t1550 = gt_eq875 + var _t1626 *pb.Primitive + if prediction898 == 4 { + _t1627 := p.parse_gt_eq() + gt_eq903 := _t1627 + _t1626 = gt_eq903 } else { - var _t1552 *pb.Primitive - if prediction870 == 3 { - _t1553 := p.parse_gt() - gt874 := _t1553 - _t1552 = gt874 + var _t1628 *pb.Primitive + if prediction898 == 3 { + _t1629 := p.parse_gt() + gt902 := _t1629 + _t1628 = gt902 } else { - var _t1554 *pb.Primitive - if prediction870 == 2 { - _t1555 := p.parse_lt_eq() - lt_eq873 := _t1555 - _t1554 = lt_eq873 + var _t1630 *pb.Primitive + if prediction898 == 2 { + _t1631 := p.parse_lt_eq() + lt_eq901 := _t1631 + _t1630 = lt_eq901 } else { - var _t1556 *pb.Primitive - if prediction870 == 1 { - _t1557 := p.parse_lt() - lt872 := _t1557 - _t1556 = lt872 + var _t1632 *pb.Primitive + if prediction898 == 1 { + _t1633 := p.parse_lt() + lt900 := _t1633 + _t1632 = lt900 } else { - var _t1558 *pb.Primitive - if prediction870 == 0 { - _t1559 := p.parse_eq() - eq871 := _t1559 - _t1558 = eq871 + var _t1634 *pb.Primitive + if prediction898 == 0 { + _t1635 := p.parse_eq() + eq899 := _t1635 + _t1634 = eq899 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in primitive", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1556 = _t1558 + _t1632 = _t1634 } - _t1554 = _t1556 + _t1630 = _t1632 } - _t1552 = _t1554 + _t1628 = _t1630 } - _t1550 = _t1552 + _t1626 = _t1628 } - _t1548 = _t1550 + _t1624 = _t1626 } - _t1546 = _t1548 + _t1622 = _t1624 } - _t1544 = _t1546 + _t1620 = _t1622 } - _t1542 = _t1544 + _t1618 = _t1620 } - _t1538 = _t1542 + _t1614 = _t1618 } - result890 := _t1538 - p.recordSpan(int(span_start889)) - return result890 + result918 := _t1614 + p.recordSpan(int(span_start917)) + return result918 } func (p *Parser) parse_eq() *pb.Primitive { - span_start893 := int64(p.spanStart()) + span_start921 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("=") - _t1560 := p.parse_term() - term891 := _t1560 - _t1561 := p.parse_term() - term_3892 := _t1561 + _t1636 := p.parse_term() + term919 := _t1636 + _t1637 := p.parse_term() + term_3920 := _t1637 p.consumeLiteral(")") - _t1562 := &pb.RelTerm{} - _t1562.RelTermType = &pb.RelTerm_Term{Term: term891} - _t1563 := &pb.RelTerm{} - _t1563.RelTermType = &pb.RelTerm_Term{Term: term_3892} - _t1564 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t1562, _t1563}} - result894 := _t1564 - p.recordSpan(int(span_start893)) - return result894 + _t1638 := &pb.RelTerm{} + _t1638.RelTermType = &pb.RelTerm_Term{Term: term919} + _t1639 := &pb.RelTerm{} + _t1639.RelTermType = &pb.RelTerm_Term{Term: term_3920} + _t1640 := &pb.Primitive{Name: "rel_primitive_eq", Terms: []*pb.RelTerm{_t1638, _t1639}} + result922 := _t1640 + p.recordSpan(int(span_start921)) + return result922 } func (p *Parser) parse_lt() *pb.Primitive { - span_start897 := int64(p.spanStart()) + span_start925 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<") - _t1565 := p.parse_term() - term895 := _t1565 - _t1566 := p.parse_term() - term_3896 := _t1566 + _t1641 := p.parse_term() + term923 := _t1641 + _t1642 := p.parse_term() + term_3924 := _t1642 p.consumeLiteral(")") - _t1567 := &pb.RelTerm{} - _t1567.RelTermType = &pb.RelTerm_Term{Term: term895} - _t1568 := &pb.RelTerm{} - _t1568.RelTermType = &pb.RelTerm_Term{Term: term_3896} - _t1569 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t1567, _t1568}} - result898 := _t1569 - p.recordSpan(int(span_start897)) - return result898 + _t1643 := &pb.RelTerm{} + _t1643.RelTermType = &pb.RelTerm_Term{Term: term923} + _t1644 := &pb.RelTerm{} + _t1644.RelTermType = &pb.RelTerm_Term{Term: term_3924} + _t1645 := &pb.Primitive{Name: "rel_primitive_lt_monotype", Terms: []*pb.RelTerm{_t1643, _t1644}} + result926 := _t1645 + p.recordSpan(int(span_start925)) + return result926 } func (p *Parser) parse_lt_eq() *pb.Primitive { - span_start901 := int64(p.spanStart()) + span_start929 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<=") - _t1570 := p.parse_term() - term899 := _t1570 - _t1571 := p.parse_term() - term_3900 := _t1571 + _t1646 := p.parse_term() + term927 := _t1646 + _t1647 := p.parse_term() + term_3928 := _t1647 p.consumeLiteral(")") - _t1572 := &pb.RelTerm{} - _t1572.RelTermType = &pb.RelTerm_Term{Term: term899} - _t1573 := &pb.RelTerm{} - _t1573.RelTermType = &pb.RelTerm_Term{Term: term_3900} - _t1574 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t1572, _t1573}} - result902 := _t1574 - p.recordSpan(int(span_start901)) - return result902 + _t1648 := &pb.RelTerm{} + _t1648.RelTermType = &pb.RelTerm_Term{Term: term927} + _t1649 := &pb.RelTerm{} + _t1649.RelTermType = &pb.RelTerm_Term{Term: term_3928} + _t1650 := &pb.Primitive{Name: "rel_primitive_lt_eq_monotype", Terms: []*pb.RelTerm{_t1648, _t1649}} + result930 := _t1650 + p.recordSpan(int(span_start929)) + return result930 } func (p *Parser) parse_gt() *pb.Primitive { - span_start905 := int64(p.spanStart()) + span_start933 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">") - _t1575 := p.parse_term() - term903 := _t1575 - _t1576 := p.parse_term() - term_3904 := _t1576 + _t1651 := p.parse_term() + term931 := _t1651 + _t1652 := p.parse_term() + term_3932 := _t1652 p.consumeLiteral(")") - _t1577 := &pb.RelTerm{} - _t1577.RelTermType = &pb.RelTerm_Term{Term: term903} - _t1578 := &pb.RelTerm{} - _t1578.RelTermType = &pb.RelTerm_Term{Term: term_3904} - _t1579 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t1577, _t1578}} - result906 := _t1579 - p.recordSpan(int(span_start905)) - return result906 + _t1653 := &pb.RelTerm{} + _t1653.RelTermType = &pb.RelTerm_Term{Term: term931} + _t1654 := &pb.RelTerm{} + _t1654.RelTermType = &pb.RelTerm_Term{Term: term_3932} + _t1655 := &pb.Primitive{Name: "rel_primitive_gt_monotype", Terms: []*pb.RelTerm{_t1653, _t1654}} + result934 := _t1655 + p.recordSpan(int(span_start933)) + return result934 } func (p *Parser) parse_gt_eq() *pb.Primitive { - span_start909 := int64(p.spanStart()) + span_start937 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">=") - _t1580 := p.parse_term() - term907 := _t1580 - _t1581 := p.parse_term() - term_3908 := _t1581 + _t1656 := p.parse_term() + term935 := _t1656 + _t1657 := p.parse_term() + term_3936 := _t1657 p.consumeLiteral(")") - _t1582 := &pb.RelTerm{} - _t1582.RelTermType = &pb.RelTerm_Term{Term: term907} - _t1583 := &pb.RelTerm{} - _t1583.RelTermType = &pb.RelTerm_Term{Term: term_3908} - _t1584 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t1582, _t1583}} - result910 := _t1584 - p.recordSpan(int(span_start909)) - return result910 + _t1658 := &pb.RelTerm{} + _t1658.RelTermType = &pb.RelTerm_Term{Term: term935} + _t1659 := &pb.RelTerm{} + _t1659.RelTermType = &pb.RelTerm_Term{Term: term_3936} + _t1660 := &pb.Primitive{Name: "rel_primitive_gt_eq_monotype", Terms: []*pb.RelTerm{_t1658, _t1659}} + result938 := _t1660 + p.recordSpan(int(span_start937)) + return result938 } func (p *Parser) parse_add() *pb.Primitive { - span_start914 := int64(p.spanStart()) + span_start942 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("+") - _t1585 := p.parse_term() - term911 := _t1585 - _t1586 := p.parse_term() - term_3912 := _t1586 - _t1587 := p.parse_term() - term_4913 := _t1587 + _t1661 := p.parse_term() + term939 := _t1661 + _t1662 := p.parse_term() + term_3940 := _t1662 + _t1663 := p.parse_term() + term_4941 := _t1663 p.consumeLiteral(")") - _t1588 := &pb.RelTerm{} - _t1588.RelTermType = &pb.RelTerm_Term{Term: term911} - _t1589 := &pb.RelTerm{} - _t1589.RelTermType = &pb.RelTerm_Term{Term: term_3912} - _t1590 := &pb.RelTerm{} - _t1590.RelTermType = &pb.RelTerm_Term{Term: term_4913} - _t1591 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t1588, _t1589, _t1590}} - result915 := _t1591 - p.recordSpan(int(span_start914)) - return result915 + _t1664 := &pb.RelTerm{} + _t1664.RelTermType = &pb.RelTerm_Term{Term: term939} + _t1665 := &pb.RelTerm{} + _t1665.RelTermType = &pb.RelTerm_Term{Term: term_3940} + _t1666 := &pb.RelTerm{} + _t1666.RelTermType = &pb.RelTerm_Term{Term: term_4941} + _t1667 := &pb.Primitive{Name: "rel_primitive_add_monotype", Terms: []*pb.RelTerm{_t1664, _t1665, _t1666}} + result943 := _t1667 + p.recordSpan(int(span_start942)) + return result943 } func (p *Parser) parse_minus() *pb.Primitive { - span_start919 := int64(p.spanStart()) + span_start947 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("-") - _t1592 := p.parse_term() - term916 := _t1592 - _t1593 := p.parse_term() - term_3917 := _t1593 - _t1594 := p.parse_term() - term_4918 := _t1594 + _t1668 := p.parse_term() + term944 := _t1668 + _t1669 := p.parse_term() + term_3945 := _t1669 + _t1670 := p.parse_term() + term_4946 := _t1670 p.consumeLiteral(")") - _t1595 := &pb.RelTerm{} - _t1595.RelTermType = &pb.RelTerm_Term{Term: term916} - _t1596 := &pb.RelTerm{} - _t1596.RelTermType = &pb.RelTerm_Term{Term: term_3917} - _t1597 := &pb.RelTerm{} - _t1597.RelTermType = &pb.RelTerm_Term{Term: term_4918} - _t1598 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t1595, _t1596, _t1597}} - result920 := _t1598 - p.recordSpan(int(span_start919)) - return result920 + _t1671 := &pb.RelTerm{} + _t1671.RelTermType = &pb.RelTerm_Term{Term: term944} + _t1672 := &pb.RelTerm{} + _t1672.RelTermType = &pb.RelTerm_Term{Term: term_3945} + _t1673 := &pb.RelTerm{} + _t1673.RelTermType = &pb.RelTerm_Term{Term: term_4946} + _t1674 := &pb.Primitive{Name: "rel_primitive_subtract_monotype", Terms: []*pb.RelTerm{_t1671, _t1672, _t1673}} + result948 := _t1674 + p.recordSpan(int(span_start947)) + return result948 } func (p *Parser) parse_multiply() *pb.Primitive { - span_start924 := int64(p.spanStart()) + span_start952 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("*") - _t1599 := p.parse_term() - term921 := _t1599 - _t1600 := p.parse_term() - term_3922 := _t1600 - _t1601 := p.parse_term() - term_4923 := _t1601 + _t1675 := p.parse_term() + term949 := _t1675 + _t1676 := p.parse_term() + term_3950 := _t1676 + _t1677 := p.parse_term() + term_4951 := _t1677 p.consumeLiteral(")") - _t1602 := &pb.RelTerm{} - _t1602.RelTermType = &pb.RelTerm_Term{Term: term921} - _t1603 := &pb.RelTerm{} - _t1603.RelTermType = &pb.RelTerm_Term{Term: term_3922} - _t1604 := &pb.RelTerm{} - _t1604.RelTermType = &pb.RelTerm_Term{Term: term_4923} - _t1605 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t1602, _t1603, _t1604}} - result925 := _t1605 - p.recordSpan(int(span_start924)) - return result925 + _t1678 := &pb.RelTerm{} + _t1678.RelTermType = &pb.RelTerm_Term{Term: term949} + _t1679 := &pb.RelTerm{} + _t1679.RelTermType = &pb.RelTerm_Term{Term: term_3950} + _t1680 := &pb.RelTerm{} + _t1680.RelTermType = &pb.RelTerm_Term{Term: term_4951} + _t1681 := &pb.Primitive{Name: "rel_primitive_multiply_monotype", Terms: []*pb.RelTerm{_t1678, _t1679, _t1680}} + result953 := _t1681 + p.recordSpan(int(span_start952)) + return result953 } func (p *Parser) parse_divide() *pb.Primitive { - span_start929 := int64(p.spanStart()) + span_start957 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("/") - _t1606 := p.parse_term() - term926 := _t1606 - _t1607 := p.parse_term() - term_3927 := _t1607 - _t1608 := p.parse_term() - term_4928 := _t1608 + _t1682 := p.parse_term() + term954 := _t1682 + _t1683 := p.parse_term() + term_3955 := _t1683 + _t1684 := p.parse_term() + term_4956 := _t1684 p.consumeLiteral(")") - _t1609 := &pb.RelTerm{} - _t1609.RelTermType = &pb.RelTerm_Term{Term: term926} - _t1610 := &pb.RelTerm{} - _t1610.RelTermType = &pb.RelTerm_Term{Term: term_3927} - _t1611 := &pb.RelTerm{} - _t1611.RelTermType = &pb.RelTerm_Term{Term: term_4928} - _t1612 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t1609, _t1610, _t1611}} - result930 := _t1612 - p.recordSpan(int(span_start929)) - return result930 + _t1685 := &pb.RelTerm{} + _t1685.RelTermType = &pb.RelTerm_Term{Term: term954} + _t1686 := &pb.RelTerm{} + _t1686.RelTermType = &pb.RelTerm_Term{Term: term_3955} + _t1687 := &pb.RelTerm{} + _t1687.RelTermType = &pb.RelTerm_Term{Term: term_4956} + _t1688 := &pb.Primitive{Name: "rel_primitive_divide_monotype", Terms: []*pb.RelTerm{_t1685, _t1686, _t1687}} + result958 := _t1688 + p.recordSpan(int(span_start957)) + return result958 } func (p *Parser) parse_rel_term() *pb.RelTerm { - span_start934 := int64(p.spanStart()) - var _t1613 int64 + span_start962 := int64(p.spanStart()) + var _t1689 int64 if p.matchLookaheadLiteral("true", 0) { - _t1613 = 1 + _t1689 = 1 } else { - var _t1614 int64 + var _t1690 int64 if p.matchLookaheadLiteral("missing", 0) { - _t1614 = 1 + _t1690 = 1 } else { - var _t1615 int64 + var _t1691 int64 if p.matchLookaheadLiteral("false", 0) { - _t1615 = 1 + _t1691 = 1 } else { - var _t1616 int64 + var _t1692 int64 if p.matchLookaheadLiteral("(", 0) { - _t1616 = 1 + _t1692 = 1 } else { - var _t1617 int64 + var _t1693 int64 if p.matchLookaheadLiteral("#", 0) { - _t1617 = 0 + _t1693 = 0 } else { - var _t1618 int64 + var _t1694 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1618 = 1 + _t1694 = 1 } else { - var _t1619 int64 + var _t1695 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t1619 = 1 + _t1695 = 1 } else { - var _t1620 int64 + var _t1696 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t1620 = 1 + _t1696 = 1 } else { - var _t1621 int64 + var _t1697 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t1621 = 1 + _t1697 = 1 } else { - var _t1622 int64 + var _t1698 int64 if p.matchLookaheadTerminal("INT", 0) { - _t1622 = 1 + _t1698 = 1 } else { - var _t1623 int64 + var _t1699 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t1623 = 1 + _t1699 = 1 } else { - var _t1624 int64 + var _t1700 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t1624 = 1 + _t1700 = 1 } else { - _t1624 = -1 + _t1700 = -1 } - _t1623 = _t1624 + _t1699 = _t1700 } - _t1622 = _t1623 + _t1698 = _t1699 } - _t1621 = _t1622 + _t1697 = _t1698 } - _t1620 = _t1621 + _t1696 = _t1697 } - _t1619 = _t1620 + _t1695 = _t1696 } - _t1618 = _t1619 + _t1694 = _t1695 } - _t1617 = _t1618 + _t1693 = _t1694 } - _t1616 = _t1617 + _t1692 = _t1693 } - _t1615 = _t1616 + _t1691 = _t1692 } - _t1614 = _t1615 + _t1690 = _t1691 } - _t1613 = _t1614 - } - prediction931 := _t1613 - var _t1625 *pb.RelTerm - if prediction931 == 1 { - _t1626 := p.parse_term() - term933 := _t1626 - _t1627 := &pb.RelTerm{} - _t1627.RelTermType = &pb.RelTerm_Term{Term: term933} - _t1625 = _t1627 + _t1689 = _t1690 + } + prediction959 := _t1689 + var _t1701 *pb.RelTerm + if prediction959 == 1 { + p.pushPath(int(2)) + _t1702 := p.parse_term() + term961 := _t1702 + p.popPath() + _t1703 := &pb.RelTerm{} + _t1703.RelTermType = &pb.RelTerm_Term{Term: term961} + _t1701 = _t1703 } else { - var _t1628 *pb.RelTerm - if prediction931 == 0 { - _t1629 := p.parse_specialized_value() - specialized_value932 := _t1629 - _t1630 := &pb.RelTerm{} - _t1630.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value932} - _t1628 = _t1630 + var _t1704 *pb.RelTerm + if prediction959 == 0 { + p.pushPath(int(1)) + _t1705 := p.parse_specialized_value() + specialized_value960 := _t1705 + p.popPath() + _t1706 := &pb.RelTerm{} + _t1706.RelTermType = &pb.RelTerm_SpecializedValue{SpecializedValue: specialized_value960} + _t1704 = _t1706 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in rel_term", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1625 = _t1628 + _t1701 = _t1704 } - result935 := _t1625 - p.recordSpan(int(span_start934)) - return result935 + result963 := _t1701 + p.recordSpan(int(span_start962)) + return result963 } func (p *Parser) parse_specialized_value() *pb.Value { - span_start937 := int64(p.spanStart()) + span_start965 := int64(p.spanStart()) p.consumeLiteral("#") - _t1631 := p.parse_value() - value936 := _t1631 - result938 := value936 - p.recordSpan(int(span_start937)) - return result938 + _t1707 := p.parse_value() + value964 := _t1707 + result966 := value964 + p.recordSpan(int(span_start965)) + return result966 } func (p *Parser) parse_rel_atom() *pb.RelAtom { - span_start948 := int64(p.spanStart()) + span_start976 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("relatom") p.pushPath(int(3)) - _t1632 := p.parse_name() - name939 := _t1632 + _t1708 := p.parse_name() + name967 := _t1708 p.popPath() p.pushPath(int(2)) - xs944 := []*pb.RelTerm{} - cond945 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - idx946 := 0 - for cond945 { - p.pushPath(int(idx946)) - _t1633 := p.parse_rel_term() - item947 := _t1633 + xs972 := []*pb.RelTerm{} + cond973 := (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx974 := 0 + for cond973 { + p.pushPath(int(idx974)) + _t1709 := p.parse_rel_term() + item975 := _t1709 p.popPath() - xs944 = append(xs944, item947) - idx946 = (idx946 + 1) - cond945 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + xs972 = append(xs972, item975) + idx974 = (idx974 + 1) + cond973 = (((((((((((p.matchLookaheadLiteral("#", 0) || p.matchLookaheadLiteral("(", 0)) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("SYMBOL", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - rel_terms943 := xs944 + rel_terms971 := xs972 p.popPath() p.consumeLiteral(")") - _t1634 := &pb.RelAtom{Name: name939, Terms: rel_terms943} - result949 := _t1634 - p.recordSpan(int(span_start948)) - return result949 + _t1710 := &pb.RelAtom{Name: name967, Terms: rel_terms971} + result977 := _t1710 + p.recordSpan(int(span_start976)) + return result977 } func (p *Parser) parse_cast() *pb.Cast { - span_start952 := int64(p.spanStart()) + span_start980 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("cast") p.pushPath(int(2)) - _t1635 := p.parse_term() - term950 := _t1635 + _t1711 := p.parse_term() + term978 := _t1711 p.popPath() p.pushPath(int(3)) - _t1636 := p.parse_term() - term_3951 := _t1636 + _t1712 := p.parse_term() + term_3979 := _t1712 p.popPath() p.consumeLiteral(")") - _t1637 := &pb.Cast{Input: term950, Result: term_3951} - result953 := _t1637 - p.recordSpan(int(span_start952)) - return result953 + _t1713 := &pb.Cast{Input: term978, Result: term_3979} + result981 := _t1713 + p.recordSpan(int(span_start980)) + return result981 } func (p *Parser) parse_attrs() []*pb.Attribute { - span_start958 := int64(p.spanStart()) + span_start990 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("attrs") - xs954 := []*pb.Attribute{} - cond955 := p.matchLookaheadLiteral("(", 0) - for cond955 { - _t1638 := p.parse_attribute() - item956 := _t1638 - xs954 = append(xs954, item956) - cond955 = p.matchLookaheadLiteral("(", 0) - } - attributes957 := xs954 + xs986 := []*pb.Attribute{} + cond987 := p.matchLookaheadLiteral("(", 0) + idx988 := 0 + for cond987 { + p.pushPath(int(idx988)) + _t1714 := p.parse_attribute() + item989 := _t1714 + p.popPath() + xs986 = append(xs986, item989) + idx988 = (idx988 + 1) + cond987 = p.matchLookaheadLiteral("(", 0) + } + attributes985 := xs986 p.consumeLiteral(")") - result959 := attributes957 - p.recordSpan(int(span_start958)) - return result959 + result991 := attributes985 + p.recordSpan(int(span_start990)) + return result991 } func (p *Parser) parse_attribute() *pb.Attribute { - span_start969 := int64(p.spanStart()) + span_start1001 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("attribute") p.pushPath(int(1)) - _t1639 := p.parse_name() - name960 := _t1639 + _t1715 := p.parse_name() + name992 := _t1715 p.popPath() p.pushPath(int(2)) - xs965 := []*pb.Value{} - cond966 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) - idx967 := 0 - for cond966 { - p.pushPath(int(idx967)) - _t1640 := p.parse_value() - item968 := _t1640 + xs997 := []*pb.Value{} + cond998 := (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + idx999 := 0 + for cond998 { + p.pushPath(int(idx999)) + _t1716 := p.parse_value() + item1000 := _t1716 p.popPath() - xs965 = append(xs965, item968) - idx967 = (idx967 + 1) - cond966 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) + xs997 = append(xs997, item1000) + idx999 = (idx999 + 1) + cond998 = (((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("false", 0)) || p.matchLookaheadLiteral("missing", 0)) || p.matchLookaheadLiteral("true", 0)) || p.matchLookaheadTerminal("DECIMAL", 0)) || p.matchLookaheadTerminal("FLOAT", 0)) || p.matchLookaheadTerminal("INT", 0)) || p.matchLookaheadTerminal("INT128", 0)) || p.matchLookaheadTerminal("STRING", 0)) || p.matchLookaheadTerminal("UINT128", 0)) } - values964 := xs965 + values996 := xs997 p.popPath() p.consumeLiteral(")") - _t1641 := &pb.Attribute{Name: name960, Args: values964} - result970 := _t1641 - p.recordSpan(int(span_start969)) - return result970 + _t1717 := &pb.Attribute{Name: name992, Args: values996} + result1002 := _t1717 + p.recordSpan(int(span_start1001)) + return result1002 } func (p *Parser) parse_algorithm() *pb.Algorithm { - span_start980 := int64(p.spanStart()) + span_start1012 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("algorithm") p.pushPath(int(1)) - xs975 := []*pb.RelationId{} - cond976 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - idx977 := 0 - for cond976 { - p.pushPath(int(idx977)) - _t1642 := p.parse_relation_id() - item978 := _t1642 + xs1007 := []*pb.RelationId{} + cond1008 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx1009 := 0 + for cond1008 { + p.pushPath(int(idx1009)) + _t1718 := p.parse_relation_id() + item1010 := _t1718 p.popPath() - xs975 = append(xs975, item978) - idx977 = (idx977 + 1) - cond976 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + xs1007 = append(xs1007, item1010) + idx1009 = (idx1009 + 1) + cond1008 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) } - relation_ids974 := xs975 + relation_ids1006 := xs1007 p.popPath() p.pushPath(int(2)) - _t1643 := p.parse_script() - script979 := _t1643 + _t1719 := p.parse_script() + script1011 := _t1719 p.popPath() p.consumeLiteral(")") - _t1644 := &pb.Algorithm{Global: relation_ids974, Body: script979} - result981 := _t1644 - p.recordSpan(int(span_start980)) - return result981 + _t1720 := &pb.Algorithm{Global: relation_ids1006, Body: script1011} + result1013 := _t1720 + p.recordSpan(int(span_start1012)) + return result1013 } func (p *Parser) parse_script() *pb.Script { - span_start990 := int64(p.spanStart()) + span_start1022 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("script") p.pushPath(int(1)) - xs986 := []*pb.Construct{} - cond987 := p.matchLookaheadLiteral("(", 0) - idx988 := 0 - for cond987 { - p.pushPath(int(idx988)) - _t1645 := p.parse_construct() - item989 := _t1645 + xs1018 := []*pb.Construct{} + cond1019 := p.matchLookaheadLiteral("(", 0) + idx1020 := 0 + for cond1019 { + p.pushPath(int(idx1020)) + _t1721 := p.parse_construct() + item1021 := _t1721 p.popPath() - xs986 = append(xs986, item989) - idx988 = (idx988 + 1) - cond987 = p.matchLookaheadLiteral("(", 0) + xs1018 = append(xs1018, item1021) + idx1020 = (idx1020 + 1) + cond1019 = p.matchLookaheadLiteral("(", 0) } - constructs985 := xs986 + constructs1017 := xs1018 p.popPath() p.consumeLiteral(")") - _t1646 := &pb.Script{Constructs: constructs985} - result991 := _t1646 - p.recordSpan(int(span_start990)) - return result991 + _t1722 := &pb.Script{Constructs: constructs1017} + result1023 := _t1722 + p.recordSpan(int(span_start1022)) + return result1023 } func (p *Parser) parse_construct() *pb.Construct { - span_start995 := int64(p.spanStart()) - var _t1647 int64 + span_start1027 := int64(p.spanStart()) + var _t1723 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1648 int64 + var _t1724 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1648 = 1 + _t1724 = 1 } else { - var _t1649 int64 + var _t1725 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1649 = 1 + _t1725 = 1 } else { - var _t1650 int64 + var _t1726 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1650 = 1 + _t1726 = 1 } else { - var _t1651 int64 + var _t1727 int64 if p.matchLookaheadLiteral("loop", 1) { - _t1651 = 0 + _t1727 = 0 } else { - var _t1652 int64 + var _t1728 int64 if p.matchLookaheadLiteral("break", 1) { - _t1652 = 1 + _t1728 = 1 } else { - var _t1653 int64 + var _t1729 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1653 = 1 + _t1729 = 1 } else { - _t1653 = -1 + _t1729 = -1 } - _t1652 = _t1653 + _t1728 = _t1729 } - _t1651 = _t1652 + _t1727 = _t1728 } - _t1650 = _t1651 + _t1726 = _t1727 } - _t1649 = _t1650 + _t1725 = _t1726 } - _t1648 = _t1649 + _t1724 = _t1725 } - _t1647 = _t1648 + _t1723 = _t1724 } else { - _t1647 = -1 - } - prediction992 := _t1647 - var _t1654 *pb.Construct - if prediction992 == 1 { - _t1655 := p.parse_instruction() - instruction994 := _t1655 - _t1656 := &pb.Construct{} - _t1656.ConstructType = &pb.Construct_Instruction{Instruction: instruction994} - _t1654 = _t1656 + _t1723 = -1 + } + prediction1024 := _t1723 + var _t1730 *pb.Construct + if prediction1024 == 1 { + p.pushPath(int(2)) + _t1731 := p.parse_instruction() + instruction1026 := _t1731 + p.popPath() + _t1732 := &pb.Construct{} + _t1732.ConstructType = &pb.Construct_Instruction{Instruction: instruction1026} + _t1730 = _t1732 } else { - var _t1657 *pb.Construct - if prediction992 == 0 { - _t1658 := p.parse_loop() - loop993 := _t1658 - _t1659 := &pb.Construct{} - _t1659.ConstructType = &pb.Construct_Loop{Loop: loop993} - _t1657 = _t1659 + var _t1733 *pb.Construct + if prediction1024 == 0 { + p.pushPath(int(1)) + _t1734 := p.parse_loop() + loop1025 := _t1734 + p.popPath() + _t1735 := &pb.Construct{} + _t1735.ConstructType = &pb.Construct_Loop{Loop: loop1025} + _t1733 = _t1735 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in construct", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1654 = _t1657 + _t1730 = _t1733 } - result996 := _t1654 - p.recordSpan(int(span_start995)) - return result996 + result1028 := _t1730 + p.recordSpan(int(span_start1027)) + return result1028 } func (p *Parser) parse_loop() *pb.Loop { - span_start999 := int64(p.spanStart()) + span_start1031 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("loop") p.pushPath(int(1)) - _t1660 := p.parse_init() - init997 := _t1660 + _t1736 := p.parse_init() + init1029 := _t1736 p.popPath() p.pushPath(int(2)) - _t1661 := p.parse_script() - script998 := _t1661 + _t1737 := p.parse_script() + script1030 := _t1737 p.popPath() p.consumeLiteral(")") - _t1662 := &pb.Loop{Init: init997, Body: script998} - result1000 := _t1662 - p.recordSpan(int(span_start999)) - return result1000 + _t1738 := &pb.Loop{Init: init1029, Body: script1030} + result1032 := _t1738 + p.recordSpan(int(span_start1031)) + return result1032 } func (p *Parser) parse_init() []*pb.Instruction { - span_start1005 := int64(p.spanStart()) + span_start1041 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("init") - xs1001 := []*pb.Instruction{} - cond1002 := p.matchLookaheadLiteral("(", 0) - for cond1002 { - _t1663 := p.parse_instruction() - item1003 := _t1663 - xs1001 = append(xs1001, item1003) - cond1002 = p.matchLookaheadLiteral("(", 0) - } - instructions1004 := xs1001 + xs1037 := []*pb.Instruction{} + cond1038 := p.matchLookaheadLiteral("(", 0) + idx1039 := 0 + for cond1038 { + p.pushPath(int(idx1039)) + _t1739 := p.parse_instruction() + item1040 := _t1739 + p.popPath() + xs1037 = append(xs1037, item1040) + idx1039 = (idx1039 + 1) + cond1038 = p.matchLookaheadLiteral("(", 0) + } + instructions1036 := xs1037 p.consumeLiteral(")") - result1006 := instructions1004 - p.recordSpan(int(span_start1005)) - return result1006 + result1042 := instructions1036 + p.recordSpan(int(span_start1041)) + return result1042 } func (p *Parser) parse_instruction() *pb.Instruction { - span_start1013 := int64(p.spanStart()) - var _t1664 int64 + span_start1049 := int64(p.spanStart()) + var _t1740 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1665 int64 + var _t1741 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1665 = 1 + _t1741 = 1 } else { - var _t1666 int64 + var _t1742 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1666 = 4 + _t1742 = 4 } else { - var _t1667 int64 + var _t1743 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1667 = 3 + _t1743 = 3 } else { - var _t1668 int64 + var _t1744 int64 if p.matchLookaheadLiteral("break", 1) { - _t1668 = 2 + _t1744 = 2 } else { - var _t1669 int64 + var _t1745 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1669 = 0 + _t1745 = 0 } else { - _t1669 = -1 + _t1745 = -1 } - _t1668 = _t1669 + _t1744 = _t1745 } - _t1667 = _t1668 + _t1743 = _t1744 } - _t1666 = _t1667 + _t1742 = _t1743 } - _t1665 = _t1666 + _t1741 = _t1742 } - _t1664 = _t1665 + _t1740 = _t1741 } else { - _t1664 = -1 - } - prediction1007 := _t1664 - var _t1670 *pb.Instruction - if prediction1007 == 4 { - _t1671 := p.parse_monus_def() - monus_def1012 := _t1671 - _t1672 := &pb.Instruction{} - _t1672.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def1012} - _t1670 = _t1672 + _t1740 = -1 + } + prediction1043 := _t1740 + var _t1746 *pb.Instruction + if prediction1043 == 4 { + p.pushPath(int(6)) + _t1747 := p.parse_monus_def() + monus_def1048 := _t1747 + p.popPath() + _t1748 := &pb.Instruction{} + _t1748.InstrType = &pb.Instruction_MonusDef{MonusDef: monus_def1048} + _t1746 = _t1748 } else { - var _t1673 *pb.Instruction - if prediction1007 == 3 { - _t1674 := p.parse_monoid_def() - monoid_def1011 := _t1674 - _t1675 := &pb.Instruction{} - _t1675.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def1011} - _t1673 = _t1675 + var _t1749 *pb.Instruction + if prediction1043 == 3 { + p.pushPath(int(5)) + _t1750 := p.parse_monoid_def() + monoid_def1047 := _t1750 + p.popPath() + _t1751 := &pb.Instruction{} + _t1751.InstrType = &pb.Instruction_MonoidDef{MonoidDef: monoid_def1047} + _t1749 = _t1751 } else { - var _t1676 *pb.Instruction - if prediction1007 == 2 { - _t1677 := p.parse_break() - break1010 := _t1677 - _t1678 := &pb.Instruction{} - _t1678.InstrType = &pb.Instruction_Break{Break: break1010} - _t1676 = _t1678 + var _t1752 *pb.Instruction + if prediction1043 == 2 { + p.pushPath(int(3)) + _t1753 := p.parse_break() + break1046 := _t1753 + p.popPath() + _t1754 := &pb.Instruction{} + _t1754.InstrType = &pb.Instruction_Break{Break: break1046} + _t1752 = _t1754 } else { - var _t1679 *pb.Instruction - if prediction1007 == 1 { - _t1680 := p.parse_upsert() - upsert1009 := _t1680 - _t1681 := &pb.Instruction{} - _t1681.InstrType = &pb.Instruction_Upsert{Upsert: upsert1009} - _t1679 = _t1681 + var _t1755 *pb.Instruction + if prediction1043 == 1 { + p.pushPath(int(2)) + _t1756 := p.parse_upsert() + upsert1045 := _t1756 + p.popPath() + _t1757 := &pb.Instruction{} + _t1757.InstrType = &pb.Instruction_Upsert{Upsert: upsert1045} + _t1755 = _t1757 } else { - var _t1682 *pb.Instruction - if prediction1007 == 0 { - _t1683 := p.parse_assign() - assign1008 := _t1683 - _t1684 := &pb.Instruction{} - _t1684.InstrType = &pb.Instruction_Assign{Assign: assign1008} - _t1682 = _t1684 + var _t1758 *pb.Instruction + if prediction1043 == 0 { + p.pushPath(int(1)) + _t1759 := p.parse_assign() + assign1044 := _t1759 + p.popPath() + _t1760 := &pb.Instruction{} + _t1760.InstrType = &pb.Instruction_Assign{Assign: assign1044} + _t1758 = _t1760 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in instruction", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1679 = _t1682 + _t1755 = _t1758 } - _t1676 = _t1679 + _t1752 = _t1755 } - _t1673 = _t1676 + _t1749 = _t1752 } - _t1670 = _t1673 + _t1746 = _t1749 } - result1014 := _t1670 - p.recordSpan(int(span_start1013)) - return result1014 + result1050 := _t1746 + p.recordSpan(int(span_start1049)) + return result1050 } func (p *Parser) parse_assign() *pb.Assign { - span_start1018 := int64(p.spanStart()) + span_start1054 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("assign") p.pushPath(int(1)) - _t1685 := p.parse_relation_id() - relation_id1015 := _t1685 + _t1761 := p.parse_relation_id() + relation_id1051 := _t1761 p.popPath() p.pushPath(int(2)) - _t1686 := p.parse_abstraction() - abstraction1016 := _t1686 + _t1762 := p.parse_abstraction() + abstraction1052 := _t1762 p.popPath() p.pushPath(int(3)) - var _t1687 []*pb.Attribute + var _t1763 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1688 := p.parse_attrs() - _t1687 = _t1688 + _t1764 := p.parse_attrs() + _t1763 = _t1764 } - attrs1017 := _t1687 + attrs1053 := _t1763 p.popPath() p.consumeLiteral(")") - _t1689 := attrs1017 - if attrs1017 == nil { - _t1689 = []*pb.Attribute{} + _t1765 := attrs1053 + if attrs1053 == nil { + _t1765 = []*pb.Attribute{} } - _t1690 := &pb.Assign{Name: relation_id1015, Body: abstraction1016, Attrs: _t1689} - result1019 := _t1690 - p.recordSpan(int(span_start1018)) - return result1019 + _t1766 := &pb.Assign{Name: relation_id1051, Body: abstraction1052, Attrs: _t1765} + result1055 := _t1766 + p.recordSpan(int(span_start1054)) + return result1055 } func (p *Parser) parse_upsert() *pb.Upsert { - span_start1023 := int64(p.spanStart()) + span_start1059 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("upsert") p.pushPath(int(1)) - _t1691 := p.parse_relation_id() - relation_id1020 := _t1691 + _t1767 := p.parse_relation_id() + relation_id1056 := _t1767 p.popPath() - _t1692 := p.parse_abstraction_with_arity() - abstraction_with_arity1021 := _t1692 + _t1768 := p.parse_abstraction_with_arity() + abstraction_with_arity1057 := _t1768 p.pushPath(int(3)) - var _t1693 []*pb.Attribute + var _t1769 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1694 := p.parse_attrs() - _t1693 = _t1694 + _t1770 := p.parse_attrs() + _t1769 = _t1770 } - attrs1022 := _t1693 + attrs1058 := _t1769 p.popPath() p.consumeLiteral(")") - _t1695 := attrs1022 - if attrs1022 == nil { - _t1695 = []*pb.Attribute{} + _t1771 := attrs1058 + if attrs1058 == nil { + _t1771 = []*pb.Attribute{} } - _t1696 := &pb.Upsert{Name: relation_id1020, Body: abstraction_with_arity1021[0].(*pb.Abstraction), Attrs: _t1695, ValueArity: abstraction_with_arity1021[1].(int64)} - result1024 := _t1696 - p.recordSpan(int(span_start1023)) - return result1024 + _t1772 := &pb.Upsert{Name: relation_id1056, Body: abstraction_with_arity1057[0].(*pb.Abstraction), Attrs: _t1771, ValueArity: abstraction_with_arity1057[1].(int64)} + result1060 := _t1772 + p.recordSpan(int(span_start1059)) + return result1060 } func (p *Parser) parse_abstraction_with_arity() []interface{} { - span_start1027 := int64(p.spanStart()) + span_start1063 := int64(p.spanStart()) p.consumeLiteral("(") - _t1697 := p.parse_bindings() - bindings1025 := _t1697 - _t1698 := p.parse_formula() - formula1026 := _t1698 + _t1773 := p.parse_bindings() + bindings1061 := _t1773 + _t1774 := p.parse_formula() + formula1062 := _t1774 p.consumeLiteral(")") - _t1699 := &pb.Abstraction{Vars: listConcat(bindings1025[0].([]*pb.Binding), bindings1025[1].([]*pb.Binding)), Value: formula1026} - result1028 := []interface{}{_t1699, int64(len(bindings1025[1].([]*pb.Binding)))} - p.recordSpan(int(span_start1027)) - return result1028 + _t1775 := &pb.Abstraction{Vars: listConcat(bindings1061[0].([]*pb.Binding), bindings1061[1].([]*pb.Binding)), Value: formula1062} + result1064 := []interface{}{_t1775, int64(len(bindings1061[1].([]*pb.Binding)))} + p.recordSpan(int(span_start1063)) + return result1064 } func (p *Parser) parse_break() *pb.Break { - span_start1032 := int64(p.spanStart()) + span_start1068 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("break") p.pushPath(int(1)) - _t1700 := p.parse_relation_id() - relation_id1029 := _t1700 + _t1776 := p.parse_relation_id() + relation_id1065 := _t1776 p.popPath() p.pushPath(int(2)) - _t1701 := p.parse_abstraction() - abstraction1030 := _t1701 + _t1777 := p.parse_abstraction() + abstraction1066 := _t1777 p.popPath() p.pushPath(int(3)) - var _t1702 []*pb.Attribute + var _t1778 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1703 := p.parse_attrs() - _t1702 = _t1703 + _t1779 := p.parse_attrs() + _t1778 = _t1779 } - attrs1031 := _t1702 + attrs1067 := _t1778 p.popPath() p.consumeLiteral(")") - _t1704 := attrs1031 - if attrs1031 == nil { - _t1704 = []*pb.Attribute{} + _t1780 := attrs1067 + if attrs1067 == nil { + _t1780 = []*pb.Attribute{} } - _t1705 := &pb.Break{Name: relation_id1029, Body: abstraction1030, Attrs: _t1704} - result1033 := _t1705 - p.recordSpan(int(span_start1032)) - return result1033 + _t1781 := &pb.Break{Name: relation_id1065, Body: abstraction1066, Attrs: _t1780} + result1069 := _t1781 + p.recordSpan(int(span_start1068)) + return result1069 } func (p *Parser) parse_monoid_def() *pb.MonoidDef { - span_start1038 := int64(p.spanStart()) + span_start1074 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("monoid") p.pushPath(int(1)) - _t1706 := p.parse_monoid() - monoid1034 := _t1706 + _t1782 := p.parse_monoid() + monoid1070 := _t1782 p.popPath() p.pushPath(int(2)) - _t1707 := p.parse_relation_id() - relation_id1035 := _t1707 + _t1783 := p.parse_relation_id() + relation_id1071 := _t1783 p.popPath() - _t1708 := p.parse_abstraction_with_arity() - abstraction_with_arity1036 := _t1708 + _t1784 := p.parse_abstraction_with_arity() + abstraction_with_arity1072 := _t1784 p.pushPath(int(4)) - var _t1709 []*pb.Attribute + var _t1785 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1710 := p.parse_attrs() - _t1709 = _t1710 + _t1786 := p.parse_attrs() + _t1785 = _t1786 } - attrs1037 := _t1709 + attrs1073 := _t1785 p.popPath() p.consumeLiteral(")") - _t1711 := attrs1037 - if attrs1037 == nil { - _t1711 = []*pb.Attribute{} + _t1787 := attrs1073 + if attrs1073 == nil { + _t1787 = []*pb.Attribute{} } - _t1712 := &pb.MonoidDef{Monoid: monoid1034, Name: relation_id1035, Body: abstraction_with_arity1036[0].(*pb.Abstraction), Attrs: _t1711, ValueArity: abstraction_with_arity1036[1].(int64)} - result1039 := _t1712 - p.recordSpan(int(span_start1038)) - return result1039 + _t1788 := &pb.MonoidDef{Monoid: monoid1070, Name: relation_id1071, Body: abstraction_with_arity1072[0].(*pb.Abstraction), Attrs: _t1787, ValueArity: abstraction_with_arity1072[1].(int64)} + result1075 := _t1788 + p.recordSpan(int(span_start1074)) + return result1075 } func (p *Parser) parse_monoid() *pb.Monoid { - span_start1045 := int64(p.spanStart()) - var _t1713 int64 + span_start1081 := int64(p.spanStart()) + var _t1789 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1714 int64 + var _t1790 int64 if p.matchLookaheadLiteral("sum", 1) { - _t1714 = 3 + _t1790 = 3 } else { - var _t1715 int64 + var _t1791 int64 if p.matchLookaheadLiteral("or", 1) { - _t1715 = 0 + _t1791 = 0 } else { - var _t1716 int64 + var _t1792 int64 if p.matchLookaheadLiteral("min", 1) { - _t1716 = 1 + _t1792 = 1 } else { - var _t1717 int64 + var _t1793 int64 if p.matchLookaheadLiteral("max", 1) { - _t1717 = 2 + _t1793 = 2 } else { - _t1717 = -1 + _t1793 = -1 } - _t1716 = _t1717 + _t1792 = _t1793 } - _t1715 = _t1716 + _t1791 = _t1792 } - _t1714 = _t1715 + _t1790 = _t1791 } - _t1713 = _t1714 + _t1789 = _t1790 } else { - _t1713 = -1 - } - prediction1040 := _t1713 - var _t1718 *pb.Monoid - if prediction1040 == 3 { - _t1719 := p.parse_sum_monoid() - sum_monoid1044 := _t1719 - _t1720 := &pb.Monoid{} - _t1720.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid1044} - _t1718 = _t1720 + _t1789 = -1 + } + prediction1076 := _t1789 + var _t1794 *pb.Monoid + if prediction1076 == 3 { + p.pushPath(int(4)) + _t1795 := p.parse_sum_monoid() + sum_monoid1080 := _t1795 + p.popPath() + _t1796 := &pb.Monoid{} + _t1796.Value = &pb.Monoid_SumMonoid{SumMonoid: sum_monoid1080} + _t1794 = _t1796 } else { - var _t1721 *pb.Monoid - if prediction1040 == 2 { - _t1722 := p.parse_max_monoid() - max_monoid1043 := _t1722 - _t1723 := &pb.Monoid{} - _t1723.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid1043} - _t1721 = _t1723 + var _t1797 *pb.Monoid + if prediction1076 == 2 { + p.pushPath(int(3)) + _t1798 := p.parse_max_monoid() + max_monoid1079 := _t1798 + p.popPath() + _t1799 := &pb.Monoid{} + _t1799.Value = &pb.Monoid_MaxMonoid{MaxMonoid: max_monoid1079} + _t1797 = _t1799 } else { - var _t1724 *pb.Monoid - if prediction1040 == 1 { - _t1725 := p.parse_min_monoid() - min_monoid1042 := _t1725 - _t1726 := &pb.Monoid{} - _t1726.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid1042} - _t1724 = _t1726 + var _t1800 *pb.Monoid + if prediction1076 == 1 { + p.pushPath(int(2)) + _t1801 := p.parse_min_monoid() + min_monoid1078 := _t1801 + p.popPath() + _t1802 := &pb.Monoid{} + _t1802.Value = &pb.Monoid_MinMonoid{MinMonoid: min_monoid1078} + _t1800 = _t1802 } else { - var _t1727 *pb.Monoid - if prediction1040 == 0 { - _t1728 := p.parse_or_monoid() - or_monoid1041 := _t1728 - _t1729 := &pb.Monoid{} - _t1729.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid1041} - _t1727 = _t1729 + var _t1803 *pb.Monoid + if prediction1076 == 0 { + p.pushPath(int(1)) + _t1804 := p.parse_or_monoid() + or_monoid1077 := _t1804 + p.popPath() + _t1805 := &pb.Monoid{} + _t1805.Value = &pb.Monoid_OrMonoid{OrMonoid: or_monoid1077} + _t1803 = _t1805 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in monoid", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1724 = _t1727 + _t1800 = _t1803 } - _t1721 = _t1724 + _t1797 = _t1800 } - _t1718 = _t1721 + _t1794 = _t1797 } - result1046 := _t1718 - p.recordSpan(int(span_start1045)) - return result1046 + result1082 := _t1794 + p.recordSpan(int(span_start1081)) + return result1082 } func (p *Parser) parse_or_monoid() *pb.OrMonoid { - span_start1047 := int64(p.spanStart()) + span_start1083 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("or") p.consumeLiteral(")") - _t1730 := &pb.OrMonoid{} - result1048 := _t1730 - p.recordSpan(int(span_start1047)) - return result1048 + _t1806 := &pb.OrMonoid{} + result1084 := _t1806 + p.recordSpan(int(span_start1083)) + return result1084 } func (p *Parser) parse_min_monoid() *pb.MinMonoid { - span_start1050 := int64(p.spanStart()) + span_start1086 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("min") p.pushPath(int(1)) - _t1731 := p.parse_type() - type1049 := _t1731 + _t1807 := p.parse_type() + type1085 := _t1807 p.popPath() p.consumeLiteral(")") - _t1732 := &pb.MinMonoid{Type: type1049} - result1051 := _t1732 - p.recordSpan(int(span_start1050)) - return result1051 + _t1808 := &pb.MinMonoid{Type: type1085} + result1087 := _t1808 + p.recordSpan(int(span_start1086)) + return result1087 } func (p *Parser) parse_max_monoid() *pb.MaxMonoid { - span_start1053 := int64(p.spanStart()) + span_start1089 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("max") p.pushPath(int(1)) - _t1733 := p.parse_type() - type1052 := _t1733 + _t1809 := p.parse_type() + type1088 := _t1809 p.popPath() p.consumeLiteral(")") - _t1734 := &pb.MaxMonoid{Type: type1052} - result1054 := _t1734 - p.recordSpan(int(span_start1053)) - return result1054 + _t1810 := &pb.MaxMonoid{Type: type1088} + result1090 := _t1810 + p.recordSpan(int(span_start1089)) + return result1090 } func (p *Parser) parse_sum_monoid() *pb.SumMonoid { - span_start1056 := int64(p.spanStart()) + span_start1092 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("sum") p.pushPath(int(1)) - _t1735 := p.parse_type() - type1055 := _t1735 + _t1811 := p.parse_type() + type1091 := _t1811 p.popPath() p.consumeLiteral(")") - _t1736 := &pb.SumMonoid{Type: type1055} - result1057 := _t1736 - p.recordSpan(int(span_start1056)) - return result1057 + _t1812 := &pb.SumMonoid{Type: type1091} + result1093 := _t1812 + p.recordSpan(int(span_start1092)) + return result1093 } func (p *Parser) parse_monus_def() *pb.MonusDef { - span_start1062 := int64(p.spanStart()) + span_start1098 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("monus") p.pushPath(int(1)) - _t1737 := p.parse_monoid() - monoid1058 := _t1737 + _t1813 := p.parse_monoid() + monoid1094 := _t1813 p.popPath() p.pushPath(int(2)) - _t1738 := p.parse_relation_id() - relation_id1059 := _t1738 + _t1814 := p.parse_relation_id() + relation_id1095 := _t1814 p.popPath() - _t1739 := p.parse_abstraction_with_arity() - abstraction_with_arity1060 := _t1739 + _t1815 := p.parse_abstraction_with_arity() + abstraction_with_arity1096 := _t1815 p.pushPath(int(4)) - var _t1740 []*pb.Attribute + var _t1816 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1741 := p.parse_attrs() - _t1740 = _t1741 + _t1817 := p.parse_attrs() + _t1816 = _t1817 } - attrs1061 := _t1740 + attrs1097 := _t1816 p.popPath() p.consumeLiteral(")") - _t1742 := attrs1061 - if attrs1061 == nil { - _t1742 = []*pb.Attribute{} + _t1818 := attrs1097 + if attrs1097 == nil { + _t1818 = []*pb.Attribute{} } - _t1743 := &pb.MonusDef{Monoid: monoid1058, Name: relation_id1059, Body: abstraction_with_arity1060[0].(*pb.Abstraction), Attrs: _t1742, ValueArity: abstraction_with_arity1060[1].(int64)} - result1063 := _t1743 - p.recordSpan(int(span_start1062)) - return result1063 + _t1819 := &pb.MonusDef{Monoid: monoid1094, Name: relation_id1095, Body: abstraction_with_arity1096[0].(*pb.Abstraction), Attrs: _t1818, ValueArity: abstraction_with_arity1096[1].(int64)} + result1099 := _t1819 + p.recordSpan(int(span_start1098)) + return result1099 } func (p *Parser) parse_constraint() *pb.Constraint { - span_start1068 := int64(p.spanStart()) + span_start1104 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("functional_dependency") p.pushPath(int(2)) - _t1744 := p.parse_relation_id() - relation_id1064 := _t1744 + _t1820 := p.parse_relation_id() + relation_id1100 := _t1820 p.popPath() - _t1745 := p.parse_abstraction() - abstraction1065 := _t1745 - _t1746 := p.parse_functional_dependency_keys() - functional_dependency_keys1066 := _t1746 - _t1747 := p.parse_functional_dependency_values() - functional_dependency_values1067 := _t1747 + _t1821 := p.parse_abstraction() + abstraction1101 := _t1821 + _t1822 := p.parse_functional_dependency_keys() + functional_dependency_keys1102 := _t1822 + _t1823 := p.parse_functional_dependency_values() + functional_dependency_values1103 := _t1823 p.consumeLiteral(")") - _t1748 := &pb.FunctionalDependency{Guard: abstraction1065, Keys: functional_dependency_keys1066, Values: functional_dependency_values1067} - _t1749 := &pb.Constraint{Name: relation_id1064} - _t1749.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t1748} - result1069 := _t1749 - p.recordSpan(int(span_start1068)) - return result1069 + _t1824 := &pb.FunctionalDependency{Guard: abstraction1101, Keys: functional_dependency_keys1102, Values: functional_dependency_values1103} + _t1825 := &pb.Constraint{Name: relation_id1100} + _t1825.ConstraintType = &pb.Constraint_FunctionalDependency{FunctionalDependency: _t1824} + result1105 := _t1825 + p.recordSpan(int(span_start1104)) + return result1105 } func (p *Parser) parse_functional_dependency_keys() []*pb.Var { - span_start1074 := int64(p.spanStart()) + span_start1114 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("keys") - xs1070 := []*pb.Var{} - cond1071 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond1071 { - _t1750 := p.parse_var() - item1072 := _t1750 - xs1070 = append(xs1070, item1072) - cond1071 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars1073 := xs1070 + xs1110 := []*pb.Var{} + cond1111 := p.matchLookaheadTerminal("SYMBOL", 0) + idx1112 := 0 + for cond1111 { + p.pushPath(int(idx1112)) + _t1826 := p.parse_var() + item1113 := _t1826 + p.popPath() + xs1110 = append(xs1110, item1113) + idx1112 = (idx1112 + 1) + cond1111 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars1109 := xs1110 p.consumeLiteral(")") - result1075 := vars1073 - p.recordSpan(int(span_start1074)) - return result1075 + result1115 := vars1109 + p.recordSpan(int(span_start1114)) + return result1115 } func (p *Parser) parse_functional_dependency_values() []*pb.Var { - span_start1080 := int64(p.spanStart()) + span_start1124 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("values") - xs1076 := []*pb.Var{} - cond1077 := p.matchLookaheadTerminal("SYMBOL", 0) - for cond1077 { - _t1751 := p.parse_var() - item1078 := _t1751 - xs1076 = append(xs1076, item1078) - cond1077 = p.matchLookaheadTerminal("SYMBOL", 0) - } - vars1079 := xs1076 + xs1120 := []*pb.Var{} + cond1121 := p.matchLookaheadTerminal("SYMBOL", 0) + idx1122 := 0 + for cond1121 { + p.pushPath(int(idx1122)) + _t1827 := p.parse_var() + item1123 := _t1827 + p.popPath() + xs1120 = append(xs1120, item1123) + idx1122 = (idx1122 + 1) + cond1121 = p.matchLookaheadTerminal("SYMBOL", 0) + } + vars1119 := xs1120 p.consumeLiteral(")") - result1081 := vars1079 - p.recordSpan(int(span_start1080)) - return result1081 + result1125 := vars1119 + p.recordSpan(int(span_start1124)) + return result1125 } func (p *Parser) parse_data() *pb.Data { - span_start1086 := int64(p.spanStart()) - var _t1752 int64 + span_start1130 := int64(p.spanStart()) + var _t1828 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1753 int64 + var _t1829 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t1753 = 0 + _t1829 = 0 } else { - var _t1754 int64 + var _t1830 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t1754 = 2 + _t1830 = 2 } else { - var _t1755 int64 + var _t1831 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t1755 = 1 + _t1831 = 1 } else { - _t1755 = -1 + _t1831 = -1 } - _t1754 = _t1755 + _t1830 = _t1831 } - _t1753 = _t1754 + _t1829 = _t1830 } - _t1752 = _t1753 + _t1828 = _t1829 } else { - _t1752 = -1 - } - prediction1082 := _t1752 - var _t1756 *pb.Data - if prediction1082 == 2 { - _t1757 := p.parse_csv_data() - csv_data1085 := _t1757 - _t1758 := &pb.Data{} - _t1758.DataType = &pb.Data_CsvData{CsvData: csv_data1085} - _t1756 = _t1758 + _t1828 = -1 + } + prediction1126 := _t1828 + var _t1832 *pb.Data + if prediction1126 == 2 { + p.pushPath(int(3)) + _t1833 := p.parse_csv_data() + csv_data1129 := _t1833 + p.popPath() + _t1834 := &pb.Data{} + _t1834.DataType = &pb.Data_CsvData{CsvData: csv_data1129} + _t1832 = _t1834 } else { - var _t1759 *pb.Data - if prediction1082 == 1 { - _t1760 := p.parse_betree_relation() - betree_relation1084 := _t1760 - _t1761 := &pb.Data{} - _t1761.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation1084} - _t1759 = _t1761 + var _t1835 *pb.Data + if prediction1126 == 1 { + p.pushPath(int(2)) + _t1836 := p.parse_betree_relation() + betree_relation1128 := _t1836 + p.popPath() + _t1837 := &pb.Data{} + _t1837.DataType = &pb.Data_BetreeRelation{BetreeRelation: betree_relation1128} + _t1835 = _t1837 } else { - var _t1762 *pb.Data - if prediction1082 == 0 { - _t1763 := p.parse_rel_edb() - rel_edb1083 := _t1763 - _t1764 := &pb.Data{} - _t1764.DataType = &pb.Data_RelEdb{RelEdb: rel_edb1083} - _t1762 = _t1764 + var _t1838 *pb.Data + if prediction1126 == 0 { + p.pushPath(int(1)) + _t1839 := p.parse_rel_edb() + rel_edb1127 := _t1839 + p.popPath() + _t1840 := &pb.Data{} + _t1840.DataType = &pb.Data_RelEdb{RelEdb: rel_edb1127} + _t1838 = _t1840 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in data", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1759 = _t1762 + _t1835 = _t1838 } - _t1756 = _t1759 + _t1832 = _t1835 } - result1087 := _t1756 - p.recordSpan(int(span_start1086)) - return result1087 + result1131 := _t1832 + p.recordSpan(int(span_start1130)) + return result1131 } func (p *Parser) parse_rel_edb() *pb.RelEDB { - span_start1091 := int64(p.spanStart()) + span_start1135 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("rel_edb") p.pushPath(int(1)) - _t1765 := p.parse_relation_id() - relation_id1088 := _t1765 + _t1841 := p.parse_relation_id() + relation_id1132 := _t1841 p.popPath() p.pushPath(int(2)) - _t1766 := p.parse_rel_edb_path() - rel_edb_path1089 := _t1766 + _t1842 := p.parse_rel_edb_path() + rel_edb_path1133 := _t1842 p.popPath() p.pushPath(int(3)) - _t1767 := p.parse_rel_edb_types() - rel_edb_types1090 := _t1767 + _t1843 := p.parse_rel_edb_types() + rel_edb_types1134 := _t1843 p.popPath() p.consumeLiteral(")") - _t1768 := &pb.RelEDB{TargetId: relation_id1088, Path: rel_edb_path1089, Types: rel_edb_types1090} - result1092 := _t1768 - p.recordSpan(int(span_start1091)) - return result1092 + _t1844 := &pb.RelEDB{TargetId: relation_id1132, Path: rel_edb_path1133, Types: rel_edb_types1134} + result1136 := _t1844 + p.recordSpan(int(span_start1135)) + return result1136 } func (p *Parser) parse_rel_edb_path() []string { - span_start1097 := int64(p.spanStart()) + span_start1145 := int64(p.spanStart()) p.consumeLiteral("[") - xs1093 := []string{} - cond1094 := p.matchLookaheadTerminal("STRING", 0) - for cond1094 { - item1095 := p.consumeTerminal("STRING").Value.str - xs1093 = append(xs1093, item1095) - cond1094 = p.matchLookaheadTerminal("STRING", 0) - } - strings1096 := xs1093 + xs1141 := []string{} + cond1142 := p.matchLookaheadTerminal("STRING", 0) + idx1143 := 0 + for cond1142 { + p.pushPath(int(idx1143)) + item1144 := p.consumeTerminal("STRING").Value.str + p.popPath() + xs1141 = append(xs1141, item1144) + idx1143 = (idx1143 + 1) + cond1142 = p.matchLookaheadTerminal("STRING", 0) + } + strings1140 := xs1141 p.consumeLiteral("]") - result1098 := strings1096 - p.recordSpan(int(span_start1097)) - return result1098 + result1146 := strings1140 + p.recordSpan(int(span_start1145)) + return result1146 } func (p *Parser) parse_rel_edb_types() []*pb.Type { - span_start1103 := int64(p.spanStart()) + span_start1155 := int64(p.spanStart()) p.consumeLiteral("[") - xs1099 := []*pb.Type{} - cond1100 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond1100 { - _t1769 := p.parse_type() - item1101 := _t1769 - xs1099 = append(xs1099, item1101) - cond1100 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types1102 := xs1099 + xs1151 := []*pb.Type{} + cond1152 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx1153 := 0 + for cond1152 { + p.pushPath(int(idx1153)) + _t1845 := p.parse_type() + item1154 := _t1845 + p.popPath() + xs1151 = append(xs1151, item1154) + idx1153 = (idx1153 + 1) + cond1152 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1150 := xs1151 p.consumeLiteral("]") - result1104 := types1102 - p.recordSpan(int(span_start1103)) - return result1104 + result1156 := types1150 + p.recordSpan(int(span_start1155)) + return result1156 } func (p *Parser) parse_betree_relation() *pb.BeTreeRelation { - span_start1107 := int64(p.spanStart()) + span_start1159 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("betree_relation") p.pushPath(int(1)) - _t1770 := p.parse_relation_id() - relation_id1105 := _t1770 + _t1846 := p.parse_relation_id() + relation_id1157 := _t1846 p.popPath() p.pushPath(int(2)) - _t1771 := p.parse_betree_info() - betree_info1106 := _t1771 + _t1847 := p.parse_betree_info() + betree_info1158 := _t1847 p.popPath() p.consumeLiteral(")") - _t1772 := &pb.BeTreeRelation{Name: relation_id1105, RelationInfo: betree_info1106} - result1108 := _t1772 - p.recordSpan(int(span_start1107)) - return result1108 + _t1848 := &pb.BeTreeRelation{Name: relation_id1157, RelationInfo: betree_info1158} + result1160 := _t1848 + p.recordSpan(int(span_start1159)) + return result1160 } func (p *Parser) parse_betree_info() *pb.BeTreeInfo { - span_start1112 := int64(p.spanStart()) + span_start1164 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("betree_info") - _t1773 := p.parse_betree_info_key_types() - betree_info_key_types1109 := _t1773 - _t1774 := p.parse_betree_info_value_types() - betree_info_value_types1110 := _t1774 - _t1775 := p.parse_config_dict() - config_dict1111 := _t1775 + _t1849 := p.parse_betree_info_key_types() + betree_info_key_types1161 := _t1849 + _t1850 := p.parse_betree_info_value_types() + betree_info_value_types1162 := _t1850 + _t1851 := p.parse_config_dict() + config_dict1163 := _t1851 p.consumeLiteral(")") - _t1776 := p.construct_betree_info(betree_info_key_types1109, betree_info_value_types1110, config_dict1111) - result1113 := _t1776 - p.recordSpan(int(span_start1112)) - return result1113 + _t1852 := p.construct_betree_info(betree_info_key_types1161, betree_info_value_types1162, config_dict1163) + result1165 := _t1852 + p.recordSpan(int(span_start1164)) + return result1165 } func (p *Parser) parse_betree_info_key_types() []*pb.Type { - span_start1118 := int64(p.spanStart()) + span_start1174 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("key_types") - xs1114 := []*pb.Type{} - cond1115 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond1115 { - _t1777 := p.parse_type() - item1116 := _t1777 - xs1114 = append(xs1114, item1116) - cond1115 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - } - types1117 := xs1114 + xs1170 := []*pb.Type{} + cond1171 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx1172 := 0 + for cond1171 { + p.pushPath(int(idx1172)) + _t1853 := p.parse_type() + item1173 := _t1853 + p.popPath() + xs1170 = append(xs1170, item1173) + idx1172 = (idx1172 + 1) + cond1171 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + } + types1169 := xs1170 p.consumeLiteral(")") - result1119 := types1117 - p.recordSpan(int(span_start1118)) - return result1119 + result1175 := types1169 + p.recordSpan(int(span_start1174)) + return result1175 } func (p *Parser) parse_betree_info_value_types() []*pb.Type { - span_start1124 := int64(p.spanStart()) + span_start1184 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("value_types") - xs1120 := []*pb.Type{} - cond1121 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - for cond1121 { - _t1778 := p.parse_type() - item1122 := _t1778 - xs1120 = append(xs1120, item1122) - cond1121 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + xs1180 := []*pb.Type{} + cond1181 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx1182 := 0 + for cond1181 { + p.pushPath(int(idx1182)) + _t1854 := p.parse_type() + item1183 := _t1854 + p.popPath() + xs1180 = append(xs1180, item1183) + idx1182 = (idx1182 + 1) + cond1181 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) } - types1123 := xs1120 + types1179 := xs1180 p.consumeLiteral(")") - result1125 := types1123 - p.recordSpan(int(span_start1124)) - return result1125 + result1185 := types1179 + p.recordSpan(int(span_start1184)) + return result1185 } func (p *Parser) parse_csv_data() *pb.CSVData { - span_start1130 := int64(p.spanStart()) + span_start1190 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_data") p.pushPath(int(1)) - _t1779 := p.parse_csvlocator() - csvlocator1126 := _t1779 + _t1855 := p.parse_csvlocator() + csvlocator1186 := _t1855 p.popPath() p.pushPath(int(2)) - _t1780 := p.parse_csv_config() - csv_config1127 := _t1780 + _t1856 := p.parse_csv_config() + csv_config1187 := _t1856 p.popPath() p.pushPath(int(3)) - _t1781 := p.parse_csv_columns() - csv_columns1128 := _t1781 + _t1857 := p.parse_csv_columns() + csv_columns1188 := _t1857 p.popPath() p.pushPath(int(4)) - _t1782 := p.parse_csv_asof() - csv_asof1129 := _t1782 + _t1858 := p.parse_csv_asof() + csv_asof1189 := _t1858 p.popPath() p.consumeLiteral(")") - _t1783 := &pb.CSVData{Locator: csvlocator1126, Config: csv_config1127, Columns: csv_columns1128, Asof: csv_asof1129} - result1131 := _t1783 - p.recordSpan(int(span_start1130)) - return result1131 + _t1859 := &pb.CSVData{Locator: csvlocator1186, Config: csv_config1187, Columns: csv_columns1188, Asof: csv_asof1189} + result1191 := _t1859 + p.recordSpan(int(span_start1190)) + return result1191 } func (p *Parser) parse_csvlocator() *pb.CSVLocator { - span_start1134 := int64(p.spanStart()) + span_start1194 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_locator") p.pushPath(int(1)) - var _t1784 []string + var _t1860 []string if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("paths", 1)) { - _t1785 := p.parse_csv_locator_paths() - _t1784 = _t1785 + _t1861 := p.parse_csv_locator_paths() + _t1860 = _t1861 } - csv_locator_paths1132 := _t1784 + csv_locator_paths1192 := _t1860 p.popPath() p.pushPath(int(2)) - var _t1786 *string + var _t1862 *string if p.matchLookaheadLiteral("(", 0) { - _t1787 := p.parse_csv_locator_inline_data() - _t1786 = ptr(_t1787) + _t1863 := p.parse_csv_locator_inline_data() + _t1862 = ptr(_t1863) } - csv_locator_inline_data1133 := _t1786 + csv_locator_inline_data1193 := _t1862 p.popPath() p.consumeLiteral(")") - _t1788 := csv_locator_paths1132 - if csv_locator_paths1132 == nil { - _t1788 = []string{} + _t1864 := csv_locator_paths1192 + if csv_locator_paths1192 == nil { + _t1864 = []string{} } - _t1789 := &pb.CSVLocator{Paths: _t1788, InlineData: []byte(deref(csv_locator_inline_data1133, ""))} - result1135 := _t1789 - p.recordSpan(int(span_start1134)) - return result1135 + _t1865 := &pb.CSVLocator{Paths: _t1864, InlineData: []byte(deref(csv_locator_inline_data1193, ""))} + result1195 := _t1865 + p.recordSpan(int(span_start1194)) + return result1195 } func (p *Parser) parse_csv_locator_paths() []string { - span_start1140 := int64(p.spanStart()) + span_start1204 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("paths") - xs1136 := []string{} - cond1137 := p.matchLookaheadTerminal("STRING", 0) - for cond1137 { - item1138 := p.consumeTerminal("STRING").Value.str - xs1136 = append(xs1136, item1138) - cond1137 = p.matchLookaheadTerminal("STRING", 0) - } - strings1139 := xs1136 + xs1200 := []string{} + cond1201 := p.matchLookaheadTerminal("STRING", 0) + idx1202 := 0 + for cond1201 { + p.pushPath(int(idx1202)) + item1203 := p.consumeTerminal("STRING").Value.str + p.popPath() + xs1200 = append(xs1200, item1203) + idx1202 = (idx1202 + 1) + cond1201 = p.matchLookaheadTerminal("STRING", 0) + } + strings1199 := xs1200 p.consumeLiteral(")") - result1141 := strings1139 - p.recordSpan(int(span_start1140)) - return result1141 + result1205 := strings1199 + p.recordSpan(int(span_start1204)) + return result1205 } func (p *Parser) parse_csv_locator_inline_data() string { - span_start1143 := int64(p.spanStart()) + span_start1207 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("inline_data") - string1142 := p.consumeTerminal("STRING").Value.str + string1206 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - result1144 := string1142 - p.recordSpan(int(span_start1143)) - return result1144 + result1208 := string1206 + p.recordSpan(int(span_start1207)) + return result1208 } func (p *Parser) parse_csv_config() *pb.CSVConfig { - span_start1146 := int64(p.spanStart()) + span_start1210 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_config") - _t1790 := p.parse_config_dict() - config_dict1145 := _t1790 + _t1866 := p.parse_config_dict() + config_dict1209 := _t1866 p.consumeLiteral(")") - _t1791 := p.construct_csv_config(config_dict1145) - result1147 := _t1791 - p.recordSpan(int(span_start1146)) - return result1147 + _t1867 := p.construct_csv_config(config_dict1209) + result1211 := _t1867 + p.recordSpan(int(span_start1210)) + return result1211 } func (p *Parser) parse_csv_columns() []*pb.CSVColumn { - span_start1152 := int64(p.spanStart()) + span_start1220 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("columns") - xs1148 := []*pb.CSVColumn{} - cond1149 := p.matchLookaheadLiteral("(", 0) - for cond1149 { - _t1792 := p.parse_csv_column() - item1150 := _t1792 - xs1148 = append(xs1148, item1150) - cond1149 = p.matchLookaheadLiteral("(", 0) - } - csv_columns1151 := xs1148 + xs1216 := []*pb.CSVColumn{} + cond1217 := p.matchLookaheadLiteral("(", 0) + idx1218 := 0 + for cond1217 { + p.pushPath(int(idx1218)) + _t1868 := p.parse_csv_column() + item1219 := _t1868 + p.popPath() + xs1216 = append(xs1216, item1219) + idx1218 = (idx1218 + 1) + cond1217 = p.matchLookaheadLiteral("(", 0) + } + csv_columns1215 := xs1216 p.consumeLiteral(")") - result1153 := csv_columns1151 - p.recordSpan(int(span_start1152)) - return result1153 + result1221 := csv_columns1215 + p.recordSpan(int(span_start1220)) + return result1221 } func (p *Parser) parse_csv_column() *pb.CSVColumn { - span_start1164 := int64(p.spanStart()) + span_start1232 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("column") p.pushPath(int(1)) - string1154 := p.consumeTerminal("STRING").Value.str + string1222 := p.consumeTerminal("STRING").Value.str p.popPath() p.pushPath(int(2)) - _t1793 := p.parse_relation_id() - relation_id1155 := _t1793 + _t1869 := p.parse_relation_id() + relation_id1223 := _t1869 p.popPath() p.consumeLiteral("[") p.pushPath(int(3)) - xs1160 := []*pb.Type{} - cond1161 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) - idx1162 := 0 - for cond1161 { - p.pushPath(int(idx1162)) - _t1794 := p.parse_type() - item1163 := _t1794 + xs1228 := []*pb.Type{} + cond1229 := ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + idx1230 := 0 + for cond1229 { + p.pushPath(int(idx1230)) + _t1870 := p.parse_type() + item1231 := _t1870 p.popPath() - xs1160 = append(xs1160, item1163) - idx1162 = (idx1162 + 1) - cond1161 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) + xs1228 = append(xs1228, item1231) + idx1230 = (idx1230 + 1) + cond1229 = ((((((((((p.matchLookaheadLiteral("(", 0) || p.matchLookaheadLiteral("BOOLEAN", 0)) || p.matchLookaheadLiteral("DATE", 0)) || p.matchLookaheadLiteral("DATETIME", 0)) || p.matchLookaheadLiteral("FLOAT", 0)) || p.matchLookaheadLiteral("INT", 0)) || p.matchLookaheadLiteral("INT128", 0)) || p.matchLookaheadLiteral("MISSING", 0)) || p.matchLookaheadLiteral("STRING", 0)) || p.matchLookaheadLiteral("UINT128", 0)) || p.matchLookaheadLiteral("UNKNOWN", 0)) } - types1159 := xs1160 + types1227 := xs1228 p.popPath() p.consumeLiteral("]") p.consumeLiteral(")") - _t1795 := &pb.CSVColumn{ColumnName: string1154, TargetId: relation_id1155, Types: types1159} - result1165 := _t1795 - p.recordSpan(int(span_start1164)) - return result1165 + _t1871 := &pb.CSVColumn{ColumnName: string1222, TargetId: relation_id1223, Types: types1227} + result1233 := _t1871 + p.recordSpan(int(span_start1232)) + return result1233 } func (p *Parser) parse_csv_asof() string { - span_start1167 := int64(p.spanStart()) + span_start1235 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("asof") - string1166 := p.consumeTerminal("STRING").Value.str + string1234 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - result1168 := string1166 - p.recordSpan(int(span_start1167)) - return result1168 + result1236 := string1234 + p.recordSpan(int(span_start1235)) + return result1236 } func (p *Parser) parse_undefine() *pb.Undefine { - span_start1170 := int64(p.spanStart()) + span_start1238 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("undefine") p.pushPath(int(1)) - _t1796 := p.parse_fragment_id() - fragment_id1169 := _t1796 + _t1872 := p.parse_fragment_id() + fragment_id1237 := _t1872 p.popPath() p.consumeLiteral(")") - _t1797 := &pb.Undefine{FragmentId: fragment_id1169} - result1171 := _t1797 - p.recordSpan(int(span_start1170)) - return result1171 + _t1873 := &pb.Undefine{FragmentId: fragment_id1237} + result1239 := _t1873 + p.recordSpan(int(span_start1238)) + return result1239 } func (p *Parser) parse_context() *pb.Context { - span_start1180 := int64(p.spanStart()) + span_start1248 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("context") p.pushPath(int(1)) - xs1176 := []*pb.RelationId{} - cond1177 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) - idx1178 := 0 - for cond1177 { - p.pushPath(int(idx1178)) - _t1798 := p.parse_relation_id() - item1179 := _t1798 + xs1244 := []*pb.RelationId{} + cond1245 := (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + idx1246 := 0 + for cond1245 { + p.pushPath(int(idx1246)) + _t1874 := p.parse_relation_id() + item1247 := _t1874 p.popPath() - xs1176 = append(xs1176, item1179) - idx1178 = (idx1178 + 1) - cond1177 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + xs1244 = append(xs1244, item1247) + idx1246 = (idx1246 + 1) + cond1245 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) } - relation_ids1175 := xs1176 + relation_ids1243 := xs1244 p.popPath() p.consumeLiteral(")") - _t1799 := &pb.Context{Relations: relation_ids1175} - result1181 := _t1799 - p.recordSpan(int(span_start1180)) - return result1181 + _t1875 := &pb.Context{Relations: relation_ids1243} + result1249 := _t1875 + p.recordSpan(int(span_start1248)) + return result1249 } func (p *Parser) parse_snapshot() *pb.Snapshot { - span_start1184 := int64(p.spanStart()) + span_start1252 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("snapshot") p.pushPath(int(1)) - _t1800 := p.parse_rel_edb_path() - rel_edb_path1182 := _t1800 + _t1876 := p.parse_rel_edb_path() + rel_edb_path1250 := _t1876 p.popPath() p.pushPath(int(2)) - _t1801 := p.parse_relation_id() - relation_id1183 := _t1801 + _t1877 := p.parse_relation_id() + relation_id1251 := _t1877 p.popPath() p.consumeLiteral(")") - _t1802 := &pb.Snapshot{DestinationPath: rel_edb_path1182, SourceRelation: relation_id1183} - result1185 := _t1802 - p.recordSpan(int(span_start1184)) - return result1185 + _t1878 := &pb.Snapshot{DestinationPath: rel_edb_path1250, SourceRelation: relation_id1251} + result1253 := _t1878 + p.recordSpan(int(span_start1252)) + return result1253 } func (p *Parser) parse_epoch_reads() []*pb.Read { - span_start1190 := int64(p.spanStart()) + span_start1262 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("reads") - xs1186 := []*pb.Read{} - cond1187 := p.matchLookaheadLiteral("(", 0) - for cond1187 { - _t1803 := p.parse_read() - item1188 := _t1803 - xs1186 = append(xs1186, item1188) - cond1187 = p.matchLookaheadLiteral("(", 0) - } - reads1189 := xs1186 + xs1258 := []*pb.Read{} + cond1259 := p.matchLookaheadLiteral("(", 0) + idx1260 := 0 + for cond1259 { + p.pushPath(int(idx1260)) + _t1879 := p.parse_read() + item1261 := _t1879 + p.popPath() + xs1258 = append(xs1258, item1261) + idx1260 = (idx1260 + 1) + cond1259 = p.matchLookaheadLiteral("(", 0) + } + reads1257 := xs1258 p.consumeLiteral(")") - result1191 := reads1189 - p.recordSpan(int(span_start1190)) - return result1191 + result1263 := reads1257 + p.recordSpan(int(span_start1262)) + return result1263 } func (p *Parser) parse_read() *pb.Read { - span_start1198 := int64(p.spanStart()) - var _t1804 int64 + span_start1270 := int64(p.spanStart()) + var _t1880 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1805 int64 + var _t1881 int64 if p.matchLookaheadLiteral("what_if", 1) { - _t1805 = 2 + _t1881 = 2 } else { - var _t1806 int64 + var _t1882 int64 if p.matchLookaheadLiteral("output", 1) { - _t1806 = 1 + _t1882 = 1 } else { - var _t1807 int64 + var _t1883 int64 if p.matchLookaheadLiteral("export", 1) { - _t1807 = 4 + _t1883 = 4 } else { - var _t1808 int64 + var _t1884 int64 if p.matchLookaheadLiteral("demand", 1) { - _t1808 = 0 + _t1884 = 0 } else { - var _t1809 int64 + var _t1885 int64 if p.matchLookaheadLiteral("abort", 1) { - _t1809 = 3 + _t1885 = 3 } else { - _t1809 = -1 + _t1885 = -1 } - _t1808 = _t1809 + _t1884 = _t1885 } - _t1807 = _t1808 + _t1883 = _t1884 } - _t1806 = _t1807 + _t1882 = _t1883 } - _t1805 = _t1806 + _t1881 = _t1882 } - _t1804 = _t1805 + _t1880 = _t1881 } else { - _t1804 = -1 - } - prediction1192 := _t1804 - var _t1810 *pb.Read - if prediction1192 == 4 { - _t1811 := p.parse_export() - export1197 := _t1811 - _t1812 := &pb.Read{} - _t1812.ReadType = &pb.Read_Export{Export: export1197} - _t1810 = _t1812 + _t1880 = -1 + } + prediction1264 := _t1880 + var _t1886 *pb.Read + if prediction1264 == 4 { + p.pushPath(int(5)) + _t1887 := p.parse_export() + export1269 := _t1887 + p.popPath() + _t1888 := &pb.Read{} + _t1888.ReadType = &pb.Read_Export{Export: export1269} + _t1886 = _t1888 } else { - var _t1813 *pb.Read - if prediction1192 == 3 { - _t1814 := p.parse_abort() - abort1196 := _t1814 - _t1815 := &pb.Read{} - _t1815.ReadType = &pb.Read_Abort{Abort: abort1196} - _t1813 = _t1815 + var _t1889 *pb.Read + if prediction1264 == 3 { + p.pushPath(int(4)) + _t1890 := p.parse_abort() + abort1268 := _t1890 + p.popPath() + _t1891 := &pb.Read{} + _t1891.ReadType = &pb.Read_Abort{Abort: abort1268} + _t1889 = _t1891 } else { - var _t1816 *pb.Read - if prediction1192 == 2 { - _t1817 := p.parse_what_if() - what_if1195 := _t1817 - _t1818 := &pb.Read{} - _t1818.ReadType = &pb.Read_WhatIf{WhatIf: what_if1195} - _t1816 = _t1818 + var _t1892 *pb.Read + if prediction1264 == 2 { + p.pushPath(int(3)) + _t1893 := p.parse_what_if() + what_if1267 := _t1893 + p.popPath() + _t1894 := &pb.Read{} + _t1894.ReadType = &pb.Read_WhatIf{WhatIf: what_if1267} + _t1892 = _t1894 } else { - var _t1819 *pb.Read - if prediction1192 == 1 { - _t1820 := p.parse_output() - output1194 := _t1820 - _t1821 := &pb.Read{} - _t1821.ReadType = &pb.Read_Output{Output: output1194} - _t1819 = _t1821 + var _t1895 *pb.Read + if prediction1264 == 1 { + p.pushPath(int(2)) + _t1896 := p.parse_output() + output1266 := _t1896 + p.popPath() + _t1897 := &pb.Read{} + _t1897.ReadType = &pb.Read_Output{Output: output1266} + _t1895 = _t1897 } else { - var _t1822 *pb.Read - if prediction1192 == 0 { - _t1823 := p.parse_demand() - demand1193 := _t1823 - _t1824 := &pb.Read{} - _t1824.ReadType = &pb.Read_Demand{Demand: demand1193} - _t1822 = _t1824 + var _t1898 *pb.Read + if prediction1264 == 0 { + p.pushPath(int(1)) + _t1899 := p.parse_demand() + demand1265 := _t1899 + p.popPath() + _t1900 := &pb.Read{} + _t1900.ReadType = &pb.Read_Demand{Demand: demand1265} + _t1898 = _t1900 } else { panic(ParseError{msg: fmt.Sprintf("%s: %s=`%v`", "Unexpected token in read", p.lookahead(0).Type, p.lookahead(0).Value)}) } - _t1819 = _t1822 + _t1895 = _t1898 } - _t1816 = _t1819 + _t1892 = _t1895 } - _t1813 = _t1816 + _t1889 = _t1892 } - _t1810 = _t1813 + _t1886 = _t1889 } - result1199 := _t1810 - p.recordSpan(int(span_start1198)) - return result1199 + result1271 := _t1886 + p.recordSpan(int(span_start1270)) + return result1271 } func (p *Parser) parse_demand() *pb.Demand { - span_start1201 := int64(p.spanStart()) + span_start1273 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("demand") p.pushPath(int(1)) - _t1825 := p.parse_relation_id() - relation_id1200 := _t1825 + _t1901 := p.parse_relation_id() + relation_id1272 := _t1901 p.popPath() p.consumeLiteral(")") - _t1826 := &pb.Demand{RelationId: relation_id1200} - result1202 := _t1826 - p.recordSpan(int(span_start1201)) - return result1202 + _t1902 := &pb.Demand{RelationId: relation_id1272} + result1274 := _t1902 + p.recordSpan(int(span_start1273)) + return result1274 } func (p *Parser) parse_output() *pb.Output { - span_start1205 := int64(p.spanStart()) + span_start1277 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("output") p.pushPath(int(1)) - _t1827 := p.parse_name() - name1203 := _t1827 + _t1903 := p.parse_name() + name1275 := _t1903 p.popPath() p.pushPath(int(2)) - _t1828 := p.parse_relation_id() - relation_id1204 := _t1828 + _t1904 := p.parse_relation_id() + relation_id1276 := _t1904 p.popPath() p.consumeLiteral(")") - _t1829 := &pb.Output{Name: name1203, RelationId: relation_id1204} - result1206 := _t1829 - p.recordSpan(int(span_start1205)) - return result1206 + _t1905 := &pb.Output{Name: name1275, RelationId: relation_id1276} + result1278 := _t1905 + p.recordSpan(int(span_start1277)) + return result1278 } func (p *Parser) parse_what_if() *pb.WhatIf { - span_start1209 := int64(p.spanStart()) + span_start1281 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("what_if") p.pushPath(int(1)) - _t1830 := p.parse_name() - name1207 := _t1830 + _t1906 := p.parse_name() + name1279 := _t1906 p.popPath() p.pushPath(int(2)) - _t1831 := p.parse_epoch() - epoch1208 := _t1831 + _t1907 := p.parse_epoch() + epoch1280 := _t1907 p.popPath() p.consumeLiteral(")") - _t1832 := &pb.WhatIf{Branch: name1207, Epoch: epoch1208} - result1210 := _t1832 - p.recordSpan(int(span_start1209)) - return result1210 + _t1908 := &pb.WhatIf{Branch: name1279, Epoch: epoch1280} + result1282 := _t1908 + p.recordSpan(int(span_start1281)) + return result1282 } func (p *Parser) parse_abort() *pb.Abort { - span_start1213 := int64(p.spanStart()) + span_start1285 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("abort") p.pushPath(int(1)) - var _t1833 *string + var _t1909 *string if (p.matchLookaheadLiteral(":", 0) && p.matchLookaheadTerminal("SYMBOL", 1)) { - _t1834 := p.parse_name() - _t1833 = ptr(_t1834) + _t1910 := p.parse_name() + _t1909 = ptr(_t1910) } - name1211 := _t1833 + name1283 := _t1909 p.popPath() p.pushPath(int(2)) - _t1835 := p.parse_relation_id() - relation_id1212 := _t1835 + _t1911 := p.parse_relation_id() + relation_id1284 := _t1911 p.popPath() p.consumeLiteral(")") - _t1836 := &pb.Abort{Name: deref(name1211, "abort"), RelationId: relation_id1212} - result1214 := _t1836 - p.recordSpan(int(span_start1213)) - return result1214 + _t1912 := &pb.Abort{Name: deref(name1283, "abort"), RelationId: relation_id1284} + result1286 := _t1912 + p.recordSpan(int(span_start1285)) + return result1286 } func (p *Parser) parse_export() *pb.Export { - span_start1216 := int64(p.spanStart()) + span_start1288 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("export") p.pushPath(int(1)) - _t1837 := p.parse_export_csv_config() - export_csv_config1215 := _t1837 + _t1913 := p.parse_export_csv_config() + export_csv_config1287 := _t1913 p.popPath() p.consumeLiteral(")") - _t1838 := &pb.Export{} - _t1838.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config1215} - result1217 := _t1838 - p.recordSpan(int(span_start1216)) - return result1217 + _t1914 := &pb.Export{} + _t1914.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config1287} + result1289 := _t1914 + p.recordSpan(int(span_start1288)) + return result1289 } func (p *Parser) parse_export_csv_config() *pb.ExportCSVConfig { - span_start1221 := int64(p.spanStart()) + span_start1293 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("export_csv_config") - _t1839 := p.parse_export_csv_path() - export_csv_path1218 := _t1839 - _t1840 := p.parse_export_csv_columns() - export_csv_columns1219 := _t1840 - _t1841 := p.parse_config_dict() - config_dict1220 := _t1841 + _t1915 := p.parse_export_csv_path() + export_csv_path1290 := _t1915 + _t1916 := p.parse_export_csv_columns() + export_csv_columns1291 := _t1916 + _t1917 := p.parse_config_dict() + config_dict1292 := _t1917 p.consumeLiteral(")") - _t1842 := p.export_csv_config(export_csv_path1218, export_csv_columns1219, config_dict1220) - result1222 := _t1842 - p.recordSpan(int(span_start1221)) - return result1222 + _t1918 := p.export_csv_config(export_csv_path1290, export_csv_columns1291, config_dict1292) + result1294 := _t1918 + p.recordSpan(int(span_start1293)) + return result1294 } func (p *Parser) parse_export_csv_path() string { - span_start1224 := int64(p.spanStart()) + span_start1296 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("path") - string1223 := p.consumeTerminal("STRING").Value.str + string1295 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - result1225 := string1223 - p.recordSpan(int(span_start1224)) - return result1225 + result1297 := string1295 + p.recordSpan(int(span_start1296)) + return result1297 } func (p *Parser) parse_export_csv_columns() []*pb.ExportCSVColumn { - span_start1230 := int64(p.spanStart()) + span_start1306 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("columns") - xs1226 := []*pb.ExportCSVColumn{} - cond1227 := p.matchLookaheadLiteral("(", 0) - for cond1227 { - _t1843 := p.parse_export_csv_column() - item1228 := _t1843 - xs1226 = append(xs1226, item1228) - cond1227 = p.matchLookaheadLiteral("(", 0) - } - export_csv_columns1229 := xs1226 + xs1302 := []*pb.ExportCSVColumn{} + cond1303 := p.matchLookaheadLiteral("(", 0) + idx1304 := 0 + for cond1303 { + p.pushPath(int(idx1304)) + _t1919 := p.parse_export_csv_column() + item1305 := _t1919 + p.popPath() + xs1302 = append(xs1302, item1305) + idx1304 = (idx1304 + 1) + cond1303 = p.matchLookaheadLiteral("(", 0) + } + export_csv_columns1301 := xs1302 p.consumeLiteral(")") - result1231 := export_csv_columns1229 - p.recordSpan(int(span_start1230)) - return result1231 + result1307 := export_csv_columns1301 + p.recordSpan(int(span_start1306)) + return result1307 } func (p *Parser) parse_export_csv_column() *pb.ExportCSVColumn { - span_start1234 := int64(p.spanStart()) + span_start1310 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("column") p.pushPath(int(1)) - string1232 := p.consumeTerminal("STRING").Value.str + string1308 := p.consumeTerminal("STRING").Value.str p.popPath() p.pushPath(int(2)) - _t1844 := p.parse_relation_id() - relation_id1233 := _t1844 + _t1920 := p.parse_relation_id() + relation_id1309 := _t1920 p.popPath() p.consumeLiteral(")") - _t1845 := &pb.ExportCSVColumn{ColumnName: string1232, ColumnData: relation_id1233} - result1235 := _t1845 - p.recordSpan(int(span_start1234)) - return result1235 + _t1921 := &pb.ExportCSVColumn{ColumnName: string1308, ColumnData: relation_id1309} + result1311 := _t1921 + p.recordSpan(int(span_start1310)) + return result1311 } diff --git a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl index 46d4cee4..7f337825 100644 --- a/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl +++ b/sdks/julia/LogicalQueryProtocol.jl/src/parser.jl @@ -362,7 +362,7 @@ function _extract_value_int32(parser::ParserState, value::Union{Nothing, Proto.V if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return Int32(_get_oneof_field(value, :int_value)) else - _t1835 = nothing + _t1911 = nothing end return Int32(default) end @@ -371,7 +371,7 @@ function _extract_value_int64(parser::ParserState, value::Union{Nothing, Proto.V if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return _get_oneof_field(value, :int_value) else - _t1836 = nothing + _t1912 = nothing end return default end @@ -380,7 +380,7 @@ function _extract_value_string(parser::ParserState, value::Union{Nothing, Proto. if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return _get_oneof_field(value, :string_value) else - _t1837 = nothing + _t1913 = nothing end return default end @@ -389,7 +389,7 @@ function _extract_value_boolean(parser::ParserState, value::Union{Nothing, Proto if (!isnothing(value) && _has_proto_field(value, Symbol("boolean_value"))) return _get_oneof_field(value, :boolean_value) else - _t1838 = nothing + _t1914 = nothing end return default end @@ -398,7 +398,7 @@ function _extract_value_string_list(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return String[_get_oneof_field(value, :string_value)] else - _t1839 = nothing + _t1915 = nothing end return default end @@ -407,7 +407,7 @@ function _try_extract_value_int64(parser::ParserState, value::Union{Nothing, Pro if (!isnothing(value) && _has_proto_field(value, Symbol("int_value"))) return _get_oneof_field(value, :int_value) else - _t1840 = nothing + _t1916 = nothing end return nothing end @@ -416,7 +416,7 @@ function _try_extract_value_float64(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("float_value"))) return _get_oneof_field(value, :float_value) else - _t1841 = nothing + _t1917 = nothing end return nothing end @@ -425,7 +425,7 @@ function _try_extract_value_bytes(parser::ParserState, value::Union{Nothing, Pro if (!isnothing(value) && _has_proto_field(value, Symbol("string_value"))) return Vector{UInt8}(_get_oneof_field(value, :string_value)) else - _t1842 = nothing + _t1918 = nothing end return nothing end @@ -434,70 +434,70 @@ function _try_extract_value_uint128(parser::ParserState, value::Union{Nothing, P if (!isnothing(value) && _has_proto_field(value, Symbol("uint128_value"))) return _get_oneof_field(value, :uint128_value) else - _t1843 = nothing + _t1919 = nothing end return nothing end function construct_csv_config(parser::ParserState, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.CSVConfig config = Dict(config_dict) - _t1844 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) - header_row = _t1844 - _t1845 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) - skip = _t1845 - _t1846 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") - new_line = _t1846 - _t1847 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") - delimiter = _t1847 - _t1848 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") - quotechar = _t1848 - _t1849 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") - escapechar = _t1849 - _t1850 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") - comment = _t1850 - _t1851 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) - missing_strings = _t1851 - _t1852 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") - decimal_separator = _t1852 - _t1853 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") - encoding = _t1853 - _t1854 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") - compression = _t1854 - _t1855 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1855 + _t1920 = _extract_value_int32(parser, get(config, "csv_header_row", nothing), 1) + header_row = _t1920 + _t1921 = _extract_value_int64(parser, get(config, "csv_skip", nothing), 0) + skip = _t1921 + _t1922 = _extract_value_string(parser, get(config, "csv_new_line", nothing), "") + new_line = _t1922 + _t1923 = _extract_value_string(parser, get(config, "csv_delimiter", nothing), ",") + delimiter = _t1923 + _t1924 = _extract_value_string(parser, get(config, "csv_quotechar", nothing), "\"") + quotechar = _t1924 + _t1925 = _extract_value_string(parser, get(config, "csv_escapechar", nothing), "\"") + escapechar = _t1925 + _t1926 = _extract_value_string(parser, get(config, "csv_comment", nothing), "") + comment = _t1926 + _t1927 = _extract_value_string_list(parser, get(config, "csv_missing_strings", nothing), String[]) + missing_strings = _t1927 + _t1928 = _extract_value_string(parser, get(config, "csv_decimal_separator", nothing), ".") + decimal_separator = _t1928 + _t1929 = _extract_value_string(parser, get(config, "csv_encoding", nothing), "utf-8") + encoding = _t1929 + _t1930 = _extract_value_string(parser, get(config, "csv_compression", nothing), "auto") + compression = _t1930 + _t1931 = Proto.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1931 end function construct_betree_info(parser::ParserState, key_types::Vector{Proto.var"#Type"}, value_types::Vector{Proto.var"#Type"}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.BeTreeInfo config = Dict(config_dict) - _t1856 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) - epsilon = _t1856 - _t1857 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) - max_pivots = _t1857 - _t1858 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) - max_deltas = _t1858 - _t1859 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) - max_leaf = _t1859 - _t1860 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1860 - _t1861 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) - root_pageid = _t1861 - _t1862 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) - inline_data = _t1862 - _t1863 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) - element_count = _t1863 - _t1864 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) - tree_height = _t1864 - _t1865 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) - relation_locator = _t1865 - _t1866 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1866 + _t1932 = _try_extract_value_float64(parser, get(config, "betree_config_epsilon", nothing)) + epsilon = _t1932 + _t1933 = _try_extract_value_int64(parser, get(config, "betree_config_max_pivots", nothing)) + max_pivots = _t1933 + _t1934 = _try_extract_value_int64(parser, get(config, "betree_config_max_deltas", nothing)) + max_deltas = _t1934 + _t1935 = _try_extract_value_int64(parser, get(config, "betree_config_max_leaf", nothing)) + max_leaf = _t1935 + _t1936 = Proto.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1936 + _t1937 = _try_extract_value_uint128(parser, get(config, "betree_locator_root_pageid", nothing)) + root_pageid = _t1937 + _t1938 = _try_extract_value_bytes(parser, get(config, "betree_locator_inline_data", nothing)) + inline_data = _t1938 + _t1939 = _try_extract_value_int64(parser, get(config, "betree_locator_element_count", nothing)) + element_count = _t1939 + _t1940 = _try_extract_value_int64(parser, get(config, "betree_locator_tree_height", nothing)) + tree_height = _t1940 + _t1941 = Proto.BeTreeLocator(location=(!isnothing(root_pageid) ? OneOf(:root_pageid, root_pageid) : (!isnothing(inline_data) ? OneOf(:inline_data, inline_data) : nothing)), element_count=element_count, tree_height=tree_height) + relation_locator = _t1941 + _t1942 = Proto.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1942 end function default_configure(parser::ParserState)::Proto.Configure - _t1867 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1867 - _t1868 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1868 + _t1943 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1943 + _t1944 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1944 end function construct_configure(parser::ParserState, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.Configure @@ -519,32 +519,32 @@ function construct_configure(parser::ParserState, config_dict::Vector{Tuple{Stri end end end - _t1869 = Proto.IVMConfig(level=maintenance_level) - ivm_config = _t1869 - _t1870 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) - semantics_version = _t1870 - _t1871 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1871 + _t1945 = Proto.IVMConfig(level=maintenance_level) + ivm_config = _t1945 + _t1946 = _extract_value_int64(parser, get(config, "semantics_version", nothing), 0) + semantics_version = _t1946 + _t1947 = Proto.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1947 end function export_csv_config(parser::ParserState, path::String, columns::Vector{Proto.ExportCSVColumn}, config_dict::Vector{Tuple{String, Proto.Value}})::Proto.ExportCSVConfig config = Dict(config_dict) - _t1872 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) - partition_size = _t1872 - _t1873 = _extract_value_string(parser, get(config, "compression", nothing), "") - compression = _t1873 - _t1874 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) - syntax_header_row = _t1874 - _t1875 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") - syntax_missing_string = _t1875 - _t1876 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") - syntax_delim = _t1876 - _t1877 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") - syntax_quotechar = _t1877 - _t1878 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") - syntax_escapechar = _t1878 - _t1879 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1879 + _t1948 = _extract_value_int64(parser, get(config, "partition_size", nothing), 0) + partition_size = _t1948 + _t1949 = _extract_value_string(parser, get(config, "compression", nothing), "") + compression = _t1949 + _t1950 = _extract_value_boolean(parser, get(config, "syntax_header_row", nothing), true) + syntax_header_row = _t1950 + _t1951 = _extract_value_string(parser, get(config, "syntax_missing_string", nothing), "") + syntax_missing_string = _t1951 + _t1952 = _extract_value_string(parser, get(config, "syntax_delim", nothing), ",") + syntax_delim = _t1952 + _t1953 = _extract_value_string(parser, get(config, "syntax_quotechar", nothing), "\"") + syntax_quotechar = _t1953 + _t1954 = _extract_value_string(parser, get(config, "syntax_escapechar", nothing), "\\") + syntax_escapechar = _t1954 + _t1955 = Proto.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1955 end # --- Parse functions --- @@ -555,21 +555,21 @@ function parse_transaction(parser::ParserState)::Proto.Transaction consume_literal!(parser, "transaction") push_path!(parser, 2) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "configure", 1)) - _t1237 = parse_configure(parser) - _t1236 = _t1237 + _t1313 = parse_configure(parser) + _t1312 = _t1313 else - _t1236 = nothing + _t1312 = nothing end - configure592 = _t1236 + configure592 = _t1312 pop_path!(parser) push_path!(parser, 3) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "sync", 1)) - _t1239 = parse_sync(parser) - _t1238 = _t1239 + _t1315 = parse_sync(parser) + _t1314 = _t1315 else - _t1238 = nothing + _t1314 = nothing end - sync593 = _t1238 + sync593 = _t1314 pop_path!(parser) push_path!(parser, 1) xs598 = Proto.Epoch[] @@ -577,8 +577,8 @@ function parse_transaction(parser::ParserState)::Proto.Transaction idx600 = 0 while cond599 push_path!(parser, idx600) - _t1240 = parse_epoch(parser) - item601 = _t1240 + _t1316 = parse_epoch(parser) + item601 = _t1316 pop_path!(parser) push!(xs598, item601) idx600 = (idx600 + 1) @@ -587,9 +587,9 @@ function parse_transaction(parser::ParserState)::Proto.Transaction epochs597 = xs598 pop_path!(parser) consume_literal!(parser, ")") - _t1241 = default_configure(parser) - _t1242 = Proto.Transaction(epochs=epochs597, configure=(!isnothing(configure592) ? configure592 : _t1241), sync=sync593) - result603 = _t1242 + _t1317 = default_configure(parser) + _t1318 = Proto.Transaction(epochs=epochs597, configure=(!isnothing(configure592) ? configure592 : _t1317), sync=sync593) + result603 = _t1318 record_span!(parser, span_start602) return result603 end @@ -598,3252 +598,3446 @@ function parse_configure(parser::ParserState)::Proto.Configure span_start605 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "configure") - _t1243 = parse_config_dict(parser) - config_dict604 = _t1243 + _t1319 = parse_config_dict(parser) + config_dict604 = _t1319 consume_literal!(parser, ")") - _t1244 = construct_configure(parser, config_dict604) - result606 = _t1244 + _t1320 = construct_configure(parser, config_dict604) + result606 = _t1320 record_span!(parser, span_start605) return result606 end function parse_config_dict(parser::ParserState)::Vector{Tuple{String, Proto.Value}} - span_start611 = span_start(parser) + span_start615 = span_start(parser) consume_literal!(parser, "{") - xs607 = Tuple{String, Proto.Value}[] - cond608 = match_lookahead_literal(parser, ":", 0) - while cond608 - _t1245 = parse_config_key_value(parser) - item609 = _t1245 - push!(xs607, item609) - cond608 = match_lookahead_literal(parser, ":", 0) - end - config_key_values610 = xs607 + xs611 = Tuple{String, Proto.Value}[] + cond612 = match_lookahead_literal(parser, ":", 0) + idx613 = 0 + while cond612 + push_path!(parser, idx613) + _t1321 = parse_config_key_value(parser) + item614 = _t1321 + pop_path!(parser) + push!(xs611, item614) + idx613 = (idx613 + 1) + cond612 = match_lookahead_literal(parser, ":", 0) + end + config_key_values610 = xs611 consume_literal!(parser, "}") - result612 = config_key_values610 - record_span!(parser, span_start611) - return result612 + result616 = config_key_values610 + record_span!(parser, span_start615) + return result616 end function parse_config_key_value(parser::ParserState)::Tuple{String, Proto.Value} - span_start615 = span_start(parser) + span_start619 = span_start(parser) consume_literal!(parser, ":") - symbol613 = consume_terminal!(parser, "SYMBOL") - _t1246 = parse_value(parser) - value614 = _t1246 - result616 = (symbol613, value614,) - record_span!(parser, span_start615) - return result616 + symbol617 = consume_terminal!(parser, "SYMBOL") + _t1322 = parse_value(parser) + value618 = _t1322 + result620 = (symbol617, value618,) + record_span!(parser, span_start619) + return result620 end function parse_value(parser::ParserState)::Proto.Value - span_start627 = span_start(parser) + span_start631 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1247 = 9 + _t1323 = 9 else if match_lookahead_literal(parser, "missing", 0) - _t1248 = 8 + _t1324 = 8 else if match_lookahead_literal(parser, "false", 0) - _t1249 = 9 + _t1325 = 9 else if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "datetime", 1) - _t1251 = 1 + _t1327 = 1 else if match_lookahead_literal(parser, "date", 1) - _t1252 = 0 + _t1328 = 0 else - _t1252 = -1 + _t1328 = -1 end - _t1251 = _t1252 + _t1327 = _t1328 end - _t1250 = _t1251 + _t1326 = _t1327 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1253 = 5 + _t1329 = 5 else if match_lookahead_terminal(parser, "STRING", 0) - _t1254 = 2 + _t1330 = 2 else if match_lookahead_terminal(parser, "INT128", 0) - _t1255 = 6 + _t1331 = 6 else if match_lookahead_terminal(parser, "INT", 0) - _t1256 = 3 + _t1332 = 3 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t1257 = 4 + _t1333 = 4 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t1258 = 7 + _t1334 = 7 else - _t1258 = -1 + _t1334 = -1 end - _t1257 = _t1258 + _t1333 = _t1334 end - _t1256 = _t1257 + _t1332 = _t1333 end - _t1255 = _t1256 + _t1331 = _t1332 end - _t1254 = _t1255 + _t1330 = _t1331 end - _t1253 = _t1254 + _t1329 = _t1330 end - _t1250 = _t1253 + _t1326 = _t1329 end - _t1249 = _t1250 + _t1325 = _t1326 end - _t1248 = _t1249 + _t1324 = _t1325 end - _t1247 = _t1248 - end - prediction617 = _t1247 - if prediction617 == 9 - _t1260 = parse_boolean_value(parser) - boolean_value626 = _t1260 - _t1261 = Proto.Value(value=OneOf(:boolean_value, boolean_value626)) - _t1259 = _t1261 + _t1323 = _t1324 + end + prediction621 = _t1323 + if prediction621 == 9 + push_path!(parser, 10) + _t1336 = parse_boolean_value(parser) + boolean_value630 = _t1336 + pop_path!(parser) + _t1337 = Proto.Value(value=OneOf(:boolean_value, boolean_value630)) + _t1335 = _t1337 else - if prediction617 == 8 + if prediction621 == 8 consume_literal!(parser, "missing") - _t1263 = Proto.MissingValue() - _t1264 = Proto.Value(value=OneOf(:missing_value, _t1263)) - _t1262 = _t1264 + _t1339 = Proto.MissingValue() + _t1340 = Proto.Value(value=OneOf(:missing_value, _t1339)) + _t1338 = _t1340 else - if prediction617 == 7 - decimal625 = consume_terminal!(parser, "DECIMAL") - _t1266 = Proto.Value(value=OneOf(:decimal_value, decimal625)) - _t1265 = _t1266 + if prediction621 == 7 + decimal629 = consume_terminal!(parser, "DECIMAL") + _t1342 = Proto.Value(value=OneOf(:decimal_value, decimal629)) + _t1341 = _t1342 else - if prediction617 == 6 - int128624 = consume_terminal!(parser, "INT128") - _t1268 = Proto.Value(value=OneOf(:int128_value, int128624)) - _t1267 = _t1268 + if prediction621 == 6 + int128628 = consume_terminal!(parser, "INT128") + _t1344 = Proto.Value(value=OneOf(:int128_value, int128628)) + _t1343 = _t1344 else - if prediction617 == 5 - uint128623 = consume_terminal!(parser, "UINT128") - _t1270 = Proto.Value(value=OneOf(:uint128_value, uint128623)) - _t1269 = _t1270 + if prediction621 == 5 + uint128627 = consume_terminal!(parser, "UINT128") + _t1346 = Proto.Value(value=OneOf(:uint128_value, uint128627)) + _t1345 = _t1346 else - if prediction617 == 4 - float622 = consume_terminal!(parser, "FLOAT") - _t1272 = Proto.Value(value=OneOf(:float_value, float622)) - _t1271 = _t1272 + if prediction621 == 4 + float626 = consume_terminal!(parser, "FLOAT") + _t1348 = Proto.Value(value=OneOf(:float_value, float626)) + _t1347 = _t1348 else - if prediction617 == 3 - int621 = consume_terminal!(parser, "INT") - _t1274 = Proto.Value(value=OneOf(:int_value, int621)) - _t1273 = _t1274 + if prediction621 == 3 + int625 = consume_terminal!(parser, "INT") + _t1350 = Proto.Value(value=OneOf(:int_value, int625)) + _t1349 = _t1350 else - if prediction617 == 2 - string620 = consume_terminal!(parser, "STRING") - _t1276 = Proto.Value(value=OneOf(:string_value, string620)) - _t1275 = _t1276 + if prediction621 == 2 + string624 = consume_terminal!(parser, "STRING") + _t1352 = Proto.Value(value=OneOf(:string_value, string624)) + _t1351 = _t1352 else - if prediction617 == 1 - _t1278 = parse_datetime(parser) - datetime619 = _t1278 - _t1279 = Proto.Value(value=OneOf(:datetime_value, datetime619)) - _t1277 = _t1279 + if prediction621 == 1 + push_path!(parser, 8) + _t1354 = parse_datetime(parser) + datetime623 = _t1354 + pop_path!(parser) + _t1355 = Proto.Value(value=OneOf(:datetime_value, datetime623)) + _t1353 = _t1355 else - if prediction617 == 0 - _t1281 = parse_date(parser) - date618 = _t1281 - _t1282 = Proto.Value(value=OneOf(:date_value, date618)) - _t1280 = _t1282 + if prediction621 == 0 + push_path!(parser, 7) + _t1357 = parse_date(parser) + date622 = _t1357 + pop_path!(parser) + _t1358 = Proto.Value(value=OneOf(:date_value, date622)) + _t1356 = _t1358 else throw(ParseError("Unexpected token in value" * ": " * string(lookahead(parser, 0)))) end - _t1277 = _t1280 + _t1353 = _t1356 end - _t1275 = _t1277 + _t1351 = _t1353 end - _t1273 = _t1275 + _t1349 = _t1351 end - _t1271 = _t1273 + _t1347 = _t1349 end - _t1269 = _t1271 + _t1345 = _t1347 end - _t1267 = _t1269 + _t1343 = _t1345 end - _t1265 = _t1267 + _t1341 = _t1343 end - _t1262 = _t1265 + _t1338 = _t1341 end - _t1259 = _t1262 + _t1335 = _t1338 end - result628 = _t1259 - record_span!(parser, span_start627) - return result628 + result632 = _t1335 + record_span!(parser, span_start631) + return result632 end function parse_date(parser::ParserState)::Proto.DateValue - span_start632 = span_start(parser) + span_start636 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "date") push_path!(parser, 1) - int629 = consume_terminal!(parser, "INT") + int633 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 2) - int_3630 = consume_terminal!(parser, "INT") + int_3634 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 3) - int_4631 = consume_terminal!(parser, "INT") + int_4635 = consume_terminal!(parser, "INT") pop_path!(parser) consume_literal!(parser, ")") - _t1283 = Proto.DateValue(year=Int32(int629), month=Int32(int_3630), day=Int32(int_4631)) - result633 = _t1283 - record_span!(parser, span_start632) - return result633 + _t1359 = Proto.DateValue(year=Int32(int633), month=Int32(int_3634), day=Int32(int_4635)) + result637 = _t1359 + record_span!(parser, span_start636) + return result637 end function parse_datetime(parser::ParserState)::Proto.DateTimeValue - span_start641 = span_start(parser) + span_start645 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "datetime") push_path!(parser, 1) - int634 = consume_terminal!(parser, "INT") + int638 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 2) - int_3635 = consume_terminal!(parser, "INT") + int_3639 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 3) - int_4636 = consume_terminal!(parser, "INT") + int_4640 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 4) - int_5637 = consume_terminal!(parser, "INT") + int_5641 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 5) - int_6638 = consume_terminal!(parser, "INT") + int_6642 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 6) - int_7639 = consume_terminal!(parser, "INT") + int_7643 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 7) if match_lookahead_terminal(parser, "INT", 0) - _t1284 = consume_terminal!(parser, "INT") + _t1360 = consume_terminal!(parser, "INT") else - _t1284 = nothing + _t1360 = nothing end - int_8640 = _t1284 + int_8644 = _t1360 pop_path!(parser) consume_literal!(parser, ")") - _t1285 = Proto.DateTimeValue(year=Int32(int634), month=Int32(int_3635), day=Int32(int_4636), hour=Int32(int_5637), minute=Int32(int_6638), second=Int32(int_7639), microsecond=Int32((!isnothing(int_8640) ? int_8640 : 0))) - result642 = _t1285 - record_span!(parser, span_start641) - return result642 + _t1361 = Proto.DateTimeValue(year=Int32(int638), month=Int32(int_3639), day=Int32(int_4640), hour=Int32(int_5641), minute=Int32(int_6642), second=Int32(int_7643), microsecond=Int32((!isnothing(int_8644) ? int_8644 : 0))) + result646 = _t1361 + record_span!(parser, span_start645) + return result646 end function parse_boolean_value(parser::ParserState)::Bool - span_start644 = span_start(parser) + span_start648 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1286 = 0 + _t1362 = 0 else if match_lookahead_literal(parser, "false", 0) - _t1287 = 1 + _t1363 = 1 else - _t1287 = -1 + _t1363 = -1 end - _t1286 = _t1287 + _t1362 = _t1363 end - prediction643 = _t1286 - if prediction643 == 1 + prediction647 = _t1362 + if prediction647 == 1 consume_literal!(parser, "false") - _t1288 = false + _t1364 = false else - if prediction643 == 0 + if prediction647 == 0 consume_literal!(parser, "true") - _t1289 = true + _t1365 = true else throw(ParseError("Unexpected token in boolean_value" * ": " * string(lookahead(parser, 0)))) end - _t1288 = _t1289 + _t1364 = _t1365 end - result645 = _t1288 - record_span!(parser, span_start644) - return result645 + result649 = _t1364 + record_span!(parser, span_start648) + return result649 end function parse_sync(parser::ParserState)::Proto.Sync - span_start654 = span_start(parser) + span_start658 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sync") push_path!(parser, 1) - xs650 = Proto.FragmentId[] - cond651 = match_lookahead_literal(parser, ":", 0) - idx652 = 0 - while cond651 - push_path!(parser, idx652) - _t1290 = parse_fragment_id(parser) - item653 = _t1290 + xs654 = Proto.FragmentId[] + cond655 = match_lookahead_literal(parser, ":", 0) + idx656 = 0 + while cond655 + push_path!(parser, idx656) + _t1366 = parse_fragment_id(parser) + item657 = _t1366 pop_path!(parser) - push!(xs650, item653) - idx652 = (idx652 + 1) - cond651 = match_lookahead_literal(parser, ":", 0) + push!(xs654, item657) + idx656 = (idx656 + 1) + cond655 = match_lookahead_literal(parser, ":", 0) end - fragment_ids649 = xs650 + fragment_ids653 = xs654 pop_path!(parser) consume_literal!(parser, ")") - _t1291 = Proto.Sync(fragments=fragment_ids649) - result655 = _t1291 - record_span!(parser, span_start654) - return result655 + _t1367 = Proto.Sync(fragments=fragment_ids653) + result659 = _t1367 + record_span!(parser, span_start658) + return result659 end function parse_fragment_id(parser::ParserState)::Proto.FragmentId - span_start657 = span_start(parser) + span_start661 = span_start(parser) consume_literal!(parser, ":") - symbol656 = consume_terminal!(parser, "SYMBOL") - result658 = Proto.FragmentId(Vector{UInt8}(symbol656)) - record_span!(parser, span_start657) - return result658 + symbol660 = consume_terminal!(parser, "SYMBOL") + result662 = Proto.FragmentId(Vector{UInt8}(symbol660)) + record_span!(parser, span_start661) + return result662 end function parse_epoch(parser::ParserState)::Proto.Epoch - span_start661 = span_start(parser) + span_start665 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "epoch") push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "writes", 1)) - _t1293 = parse_epoch_writes(parser) - _t1292 = _t1293 + _t1369 = parse_epoch_writes(parser) + _t1368 = _t1369 else - _t1292 = nothing + _t1368 = nothing end - epoch_writes659 = _t1292 + epoch_writes663 = _t1368 pop_path!(parser) push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t1295 = parse_epoch_reads(parser) - _t1294 = _t1295 + _t1371 = parse_epoch_reads(parser) + _t1370 = _t1371 else - _t1294 = nothing + _t1370 = nothing end - epoch_reads660 = _t1294 + epoch_reads664 = _t1370 pop_path!(parser) consume_literal!(parser, ")") - _t1296 = Proto.Epoch(writes=(!isnothing(epoch_writes659) ? epoch_writes659 : Proto.Write[]), reads=(!isnothing(epoch_reads660) ? epoch_reads660 : Proto.Read[])) - result662 = _t1296 - record_span!(parser, span_start661) - return result662 + _t1372 = Proto.Epoch(writes=(!isnothing(epoch_writes663) ? epoch_writes663 : Proto.Write[]), reads=(!isnothing(epoch_reads664) ? epoch_reads664 : Proto.Read[])) + result666 = _t1372 + record_span!(parser, span_start665) + return result666 end function parse_epoch_writes(parser::ParserState)::Vector{Proto.Write} - span_start667 = span_start(parser) + span_start675 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "writes") - xs663 = Proto.Write[] - cond664 = match_lookahead_literal(parser, "(", 0) - while cond664 - _t1297 = parse_write(parser) - item665 = _t1297 - push!(xs663, item665) - cond664 = match_lookahead_literal(parser, "(", 0) + xs671 = Proto.Write[] + cond672 = match_lookahead_literal(parser, "(", 0) + idx673 = 0 + while cond672 + push_path!(parser, idx673) + _t1373 = parse_write(parser) + item674 = _t1373 + pop_path!(parser) + push!(xs671, item674) + idx673 = (idx673 + 1) + cond672 = match_lookahead_literal(parser, "(", 0) end - writes666 = xs663 + writes670 = xs671 consume_literal!(parser, ")") - result668 = writes666 - record_span!(parser, span_start667) - return result668 + result676 = writes670 + record_span!(parser, span_start675) + return result676 end function parse_write(parser::ParserState)::Proto.Write - span_start674 = span_start(parser) + span_start682 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "undefine", 1) - _t1299 = 1 + _t1375 = 1 else if match_lookahead_literal(parser, "snapshot", 1) - _t1300 = 3 + _t1376 = 3 else if match_lookahead_literal(parser, "define", 1) - _t1301 = 0 + _t1377 = 0 else if match_lookahead_literal(parser, "context", 1) - _t1302 = 2 + _t1378 = 2 else - _t1302 = -1 + _t1378 = -1 end - _t1301 = _t1302 + _t1377 = _t1378 end - _t1300 = _t1301 + _t1376 = _t1377 end - _t1299 = _t1300 + _t1375 = _t1376 end - _t1298 = _t1299 + _t1374 = _t1375 else - _t1298 = -1 - end - prediction669 = _t1298 - if prediction669 == 3 - _t1304 = parse_snapshot(parser) - snapshot673 = _t1304 - _t1305 = Proto.Write(write_type=OneOf(:snapshot, snapshot673)) - _t1303 = _t1305 + _t1374 = -1 + end + prediction677 = _t1374 + if prediction677 == 3 + push_path!(parser, 5) + _t1380 = parse_snapshot(parser) + snapshot681 = _t1380 + pop_path!(parser) + _t1381 = Proto.Write(write_type=OneOf(:snapshot, snapshot681)) + _t1379 = _t1381 else - if prediction669 == 2 - _t1307 = parse_context(parser) - context672 = _t1307 - _t1308 = Proto.Write(write_type=OneOf(:context, context672)) - _t1306 = _t1308 + if prediction677 == 2 + push_path!(parser, 3) + _t1383 = parse_context(parser) + context680 = _t1383 + pop_path!(parser) + _t1384 = Proto.Write(write_type=OneOf(:context, context680)) + _t1382 = _t1384 else - if prediction669 == 1 - _t1310 = parse_undefine(parser) - undefine671 = _t1310 - _t1311 = Proto.Write(write_type=OneOf(:undefine, undefine671)) - _t1309 = _t1311 + if prediction677 == 1 + push_path!(parser, 2) + _t1386 = parse_undefine(parser) + undefine679 = _t1386 + pop_path!(parser) + _t1387 = Proto.Write(write_type=OneOf(:undefine, undefine679)) + _t1385 = _t1387 else - if prediction669 == 0 - _t1313 = parse_define(parser) - define670 = _t1313 - _t1314 = Proto.Write(write_type=OneOf(:define, define670)) - _t1312 = _t1314 + if prediction677 == 0 + push_path!(parser, 1) + _t1389 = parse_define(parser) + define678 = _t1389 + pop_path!(parser) + _t1390 = Proto.Write(write_type=OneOf(:define, define678)) + _t1388 = _t1390 else throw(ParseError("Unexpected token in write" * ": " * string(lookahead(parser, 0)))) end - _t1309 = _t1312 + _t1385 = _t1388 end - _t1306 = _t1309 + _t1382 = _t1385 end - _t1303 = _t1306 + _t1379 = _t1382 end - result675 = _t1303 - record_span!(parser, span_start674) - return result675 + result683 = _t1379 + record_span!(parser, span_start682) + return result683 end function parse_define(parser::ParserState)::Proto.Define - span_start677 = span_start(parser) + span_start685 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "define") push_path!(parser, 1) - _t1315 = parse_fragment(parser) - fragment676 = _t1315 + _t1391 = parse_fragment(parser) + fragment684 = _t1391 pop_path!(parser) consume_literal!(parser, ")") - _t1316 = Proto.Define(fragment=fragment676) - result678 = _t1316 - record_span!(parser, span_start677) - return result678 + _t1392 = Proto.Define(fragment=fragment684) + result686 = _t1392 + record_span!(parser, span_start685) + return result686 end function parse_fragment(parser::ParserState)::Proto.Fragment - span_start684 = span_start(parser) + span_start696 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "fragment") - _t1317 = parse_new_fragment_id(parser) - new_fragment_id679 = _t1317 - xs680 = Proto.Declaration[] - cond681 = match_lookahead_literal(parser, "(", 0) - while cond681 - _t1318 = parse_declaration(parser) - item682 = _t1318 - push!(xs680, item682) - cond681 = match_lookahead_literal(parser, "(", 0) + _t1393 = parse_new_fragment_id(parser) + new_fragment_id687 = _t1393 + push_path!(parser, 2) + xs692 = Proto.Declaration[] + cond693 = match_lookahead_literal(parser, "(", 0) + idx694 = 0 + while cond693 + push_path!(parser, idx694) + _t1394 = parse_declaration(parser) + item695 = _t1394 + pop_path!(parser) + push!(xs692, item695) + idx694 = (idx694 + 1) + cond693 = match_lookahead_literal(parser, "(", 0) end - declarations683 = xs680 + declarations691 = xs692 + pop_path!(parser) consume_literal!(parser, ")") - result685 = construct_fragment(parser, new_fragment_id679, declarations683) - record_span!(parser, span_start684) - return result685 + result697 = construct_fragment(parser, new_fragment_id687, declarations691) + record_span!(parser, span_start696) + return result697 end function parse_new_fragment_id(parser::ParserState)::Proto.FragmentId - span_start687 = span_start(parser) - _t1319 = parse_fragment_id(parser) - fragment_id686 = _t1319 - start_fragment!(parser, fragment_id686) - result688 = fragment_id686 - record_span!(parser, span_start687) - return result688 + span_start699 = span_start(parser) + _t1395 = parse_fragment_id(parser) + fragment_id698 = _t1395 + start_fragment!(parser, fragment_id698) + result700 = fragment_id698 + record_span!(parser, span_start699) + return result700 end function parse_declaration(parser::ParserState)::Proto.Declaration - span_start694 = span_start(parser) + span_start706 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t1321 = 3 + _t1397 = 3 else if match_lookahead_literal(parser, "functional_dependency", 1) - _t1322 = 2 + _t1398 = 2 else if match_lookahead_literal(parser, "def", 1) - _t1323 = 0 + _t1399 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t1324 = 3 + _t1400 = 3 else if match_lookahead_literal(parser, "betree_relation", 1) - _t1325 = 3 + _t1401 = 3 else if match_lookahead_literal(parser, "algorithm", 1) - _t1326 = 1 + _t1402 = 1 else - _t1326 = -1 + _t1402 = -1 end - _t1325 = _t1326 + _t1401 = _t1402 end - _t1324 = _t1325 + _t1400 = _t1401 end - _t1323 = _t1324 + _t1399 = _t1400 end - _t1322 = _t1323 + _t1398 = _t1399 end - _t1321 = _t1322 + _t1397 = _t1398 end - _t1320 = _t1321 + _t1396 = _t1397 else - _t1320 = -1 - end - prediction689 = _t1320 - if prediction689 == 3 - _t1328 = parse_data(parser) - data693 = _t1328 - _t1329 = Proto.Declaration(declaration_type=OneOf(:data, data693)) - _t1327 = _t1329 + _t1396 = -1 + end + prediction701 = _t1396 + if prediction701 == 3 + push_path!(parser, 4) + _t1404 = parse_data(parser) + data705 = _t1404 + pop_path!(parser) + _t1405 = Proto.Declaration(declaration_type=OneOf(:data, data705)) + _t1403 = _t1405 else - if prediction689 == 2 - _t1331 = parse_constraint(parser) - constraint692 = _t1331 - _t1332 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint692)) - _t1330 = _t1332 + if prediction701 == 2 + push_path!(parser, 3) + _t1407 = parse_constraint(parser) + constraint704 = _t1407 + pop_path!(parser) + _t1408 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint704)) + _t1406 = _t1408 else - if prediction689 == 1 - _t1334 = parse_algorithm(parser) - algorithm691 = _t1334 - _t1335 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm691)) - _t1333 = _t1335 + if prediction701 == 1 + push_path!(parser, 2) + _t1410 = parse_algorithm(parser) + algorithm703 = _t1410 + pop_path!(parser) + _t1411 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm703)) + _t1409 = _t1411 else - if prediction689 == 0 - _t1337 = parse_def(parser) - def690 = _t1337 - _t1338 = Proto.Declaration(declaration_type=OneOf(:def, def690)) - _t1336 = _t1338 + if prediction701 == 0 + push_path!(parser, 1) + _t1413 = parse_def(parser) + def702 = _t1413 + pop_path!(parser) + _t1414 = Proto.Declaration(declaration_type=OneOf(:def, def702)) + _t1412 = _t1414 else throw(ParseError("Unexpected token in declaration" * ": " * string(lookahead(parser, 0)))) end - _t1333 = _t1336 + _t1409 = _t1412 end - _t1330 = _t1333 + _t1406 = _t1409 end - _t1327 = _t1330 + _t1403 = _t1406 end - result695 = _t1327 - record_span!(parser, span_start694) - return result695 + result707 = _t1403 + record_span!(parser, span_start706) + return result707 end function parse_def(parser::ParserState)::Proto.Def - span_start699 = span_start(parser) + span_start711 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "def") push_path!(parser, 1) - _t1339 = parse_relation_id(parser) - relation_id696 = _t1339 + _t1415 = parse_relation_id(parser) + relation_id708 = _t1415 pop_path!(parser) push_path!(parser, 2) - _t1340 = parse_abstraction(parser) - abstraction697 = _t1340 + _t1416 = parse_abstraction(parser) + abstraction709 = _t1416 pop_path!(parser) push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1342 = parse_attrs(parser) - _t1341 = _t1342 + _t1418 = parse_attrs(parser) + _t1417 = _t1418 else - _t1341 = nothing + _t1417 = nothing end - attrs698 = _t1341 + attrs710 = _t1417 pop_path!(parser) consume_literal!(parser, ")") - _t1343 = Proto.Def(name=relation_id696, body=abstraction697, attrs=(!isnothing(attrs698) ? attrs698 : Proto.Attribute[])) - result700 = _t1343 - record_span!(parser, span_start699) - return result700 + _t1419 = Proto.Def(name=relation_id708, body=abstraction709, attrs=(!isnothing(attrs710) ? attrs710 : Proto.Attribute[])) + result712 = _t1419 + record_span!(parser, span_start711) + return result712 end function parse_relation_id(parser::ParserState)::Proto.RelationId - span_start704 = span_start(parser) + span_start716 = span_start(parser) if match_lookahead_literal(parser, ":", 0) - _t1344 = 0 + _t1420 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1345 = 1 + _t1421 = 1 else - _t1345 = -1 + _t1421 = -1 end - _t1344 = _t1345 + _t1420 = _t1421 end - prediction701 = _t1344 - if prediction701 == 1 - uint128703 = consume_terminal!(parser, "UINT128") - _t1346 = Proto.RelationId(uint128703.low, uint128703.high) + prediction713 = _t1420 + if prediction713 == 1 + uint128715 = consume_terminal!(parser, "UINT128") + _t1422 = Proto.RelationId(uint128715.low, uint128715.high) else - if prediction701 == 0 + if prediction713 == 0 consume_literal!(parser, ":") - symbol702 = consume_terminal!(parser, "SYMBOL") - _t1347 = relation_id_from_string(parser, symbol702) + symbol714 = consume_terminal!(parser, "SYMBOL") + _t1423 = relation_id_from_string(parser, symbol714) else throw(ParseError("Unexpected token in relation_id" * ": " * string(lookahead(parser, 0)))) end - _t1346 = _t1347 + _t1422 = _t1423 end - result705 = _t1346 - record_span!(parser, span_start704) - return result705 + result717 = _t1422 + record_span!(parser, span_start716) + return result717 end function parse_abstraction(parser::ParserState)::Proto.Abstraction - span_start708 = span_start(parser) + span_start720 = span_start(parser) consume_literal!(parser, "(") - _t1348 = parse_bindings(parser) - bindings706 = _t1348 + _t1424 = parse_bindings(parser) + bindings718 = _t1424 push_path!(parser, 2) - _t1349 = parse_formula(parser) - formula707 = _t1349 + _t1425 = parse_formula(parser) + formula719 = _t1425 pop_path!(parser) consume_literal!(parser, ")") - _t1350 = Proto.Abstraction(vars=vcat(bindings706[1], !isnothing(bindings706[2]) ? bindings706[2] : []), value=formula707) - result709 = _t1350 - record_span!(parser, span_start708) - return result709 + _t1426 = Proto.Abstraction(vars=vcat(bindings718[1], !isnothing(bindings718[2]) ? bindings718[2] : []), value=formula719) + result721 = _t1426 + record_span!(parser, span_start720) + return result721 end function parse_bindings(parser::ParserState)::Tuple{Vector{Proto.Binding}, Vector{Proto.Binding}} - span_start715 = span_start(parser) + span_start731 = span_start(parser) consume_literal!(parser, "[") - xs710 = Proto.Binding[] - cond711 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond711 - _t1351 = parse_binding(parser) - item712 = _t1351 - push!(xs710, item712) - cond711 = match_lookahead_terminal(parser, "SYMBOL", 0) - end - bindings713 = xs710 + xs726 = Proto.Binding[] + cond727 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx728 = 0 + while cond727 + push_path!(parser, idx728) + _t1427 = parse_binding(parser) + item729 = _t1427 + pop_path!(parser) + push!(xs726, item729) + idx728 = (idx728 + 1) + cond727 = match_lookahead_terminal(parser, "SYMBOL", 0) + end + bindings725 = xs726 if match_lookahead_literal(parser, "|", 0) - _t1353 = parse_value_bindings(parser) - _t1352 = _t1353 + _t1429 = parse_value_bindings(parser) + _t1428 = _t1429 else - _t1352 = nothing + _t1428 = nothing end - value_bindings714 = _t1352 + value_bindings730 = _t1428 consume_literal!(parser, "]") - result716 = (bindings713, (!isnothing(value_bindings714) ? value_bindings714 : Proto.Binding[]),) - record_span!(parser, span_start715) - return result716 + result732 = (bindings725, (!isnothing(value_bindings730) ? value_bindings730 : Proto.Binding[]),) + record_span!(parser, span_start731) + return result732 end function parse_binding(parser::ParserState)::Proto.Binding - span_start719 = span_start(parser) - symbol717 = consume_terminal!(parser, "SYMBOL") + span_start735 = span_start(parser) + symbol733 = consume_terminal!(parser, "SYMBOL") consume_literal!(parser, "::") push_path!(parser, 2) - _t1354 = parse_type(parser) - type718 = _t1354 + _t1430 = parse_type(parser) + type734 = _t1430 pop_path!(parser) - _t1355 = Proto.Var(name=symbol717) - _t1356 = Proto.Binding(var=_t1355, var"#type"=type718) - result720 = _t1356 - record_span!(parser, span_start719) - return result720 + _t1431 = Proto.Var(name=symbol733) + _t1432 = Proto.Binding(var=_t1431, var"#type"=type734) + result736 = _t1432 + record_span!(parser, span_start735) + return result736 end function parse_type(parser::ParserState)::Proto.var"#Type" - span_start733 = span_start(parser) + span_start749 = span_start(parser) if match_lookahead_literal(parser, "UNKNOWN", 0) - _t1357 = 0 + _t1433 = 0 else if match_lookahead_literal(parser, "UINT128", 0) - _t1358 = 4 + _t1434 = 4 else if match_lookahead_literal(parser, "STRING", 0) - _t1359 = 1 + _t1435 = 1 else if match_lookahead_literal(parser, "MISSING", 0) - _t1360 = 8 + _t1436 = 8 else if match_lookahead_literal(parser, "INT128", 0) - _t1361 = 5 + _t1437 = 5 else if match_lookahead_literal(parser, "INT", 0) - _t1362 = 2 + _t1438 = 2 else if match_lookahead_literal(parser, "FLOAT", 0) - _t1363 = 3 + _t1439 = 3 else if match_lookahead_literal(parser, "DATETIME", 0) - _t1364 = 7 + _t1440 = 7 else if match_lookahead_literal(parser, "DATE", 0) - _t1365 = 6 + _t1441 = 6 else if match_lookahead_literal(parser, "BOOLEAN", 0) - _t1366 = 10 + _t1442 = 10 else if match_lookahead_literal(parser, "(", 0) - _t1367 = 9 + _t1443 = 9 else - _t1367 = -1 + _t1443 = -1 end - _t1366 = _t1367 + _t1442 = _t1443 end - _t1365 = _t1366 + _t1441 = _t1442 end - _t1364 = _t1365 + _t1440 = _t1441 end - _t1363 = _t1364 + _t1439 = _t1440 end - _t1362 = _t1363 + _t1438 = _t1439 end - _t1361 = _t1362 + _t1437 = _t1438 end - _t1360 = _t1361 + _t1436 = _t1437 end - _t1359 = _t1360 + _t1435 = _t1436 end - _t1358 = _t1359 + _t1434 = _t1435 end - _t1357 = _t1358 - end - prediction721 = _t1357 - if prediction721 == 10 - _t1369 = parse_boolean_type(parser) - boolean_type732 = _t1369 - _t1370 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type732)) - _t1368 = _t1370 + _t1433 = _t1434 + end + prediction737 = _t1433 + if prediction737 == 10 + push_path!(parser, 11) + _t1445 = parse_boolean_type(parser) + boolean_type748 = _t1445 + pop_path!(parser) + _t1446 = Proto.var"#Type"(var"#type"=OneOf(:boolean_type, boolean_type748)) + _t1444 = _t1446 else - if prediction721 == 9 - _t1372 = parse_decimal_type(parser) - decimal_type731 = _t1372 - _t1373 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type731)) - _t1371 = _t1373 + if prediction737 == 9 + push_path!(parser, 10) + _t1448 = parse_decimal_type(parser) + decimal_type747 = _t1448 + pop_path!(parser) + _t1449 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type747)) + _t1447 = _t1449 else - if prediction721 == 8 - _t1375 = parse_missing_type(parser) - missing_type730 = _t1375 - _t1376 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type730)) - _t1374 = _t1376 + if prediction737 == 8 + push_path!(parser, 9) + _t1451 = parse_missing_type(parser) + missing_type746 = _t1451 + pop_path!(parser) + _t1452 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type746)) + _t1450 = _t1452 else - if prediction721 == 7 - _t1378 = parse_datetime_type(parser) - datetime_type729 = _t1378 - _t1379 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type729)) - _t1377 = _t1379 + if prediction737 == 7 + push_path!(parser, 8) + _t1454 = parse_datetime_type(parser) + datetime_type745 = _t1454 + pop_path!(parser) + _t1455 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type745)) + _t1453 = _t1455 else - if prediction721 == 6 - _t1381 = parse_date_type(parser) - date_type728 = _t1381 - _t1382 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type728)) - _t1380 = _t1382 + if prediction737 == 6 + push_path!(parser, 7) + _t1457 = parse_date_type(parser) + date_type744 = _t1457 + pop_path!(parser) + _t1458 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type744)) + _t1456 = _t1458 else - if prediction721 == 5 - _t1384 = parse_int128_type(parser) - int128_type727 = _t1384 - _t1385 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type727)) - _t1383 = _t1385 + if prediction737 == 5 + push_path!(parser, 6) + _t1460 = parse_int128_type(parser) + int128_type743 = _t1460 + pop_path!(parser) + _t1461 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type743)) + _t1459 = _t1461 else - if prediction721 == 4 - _t1387 = parse_uint128_type(parser) - uint128_type726 = _t1387 - _t1388 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type726)) - _t1386 = _t1388 + if prediction737 == 4 + push_path!(parser, 5) + _t1463 = parse_uint128_type(parser) + uint128_type742 = _t1463 + pop_path!(parser) + _t1464 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type742)) + _t1462 = _t1464 else - if prediction721 == 3 - _t1390 = parse_float_type(parser) - float_type725 = _t1390 - _t1391 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type725)) - _t1389 = _t1391 + if prediction737 == 3 + push_path!(parser, 4) + _t1466 = parse_float_type(parser) + float_type741 = _t1466 + pop_path!(parser) + _t1467 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type741)) + _t1465 = _t1467 else - if prediction721 == 2 - _t1393 = parse_int_type(parser) - int_type724 = _t1393 - _t1394 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type724)) - _t1392 = _t1394 + if prediction737 == 2 + push_path!(parser, 3) + _t1469 = parse_int_type(parser) + int_type740 = _t1469 + pop_path!(parser) + _t1470 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type740)) + _t1468 = _t1470 else - if prediction721 == 1 - _t1396 = parse_string_type(parser) - string_type723 = _t1396 - _t1397 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type723)) - _t1395 = _t1397 + if prediction737 == 1 + push_path!(parser, 2) + _t1472 = parse_string_type(parser) + string_type739 = _t1472 + pop_path!(parser) + _t1473 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type739)) + _t1471 = _t1473 else - if prediction721 == 0 - _t1399 = parse_unspecified_type(parser) - unspecified_type722 = _t1399 - _t1400 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type722)) - _t1398 = _t1400 + if prediction737 == 0 + push_path!(parser, 1) + _t1475 = parse_unspecified_type(parser) + unspecified_type738 = _t1475 + pop_path!(parser) + _t1476 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type738)) + _t1474 = _t1476 else throw(ParseError("Unexpected token in type" * ": " * string(lookahead(parser, 0)))) end - _t1395 = _t1398 + _t1471 = _t1474 end - _t1392 = _t1395 + _t1468 = _t1471 end - _t1389 = _t1392 + _t1465 = _t1468 end - _t1386 = _t1389 + _t1462 = _t1465 end - _t1383 = _t1386 + _t1459 = _t1462 end - _t1380 = _t1383 + _t1456 = _t1459 end - _t1377 = _t1380 + _t1453 = _t1456 end - _t1374 = _t1377 + _t1450 = _t1453 end - _t1371 = _t1374 + _t1447 = _t1450 end - _t1368 = _t1371 + _t1444 = _t1447 end - result734 = _t1368 - record_span!(parser, span_start733) - return result734 + result750 = _t1444 + record_span!(parser, span_start749) + return result750 end function parse_unspecified_type(parser::ParserState)::Proto.UnspecifiedType - span_start735 = span_start(parser) + span_start751 = span_start(parser) consume_literal!(parser, "UNKNOWN") - _t1401 = Proto.UnspecifiedType() - result736 = _t1401 - record_span!(parser, span_start735) - return result736 + _t1477 = Proto.UnspecifiedType() + result752 = _t1477 + record_span!(parser, span_start751) + return result752 end function parse_string_type(parser::ParserState)::Proto.StringType - span_start737 = span_start(parser) + span_start753 = span_start(parser) consume_literal!(parser, "STRING") - _t1402 = Proto.StringType() - result738 = _t1402 - record_span!(parser, span_start737) - return result738 + _t1478 = Proto.StringType() + result754 = _t1478 + record_span!(parser, span_start753) + return result754 end function parse_int_type(parser::ParserState)::Proto.IntType - span_start739 = span_start(parser) + span_start755 = span_start(parser) consume_literal!(parser, "INT") - _t1403 = Proto.IntType() - result740 = _t1403 - record_span!(parser, span_start739) - return result740 + _t1479 = Proto.IntType() + result756 = _t1479 + record_span!(parser, span_start755) + return result756 end function parse_float_type(parser::ParserState)::Proto.FloatType - span_start741 = span_start(parser) + span_start757 = span_start(parser) consume_literal!(parser, "FLOAT") - _t1404 = Proto.FloatType() - result742 = _t1404 - record_span!(parser, span_start741) - return result742 + _t1480 = Proto.FloatType() + result758 = _t1480 + record_span!(parser, span_start757) + return result758 end function parse_uint128_type(parser::ParserState)::Proto.UInt128Type - span_start743 = span_start(parser) + span_start759 = span_start(parser) consume_literal!(parser, "UINT128") - _t1405 = Proto.UInt128Type() - result744 = _t1405 - record_span!(parser, span_start743) - return result744 + _t1481 = Proto.UInt128Type() + result760 = _t1481 + record_span!(parser, span_start759) + return result760 end function parse_int128_type(parser::ParserState)::Proto.Int128Type - span_start745 = span_start(parser) + span_start761 = span_start(parser) consume_literal!(parser, "INT128") - _t1406 = Proto.Int128Type() - result746 = _t1406 - record_span!(parser, span_start745) - return result746 + _t1482 = Proto.Int128Type() + result762 = _t1482 + record_span!(parser, span_start761) + return result762 end function parse_date_type(parser::ParserState)::Proto.DateType - span_start747 = span_start(parser) + span_start763 = span_start(parser) consume_literal!(parser, "DATE") - _t1407 = Proto.DateType() - result748 = _t1407 - record_span!(parser, span_start747) - return result748 + _t1483 = Proto.DateType() + result764 = _t1483 + record_span!(parser, span_start763) + return result764 end function parse_datetime_type(parser::ParserState)::Proto.DateTimeType - span_start749 = span_start(parser) + span_start765 = span_start(parser) consume_literal!(parser, "DATETIME") - _t1408 = Proto.DateTimeType() - result750 = _t1408 - record_span!(parser, span_start749) - return result750 + _t1484 = Proto.DateTimeType() + result766 = _t1484 + record_span!(parser, span_start765) + return result766 end function parse_missing_type(parser::ParserState)::Proto.MissingType - span_start751 = span_start(parser) + span_start767 = span_start(parser) consume_literal!(parser, "MISSING") - _t1409 = Proto.MissingType() - result752 = _t1409 - record_span!(parser, span_start751) - return result752 + _t1485 = Proto.MissingType() + result768 = _t1485 + record_span!(parser, span_start767) + return result768 end function parse_decimal_type(parser::ParserState)::Proto.DecimalType - span_start755 = span_start(parser) + span_start771 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "DECIMAL") push_path!(parser, 1) - int753 = consume_terminal!(parser, "INT") + int769 = consume_terminal!(parser, "INT") pop_path!(parser) push_path!(parser, 2) - int_3754 = consume_terminal!(parser, "INT") + int_3770 = consume_terminal!(parser, "INT") pop_path!(parser) consume_literal!(parser, ")") - _t1410 = Proto.DecimalType(precision=Int32(int753), scale=Int32(int_3754)) - result756 = _t1410 - record_span!(parser, span_start755) - return result756 + _t1486 = Proto.DecimalType(precision=Int32(int769), scale=Int32(int_3770)) + result772 = _t1486 + record_span!(parser, span_start771) + return result772 end function parse_boolean_type(parser::ParserState)::Proto.BooleanType - span_start757 = span_start(parser) + span_start773 = span_start(parser) consume_literal!(parser, "BOOLEAN") - _t1411 = Proto.BooleanType() - result758 = _t1411 - record_span!(parser, span_start757) - return result758 + _t1487 = Proto.BooleanType() + result774 = _t1487 + record_span!(parser, span_start773) + return result774 end function parse_value_bindings(parser::ParserState)::Vector{Proto.Binding} - span_start763 = span_start(parser) + span_start783 = span_start(parser) consume_literal!(parser, "|") - xs759 = Proto.Binding[] - cond760 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond760 - _t1412 = parse_binding(parser) - item761 = _t1412 - push!(xs759, item761) - cond760 = match_lookahead_terminal(parser, "SYMBOL", 0) - end - bindings762 = xs759 - result764 = bindings762 - record_span!(parser, span_start763) - return result764 + xs779 = Proto.Binding[] + cond780 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx781 = 0 + while cond780 + push_path!(parser, idx781) + _t1488 = parse_binding(parser) + item782 = _t1488 + pop_path!(parser) + push!(xs779, item782) + idx781 = (idx781 + 1) + cond780 = match_lookahead_terminal(parser, "SYMBOL", 0) + end + bindings778 = xs779 + result784 = bindings778 + record_span!(parser, span_start783) + return result784 end function parse_formula(parser::ParserState)::Proto.Formula - span_start779 = span_start(parser) + span_start799 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "true", 1) - _t1414 = 0 + _t1490 = 0 else if match_lookahead_literal(parser, "relatom", 1) - _t1415 = 11 + _t1491 = 11 else if match_lookahead_literal(parser, "reduce", 1) - _t1416 = 3 + _t1492 = 3 else if match_lookahead_literal(parser, "primitive", 1) - _t1417 = 10 + _t1493 = 10 else if match_lookahead_literal(parser, "pragma", 1) - _t1418 = 9 + _t1494 = 9 else if match_lookahead_literal(parser, "or", 1) - _t1419 = 5 + _t1495 = 5 else if match_lookahead_literal(parser, "not", 1) - _t1420 = 6 + _t1496 = 6 else if match_lookahead_literal(parser, "ffi", 1) - _t1421 = 7 + _t1497 = 7 else if match_lookahead_literal(parser, "false", 1) - _t1422 = 1 + _t1498 = 1 else if match_lookahead_literal(parser, "exists", 1) - _t1423 = 2 + _t1499 = 2 else if match_lookahead_literal(parser, "cast", 1) - _t1424 = 12 + _t1500 = 12 else if match_lookahead_literal(parser, "atom", 1) - _t1425 = 8 + _t1501 = 8 else if match_lookahead_literal(parser, "and", 1) - _t1426 = 4 + _t1502 = 4 else if match_lookahead_literal(parser, ">=", 1) - _t1427 = 10 + _t1503 = 10 else if match_lookahead_literal(parser, ">", 1) - _t1428 = 10 + _t1504 = 10 else if match_lookahead_literal(parser, "=", 1) - _t1429 = 10 + _t1505 = 10 else if match_lookahead_literal(parser, "<=", 1) - _t1430 = 10 + _t1506 = 10 else if match_lookahead_literal(parser, "<", 1) - _t1431 = 10 + _t1507 = 10 else if match_lookahead_literal(parser, "/", 1) - _t1432 = 10 + _t1508 = 10 else if match_lookahead_literal(parser, "-", 1) - _t1433 = 10 + _t1509 = 10 else if match_lookahead_literal(parser, "+", 1) - _t1434 = 10 + _t1510 = 10 else if match_lookahead_literal(parser, "*", 1) - _t1435 = 10 + _t1511 = 10 else - _t1435 = -1 + _t1511 = -1 end - _t1434 = _t1435 + _t1510 = _t1511 end - _t1433 = _t1434 + _t1509 = _t1510 end - _t1432 = _t1433 + _t1508 = _t1509 end - _t1431 = _t1432 + _t1507 = _t1508 end - _t1430 = _t1431 + _t1506 = _t1507 end - _t1429 = _t1430 + _t1505 = _t1506 end - _t1428 = _t1429 + _t1504 = _t1505 end - _t1427 = _t1428 + _t1503 = _t1504 end - _t1426 = _t1427 + _t1502 = _t1503 end - _t1425 = _t1426 + _t1501 = _t1502 end - _t1424 = _t1425 + _t1500 = _t1501 end - _t1423 = _t1424 + _t1499 = _t1500 end - _t1422 = _t1423 + _t1498 = _t1499 end - _t1421 = _t1422 + _t1497 = _t1498 end - _t1420 = _t1421 + _t1496 = _t1497 end - _t1419 = _t1420 + _t1495 = _t1496 end - _t1418 = _t1419 + _t1494 = _t1495 end - _t1417 = _t1418 + _t1493 = _t1494 end - _t1416 = _t1417 + _t1492 = _t1493 end - _t1415 = _t1416 + _t1491 = _t1492 end - _t1414 = _t1415 + _t1490 = _t1491 end - _t1413 = _t1414 + _t1489 = _t1490 else - _t1413 = -1 - end - prediction765 = _t1413 - if prediction765 == 12 - _t1437 = parse_cast(parser) - cast778 = _t1437 - _t1438 = Proto.Formula(formula_type=OneOf(:cast, cast778)) - _t1436 = _t1438 + _t1489 = -1 + end + prediction785 = _t1489 + if prediction785 == 12 + push_path!(parser, 11) + _t1513 = parse_cast(parser) + cast798 = _t1513 + pop_path!(parser) + _t1514 = Proto.Formula(formula_type=OneOf(:cast, cast798)) + _t1512 = _t1514 else - if prediction765 == 11 - _t1440 = parse_rel_atom(parser) - rel_atom777 = _t1440 - _t1441 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom777)) - _t1439 = _t1441 + if prediction785 == 11 + push_path!(parser, 10) + _t1516 = parse_rel_atom(parser) + rel_atom797 = _t1516 + pop_path!(parser) + _t1517 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom797)) + _t1515 = _t1517 else - if prediction765 == 10 - _t1443 = parse_primitive(parser) - primitive776 = _t1443 - _t1444 = Proto.Formula(formula_type=OneOf(:primitive, primitive776)) - _t1442 = _t1444 + if prediction785 == 10 + push_path!(parser, 9) + _t1519 = parse_primitive(parser) + primitive796 = _t1519 + pop_path!(parser) + _t1520 = Proto.Formula(formula_type=OneOf(:primitive, primitive796)) + _t1518 = _t1520 else - if prediction765 == 9 - _t1446 = parse_pragma(parser) - pragma775 = _t1446 - _t1447 = Proto.Formula(formula_type=OneOf(:pragma, pragma775)) - _t1445 = _t1447 + if prediction785 == 9 + push_path!(parser, 8) + _t1522 = parse_pragma(parser) + pragma795 = _t1522 + pop_path!(parser) + _t1523 = Proto.Formula(formula_type=OneOf(:pragma, pragma795)) + _t1521 = _t1523 else - if prediction765 == 8 - _t1449 = parse_atom(parser) - atom774 = _t1449 - _t1450 = Proto.Formula(formula_type=OneOf(:atom, atom774)) - _t1448 = _t1450 + if prediction785 == 8 + push_path!(parser, 7) + _t1525 = parse_atom(parser) + atom794 = _t1525 + pop_path!(parser) + _t1526 = Proto.Formula(formula_type=OneOf(:atom, atom794)) + _t1524 = _t1526 else - if prediction765 == 7 - _t1452 = parse_ffi(parser) - ffi773 = _t1452 - _t1453 = Proto.Formula(formula_type=OneOf(:ffi, ffi773)) - _t1451 = _t1453 + if prediction785 == 7 + push_path!(parser, 6) + _t1528 = parse_ffi(parser) + ffi793 = _t1528 + pop_path!(parser) + _t1529 = Proto.Formula(formula_type=OneOf(:ffi, ffi793)) + _t1527 = _t1529 else - if prediction765 == 6 - _t1455 = parse_not(parser) - not772 = _t1455 - _t1456 = Proto.Formula(formula_type=OneOf(:not, not772)) - _t1454 = _t1456 + if prediction785 == 6 + push_path!(parser, 5) + _t1531 = parse_not(parser) + not792 = _t1531 + pop_path!(parser) + _t1532 = Proto.Formula(formula_type=OneOf(:not, not792)) + _t1530 = _t1532 else - if prediction765 == 5 - _t1458 = parse_disjunction(parser) - disjunction771 = _t1458 - _t1459 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction771)) - _t1457 = _t1459 + if prediction785 == 5 + push_path!(parser, 4) + _t1534 = parse_disjunction(parser) + disjunction791 = _t1534 + pop_path!(parser) + _t1535 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction791)) + _t1533 = _t1535 else - if prediction765 == 4 - _t1461 = parse_conjunction(parser) - conjunction770 = _t1461 - _t1462 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction770)) - _t1460 = _t1462 + if prediction785 == 4 + push_path!(parser, 3) + _t1537 = parse_conjunction(parser) + conjunction790 = _t1537 + pop_path!(parser) + _t1538 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction790)) + _t1536 = _t1538 else - if prediction765 == 3 - _t1464 = parse_reduce(parser) - reduce769 = _t1464 - _t1465 = Proto.Formula(formula_type=OneOf(:reduce, reduce769)) - _t1463 = _t1465 + if prediction785 == 3 + push_path!(parser, 2) + _t1540 = parse_reduce(parser) + reduce789 = _t1540 + pop_path!(parser) + _t1541 = Proto.Formula(formula_type=OneOf(:reduce, reduce789)) + _t1539 = _t1541 else - if prediction765 == 2 - _t1467 = parse_exists(parser) - exists768 = _t1467 - _t1468 = Proto.Formula(formula_type=OneOf(:exists, exists768)) - _t1466 = _t1468 + if prediction785 == 2 + push_path!(parser, 1) + _t1543 = parse_exists(parser) + exists788 = _t1543 + pop_path!(parser) + _t1544 = Proto.Formula(formula_type=OneOf(:exists, exists788)) + _t1542 = _t1544 else - if prediction765 == 1 - _t1470 = parse_false(parser) - false767 = _t1470 - _t1471 = Proto.Formula(formula_type=OneOf(:disjunction, false767)) - _t1469 = _t1471 + if prediction785 == 1 + push_path!(parser, 4) + _t1546 = parse_false(parser) + false787 = _t1546 + pop_path!(parser) + _t1547 = Proto.Formula(formula_type=OneOf(:disjunction, false787)) + _t1545 = _t1547 else - if prediction765 == 0 - _t1473 = parse_true(parser) - true766 = _t1473 - _t1474 = Proto.Formula(formula_type=OneOf(:conjunction, true766)) - _t1472 = _t1474 + if prediction785 == 0 + push_path!(parser, 3) + _t1549 = parse_true(parser) + true786 = _t1549 + pop_path!(parser) + _t1550 = Proto.Formula(formula_type=OneOf(:conjunction, true786)) + _t1548 = _t1550 else throw(ParseError("Unexpected token in formula" * ": " * string(lookahead(parser, 0)))) end - _t1469 = _t1472 + _t1545 = _t1548 end - _t1466 = _t1469 + _t1542 = _t1545 end - _t1463 = _t1466 + _t1539 = _t1542 end - _t1460 = _t1463 + _t1536 = _t1539 end - _t1457 = _t1460 + _t1533 = _t1536 end - _t1454 = _t1457 + _t1530 = _t1533 end - _t1451 = _t1454 + _t1527 = _t1530 end - _t1448 = _t1451 + _t1524 = _t1527 end - _t1445 = _t1448 + _t1521 = _t1524 end - _t1442 = _t1445 + _t1518 = _t1521 end - _t1439 = _t1442 + _t1515 = _t1518 end - _t1436 = _t1439 + _t1512 = _t1515 end - result780 = _t1436 - record_span!(parser, span_start779) - return result780 + result800 = _t1512 + record_span!(parser, span_start799) + return result800 end function parse_true(parser::ParserState)::Proto.Conjunction - span_start781 = span_start(parser) + span_start801 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "true") consume_literal!(parser, ")") - _t1475 = Proto.Conjunction(args=Proto.Formula[]) - result782 = _t1475 - record_span!(parser, span_start781) - return result782 + _t1551 = Proto.Conjunction(args=Proto.Formula[]) + result802 = _t1551 + record_span!(parser, span_start801) + return result802 end function parse_false(parser::ParserState)::Proto.Disjunction - span_start783 = span_start(parser) + span_start803 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "false") consume_literal!(parser, ")") - _t1476 = Proto.Disjunction(args=Proto.Formula[]) - result784 = _t1476 - record_span!(parser, span_start783) - return result784 + _t1552 = Proto.Disjunction(args=Proto.Formula[]) + result804 = _t1552 + record_span!(parser, span_start803) + return result804 end function parse_exists(parser::ParserState)::Proto.Exists - span_start787 = span_start(parser) + span_start807 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "exists") - _t1477 = parse_bindings(parser) - bindings785 = _t1477 - _t1478 = parse_formula(parser) - formula786 = _t1478 + _t1553 = parse_bindings(parser) + bindings805 = _t1553 + _t1554 = parse_formula(parser) + formula806 = _t1554 consume_literal!(parser, ")") - _t1479 = Proto.Abstraction(vars=vcat(bindings785[1], !isnothing(bindings785[2]) ? bindings785[2] : []), value=formula786) - _t1480 = Proto.Exists(body=_t1479) - result788 = _t1480 - record_span!(parser, span_start787) - return result788 + _t1555 = Proto.Abstraction(vars=vcat(bindings805[1], !isnothing(bindings805[2]) ? bindings805[2] : []), value=formula806) + _t1556 = Proto.Exists(body=_t1555) + result808 = _t1556 + record_span!(parser, span_start807) + return result808 end function parse_reduce(parser::ParserState)::Proto.Reduce - span_start792 = span_start(parser) + span_start812 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reduce") push_path!(parser, 1) - _t1481 = parse_abstraction(parser) - abstraction789 = _t1481 + _t1557 = parse_abstraction(parser) + abstraction809 = _t1557 pop_path!(parser) push_path!(parser, 2) - _t1482 = parse_abstraction(parser) - abstraction_3790 = _t1482 + _t1558 = parse_abstraction(parser) + abstraction_3810 = _t1558 pop_path!(parser) push_path!(parser, 3) - _t1483 = parse_terms(parser) - terms791 = _t1483 + _t1559 = parse_terms(parser) + terms811 = _t1559 pop_path!(parser) consume_literal!(parser, ")") - _t1484 = Proto.Reduce(op=abstraction789, body=abstraction_3790, terms=terms791) - result793 = _t1484 - record_span!(parser, span_start792) - return result793 + _t1560 = Proto.Reduce(op=abstraction809, body=abstraction_3810, terms=terms811) + result813 = _t1560 + record_span!(parser, span_start812) + return result813 end function parse_terms(parser::ParserState)::Vector{Proto.Term} - span_start798 = span_start(parser) + span_start822 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "terms") - xs794 = Proto.Term[] - cond795 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - while cond795 - _t1485 = parse_term(parser) - item796 = _t1485 - push!(xs794, item796) - cond795 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + xs818 = Proto.Term[] + cond819 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx820 = 0 + while cond819 + push_path!(parser, idx820) + _t1561 = parse_term(parser) + item821 = _t1561 + pop_path!(parser) + push!(xs818, item821) + idx820 = (idx820 + 1) + cond819 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms797 = xs794 + terms817 = xs818 consume_literal!(parser, ")") - result799 = terms797 - record_span!(parser, span_start798) - return result799 + result823 = terms817 + record_span!(parser, span_start822) + return result823 end function parse_term(parser::ParserState)::Proto.Term - span_start803 = span_start(parser) + span_start827 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1486 = 1 + _t1562 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t1487 = 1 + _t1563 = 1 else if match_lookahead_literal(parser, "false", 0) - _t1488 = 1 + _t1564 = 1 else if match_lookahead_literal(parser, "(", 0) - _t1489 = 1 + _t1565 = 1 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1490 = 1 + _t1566 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t1491 = 0 + _t1567 = 0 else if match_lookahead_terminal(parser, "STRING", 0) - _t1492 = 1 + _t1568 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t1493 = 1 + _t1569 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t1494 = 1 + _t1570 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t1495 = 1 + _t1571 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t1496 = 1 + _t1572 = 1 else - _t1496 = -1 + _t1572 = -1 end - _t1495 = _t1496 + _t1571 = _t1572 end - _t1494 = _t1495 + _t1570 = _t1571 end - _t1493 = _t1494 + _t1569 = _t1570 end - _t1492 = _t1493 + _t1568 = _t1569 end - _t1491 = _t1492 + _t1567 = _t1568 end - _t1490 = _t1491 + _t1566 = _t1567 end - _t1489 = _t1490 + _t1565 = _t1566 end - _t1488 = _t1489 + _t1564 = _t1565 end - _t1487 = _t1488 + _t1563 = _t1564 end - _t1486 = _t1487 - end - prediction800 = _t1486 - if prediction800 == 1 - _t1498 = parse_constant(parser) - constant802 = _t1498 - _t1499 = Proto.Term(term_type=OneOf(:constant, constant802)) - _t1497 = _t1499 + _t1562 = _t1563 + end + prediction824 = _t1562 + if prediction824 == 1 + push_path!(parser, 2) + _t1574 = parse_constant(parser) + constant826 = _t1574 + pop_path!(parser) + _t1575 = Proto.Term(term_type=OneOf(:constant, constant826)) + _t1573 = _t1575 else - if prediction800 == 0 - _t1501 = parse_var(parser) - var801 = _t1501 - _t1502 = Proto.Term(term_type=OneOf(:var, var801)) - _t1500 = _t1502 + if prediction824 == 0 + push_path!(parser, 1) + _t1577 = parse_var(parser) + var825 = _t1577 + pop_path!(parser) + _t1578 = Proto.Term(term_type=OneOf(:var, var825)) + _t1576 = _t1578 else throw(ParseError("Unexpected token in term" * ": " * string(lookahead(parser, 0)))) end - _t1497 = _t1500 + _t1573 = _t1576 end - result804 = _t1497 - record_span!(parser, span_start803) - return result804 + result828 = _t1573 + record_span!(parser, span_start827) + return result828 end function parse_var(parser::ParserState)::Proto.Var - span_start806 = span_start(parser) - symbol805 = consume_terminal!(parser, "SYMBOL") - _t1503 = Proto.Var(name=symbol805) - result807 = _t1503 - record_span!(parser, span_start806) - return result807 + span_start830 = span_start(parser) + symbol829 = consume_terminal!(parser, "SYMBOL") + _t1579 = Proto.Var(name=symbol829) + result831 = _t1579 + record_span!(parser, span_start830) + return result831 end function parse_constant(parser::ParserState)::Proto.Value - span_start809 = span_start(parser) - _t1504 = parse_value(parser) - value808 = _t1504 - result810 = value808 - record_span!(parser, span_start809) - return result810 + span_start833 = span_start(parser) + _t1580 = parse_value(parser) + value832 = _t1580 + result834 = value832 + record_span!(parser, span_start833) + return result834 end function parse_conjunction(parser::ParserState)::Proto.Conjunction - span_start819 = span_start(parser) + span_start843 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "and") push_path!(parser, 1) - xs815 = Proto.Formula[] - cond816 = match_lookahead_literal(parser, "(", 0) - idx817 = 0 - while cond816 - push_path!(parser, idx817) - _t1505 = parse_formula(parser) - item818 = _t1505 + xs839 = Proto.Formula[] + cond840 = match_lookahead_literal(parser, "(", 0) + idx841 = 0 + while cond840 + push_path!(parser, idx841) + _t1581 = parse_formula(parser) + item842 = _t1581 pop_path!(parser) - push!(xs815, item818) - idx817 = (idx817 + 1) - cond816 = match_lookahead_literal(parser, "(", 0) + push!(xs839, item842) + idx841 = (idx841 + 1) + cond840 = match_lookahead_literal(parser, "(", 0) end - formulas814 = xs815 + formulas838 = xs839 pop_path!(parser) consume_literal!(parser, ")") - _t1506 = Proto.Conjunction(args=formulas814) - result820 = _t1506 - record_span!(parser, span_start819) - return result820 + _t1582 = Proto.Conjunction(args=formulas838) + result844 = _t1582 + record_span!(parser, span_start843) + return result844 end function parse_disjunction(parser::ParserState)::Proto.Disjunction - span_start829 = span_start(parser) + span_start853 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") push_path!(parser, 1) - xs825 = Proto.Formula[] - cond826 = match_lookahead_literal(parser, "(", 0) - idx827 = 0 - while cond826 - push_path!(parser, idx827) - _t1507 = parse_formula(parser) - item828 = _t1507 + xs849 = Proto.Formula[] + cond850 = match_lookahead_literal(parser, "(", 0) + idx851 = 0 + while cond850 + push_path!(parser, idx851) + _t1583 = parse_formula(parser) + item852 = _t1583 pop_path!(parser) - push!(xs825, item828) - idx827 = (idx827 + 1) - cond826 = match_lookahead_literal(parser, "(", 0) + push!(xs849, item852) + idx851 = (idx851 + 1) + cond850 = match_lookahead_literal(parser, "(", 0) end - formulas824 = xs825 + formulas848 = xs849 pop_path!(parser) consume_literal!(parser, ")") - _t1508 = Proto.Disjunction(args=formulas824) - result830 = _t1508 - record_span!(parser, span_start829) - return result830 + _t1584 = Proto.Disjunction(args=formulas848) + result854 = _t1584 + record_span!(parser, span_start853) + return result854 end function parse_not(parser::ParserState)::Proto.Not - span_start832 = span_start(parser) + span_start856 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "not") push_path!(parser, 1) - _t1509 = parse_formula(parser) - formula831 = _t1509 + _t1585 = parse_formula(parser) + formula855 = _t1585 pop_path!(parser) consume_literal!(parser, ")") - _t1510 = Proto.Not(arg=formula831) - result833 = _t1510 - record_span!(parser, span_start832) - return result833 + _t1586 = Proto.Not(arg=formula855) + result857 = _t1586 + record_span!(parser, span_start856) + return result857 end function parse_ffi(parser::ParserState)::Proto.FFI - span_start837 = span_start(parser) + span_start861 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "ffi") push_path!(parser, 1) - _t1511 = parse_name(parser) - name834 = _t1511 + _t1587 = parse_name(parser) + name858 = _t1587 pop_path!(parser) push_path!(parser, 2) - _t1512 = parse_ffi_args(parser) - ffi_args835 = _t1512 + _t1588 = parse_ffi_args(parser) + ffi_args859 = _t1588 pop_path!(parser) push_path!(parser, 3) - _t1513 = parse_terms(parser) - terms836 = _t1513 + _t1589 = parse_terms(parser) + terms860 = _t1589 pop_path!(parser) consume_literal!(parser, ")") - _t1514 = Proto.FFI(name=name834, args=ffi_args835, terms=terms836) - result838 = _t1514 - record_span!(parser, span_start837) - return result838 + _t1590 = Proto.FFI(name=name858, args=ffi_args859, terms=terms860) + result862 = _t1590 + record_span!(parser, span_start861) + return result862 end function parse_name(parser::ParserState)::String - span_start840 = span_start(parser) + span_start864 = span_start(parser) consume_literal!(parser, ":") - symbol839 = consume_terminal!(parser, "SYMBOL") - result841 = symbol839 - record_span!(parser, span_start840) - return result841 + symbol863 = consume_terminal!(parser, "SYMBOL") + result865 = symbol863 + record_span!(parser, span_start864) + return result865 end function parse_ffi_args(parser::ParserState)::Vector{Proto.Abstraction} - span_start846 = span_start(parser) + span_start874 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "args") - xs842 = Proto.Abstraction[] - cond843 = match_lookahead_literal(parser, "(", 0) - while cond843 - _t1515 = parse_abstraction(parser) - item844 = _t1515 - push!(xs842, item844) - cond843 = match_lookahead_literal(parser, "(", 0) + xs870 = Proto.Abstraction[] + cond871 = match_lookahead_literal(parser, "(", 0) + idx872 = 0 + while cond871 + push_path!(parser, idx872) + _t1591 = parse_abstraction(parser) + item873 = _t1591 + pop_path!(parser) + push!(xs870, item873) + idx872 = (idx872 + 1) + cond871 = match_lookahead_literal(parser, "(", 0) end - abstractions845 = xs842 + abstractions869 = xs870 consume_literal!(parser, ")") - result847 = abstractions845 - record_span!(parser, span_start846) - return result847 + result875 = abstractions869 + record_span!(parser, span_start874) + return result875 end function parse_atom(parser::ParserState)::Proto.Atom - span_start857 = span_start(parser) + span_start885 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "atom") push_path!(parser, 1) - _t1516 = parse_relation_id(parser) - relation_id848 = _t1516 + _t1592 = parse_relation_id(parser) + relation_id876 = _t1592 pop_path!(parser) push_path!(parser, 2) - xs853 = Proto.Term[] - cond854 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - idx855 = 0 - while cond854 - push_path!(parser, idx855) - _t1517 = parse_term(parser) - item856 = _t1517 + xs881 = Proto.Term[] + cond882 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx883 = 0 + while cond882 + push_path!(parser, idx883) + _t1593 = parse_term(parser) + item884 = _t1593 pop_path!(parser) - push!(xs853, item856) - idx855 = (idx855 + 1) - cond854 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs881, item884) + idx883 = (idx883 + 1) + cond882 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms852 = xs853 + terms880 = xs881 pop_path!(parser) consume_literal!(parser, ")") - _t1518 = Proto.Atom(name=relation_id848, terms=terms852) - result858 = _t1518 - record_span!(parser, span_start857) - return result858 + _t1594 = Proto.Atom(name=relation_id876, terms=terms880) + result886 = _t1594 + record_span!(parser, span_start885) + return result886 end function parse_pragma(parser::ParserState)::Proto.Pragma - span_start868 = span_start(parser) + span_start896 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "pragma") push_path!(parser, 1) - _t1519 = parse_name(parser) - name859 = _t1519 + _t1595 = parse_name(parser) + name887 = _t1595 pop_path!(parser) push_path!(parser, 2) - xs864 = Proto.Term[] - cond865 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - idx866 = 0 - while cond865 - push_path!(parser, idx866) - _t1520 = parse_term(parser) - item867 = _t1520 + xs892 = Proto.Term[] + cond893 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx894 = 0 + while cond893 + push_path!(parser, idx894) + _t1596 = parse_term(parser) + item895 = _t1596 pop_path!(parser) - push!(xs864, item867) - idx866 = (idx866 + 1) - cond865 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs892, item895) + idx894 = (idx894 + 1) + cond893 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - terms863 = xs864 + terms891 = xs892 pop_path!(parser) consume_literal!(parser, ")") - _t1521 = Proto.Pragma(name=name859, terms=terms863) - result869 = _t1521 - record_span!(parser, span_start868) - return result869 + _t1597 = Proto.Pragma(name=name887, terms=terms891) + result897 = _t1597 + record_span!(parser, span_start896) + return result897 end function parse_primitive(parser::ParserState)::Proto.Primitive - span_start889 = span_start(parser) + span_start917 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "primitive", 1) - _t1523 = 9 + _t1599 = 9 else if match_lookahead_literal(parser, ">=", 1) - _t1524 = 4 + _t1600 = 4 else if match_lookahead_literal(parser, ">", 1) - _t1525 = 3 + _t1601 = 3 else if match_lookahead_literal(parser, "=", 1) - _t1526 = 0 + _t1602 = 0 else if match_lookahead_literal(parser, "<=", 1) - _t1527 = 2 + _t1603 = 2 else if match_lookahead_literal(parser, "<", 1) - _t1528 = 1 + _t1604 = 1 else if match_lookahead_literal(parser, "/", 1) - _t1529 = 8 + _t1605 = 8 else if match_lookahead_literal(parser, "-", 1) - _t1530 = 6 + _t1606 = 6 else if match_lookahead_literal(parser, "+", 1) - _t1531 = 5 + _t1607 = 5 else if match_lookahead_literal(parser, "*", 1) - _t1532 = 7 + _t1608 = 7 else - _t1532 = -1 + _t1608 = -1 end - _t1531 = _t1532 + _t1607 = _t1608 end - _t1530 = _t1531 + _t1606 = _t1607 end - _t1529 = _t1530 + _t1605 = _t1606 end - _t1528 = _t1529 + _t1604 = _t1605 end - _t1527 = _t1528 + _t1603 = _t1604 end - _t1526 = _t1527 + _t1602 = _t1603 end - _t1525 = _t1526 + _t1601 = _t1602 end - _t1524 = _t1525 + _t1600 = _t1601 end - _t1523 = _t1524 + _t1599 = _t1600 end - _t1522 = _t1523 + _t1598 = _t1599 else - _t1522 = -1 + _t1598 = -1 end - prediction870 = _t1522 - if prediction870 == 9 + prediction898 = _t1598 + if prediction898 == 9 consume_literal!(parser, "(") consume_literal!(parser, "primitive") push_path!(parser, 1) - _t1534 = parse_name(parser) - name880 = _t1534 + _t1610 = parse_name(parser) + name908 = _t1610 pop_path!(parser) push_path!(parser, 2) - xs885 = Proto.RelTerm[] - cond886 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - idx887 = 0 - while cond886 - push_path!(parser, idx887) - _t1535 = parse_rel_term(parser) - item888 = _t1535 + xs913 = Proto.RelTerm[] + cond914 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx915 = 0 + while cond914 + push_path!(parser, idx915) + _t1611 = parse_rel_term(parser) + item916 = _t1611 pop_path!(parser) - push!(xs885, item888) - idx887 = (idx887 + 1) - cond886 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs913, item916) + idx915 = (idx915 + 1) + cond914 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - rel_terms884 = xs885 + rel_terms912 = xs913 pop_path!(parser) consume_literal!(parser, ")") - _t1536 = Proto.Primitive(name=name880, terms=rel_terms884) - _t1533 = _t1536 + _t1612 = Proto.Primitive(name=name908, terms=rel_terms912) + _t1609 = _t1612 else - if prediction870 == 8 - _t1538 = parse_divide(parser) - divide879 = _t1538 - _t1537 = divide879 + if prediction898 == 8 + _t1614 = parse_divide(parser) + divide907 = _t1614 + _t1613 = divide907 else - if prediction870 == 7 - _t1540 = parse_multiply(parser) - multiply878 = _t1540 - _t1539 = multiply878 + if prediction898 == 7 + _t1616 = parse_multiply(parser) + multiply906 = _t1616 + _t1615 = multiply906 else - if prediction870 == 6 - _t1542 = parse_minus(parser) - minus877 = _t1542 - _t1541 = minus877 + if prediction898 == 6 + _t1618 = parse_minus(parser) + minus905 = _t1618 + _t1617 = minus905 else - if prediction870 == 5 - _t1544 = parse_add(parser) - add876 = _t1544 - _t1543 = add876 + if prediction898 == 5 + _t1620 = parse_add(parser) + add904 = _t1620 + _t1619 = add904 else - if prediction870 == 4 - _t1546 = parse_gt_eq(parser) - gt_eq875 = _t1546 - _t1545 = gt_eq875 + if prediction898 == 4 + _t1622 = parse_gt_eq(parser) + gt_eq903 = _t1622 + _t1621 = gt_eq903 else - if prediction870 == 3 - _t1548 = parse_gt(parser) - gt874 = _t1548 - _t1547 = gt874 + if prediction898 == 3 + _t1624 = parse_gt(parser) + gt902 = _t1624 + _t1623 = gt902 else - if prediction870 == 2 - _t1550 = parse_lt_eq(parser) - lt_eq873 = _t1550 - _t1549 = lt_eq873 + if prediction898 == 2 + _t1626 = parse_lt_eq(parser) + lt_eq901 = _t1626 + _t1625 = lt_eq901 else - if prediction870 == 1 - _t1552 = parse_lt(parser) - lt872 = _t1552 - _t1551 = lt872 + if prediction898 == 1 + _t1628 = parse_lt(parser) + lt900 = _t1628 + _t1627 = lt900 else - if prediction870 == 0 - _t1554 = parse_eq(parser) - eq871 = _t1554 - _t1553 = eq871 + if prediction898 == 0 + _t1630 = parse_eq(parser) + eq899 = _t1630 + _t1629 = eq899 else throw(ParseError("Unexpected token in primitive" * ": " * string(lookahead(parser, 0)))) end - _t1551 = _t1553 + _t1627 = _t1629 end - _t1549 = _t1551 + _t1625 = _t1627 end - _t1547 = _t1549 + _t1623 = _t1625 end - _t1545 = _t1547 + _t1621 = _t1623 end - _t1543 = _t1545 + _t1619 = _t1621 end - _t1541 = _t1543 + _t1617 = _t1619 end - _t1539 = _t1541 + _t1615 = _t1617 end - _t1537 = _t1539 + _t1613 = _t1615 end - _t1533 = _t1537 + _t1609 = _t1613 end - result890 = _t1533 - record_span!(parser, span_start889) - return result890 + result918 = _t1609 + record_span!(parser, span_start917) + return result918 end function parse_eq(parser::ParserState)::Proto.Primitive - span_start893 = span_start(parser) + span_start921 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "=") - _t1555 = parse_term(parser) - term891 = _t1555 - _t1556 = parse_term(parser) - term_3892 = _t1556 + _t1631 = parse_term(parser) + term919 = _t1631 + _t1632 = parse_term(parser) + term_3920 = _t1632 consume_literal!(parser, ")") - _t1557 = Proto.RelTerm(rel_term_type=OneOf(:term, term891)) - _t1558 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3892)) - _t1559 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t1557, _t1558]) - result894 = _t1559 - record_span!(parser, span_start893) - return result894 + _t1633 = Proto.RelTerm(rel_term_type=OneOf(:term, term919)) + _t1634 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3920)) + _t1635 = Proto.Primitive(name="rel_primitive_eq", terms=Proto.RelTerm[_t1633, _t1634]) + result922 = _t1635 + record_span!(parser, span_start921) + return result922 end function parse_lt(parser::ParserState)::Proto.Primitive - span_start897 = span_start(parser) + span_start925 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<") - _t1560 = parse_term(parser) - term895 = _t1560 - _t1561 = parse_term(parser) - term_3896 = _t1561 + _t1636 = parse_term(parser) + term923 = _t1636 + _t1637 = parse_term(parser) + term_3924 = _t1637 consume_literal!(parser, ")") - _t1562 = Proto.RelTerm(rel_term_type=OneOf(:term, term895)) - _t1563 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3896)) - _t1564 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t1562, _t1563]) - result898 = _t1564 - record_span!(parser, span_start897) - return result898 + _t1638 = Proto.RelTerm(rel_term_type=OneOf(:term, term923)) + _t1639 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3924)) + _t1640 = Proto.Primitive(name="rel_primitive_lt_monotype", terms=Proto.RelTerm[_t1638, _t1639]) + result926 = _t1640 + record_span!(parser, span_start925) + return result926 end function parse_lt_eq(parser::ParserState)::Proto.Primitive - span_start901 = span_start(parser) + span_start929 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<=") - _t1565 = parse_term(parser) - term899 = _t1565 - _t1566 = parse_term(parser) - term_3900 = _t1566 - consume_literal!(parser, ")") - _t1567 = Proto.RelTerm(rel_term_type=OneOf(:term, term899)) - _t1568 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3900)) - _t1569 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t1567, _t1568]) - result902 = _t1569 - record_span!(parser, span_start901) - return result902 + _t1641 = parse_term(parser) + term927 = _t1641 + _t1642 = parse_term(parser) + term_3928 = _t1642 + consume_literal!(parser, ")") + _t1643 = Proto.RelTerm(rel_term_type=OneOf(:term, term927)) + _t1644 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3928)) + _t1645 = Proto.Primitive(name="rel_primitive_lt_eq_monotype", terms=Proto.RelTerm[_t1643, _t1644]) + result930 = _t1645 + record_span!(parser, span_start929) + return result930 end function parse_gt(parser::ParserState)::Proto.Primitive - span_start905 = span_start(parser) + span_start933 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">") - _t1570 = parse_term(parser) - term903 = _t1570 - _t1571 = parse_term(parser) - term_3904 = _t1571 + _t1646 = parse_term(parser) + term931 = _t1646 + _t1647 = parse_term(parser) + term_3932 = _t1647 consume_literal!(parser, ")") - _t1572 = Proto.RelTerm(rel_term_type=OneOf(:term, term903)) - _t1573 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3904)) - _t1574 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t1572, _t1573]) - result906 = _t1574 - record_span!(parser, span_start905) - return result906 + _t1648 = Proto.RelTerm(rel_term_type=OneOf(:term, term931)) + _t1649 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3932)) + _t1650 = Proto.Primitive(name="rel_primitive_gt_monotype", terms=Proto.RelTerm[_t1648, _t1649]) + result934 = _t1650 + record_span!(parser, span_start933) + return result934 end function parse_gt_eq(parser::ParserState)::Proto.Primitive - span_start909 = span_start(parser) + span_start937 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">=") - _t1575 = parse_term(parser) - term907 = _t1575 - _t1576 = parse_term(parser) - term_3908 = _t1576 - consume_literal!(parser, ")") - _t1577 = Proto.RelTerm(rel_term_type=OneOf(:term, term907)) - _t1578 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3908)) - _t1579 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t1577, _t1578]) - result910 = _t1579 - record_span!(parser, span_start909) - return result910 + _t1651 = parse_term(parser) + term935 = _t1651 + _t1652 = parse_term(parser) + term_3936 = _t1652 + consume_literal!(parser, ")") + _t1653 = Proto.RelTerm(rel_term_type=OneOf(:term, term935)) + _t1654 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3936)) + _t1655 = Proto.Primitive(name="rel_primitive_gt_eq_monotype", terms=Proto.RelTerm[_t1653, _t1654]) + result938 = _t1655 + record_span!(parser, span_start937) + return result938 end function parse_add(parser::ParserState)::Proto.Primitive - span_start914 = span_start(parser) + span_start942 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "+") - _t1580 = parse_term(parser) - term911 = _t1580 - _t1581 = parse_term(parser) - term_3912 = _t1581 - _t1582 = parse_term(parser) - term_4913 = _t1582 - consume_literal!(parser, ")") - _t1583 = Proto.RelTerm(rel_term_type=OneOf(:term, term911)) - _t1584 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3912)) - _t1585 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4913)) - _t1586 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t1583, _t1584, _t1585]) - result915 = _t1586 - record_span!(parser, span_start914) - return result915 + _t1656 = parse_term(parser) + term939 = _t1656 + _t1657 = parse_term(parser) + term_3940 = _t1657 + _t1658 = parse_term(parser) + term_4941 = _t1658 + consume_literal!(parser, ")") + _t1659 = Proto.RelTerm(rel_term_type=OneOf(:term, term939)) + _t1660 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3940)) + _t1661 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4941)) + _t1662 = Proto.Primitive(name="rel_primitive_add_monotype", terms=Proto.RelTerm[_t1659, _t1660, _t1661]) + result943 = _t1662 + record_span!(parser, span_start942) + return result943 end function parse_minus(parser::ParserState)::Proto.Primitive - span_start919 = span_start(parser) + span_start947 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "-") - _t1587 = parse_term(parser) - term916 = _t1587 - _t1588 = parse_term(parser) - term_3917 = _t1588 - _t1589 = parse_term(parser) - term_4918 = _t1589 - consume_literal!(parser, ")") - _t1590 = Proto.RelTerm(rel_term_type=OneOf(:term, term916)) - _t1591 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3917)) - _t1592 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4918)) - _t1593 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t1590, _t1591, _t1592]) - result920 = _t1593 - record_span!(parser, span_start919) - return result920 + _t1663 = parse_term(parser) + term944 = _t1663 + _t1664 = parse_term(parser) + term_3945 = _t1664 + _t1665 = parse_term(parser) + term_4946 = _t1665 + consume_literal!(parser, ")") + _t1666 = Proto.RelTerm(rel_term_type=OneOf(:term, term944)) + _t1667 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3945)) + _t1668 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4946)) + _t1669 = Proto.Primitive(name="rel_primitive_subtract_monotype", terms=Proto.RelTerm[_t1666, _t1667, _t1668]) + result948 = _t1669 + record_span!(parser, span_start947) + return result948 end function parse_multiply(parser::ParserState)::Proto.Primitive - span_start924 = span_start(parser) + span_start952 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "*") - _t1594 = parse_term(parser) - term921 = _t1594 - _t1595 = parse_term(parser) - term_3922 = _t1595 - _t1596 = parse_term(parser) - term_4923 = _t1596 - consume_literal!(parser, ")") - _t1597 = Proto.RelTerm(rel_term_type=OneOf(:term, term921)) - _t1598 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3922)) - _t1599 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4923)) - _t1600 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t1597, _t1598, _t1599]) - result925 = _t1600 - record_span!(parser, span_start924) - return result925 + _t1670 = parse_term(parser) + term949 = _t1670 + _t1671 = parse_term(parser) + term_3950 = _t1671 + _t1672 = parse_term(parser) + term_4951 = _t1672 + consume_literal!(parser, ")") + _t1673 = Proto.RelTerm(rel_term_type=OneOf(:term, term949)) + _t1674 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3950)) + _t1675 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4951)) + _t1676 = Proto.Primitive(name="rel_primitive_multiply_monotype", terms=Proto.RelTerm[_t1673, _t1674, _t1675]) + result953 = _t1676 + record_span!(parser, span_start952) + return result953 end function parse_divide(parser::ParserState)::Proto.Primitive - span_start929 = span_start(parser) + span_start957 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "/") - _t1601 = parse_term(parser) - term926 = _t1601 - _t1602 = parse_term(parser) - term_3927 = _t1602 - _t1603 = parse_term(parser) - term_4928 = _t1603 - consume_literal!(parser, ")") - _t1604 = Proto.RelTerm(rel_term_type=OneOf(:term, term926)) - _t1605 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3927)) - _t1606 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4928)) - _t1607 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t1604, _t1605, _t1606]) - result930 = _t1607 - record_span!(parser, span_start929) - return result930 + _t1677 = parse_term(parser) + term954 = _t1677 + _t1678 = parse_term(parser) + term_3955 = _t1678 + _t1679 = parse_term(parser) + term_4956 = _t1679 + consume_literal!(parser, ")") + _t1680 = Proto.RelTerm(rel_term_type=OneOf(:term, term954)) + _t1681 = Proto.RelTerm(rel_term_type=OneOf(:term, term_3955)) + _t1682 = Proto.RelTerm(rel_term_type=OneOf(:term, term_4956)) + _t1683 = Proto.Primitive(name="rel_primitive_divide_monotype", terms=Proto.RelTerm[_t1680, _t1681, _t1682]) + result958 = _t1683 + record_span!(parser, span_start957) + return result958 end function parse_rel_term(parser::ParserState)::Proto.RelTerm - span_start934 = span_start(parser) + span_start962 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1608 = 1 + _t1684 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t1609 = 1 + _t1685 = 1 else if match_lookahead_literal(parser, "false", 0) - _t1610 = 1 + _t1686 = 1 else if match_lookahead_literal(parser, "(", 0) - _t1611 = 1 + _t1687 = 1 else if match_lookahead_literal(parser, "#", 0) - _t1612 = 0 + _t1688 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1613 = 1 + _t1689 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t1614 = 1 + _t1690 = 1 else if match_lookahead_terminal(parser, "STRING", 0) - _t1615 = 1 + _t1691 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t1616 = 1 + _t1692 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t1617 = 1 + _t1693 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t1618 = 1 + _t1694 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t1619 = 1 + _t1695 = 1 else - _t1619 = -1 + _t1695 = -1 end - _t1618 = _t1619 + _t1694 = _t1695 end - _t1617 = _t1618 + _t1693 = _t1694 end - _t1616 = _t1617 + _t1692 = _t1693 end - _t1615 = _t1616 + _t1691 = _t1692 end - _t1614 = _t1615 + _t1690 = _t1691 end - _t1613 = _t1614 + _t1689 = _t1690 end - _t1612 = _t1613 + _t1688 = _t1689 end - _t1611 = _t1612 + _t1687 = _t1688 end - _t1610 = _t1611 + _t1686 = _t1687 end - _t1609 = _t1610 + _t1685 = _t1686 end - _t1608 = _t1609 - end - prediction931 = _t1608 - if prediction931 == 1 - _t1621 = parse_term(parser) - term933 = _t1621 - _t1622 = Proto.RelTerm(rel_term_type=OneOf(:term, term933)) - _t1620 = _t1622 + _t1684 = _t1685 + end + prediction959 = _t1684 + if prediction959 == 1 + push_path!(parser, 2) + _t1697 = parse_term(parser) + term961 = _t1697 + pop_path!(parser) + _t1698 = Proto.RelTerm(rel_term_type=OneOf(:term, term961)) + _t1696 = _t1698 else - if prediction931 == 0 - _t1624 = parse_specialized_value(parser) - specialized_value932 = _t1624 - _t1625 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value932)) - _t1623 = _t1625 + if prediction959 == 0 + push_path!(parser, 1) + _t1700 = parse_specialized_value(parser) + specialized_value960 = _t1700 + pop_path!(parser) + _t1701 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value960)) + _t1699 = _t1701 else throw(ParseError("Unexpected token in rel_term" * ": " * string(lookahead(parser, 0)))) end - _t1620 = _t1623 + _t1696 = _t1699 end - result935 = _t1620 - record_span!(parser, span_start934) - return result935 + result963 = _t1696 + record_span!(parser, span_start962) + return result963 end function parse_specialized_value(parser::ParserState)::Proto.Value - span_start937 = span_start(parser) + span_start965 = span_start(parser) consume_literal!(parser, "#") - _t1626 = parse_value(parser) - value936 = _t1626 - result938 = value936 - record_span!(parser, span_start937) - return result938 + _t1702 = parse_value(parser) + value964 = _t1702 + result966 = value964 + record_span!(parser, span_start965) + return result966 end function parse_rel_atom(parser::ParserState)::Proto.RelAtom - span_start948 = span_start(parser) + span_start976 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "relatom") push_path!(parser, 3) - _t1627 = parse_name(parser) - name939 = _t1627 + _t1703 = parse_name(parser) + name967 = _t1703 pop_path!(parser) push_path!(parser, 2) - xs944 = Proto.RelTerm[] - cond945 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - idx946 = 0 - while cond945 - push_path!(parser, idx946) - _t1628 = parse_rel_term(parser) - item947 = _t1628 + xs972 = Proto.RelTerm[] + cond973 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx974 = 0 + while cond973 + push_path!(parser, idx974) + _t1704 = parse_rel_term(parser) + item975 = _t1704 pop_path!(parser) - push!(xs944, item947) - idx946 = (idx946 + 1) - cond945 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs972, item975) + idx974 = (idx974 + 1) + cond973 = (((((((((((match_lookahead_literal(parser, "#", 0) || match_lookahead_literal(parser, "(", 0)) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "SYMBOL", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - rel_terms943 = xs944 + rel_terms971 = xs972 pop_path!(parser) consume_literal!(parser, ")") - _t1629 = Proto.RelAtom(name=name939, terms=rel_terms943) - result949 = _t1629 - record_span!(parser, span_start948) - return result949 + _t1705 = Proto.RelAtom(name=name967, terms=rel_terms971) + result977 = _t1705 + record_span!(parser, span_start976) + return result977 end function parse_cast(parser::ParserState)::Proto.Cast - span_start952 = span_start(parser) + span_start980 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "cast") push_path!(parser, 2) - _t1630 = parse_term(parser) - term950 = _t1630 + _t1706 = parse_term(parser) + term978 = _t1706 pop_path!(parser) push_path!(parser, 3) - _t1631 = parse_term(parser) - term_3951 = _t1631 + _t1707 = parse_term(parser) + term_3979 = _t1707 pop_path!(parser) consume_literal!(parser, ")") - _t1632 = Proto.Cast(input=term950, result=term_3951) - result953 = _t1632 - record_span!(parser, span_start952) - return result953 + _t1708 = Proto.Cast(input=term978, result=term_3979) + result981 = _t1708 + record_span!(parser, span_start980) + return result981 end function parse_attrs(parser::ParserState)::Vector{Proto.Attribute} - span_start958 = span_start(parser) + span_start990 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attrs") - xs954 = Proto.Attribute[] - cond955 = match_lookahead_literal(parser, "(", 0) - while cond955 - _t1633 = parse_attribute(parser) - item956 = _t1633 - push!(xs954, item956) - cond955 = match_lookahead_literal(parser, "(", 0) + xs986 = Proto.Attribute[] + cond987 = match_lookahead_literal(parser, "(", 0) + idx988 = 0 + while cond987 + push_path!(parser, idx988) + _t1709 = parse_attribute(parser) + item989 = _t1709 + pop_path!(parser) + push!(xs986, item989) + idx988 = (idx988 + 1) + cond987 = match_lookahead_literal(parser, "(", 0) end - attributes957 = xs954 + attributes985 = xs986 consume_literal!(parser, ")") - result959 = attributes957 - record_span!(parser, span_start958) - return result959 + result991 = attributes985 + record_span!(parser, span_start990) + return result991 end function parse_attribute(parser::ParserState)::Proto.Attribute - span_start969 = span_start(parser) + span_start1001 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "attribute") push_path!(parser, 1) - _t1634 = parse_name(parser) - name960 = _t1634 + _t1710 = parse_name(parser) + name992 = _t1710 pop_path!(parser) push_path!(parser, 2) - xs965 = Proto.Value[] - cond966 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) - idx967 = 0 - while cond966 - push_path!(parser, idx967) - _t1635 = parse_value(parser) - item968 = _t1635 + xs997 = Proto.Value[] + cond998 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + idx999 = 0 + while cond998 + push_path!(parser, idx999) + _t1711 = parse_value(parser) + item1000 = _t1711 pop_path!(parser) - push!(xs965, item968) - idx967 = (idx967 + 1) - cond966 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs997, item1000) + idx999 = (idx999 + 1) + cond998 = (((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "false", 0)) || match_lookahead_literal(parser, "missing", 0)) || match_lookahead_literal(parser, "true", 0)) || match_lookahead_terminal(parser, "DECIMAL", 0)) || match_lookahead_terminal(parser, "FLOAT", 0)) || match_lookahead_terminal(parser, "INT", 0)) || match_lookahead_terminal(parser, "INT128", 0)) || match_lookahead_terminal(parser, "STRING", 0)) || match_lookahead_terminal(parser, "UINT128", 0)) end - values964 = xs965 + values996 = xs997 pop_path!(parser) consume_literal!(parser, ")") - _t1636 = Proto.Attribute(name=name960, args=values964) - result970 = _t1636 - record_span!(parser, span_start969) - return result970 + _t1712 = Proto.Attribute(name=name992, args=values996) + result1002 = _t1712 + record_span!(parser, span_start1001) + return result1002 end function parse_algorithm(parser::ParserState)::Proto.Algorithm - span_start980 = span_start(parser) + span_start1012 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "algorithm") push_path!(parser, 1) - xs975 = Proto.RelationId[] - cond976 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - idx977 = 0 - while cond976 - push_path!(parser, idx977) - _t1637 = parse_relation_id(parser) - item978 = _t1637 + xs1007 = Proto.RelationId[] + cond1008 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx1009 = 0 + while cond1008 + push_path!(parser, idx1009) + _t1713 = parse_relation_id(parser) + item1010 = _t1713 pop_path!(parser) - push!(xs975, item978) - idx977 = (idx977 + 1) - cond976 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs1007, item1010) + idx1009 = (idx1009 + 1) + cond1008 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) end - relation_ids974 = xs975 + relation_ids1006 = xs1007 pop_path!(parser) push_path!(parser, 2) - _t1638 = parse_script(parser) - script979 = _t1638 + _t1714 = parse_script(parser) + script1011 = _t1714 pop_path!(parser) consume_literal!(parser, ")") - _t1639 = Proto.Algorithm(var"#global"=relation_ids974, body=script979) - result981 = _t1639 - record_span!(parser, span_start980) - return result981 + _t1715 = Proto.Algorithm(var"#global"=relation_ids1006, body=script1011) + result1013 = _t1715 + record_span!(parser, span_start1012) + return result1013 end function parse_script(parser::ParserState)::Proto.Script - span_start990 = span_start(parser) + span_start1022 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "script") push_path!(parser, 1) - xs986 = Proto.Construct[] - cond987 = match_lookahead_literal(parser, "(", 0) - idx988 = 0 - while cond987 - push_path!(parser, idx988) - _t1640 = parse_construct(parser) - item989 = _t1640 + xs1018 = Proto.Construct[] + cond1019 = match_lookahead_literal(parser, "(", 0) + idx1020 = 0 + while cond1019 + push_path!(parser, idx1020) + _t1716 = parse_construct(parser) + item1021 = _t1716 pop_path!(parser) - push!(xs986, item989) - idx988 = (idx988 + 1) - cond987 = match_lookahead_literal(parser, "(", 0) + push!(xs1018, item1021) + idx1020 = (idx1020 + 1) + cond1019 = match_lookahead_literal(parser, "(", 0) end - constructs985 = xs986 + constructs1017 = xs1018 pop_path!(parser) consume_literal!(parser, ")") - _t1641 = Proto.Script(constructs=constructs985) - result991 = _t1641 - record_span!(parser, span_start990) - return result991 + _t1717 = Proto.Script(constructs=constructs1017) + result1023 = _t1717 + record_span!(parser, span_start1022) + return result1023 end function parse_construct(parser::ParserState)::Proto.Construct - span_start995 = span_start(parser) + span_start1027 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1643 = 1 + _t1719 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1644 = 1 + _t1720 = 1 else if match_lookahead_literal(parser, "monoid", 1) - _t1645 = 1 + _t1721 = 1 else if match_lookahead_literal(parser, "loop", 1) - _t1646 = 0 + _t1722 = 0 else if match_lookahead_literal(parser, "break", 1) - _t1647 = 1 + _t1723 = 1 else if match_lookahead_literal(parser, "assign", 1) - _t1648 = 1 + _t1724 = 1 else - _t1648 = -1 + _t1724 = -1 end - _t1647 = _t1648 + _t1723 = _t1724 end - _t1646 = _t1647 + _t1722 = _t1723 end - _t1645 = _t1646 + _t1721 = _t1722 end - _t1644 = _t1645 + _t1720 = _t1721 end - _t1643 = _t1644 + _t1719 = _t1720 end - _t1642 = _t1643 + _t1718 = _t1719 else - _t1642 = -1 - end - prediction992 = _t1642 - if prediction992 == 1 - _t1650 = parse_instruction(parser) - instruction994 = _t1650 - _t1651 = Proto.Construct(construct_type=OneOf(:instruction, instruction994)) - _t1649 = _t1651 + _t1718 = -1 + end + prediction1024 = _t1718 + if prediction1024 == 1 + push_path!(parser, 2) + _t1726 = parse_instruction(parser) + instruction1026 = _t1726 + pop_path!(parser) + _t1727 = Proto.Construct(construct_type=OneOf(:instruction, instruction1026)) + _t1725 = _t1727 else - if prediction992 == 0 - _t1653 = parse_loop(parser) - loop993 = _t1653 - _t1654 = Proto.Construct(construct_type=OneOf(:loop, loop993)) - _t1652 = _t1654 + if prediction1024 == 0 + push_path!(parser, 1) + _t1729 = parse_loop(parser) + loop1025 = _t1729 + pop_path!(parser) + _t1730 = Proto.Construct(construct_type=OneOf(:loop, loop1025)) + _t1728 = _t1730 else throw(ParseError("Unexpected token in construct" * ": " * string(lookahead(parser, 0)))) end - _t1649 = _t1652 + _t1725 = _t1728 end - result996 = _t1649 - record_span!(parser, span_start995) - return result996 + result1028 = _t1725 + record_span!(parser, span_start1027) + return result1028 end function parse_loop(parser::ParserState)::Proto.Loop - span_start999 = span_start(parser) + span_start1031 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "loop") push_path!(parser, 1) - _t1655 = parse_init(parser) - init997 = _t1655 + _t1731 = parse_init(parser) + init1029 = _t1731 pop_path!(parser) push_path!(parser, 2) - _t1656 = parse_script(parser) - script998 = _t1656 + _t1732 = parse_script(parser) + script1030 = _t1732 pop_path!(parser) consume_literal!(parser, ")") - _t1657 = Proto.Loop(init=init997, body=script998) - result1000 = _t1657 - record_span!(parser, span_start999) - return result1000 + _t1733 = Proto.Loop(init=init1029, body=script1030) + result1032 = _t1733 + record_span!(parser, span_start1031) + return result1032 end function parse_init(parser::ParserState)::Vector{Proto.Instruction} - span_start1005 = span_start(parser) + span_start1041 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "init") - xs1001 = Proto.Instruction[] - cond1002 = match_lookahead_literal(parser, "(", 0) - while cond1002 - _t1658 = parse_instruction(parser) - item1003 = _t1658 - push!(xs1001, item1003) - cond1002 = match_lookahead_literal(parser, "(", 0) + xs1037 = Proto.Instruction[] + cond1038 = match_lookahead_literal(parser, "(", 0) + idx1039 = 0 + while cond1038 + push_path!(parser, idx1039) + _t1734 = parse_instruction(parser) + item1040 = _t1734 + pop_path!(parser) + push!(xs1037, item1040) + idx1039 = (idx1039 + 1) + cond1038 = match_lookahead_literal(parser, "(", 0) end - instructions1004 = xs1001 + instructions1036 = xs1037 consume_literal!(parser, ")") - result1006 = instructions1004 - record_span!(parser, span_start1005) - return result1006 + result1042 = instructions1036 + record_span!(parser, span_start1041) + return result1042 end function parse_instruction(parser::ParserState)::Proto.Instruction - span_start1013 = span_start(parser) + span_start1049 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1660 = 1 + _t1736 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1661 = 4 + _t1737 = 4 else if match_lookahead_literal(parser, "monoid", 1) - _t1662 = 3 + _t1738 = 3 else if match_lookahead_literal(parser, "break", 1) - _t1663 = 2 + _t1739 = 2 else if match_lookahead_literal(parser, "assign", 1) - _t1664 = 0 + _t1740 = 0 else - _t1664 = -1 + _t1740 = -1 end - _t1663 = _t1664 + _t1739 = _t1740 end - _t1662 = _t1663 + _t1738 = _t1739 end - _t1661 = _t1662 + _t1737 = _t1738 end - _t1660 = _t1661 + _t1736 = _t1737 end - _t1659 = _t1660 + _t1735 = _t1736 else - _t1659 = -1 - end - prediction1007 = _t1659 - if prediction1007 == 4 - _t1666 = parse_monus_def(parser) - monus_def1012 = _t1666 - _t1667 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def1012)) - _t1665 = _t1667 + _t1735 = -1 + end + prediction1043 = _t1735 + if prediction1043 == 4 + push_path!(parser, 6) + _t1742 = parse_monus_def(parser) + monus_def1048 = _t1742 + pop_path!(parser) + _t1743 = Proto.Instruction(instr_type=OneOf(:monus_def, monus_def1048)) + _t1741 = _t1743 else - if prediction1007 == 3 - _t1669 = parse_monoid_def(parser) - monoid_def1011 = _t1669 - _t1670 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def1011)) - _t1668 = _t1670 + if prediction1043 == 3 + push_path!(parser, 5) + _t1745 = parse_monoid_def(parser) + monoid_def1047 = _t1745 + pop_path!(parser) + _t1746 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def1047)) + _t1744 = _t1746 else - if prediction1007 == 2 - _t1672 = parse_break(parser) - break1010 = _t1672 - _t1673 = Proto.Instruction(instr_type=OneOf(:var"#break", break1010)) - _t1671 = _t1673 + if prediction1043 == 2 + push_path!(parser, 3) + _t1748 = parse_break(parser) + break1046 = _t1748 + pop_path!(parser) + _t1749 = Proto.Instruction(instr_type=OneOf(:var"#break", break1046)) + _t1747 = _t1749 else - if prediction1007 == 1 - _t1675 = parse_upsert(parser) - upsert1009 = _t1675 - _t1676 = Proto.Instruction(instr_type=OneOf(:upsert, upsert1009)) - _t1674 = _t1676 + if prediction1043 == 1 + push_path!(parser, 2) + _t1751 = parse_upsert(parser) + upsert1045 = _t1751 + pop_path!(parser) + _t1752 = Proto.Instruction(instr_type=OneOf(:upsert, upsert1045)) + _t1750 = _t1752 else - if prediction1007 == 0 - _t1678 = parse_assign(parser) - assign1008 = _t1678 - _t1679 = Proto.Instruction(instr_type=OneOf(:assign, assign1008)) - _t1677 = _t1679 + if prediction1043 == 0 + push_path!(parser, 1) + _t1754 = parse_assign(parser) + assign1044 = _t1754 + pop_path!(parser) + _t1755 = Proto.Instruction(instr_type=OneOf(:assign, assign1044)) + _t1753 = _t1755 else throw(ParseError("Unexpected token in instruction" * ": " * string(lookahead(parser, 0)))) end - _t1674 = _t1677 + _t1750 = _t1753 end - _t1671 = _t1674 + _t1747 = _t1750 end - _t1668 = _t1671 + _t1744 = _t1747 end - _t1665 = _t1668 + _t1741 = _t1744 end - result1014 = _t1665 - record_span!(parser, span_start1013) - return result1014 + result1050 = _t1741 + record_span!(parser, span_start1049) + return result1050 end function parse_assign(parser::ParserState)::Proto.Assign - span_start1018 = span_start(parser) + span_start1054 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "assign") push_path!(parser, 1) - _t1680 = parse_relation_id(parser) - relation_id1015 = _t1680 + _t1756 = parse_relation_id(parser) + relation_id1051 = _t1756 pop_path!(parser) push_path!(parser, 2) - _t1681 = parse_abstraction(parser) - abstraction1016 = _t1681 + _t1757 = parse_abstraction(parser) + abstraction1052 = _t1757 pop_path!(parser) push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1683 = parse_attrs(parser) - _t1682 = _t1683 + _t1759 = parse_attrs(parser) + _t1758 = _t1759 else - _t1682 = nothing + _t1758 = nothing end - attrs1017 = _t1682 + attrs1053 = _t1758 pop_path!(parser) consume_literal!(parser, ")") - _t1684 = Proto.Assign(name=relation_id1015, body=abstraction1016, attrs=(!isnothing(attrs1017) ? attrs1017 : Proto.Attribute[])) - result1019 = _t1684 - record_span!(parser, span_start1018) - return result1019 + _t1760 = Proto.Assign(name=relation_id1051, body=abstraction1052, attrs=(!isnothing(attrs1053) ? attrs1053 : Proto.Attribute[])) + result1055 = _t1760 + record_span!(parser, span_start1054) + return result1055 end function parse_upsert(parser::ParserState)::Proto.Upsert - span_start1023 = span_start(parser) + span_start1059 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "upsert") push_path!(parser, 1) - _t1685 = parse_relation_id(parser) - relation_id1020 = _t1685 + _t1761 = parse_relation_id(parser) + relation_id1056 = _t1761 pop_path!(parser) - _t1686 = parse_abstraction_with_arity(parser) - abstraction_with_arity1021 = _t1686 + _t1762 = parse_abstraction_with_arity(parser) + abstraction_with_arity1057 = _t1762 push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1688 = parse_attrs(parser) - _t1687 = _t1688 + _t1764 = parse_attrs(parser) + _t1763 = _t1764 else - _t1687 = nothing + _t1763 = nothing end - attrs1022 = _t1687 + attrs1058 = _t1763 pop_path!(parser) consume_literal!(parser, ")") - _t1689 = Proto.Upsert(name=relation_id1020, body=abstraction_with_arity1021[1], attrs=(!isnothing(attrs1022) ? attrs1022 : Proto.Attribute[]), value_arity=abstraction_with_arity1021[2]) - result1024 = _t1689 - record_span!(parser, span_start1023) - return result1024 + _t1765 = Proto.Upsert(name=relation_id1056, body=abstraction_with_arity1057[1], attrs=(!isnothing(attrs1058) ? attrs1058 : Proto.Attribute[]), value_arity=abstraction_with_arity1057[2]) + result1060 = _t1765 + record_span!(parser, span_start1059) + return result1060 end function parse_abstraction_with_arity(parser::ParserState)::Tuple{Proto.Abstraction, Int64} - span_start1027 = span_start(parser) + span_start1063 = span_start(parser) consume_literal!(parser, "(") - _t1690 = parse_bindings(parser) - bindings1025 = _t1690 - _t1691 = parse_formula(parser) - formula1026 = _t1691 + _t1766 = parse_bindings(parser) + bindings1061 = _t1766 + _t1767 = parse_formula(parser) + formula1062 = _t1767 consume_literal!(parser, ")") - _t1692 = Proto.Abstraction(vars=vcat(bindings1025[1], !isnothing(bindings1025[2]) ? bindings1025[2] : []), value=formula1026) - result1028 = (_t1692, length(bindings1025[2]),) - record_span!(parser, span_start1027) - return result1028 + _t1768 = Proto.Abstraction(vars=vcat(bindings1061[1], !isnothing(bindings1061[2]) ? bindings1061[2] : []), value=formula1062) + result1064 = (_t1768, length(bindings1061[2]),) + record_span!(parser, span_start1063) + return result1064 end function parse_break(parser::ParserState)::Proto.Break - span_start1032 = span_start(parser) + span_start1068 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "break") push_path!(parser, 1) - _t1693 = parse_relation_id(parser) - relation_id1029 = _t1693 + _t1769 = parse_relation_id(parser) + relation_id1065 = _t1769 pop_path!(parser) push_path!(parser, 2) - _t1694 = parse_abstraction(parser) - abstraction1030 = _t1694 + _t1770 = parse_abstraction(parser) + abstraction1066 = _t1770 pop_path!(parser) push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1696 = parse_attrs(parser) - _t1695 = _t1696 + _t1772 = parse_attrs(parser) + _t1771 = _t1772 else - _t1695 = nothing + _t1771 = nothing end - attrs1031 = _t1695 + attrs1067 = _t1771 pop_path!(parser) consume_literal!(parser, ")") - _t1697 = Proto.Break(name=relation_id1029, body=abstraction1030, attrs=(!isnothing(attrs1031) ? attrs1031 : Proto.Attribute[])) - result1033 = _t1697 - record_span!(parser, span_start1032) - return result1033 + _t1773 = Proto.Break(name=relation_id1065, body=abstraction1066, attrs=(!isnothing(attrs1067) ? attrs1067 : Proto.Attribute[])) + result1069 = _t1773 + record_span!(parser, span_start1068) + return result1069 end function parse_monoid_def(parser::ParserState)::Proto.MonoidDef - span_start1038 = span_start(parser) + span_start1074 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monoid") push_path!(parser, 1) - _t1698 = parse_monoid(parser) - monoid1034 = _t1698 + _t1774 = parse_monoid(parser) + monoid1070 = _t1774 pop_path!(parser) push_path!(parser, 2) - _t1699 = parse_relation_id(parser) - relation_id1035 = _t1699 + _t1775 = parse_relation_id(parser) + relation_id1071 = _t1775 pop_path!(parser) - _t1700 = parse_abstraction_with_arity(parser) - abstraction_with_arity1036 = _t1700 + _t1776 = parse_abstraction_with_arity(parser) + abstraction_with_arity1072 = _t1776 push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1702 = parse_attrs(parser) - _t1701 = _t1702 + _t1778 = parse_attrs(parser) + _t1777 = _t1778 else - _t1701 = nothing + _t1777 = nothing end - attrs1037 = _t1701 + attrs1073 = _t1777 pop_path!(parser) consume_literal!(parser, ")") - _t1703 = Proto.MonoidDef(monoid=monoid1034, name=relation_id1035, body=abstraction_with_arity1036[1], attrs=(!isnothing(attrs1037) ? attrs1037 : Proto.Attribute[]), value_arity=abstraction_with_arity1036[2]) - result1039 = _t1703 - record_span!(parser, span_start1038) - return result1039 + _t1779 = Proto.MonoidDef(monoid=monoid1070, name=relation_id1071, body=abstraction_with_arity1072[1], attrs=(!isnothing(attrs1073) ? attrs1073 : Proto.Attribute[]), value_arity=abstraction_with_arity1072[2]) + result1075 = _t1779 + record_span!(parser, span_start1074) + return result1075 end function parse_monoid(parser::ParserState)::Proto.Monoid - span_start1045 = span_start(parser) + span_start1081 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "sum", 1) - _t1705 = 3 + _t1781 = 3 else if match_lookahead_literal(parser, "or", 1) - _t1706 = 0 + _t1782 = 0 else if match_lookahead_literal(parser, "min", 1) - _t1707 = 1 + _t1783 = 1 else if match_lookahead_literal(parser, "max", 1) - _t1708 = 2 + _t1784 = 2 else - _t1708 = -1 + _t1784 = -1 end - _t1707 = _t1708 + _t1783 = _t1784 end - _t1706 = _t1707 + _t1782 = _t1783 end - _t1705 = _t1706 + _t1781 = _t1782 end - _t1704 = _t1705 + _t1780 = _t1781 else - _t1704 = -1 - end - prediction1040 = _t1704 - if prediction1040 == 3 - _t1710 = parse_sum_monoid(parser) - sum_monoid1044 = _t1710 - _t1711 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid1044)) - _t1709 = _t1711 + _t1780 = -1 + end + prediction1076 = _t1780 + if prediction1076 == 3 + push_path!(parser, 4) + _t1786 = parse_sum_monoid(parser) + sum_monoid1080 = _t1786 + pop_path!(parser) + _t1787 = Proto.Monoid(value=OneOf(:sum_monoid, sum_monoid1080)) + _t1785 = _t1787 else - if prediction1040 == 2 - _t1713 = parse_max_monoid(parser) - max_monoid1043 = _t1713 - _t1714 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid1043)) - _t1712 = _t1714 + if prediction1076 == 2 + push_path!(parser, 3) + _t1789 = parse_max_monoid(parser) + max_monoid1079 = _t1789 + pop_path!(parser) + _t1790 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid1079)) + _t1788 = _t1790 else - if prediction1040 == 1 - _t1716 = parse_min_monoid(parser) - min_monoid1042 = _t1716 - _t1717 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid1042)) - _t1715 = _t1717 + if prediction1076 == 1 + push_path!(parser, 2) + _t1792 = parse_min_monoid(parser) + min_monoid1078 = _t1792 + pop_path!(parser) + _t1793 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid1078)) + _t1791 = _t1793 else - if prediction1040 == 0 - _t1719 = parse_or_monoid(parser) - or_monoid1041 = _t1719 - _t1720 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid1041)) - _t1718 = _t1720 + if prediction1076 == 0 + push_path!(parser, 1) + _t1795 = parse_or_monoid(parser) + or_monoid1077 = _t1795 + pop_path!(parser) + _t1796 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid1077)) + _t1794 = _t1796 else throw(ParseError("Unexpected token in monoid" * ": " * string(lookahead(parser, 0)))) end - _t1715 = _t1718 + _t1791 = _t1794 end - _t1712 = _t1715 + _t1788 = _t1791 end - _t1709 = _t1712 + _t1785 = _t1788 end - result1046 = _t1709 - record_span!(parser, span_start1045) - return result1046 + result1082 = _t1785 + record_span!(parser, span_start1081) + return result1082 end function parse_or_monoid(parser::ParserState)::Proto.OrMonoid - span_start1047 = span_start(parser) + span_start1083 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") consume_literal!(parser, ")") - _t1721 = Proto.OrMonoid() - result1048 = _t1721 - record_span!(parser, span_start1047) - return result1048 + _t1797 = Proto.OrMonoid() + result1084 = _t1797 + record_span!(parser, span_start1083) + return result1084 end function parse_min_monoid(parser::ParserState)::Proto.MinMonoid - span_start1050 = span_start(parser) + span_start1086 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "min") push_path!(parser, 1) - _t1722 = parse_type(parser) - type1049 = _t1722 + _t1798 = parse_type(parser) + type1085 = _t1798 pop_path!(parser) consume_literal!(parser, ")") - _t1723 = Proto.MinMonoid(var"#type"=type1049) - result1051 = _t1723 - record_span!(parser, span_start1050) - return result1051 + _t1799 = Proto.MinMonoid(var"#type"=type1085) + result1087 = _t1799 + record_span!(parser, span_start1086) + return result1087 end function parse_max_monoid(parser::ParserState)::Proto.MaxMonoid - span_start1053 = span_start(parser) + span_start1089 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "max") push_path!(parser, 1) - _t1724 = parse_type(parser) - type1052 = _t1724 + _t1800 = parse_type(parser) + type1088 = _t1800 pop_path!(parser) consume_literal!(parser, ")") - _t1725 = Proto.MaxMonoid(var"#type"=type1052) - result1054 = _t1725 - record_span!(parser, span_start1053) - return result1054 + _t1801 = Proto.MaxMonoid(var"#type"=type1088) + result1090 = _t1801 + record_span!(parser, span_start1089) + return result1090 end function parse_sum_monoid(parser::ParserState)::Proto.SumMonoid - span_start1056 = span_start(parser) + span_start1092 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sum") push_path!(parser, 1) - _t1726 = parse_type(parser) - type1055 = _t1726 + _t1802 = parse_type(parser) + type1091 = _t1802 pop_path!(parser) consume_literal!(parser, ")") - _t1727 = Proto.SumMonoid(var"#type"=type1055) - result1057 = _t1727 - record_span!(parser, span_start1056) - return result1057 + _t1803 = Proto.SumMonoid(var"#type"=type1091) + result1093 = _t1803 + record_span!(parser, span_start1092) + return result1093 end function parse_monus_def(parser::ParserState)::Proto.MonusDef - span_start1062 = span_start(parser) + span_start1098 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "monus") push_path!(parser, 1) - _t1728 = parse_monoid(parser) - monoid1058 = _t1728 + _t1804 = parse_monoid(parser) + monoid1094 = _t1804 pop_path!(parser) push_path!(parser, 2) - _t1729 = parse_relation_id(parser) - relation_id1059 = _t1729 + _t1805 = parse_relation_id(parser) + relation_id1095 = _t1805 pop_path!(parser) - _t1730 = parse_abstraction_with_arity(parser) - abstraction_with_arity1060 = _t1730 + _t1806 = parse_abstraction_with_arity(parser) + abstraction_with_arity1096 = _t1806 push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1732 = parse_attrs(parser) - _t1731 = _t1732 + _t1808 = parse_attrs(parser) + _t1807 = _t1808 else - _t1731 = nothing + _t1807 = nothing end - attrs1061 = _t1731 + attrs1097 = _t1807 pop_path!(parser) consume_literal!(parser, ")") - _t1733 = Proto.MonusDef(monoid=monoid1058, name=relation_id1059, body=abstraction_with_arity1060[1], attrs=(!isnothing(attrs1061) ? attrs1061 : Proto.Attribute[]), value_arity=abstraction_with_arity1060[2]) - result1063 = _t1733 - record_span!(parser, span_start1062) - return result1063 + _t1809 = Proto.MonusDef(monoid=monoid1094, name=relation_id1095, body=abstraction_with_arity1096[1], attrs=(!isnothing(attrs1097) ? attrs1097 : Proto.Attribute[]), value_arity=abstraction_with_arity1096[2]) + result1099 = _t1809 + record_span!(parser, span_start1098) + return result1099 end function parse_constraint(parser::ParserState)::Proto.Constraint - span_start1068 = span_start(parser) + span_start1104 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "functional_dependency") push_path!(parser, 2) - _t1734 = parse_relation_id(parser) - relation_id1064 = _t1734 - pop_path!(parser) - _t1735 = parse_abstraction(parser) - abstraction1065 = _t1735 - _t1736 = parse_functional_dependency_keys(parser) - functional_dependency_keys1066 = _t1736 - _t1737 = parse_functional_dependency_values(parser) - functional_dependency_values1067 = _t1737 - consume_literal!(parser, ")") - _t1738 = Proto.FunctionalDependency(guard=abstraction1065, keys=functional_dependency_keys1066, values=functional_dependency_values1067) - _t1739 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t1738), name=relation_id1064) - result1069 = _t1739 - record_span!(parser, span_start1068) - return result1069 + _t1810 = parse_relation_id(parser) + relation_id1100 = _t1810 + pop_path!(parser) + _t1811 = parse_abstraction(parser) + abstraction1101 = _t1811 + _t1812 = parse_functional_dependency_keys(parser) + functional_dependency_keys1102 = _t1812 + _t1813 = parse_functional_dependency_values(parser) + functional_dependency_values1103 = _t1813 + consume_literal!(parser, ")") + _t1814 = Proto.FunctionalDependency(guard=abstraction1101, keys=functional_dependency_keys1102, values=functional_dependency_values1103) + _t1815 = Proto.Constraint(constraint_type=OneOf(:functional_dependency, _t1814), name=relation_id1100) + result1105 = _t1815 + record_span!(parser, span_start1104) + return result1105 end function parse_functional_dependency_keys(parser::ParserState)::Vector{Proto.Var} - span_start1074 = span_start(parser) + span_start1114 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "keys") - xs1070 = Proto.Var[] - cond1071 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond1071 - _t1740 = parse_var(parser) - item1072 = _t1740 - push!(xs1070, item1072) - cond1071 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs1110 = Proto.Var[] + cond1111 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx1112 = 0 + while cond1111 + push_path!(parser, idx1112) + _t1816 = parse_var(parser) + item1113 = _t1816 + pop_path!(parser) + push!(xs1110, item1113) + idx1112 = (idx1112 + 1) + cond1111 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars1073 = xs1070 + vars1109 = xs1110 consume_literal!(parser, ")") - result1075 = vars1073 - record_span!(parser, span_start1074) - return result1075 + result1115 = vars1109 + record_span!(parser, span_start1114) + return result1115 end function parse_functional_dependency_values(parser::ParserState)::Vector{Proto.Var} - span_start1080 = span_start(parser) + span_start1124 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "values") - xs1076 = Proto.Var[] - cond1077 = match_lookahead_terminal(parser, "SYMBOL", 0) - while cond1077 - _t1741 = parse_var(parser) - item1078 = _t1741 - push!(xs1076, item1078) - cond1077 = match_lookahead_terminal(parser, "SYMBOL", 0) + xs1120 = Proto.Var[] + cond1121 = match_lookahead_terminal(parser, "SYMBOL", 0) + idx1122 = 0 + while cond1121 + push_path!(parser, idx1122) + _t1817 = parse_var(parser) + item1123 = _t1817 + pop_path!(parser) + push!(xs1120, item1123) + idx1122 = (idx1122 + 1) + cond1121 = match_lookahead_terminal(parser, "SYMBOL", 0) end - vars1079 = xs1076 + vars1119 = xs1120 consume_literal!(parser, ")") - result1081 = vars1079 - record_span!(parser, span_start1080) - return result1081 + result1125 = vars1119 + record_span!(parser, span_start1124) + return result1125 end function parse_data(parser::ParserState)::Proto.Data - span_start1086 = span_start(parser) + span_start1130 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t1743 = 0 + _t1819 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t1744 = 2 + _t1820 = 2 else if match_lookahead_literal(parser, "betree_relation", 1) - _t1745 = 1 + _t1821 = 1 else - _t1745 = -1 + _t1821 = -1 end - _t1744 = _t1745 + _t1820 = _t1821 end - _t1743 = _t1744 + _t1819 = _t1820 end - _t1742 = _t1743 + _t1818 = _t1819 else - _t1742 = -1 - end - prediction1082 = _t1742 - if prediction1082 == 2 - _t1747 = parse_csv_data(parser) - csv_data1085 = _t1747 - _t1748 = Proto.Data(data_type=OneOf(:csv_data, csv_data1085)) - _t1746 = _t1748 + _t1818 = -1 + end + prediction1126 = _t1818 + if prediction1126 == 2 + push_path!(parser, 3) + _t1823 = parse_csv_data(parser) + csv_data1129 = _t1823 + pop_path!(parser) + _t1824 = Proto.Data(data_type=OneOf(:csv_data, csv_data1129)) + _t1822 = _t1824 else - if prediction1082 == 1 - _t1750 = parse_betree_relation(parser) - betree_relation1084 = _t1750 - _t1751 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation1084)) - _t1749 = _t1751 + if prediction1126 == 1 + push_path!(parser, 2) + _t1826 = parse_betree_relation(parser) + betree_relation1128 = _t1826 + pop_path!(parser) + _t1827 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation1128)) + _t1825 = _t1827 else - if prediction1082 == 0 - _t1753 = parse_rel_edb(parser) - rel_edb1083 = _t1753 - _t1754 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb1083)) - _t1752 = _t1754 + if prediction1126 == 0 + push_path!(parser, 1) + _t1829 = parse_rel_edb(parser) + rel_edb1127 = _t1829 + pop_path!(parser) + _t1830 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb1127)) + _t1828 = _t1830 else throw(ParseError("Unexpected token in data" * ": " * string(lookahead(parser, 0)))) end - _t1749 = _t1752 + _t1825 = _t1828 end - _t1746 = _t1749 + _t1822 = _t1825 end - result1087 = _t1746 - record_span!(parser, span_start1086) - return result1087 + result1131 = _t1822 + record_span!(parser, span_start1130) + return result1131 end function parse_rel_edb(parser::ParserState)::Proto.RelEDB - span_start1091 = span_start(parser) + span_start1135 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "rel_edb") push_path!(parser, 1) - _t1755 = parse_relation_id(parser) - relation_id1088 = _t1755 + _t1831 = parse_relation_id(parser) + relation_id1132 = _t1831 pop_path!(parser) push_path!(parser, 2) - _t1756 = parse_rel_edb_path(parser) - rel_edb_path1089 = _t1756 + _t1832 = parse_rel_edb_path(parser) + rel_edb_path1133 = _t1832 pop_path!(parser) push_path!(parser, 3) - _t1757 = parse_rel_edb_types(parser) - rel_edb_types1090 = _t1757 + _t1833 = parse_rel_edb_types(parser) + rel_edb_types1134 = _t1833 pop_path!(parser) consume_literal!(parser, ")") - _t1758 = Proto.RelEDB(target_id=relation_id1088, path=rel_edb_path1089, types=rel_edb_types1090) - result1092 = _t1758 - record_span!(parser, span_start1091) - return result1092 + _t1834 = Proto.RelEDB(target_id=relation_id1132, path=rel_edb_path1133, types=rel_edb_types1134) + result1136 = _t1834 + record_span!(parser, span_start1135) + return result1136 end function parse_rel_edb_path(parser::ParserState)::Vector{String} - span_start1097 = span_start(parser) + span_start1145 = span_start(parser) consume_literal!(parser, "[") - xs1093 = String[] - cond1094 = match_lookahead_terminal(parser, "STRING", 0) - while cond1094 - item1095 = consume_terminal!(parser, "STRING") - push!(xs1093, item1095) - cond1094 = match_lookahead_terminal(parser, "STRING", 0) - end - strings1096 = xs1093 + xs1141 = String[] + cond1142 = match_lookahead_terminal(parser, "STRING", 0) + idx1143 = 0 + while cond1142 + push_path!(parser, idx1143) + item1144 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push!(xs1141, item1144) + idx1143 = (idx1143 + 1) + cond1142 = match_lookahead_terminal(parser, "STRING", 0) + end + strings1140 = xs1141 consume_literal!(parser, "]") - result1098 = strings1096 - record_span!(parser, span_start1097) - return result1098 + result1146 = strings1140 + record_span!(parser, span_start1145) + return result1146 end function parse_rel_edb_types(parser::ParserState)::Vector{Proto.var"#Type"} - span_start1103 = span_start(parser) + span_start1155 = span_start(parser) consume_literal!(parser, "[") - xs1099 = Proto.var"#Type"[] - cond1100 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond1100 - _t1759 = parse_type(parser) - item1101 = _t1759 - push!(xs1099, item1101) - cond1100 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - end - types1102 = xs1099 + xs1151 = Proto.var"#Type"[] + cond1152 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx1153 = 0 + while cond1152 + push_path!(parser, idx1153) + _t1835 = parse_type(parser) + item1154 = _t1835 + pop_path!(parser) + push!(xs1151, item1154) + idx1153 = (idx1153 + 1) + cond1152 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + end + types1150 = xs1151 consume_literal!(parser, "]") - result1104 = types1102 - record_span!(parser, span_start1103) - return result1104 + result1156 = types1150 + record_span!(parser, span_start1155) + return result1156 end function parse_betree_relation(parser::ParserState)::Proto.BeTreeRelation - span_start1107 = span_start(parser) + span_start1159 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_relation") push_path!(parser, 1) - _t1760 = parse_relation_id(parser) - relation_id1105 = _t1760 + _t1836 = parse_relation_id(parser) + relation_id1157 = _t1836 pop_path!(parser) push_path!(parser, 2) - _t1761 = parse_betree_info(parser) - betree_info1106 = _t1761 + _t1837 = parse_betree_info(parser) + betree_info1158 = _t1837 pop_path!(parser) consume_literal!(parser, ")") - _t1762 = Proto.BeTreeRelation(name=relation_id1105, relation_info=betree_info1106) - result1108 = _t1762 - record_span!(parser, span_start1107) - return result1108 + _t1838 = Proto.BeTreeRelation(name=relation_id1157, relation_info=betree_info1158) + result1160 = _t1838 + record_span!(parser, span_start1159) + return result1160 end function parse_betree_info(parser::ParserState)::Proto.BeTreeInfo - span_start1112 = span_start(parser) + span_start1164 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "betree_info") - _t1763 = parse_betree_info_key_types(parser) - betree_info_key_types1109 = _t1763 - _t1764 = parse_betree_info_value_types(parser) - betree_info_value_types1110 = _t1764 - _t1765 = parse_config_dict(parser) - config_dict1111 = _t1765 - consume_literal!(parser, ")") - _t1766 = construct_betree_info(parser, betree_info_key_types1109, betree_info_value_types1110, config_dict1111) - result1113 = _t1766 - record_span!(parser, span_start1112) - return result1113 + _t1839 = parse_betree_info_key_types(parser) + betree_info_key_types1161 = _t1839 + _t1840 = parse_betree_info_value_types(parser) + betree_info_value_types1162 = _t1840 + _t1841 = parse_config_dict(parser) + config_dict1163 = _t1841 + consume_literal!(parser, ")") + _t1842 = construct_betree_info(parser, betree_info_key_types1161, betree_info_value_types1162, config_dict1163) + result1165 = _t1842 + record_span!(parser, span_start1164) + return result1165 end function parse_betree_info_key_types(parser::ParserState)::Vector{Proto.var"#Type"} - span_start1118 = span_start(parser) + span_start1174 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "key_types") - xs1114 = Proto.var"#Type"[] - cond1115 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond1115 - _t1767 = parse_type(parser) - item1116 = _t1767 - push!(xs1114, item1116) - cond1115 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs1170 = Proto.var"#Type"[] + cond1171 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx1172 = 0 + while cond1171 + push_path!(parser, idx1172) + _t1843 = parse_type(parser) + item1173 = _t1843 + pop_path!(parser) + push!(xs1170, item1173) + idx1172 = (idx1172 + 1) + cond1171 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types1117 = xs1114 + types1169 = xs1170 consume_literal!(parser, ")") - result1119 = types1117 - record_span!(parser, span_start1118) - return result1119 + result1175 = types1169 + record_span!(parser, span_start1174) + return result1175 end function parse_betree_info_value_types(parser::ParserState)::Vector{Proto.var"#Type"} - span_start1124 = span_start(parser) + span_start1184 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "value_types") - xs1120 = Proto.var"#Type"[] - cond1121 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - while cond1121 - _t1768 = parse_type(parser) - item1122 = _t1768 - push!(xs1120, item1122) - cond1121 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + xs1180 = Proto.var"#Type"[] + cond1181 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx1182 = 0 + while cond1181 + push_path!(parser, idx1182) + _t1844 = parse_type(parser) + item1183 = _t1844 + pop_path!(parser) + push!(xs1180, item1183) + idx1182 = (idx1182 + 1) + cond1181 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types1123 = xs1120 + types1179 = xs1180 consume_literal!(parser, ")") - result1125 = types1123 - record_span!(parser, span_start1124) - return result1125 + result1185 = types1179 + record_span!(parser, span_start1184) + return result1185 end function parse_csv_data(parser::ParserState)::Proto.CSVData - span_start1130 = span_start(parser) + span_start1190 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_data") push_path!(parser, 1) - _t1769 = parse_csvlocator(parser) - csvlocator1126 = _t1769 + _t1845 = parse_csvlocator(parser) + csvlocator1186 = _t1845 pop_path!(parser) push_path!(parser, 2) - _t1770 = parse_csv_config(parser) - csv_config1127 = _t1770 + _t1846 = parse_csv_config(parser) + csv_config1187 = _t1846 pop_path!(parser) push_path!(parser, 3) - _t1771 = parse_csv_columns(parser) - csv_columns1128 = _t1771 + _t1847 = parse_csv_columns(parser) + csv_columns1188 = _t1847 pop_path!(parser) push_path!(parser, 4) - _t1772 = parse_csv_asof(parser) - csv_asof1129 = _t1772 + _t1848 = parse_csv_asof(parser) + csv_asof1189 = _t1848 pop_path!(parser) consume_literal!(parser, ")") - _t1773 = Proto.CSVData(locator=csvlocator1126, config=csv_config1127, columns=csv_columns1128, asof=csv_asof1129) - result1131 = _t1773 - record_span!(parser, span_start1130) - return result1131 + _t1849 = Proto.CSVData(locator=csvlocator1186, config=csv_config1187, columns=csv_columns1188, asof=csv_asof1189) + result1191 = _t1849 + record_span!(parser, span_start1190) + return result1191 end function parse_csvlocator(parser::ParserState)::Proto.CSVLocator - span_start1134 = span_start(parser) + span_start1194 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_locator") push_path!(parser, 1) if (match_lookahead_literal(parser, "(", 0) && match_lookahead_literal(parser, "paths", 1)) - _t1775 = parse_csv_locator_paths(parser) - _t1774 = _t1775 + _t1851 = parse_csv_locator_paths(parser) + _t1850 = _t1851 else - _t1774 = nothing + _t1850 = nothing end - csv_locator_paths1132 = _t1774 + csv_locator_paths1192 = _t1850 pop_path!(parser) push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t1777 = parse_csv_locator_inline_data(parser) - _t1776 = _t1777 + _t1853 = parse_csv_locator_inline_data(parser) + _t1852 = _t1853 else - _t1776 = nothing + _t1852 = nothing end - csv_locator_inline_data1133 = _t1776 + csv_locator_inline_data1193 = _t1852 pop_path!(parser) consume_literal!(parser, ")") - _t1778 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths1132) ? csv_locator_paths1132 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data1133) ? csv_locator_inline_data1133 : ""))) - result1135 = _t1778 - record_span!(parser, span_start1134) - return result1135 + _t1854 = Proto.CSVLocator(paths=(!isnothing(csv_locator_paths1192) ? csv_locator_paths1192 : String[]), inline_data=Vector{UInt8}((!isnothing(csv_locator_inline_data1193) ? csv_locator_inline_data1193 : ""))) + result1195 = _t1854 + record_span!(parser, span_start1194) + return result1195 end function parse_csv_locator_paths(parser::ParserState)::Vector{String} - span_start1140 = span_start(parser) + span_start1204 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "paths") - xs1136 = String[] - cond1137 = match_lookahead_terminal(parser, "STRING", 0) - while cond1137 - item1138 = consume_terminal!(parser, "STRING") - push!(xs1136, item1138) - cond1137 = match_lookahead_terminal(parser, "STRING", 0) + xs1200 = String[] + cond1201 = match_lookahead_terminal(parser, "STRING", 0) + idx1202 = 0 + while cond1201 + push_path!(parser, idx1202) + item1203 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push!(xs1200, item1203) + idx1202 = (idx1202 + 1) + cond1201 = match_lookahead_terminal(parser, "STRING", 0) end - strings1139 = xs1136 + strings1199 = xs1200 consume_literal!(parser, ")") - result1141 = strings1139 - record_span!(parser, span_start1140) - return result1141 + result1205 = strings1199 + record_span!(parser, span_start1204) + return result1205 end function parse_csv_locator_inline_data(parser::ParserState)::String - span_start1143 = span_start(parser) + span_start1207 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "inline_data") - string1142 = consume_terminal!(parser, "STRING") + string1206 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - result1144 = string1142 - record_span!(parser, span_start1143) - return result1144 + result1208 = string1206 + record_span!(parser, span_start1207) + return result1208 end function parse_csv_config(parser::ParserState)::Proto.CSVConfig - span_start1146 = span_start(parser) + span_start1210 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_config") - _t1779 = parse_config_dict(parser) - config_dict1145 = _t1779 + _t1855 = parse_config_dict(parser) + config_dict1209 = _t1855 consume_literal!(parser, ")") - _t1780 = construct_csv_config(parser, config_dict1145) - result1147 = _t1780 - record_span!(parser, span_start1146) - return result1147 + _t1856 = construct_csv_config(parser, config_dict1209) + result1211 = _t1856 + record_span!(parser, span_start1210) + return result1211 end function parse_csv_columns(parser::ParserState)::Vector{Proto.CSVColumn} - span_start1152 = span_start(parser) + span_start1220 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs1148 = Proto.CSVColumn[] - cond1149 = match_lookahead_literal(parser, "(", 0) - while cond1149 - _t1781 = parse_csv_column(parser) - item1150 = _t1781 - push!(xs1148, item1150) - cond1149 = match_lookahead_literal(parser, "(", 0) + xs1216 = Proto.CSVColumn[] + cond1217 = match_lookahead_literal(parser, "(", 0) + idx1218 = 0 + while cond1217 + push_path!(parser, idx1218) + _t1857 = parse_csv_column(parser) + item1219 = _t1857 + pop_path!(parser) + push!(xs1216, item1219) + idx1218 = (idx1218 + 1) + cond1217 = match_lookahead_literal(parser, "(", 0) end - csv_columns1151 = xs1148 + csv_columns1215 = xs1216 consume_literal!(parser, ")") - result1153 = csv_columns1151 - record_span!(parser, span_start1152) - return result1153 + result1221 = csv_columns1215 + record_span!(parser, span_start1220) + return result1221 end function parse_csv_column(parser::ParserState)::Proto.CSVColumn - span_start1164 = span_start(parser) + span_start1232 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") push_path!(parser, 1) - string1154 = consume_terminal!(parser, "STRING") + string1222 = consume_terminal!(parser, "STRING") pop_path!(parser) push_path!(parser, 2) - _t1782 = parse_relation_id(parser) - relation_id1155 = _t1782 + _t1858 = parse_relation_id(parser) + relation_id1223 = _t1858 pop_path!(parser) consume_literal!(parser, "[") push_path!(parser, 3) - xs1160 = Proto.var"#Type"[] - cond1161 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) - idx1162 = 0 - while cond1161 - push_path!(parser, idx1162) - _t1783 = parse_type(parser) - item1163 = _t1783 + xs1228 = Proto.var"#Type"[] + cond1229 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + idx1230 = 0 + while cond1229 + push_path!(parser, idx1230) + _t1859 = parse_type(parser) + item1231 = _t1859 pop_path!(parser) - push!(xs1160, item1163) - idx1162 = (idx1162 + 1) - cond1161 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) + push!(xs1228, item1231) + idx1230 = (idx1230 + 1) + cond1229 = ((((((((((match_lookahead_literal(parser, "(", 0) || match_lookahead_literal(parser, "BOOLEAN", 0)) || match_lookahead_literal(parser, "DATE", 0)) || match_lookahead_literal(parser, "DATETIME", 0)) || match_lookahead_literal(parser, "FLOAT", 0)) || match_lookahead_literal(parser, "INT", 0)) || match_lookahead_literal(parser, "INT128", 0)) || match_lookahead_literal(parser, "MISSING", 0)) || match_lookahead_literal(parser, "STRING", 0)) || match_lookahead_literal(parser, "UINT128", 0)) || match_lookahead_literal(parser, "UNKNOWN", 0)) end - types1159 = xs1160 + types1227 = xs1228 pop_path!(parser) consume_literal!(parser, "]") consume_literal!(parser, ")") - _t1784 = Proto.CSVColumn(column_name=string1154, target_id=relation_id1155, types=types1159) - result1165 = _t1784 - record_span!(parser, span_start1164) - return result1165 + _t1860 = Proto.CSVColumn(column_name=string1222, target_id=relation_id1223, types=types1227) + result1233 = _t1860 + record_span!(parser, span_start1232) + return result1233 end function parse_csv_asof(parser::ParserState)::String - span_start1167 = span_start(parser) + span_start1235 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "asof") - string1166 = consume_terminal!(parser, "STRING") + string1234 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - result1168 = string1166 - record_span!(parser, span_start1167) - return result1168 + result1236 = string1234 + record_span!(parser, span_start1235) + return result1236 end function parse_undefine(parser::ParserState)::Proto.Undefine - span_start1170 = span_start(parser) + span_start1238 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "undefine") push_path!(parser, 1) - _t1785 = parse_fragment_id(parser) - fragment_id1169 = _t1785 + _t1861 = parse_fragment_id(parser) + fragment_id1237 = _t1861 pop_path!(parser) consume_literal!(parser, ")") - _t1786 = Proto.Undefine(fragment_id=fragment_id1169) - result1171 = _t1786 - record_span!(parser, span_start1170) - return result1171 + _t1862 = Proto.Undefine(fragment_id=fragment_id1237) + result1239 = _t1862 + record_span!(parser, span_start1238) + return result1239 end function parse_context(parser::ParserState)::Proto.Context - span_start1180 = span_start(parser) + span_start1248 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "context") push_path!(parser, 1) - xs1176 = Proto.RelationId[] - cond1177 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) - idx1178 = 0 - while cond1177 - push_path!(parser, idx1178) - _t1787 = parse_relation_id(parser) - item1179 = _t1787 + xs1244 = Proto.RelationId[] + cond1245 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + idx1246 = 0 + while cond1245 + push_path!(parser, idx1246) + _t1863 = parse_relation_id(parser) + item1247 = _t1863 pop_path!(parser) - push!(xs1176, item1179) - idx1178 = (idx1178 + 1) - cond1177 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + push!(xs1244, item1247) + idx1246 = (idx1246 + 1) + cond1245 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) end - relation_ids1175 = xs1176 + relation_ids1243 = xs1244 pop_path!(parser) consume_literal!(parser, ")") - _t1788 = Proto.Context(relations=relation_ids1175) - result1181 = _t1788 - record_span!(parser, span_start1180) - return result1181 + _t1864 = Proto.Context(relations=relation_ids1243) + result1249 = _t1864 + record_span!(parser, span_start1248) + return result1249 end function parse_snapshot(parser::ParserState)::Proto.Snapshot - span_start1184 = span_start(parser) + span_start1252 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "snapshot") push_path!(parser, 1) - _t1789 = parse_rel_edb_path(parser) - rel_edb_path1182 = _t1789 + _t1865 = parse_rel_edb_path(parser) + rel_edb_path1250 = _t1865 pop_path!(parser) push_path!(parser, 2) - _t1790 = parse_relation_id(parser) - relation_id1183 = _t1790 + _t1866 = parse_relation_id(parser) + relation_id1251 = _t1866 pop_path!(parser) consume_literal!(parser, ")") - _t1791 = Proto.Snapshot(destination_path=rel_edb_path1182, source_relation=relation_id1183) - result1185 = _t1791 - record_span!(parser, span_start1184) - return result1185 + _t1867 = Proto.Snapshot(destination_path=rel_edb_path1250, source_relation=relation_id1251) + result1253 = _t1867 + record_span!(parser, span_start1252) + return result1253 end function parse_epoch_reads(parser::ParserState)::Vector{Proto.Read} - span_start1190 = span_start(parser) + span_start1262 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "reads") - xs1186 = Proto.Read[] - cond1187 = match_lookahead_literal(parser, "(", 0) - while cond1187 - _t1792 = parse_read(parser) - item1188 = _t1792 - push!(xs1186, item1188) - cond1187 = match_lookahead_literal(parser, "(", 0) + xs1258 = Proto.Read[] + cond1259 = match_lookahead_literal(parser, "(", 0) + idx1260 = 0 + while cond1259 + push_path!(parser, idx1260) + _t1868 = parse_read(parser) + item1261 = _t1868 + pop_path!(parser) + push!(xs1258, item1261) + idx1260 = (idx1260 + 1) + cond1259 = match_lookahead_literal(parser, "(", 0) end - reads1189 = xs1186 + reads1257 = xs1258 consume_literal!(parser, ")") - result1191 = reads1189 - record_span!(parser, span_start1190) - return result1191 + result1263 = reads1257 + record_span!(parser, span_start1262) + return result1263 end function parse_read(parser::ParserState)::Proto.Read - span_start1198 = span_start(parser) + span_start1270 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "what_if", 1) - _t1794 = 2 + _t1870 = 2 else if match_lookahead_literal(parser, "output", 1) - _t1795 = 1 + _t1871 = 1 else if match_lookahead_literal(parser, "export", 1) - _t1796 = 4 + _t1872 = 4 else if match_lookahead_literal(parser, "demand", 1) - _t1797 = 0 + _t1873 = 0 else if match_lookahead_literal(parser, "abort", 1) - _t1798 = 3 + _t1874 = 3 else - _t1798 = -1 + _t1874 = -1 end - _t1797 = _t1798 + _t1873 = _t1874 end - _t1796 = _t1797 + _t1872 = _t1873 end - _t1795 = _t1796 + _t1871 = _t1872 end - _t1794 = _t1795 + _t1870 = _t1871 end - _t1793 = _t1794 + _t1869 = _t1870 else - _t1793 = -1 - end - prediction1192 = _t1793 - if prediction1192 == 4 - _t1800 = parse_export(parser) - export1197 = _t1800 - _t1801 = Proto.Read(read_type=OneOf(:var"#export", export1197)) - _t1799 = _t1801 + _t1869 = -1 + end + prediction1264 = _t1869 + if prediction1264 == 4 + push_path!(parser, 5) + _t1876 = parse_export(parser) + export1269 = _t1876 + pop_path!(parser) + _t1877 = Proto.Read(read_type=OneOf(:var"#export", export1269)) + _t1875 = _t1877 else - if prediction1192 == 3 - _t1803 = parse_abort(parser) - abort1196 = _t1803 - _t1804 = Proto.Read(read_type=OneOf(:abort, abort1196)) - _t1802 = _t1804 + if prediction1264 == 3 + push_path!(parser, 4) + _t1879 = parse_abort(parser) + abort1268 = _t1879 + pop_path!(parser) + _t1880 = Proto.Read(read_type=OneOf(:abort, abort1268)) + _t1878 = _t1880 else - if prediction1192 == 2 - _t1806 = parse_what_if(parser) - what_if1195 = _t1806 - _t1807 = Proto.Read(read_type=OneOf(:what_if, what_if1195)) - _t1805 = _t1807 + if prediction1264 == 2 + push_path!(parser, 3) + _t1882 = parse_what_if(parser) + what_if1267 = _t1882 + pop_path!(parser) + _t1883 = Proto.Read(read_type=OneOf(:what_if, what_if1267)) + _t1881 = _t1883 else - if prediction1192 == 1 - _t1809 = parse_output(parser) - output1194 = _t1809 - _t1810 = Proto.Read(read_type=OneOf(:output, output1194)) - _t1808 = _t1810 + if prediction1264 == 1 + push_path!(parser, 2) + _t1885 = parse_output(parser) + output1266 = _t1885 + pop_path!(parser) + _t1886 = Proto.Read(read_type=OneOf(:output, output1266)) + _t1884 = _t1886 else - if prediction1192 == 0 - _t1812 = parse_demand(parser) - demand1193 = _t1812 - _t1813 = Proto.Read(read_type=OneOf(:demand, demand1193)) - _t1811 = _t1813 + if prediction1264 == 0 + push_path!(parser, 1) + _t1888 = parse_demand(parser) + demand1265 = _t1888 + pop_path!(parser) + _t1889 = Proto.Read(read_type=OneOf(:demand, demand1265)) + _t1887 = _t1889 else throw(ParseError("Unexpected token in read" * ": " * string(lookahead(parser, 0)))) end - _t1808 = _t1811 + _t1884 = _t1887 end - _t1805 = _t1808 + _t1881 = _t1884 end - _t1802 = _t1805 + _t1878 = _t1881 end - _t1799 = _t1802 + _t1875 = _t1878 end - result1199 = _t1799 - record_span!(parser, span_start1198) - return result1199 + result1271 = _t1875 + record_span!(parser, span_start1270) + return result1271 end function parse_demand(parser::ParserState)::Proto.Demand - span_start1201 = span_start(parser) + span_start1273 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "demand") push_path!(parser, 1) - _t1814 = parse_relation_id(parser) - relation_id1200 = _t1814 + _t1890 = parse_relation_id(parser) + relation_id1272 = _t1890 pop_path!(parser) consume_literal!(parser, ")") - _t1815 = Proto.Demand(relation_id=relation_id1200) - result1202 = _t1815 - record_span!(parser, span_start1201) - return result1202 + _t1891 = Proto.Demand(relation_id=relation_id1272) + result1274 = _t1891 + record_span!(parser, span_start1273) + return result1274 end function parse_output(parser::ParserState)::Proto.Output - span_start1205 = span_start(parser) + span_start1277 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "output") push_path!(parser, 1) - _t1816 = parse_name(parser) - name1203 = _t1816 + _t1892 = parse_name(parser) + name1275 = _t1892 pop_path!(parser) push_path!(parser, 2) - _t1817 = parse_relation_id(parser) - relation_id1204 = _t1817 + _t1893 = parse_relation_id(parser) + relation_id1276 = _t1893 pop_path!(parser) consume_literal!(parser, ")") - _t1818 = Proto.Output(name=name1203, relation_id=relation_id1204) - result1206 = _t1818 - record_span!(parser, span_start1205) - return result1206 + _t1894 = Proto.Output(name=name1275, relation_id=relation_id1276) + result1278 = _t1894 + record_span!(parser, span_start1277) + return result1278 end function parse_what_if(parser::ParserState)::Proto.WhatIf - span_start1209 = span_start(parser) + span_start1281 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "what_if") push_path!(parser, 1) - _t1819 = parse_name(parser) - name1207 = _t1819 + _t1895 = parse_name(parser) + name1279 = _t1895 pop_path!(parser) push_path!(parser, 2) - _t1820 = parse_epoch(parser) - epoch1208 = _t1820 + _t1896 = parse_epoch(parser) + epoch1280 = _t1896 pop_path!(parser) consume_literal!(parser, ")") - _t1821 = Proto.WhatIf(branch=name1207, epoch=epoch1208) - result1210 = _t1821 - record_span!(parser, span_start1209) - return result1210 + _t1897 = Proto.WhatIf(branch=name1279, epoch=epoch1280) + result1282 = _t1897 + record_span!(parser, span_start1281) + return result1282 end function parse_abort(parser::ParserState)::Proto.Abort - span_start1213 = span_start(parser) + span_start1285 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "abort") push_path!(parser, 1) if (match_lookahead_literal(parser, ":", 0) && match_lookahead_terminal(parser, "SYMBOL", 1)) - _t1823 = parse_name(parser) - _t1822 = _t1823 + _t1899 = parse_name(parser) + _t1898 = _t1899 else - _t1822 = nothing + _t1898 = nothing end - name1211 = _t1822 + name1283 = _t1898 pop_path!(parser) push_path!(parser, 2) - _t1824 = parse_relation_id(parser) - relation_id1212 = _t1824 + _t1900 = parse_relation_id(parser) + relation_id1284 = _t1900 pop_path!(parser) consume_literal!(parser, ")") - _t1825 = Proto.Abort(name=(!isnothing(name1211) ? name1211 : "abort"), relation_id=relation_id1212) - result1214 = _t1825 - record_span!(parser, span_start1213) - return result1214 + _t1901 = Proto.Abort(name=(!isnothing(name1283) ? name1283 : "abort"), relation_id=relation_id1284) + result1286 = _t1901 + record_span!(parser, span_start1285) + return result1286 end function parse_export(parser::ParserState)::Proto.Export - span_start1216 = span_start(parser) + span_start1288 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export") push_path!(parser, 1) - _t1826 = parse_export_csv_config(parser) - export_csv_config1215 = _t1826 + _t1902 = parse_export_csv_config(parser) + export_csv_config1287 = _t1902 pop_path!(parser) consume_literal!(parser, ")") - _t1827 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config1215)) - result1217 = _t1827 - record_span!(parser, span_start1216) - return result1217 + _t1903 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config1287)) + result1289 = _t1903 + record_span!(parser, span_start1288) + return result1289 end function parse_export_csv_config(parser::ParserState)::Proto.ExportCSVConfig - span_start1221 = span_start(parser) + span_start1293 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export_csv_config") - _t1828 = parse_export_csv_path(parser) - export_csv_path1218 = _t1828 - _t1829 = parse_export_csv_columns(parser) - export_csv_columns1219 = _t1829 - _t1830 = parse_config_dict(parser) - config_dict1220 = _t1830 + _t1904 = parse_export_csv_path(parser) + export_csv_path1290 = _t1904 + _t1905 = parse_export_csv_columns(parser) + export_csv_columns1291 = _t1905 + _t1906 = parse_config_dict(parser) + config_dict1292 = _t1906 consume_literal!(parser, ")") - _t1831 = export_csv_config(parser, export_csv_path1218, export_csv_columns1219, config_dict1220) - result1222 = _t1831 - record_span!(parser, span_start1221) - return result1222 + _t1907 = export_csv_config(parser, export_csv_path1290, export_csv_columns1291, config_dict1292) + result1294 = _t1907 + record_span!(parser, span_start1293) + return result1294 end function parse_export_csv_path(parser::ParserState)::String - span_start1224 = span_start(parser) + span_start1296 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "path") - string1223 = consume_terminal!(parser, "STRING") + string1295 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - result1225 = string1223 - record_span!(parser, span_start1224) - return result1225 + result1297 = string1295 + record_span!(parser, span_start1296) + return result1297 end function parse_export_csv_columns(parser::ParserState)::Vector{Proto.ExportCSVColumn} - span_start1230 = span_start(parser) + span_start1306 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "columns") - xs1226 = Proto.ExportCSVColumn[] - cond1227 = match_lookahead_literal(parser, "(", 0) - while cond1227 - _t1832 = parse_export_csv_column(parser) - item1228 = _t1832 - push!(xs1226, item1228) - cond1227 = match_lookahead_literal(parser, "(", 0) + xs1302 = Proto.ExportCSVColumn[] + cond1303 = match_lookahead_literal(parser, "(", 0) + idx1304 = 0 + while cond1303 + push_path!(parser, idx1304) + _t1908 = parse_export_csv_column(parser) + item1305 = _t1908 + pop_path!(parser) + push!(xs1302, item1305) + idx1304 = (idx1304 + 1) + cond1303 = match_lookahead_literal(parser, "(", 0) end - export_csv_columns1229 = xs1226 + export_csv_columns1301 = xs1302 consume_literal!(parser, ")") - result1231 = export_csv_columns1229 - record_span!(parser, span_start1230) - return result1231 + result1307 = export_csv_columns1301 + record_span!(parser, span_start1306) + return result1307 end function parse_export_csv_column(parser::ParserState)::Proto.ExportCSVColumn - span_start1234 = span_start(parser) + span_start1310 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "column") push_path!(parser, 1) - string1232 = consume_terminal!(parser, "STRING") + string1308 = consume_terminal!(parser, "STRING") pop_path!(parser) push_path!(parser, 2) - _t1833 = parse_relation_id(parser) - relation_id1233 = _t1833 + _t1909 = parse_relation_id(parser) + relation_id1309 = _t1909 pop_path!(parser) consume_literal!(parser, ")") - _t1834 = Proto.ExportCSVColumn(column_name=string1232, column_data=relation_id1233) - result1235 = _t1834 - record_span!(parser, span_start1234) - return result1235 + _t1910 = Proto.ExportCSVColumn(column_name=string1308, column_data=relation_id1309) + result1311 = _t1910 + record_span!(parser, span_start1310) + return result1311 end diff --git a/sdks/python/src/lqp/cli.py b/sdks/python/src/lqp/cli.py index 73fea2cb..69ca67ff 100644 --- a/sdks/python/src/lqp/cli.py +++ b/sdks/python/src/lqp/cli.py @@ -17,6 +17,7 @@ def parse_input(filename: str, validate: bool = True): """Parse an input file (.lqp or .bin) and return a protobuf Transaction.""" + provenance = None if filename.endswith(".bin"): with open(filename, "rb") as f: data = f.read() @@ -25,10 +26,10 @@ def parse_input(filename: str, validate: bool = True): else: with open(filename) as f: lqp_text = f.read() - txn, _ = parse(lqp_text) + txn, provenance = parse(lqp_text) if validate: - validate_proto(txn) + validate_proto(txn, provenance=provenance, filename=os.path.basename(filename)) return txn diff --git a/sdks/python/src/lqp/gen/parser.py b/sdks/python/src/lqp/gen/parser.py index 047413e6..15473fe8 100644 --- a/sdks/python/src/lqp/gen/parser.py +++ b/sdks/python/src/lqp/gen/parser.py @@ -385,177 +385,177 @@ def relation_id_to_uint128(self, msg): def _extract_value_int32(self, value: logic_pb2.Value | None, default: int) -> int: if value is not None: assert value is not None - _t1835 = value.HasField("int_value") + _t1911 = value.HasField("int_value") else: - _t1835 = False - if _t1835: + _t1911 = False + if _t1911: assert value is not None return int(value.int_value) else: - _t1836 = None + _t1912 = None return int(default) def _extract_value_int64(self, value: logic_pb2.Value | None, default: int) -> int: if value is not None: assert value is not None - _t1837 = value.HasField("int_value") + _t1913 = value.HasField("int_value") else: - _t1837 = False - if _t1837: + _t1913 = False + if _t1913: assert value is not None return value.int_value else: - _t1838 = None + _t1914 = None return default def _extract_value_string(self, value: logic_pb2.Value | None, default: str) -> str: if value is not None: assert value is not None - _t1839 = value.HasField("string_value") + _t1915 = value.HasField("string_value") else: - _t1839 = False - if _t1839: + _t1915 = False + if _t1915: assert value is not None return value.string_value else: - _t1840 = None + _t1916 = None return default def _extract_value_boolean(self, value: logic_pb2.Value | None, default: bool) -> bool: if value is not None: assert value is not None - _t1841 = value.HasField("boolean_value") + _t1917 = value.HasField("boolean_value") else: - _t1841 = False - if _t1841: + _t1917 = False + if _t1917: assert value is not None return value.boolean_value else: - _t1842 = None + _t1918 = None return default def _extract_value_string_list(self, value: logic_pb2.Value | None, default: Sequence[str]) -> Sequence[str]: if value is not None: assert value is not None - _t1843 = value.HasField("string_value") + _t1919 = value.HasField("string_value") else: - _t1843 = False - if _t1843: + _t1919 = False + if _t1919: assert value is not None return [value.string_value] else: - _t1844 = None + _t1920 = None return default def _try_extract_value_int64(self, value: logic_pb2.Value | None) -> int | None: if value is not None: assert value is not None - _t1845 = value.HasField("int_value") + _t1921 = value.HasField("int_value") else: - _t1845 = False - if _t1845: + _t1921 = False + if _t1921: assert value is not None return value.int_value else: - _t1846 = None + _t1922 = None return None def _try_extract_value_float64(self, value: logic_pb2.Value | None) -> float | None: if value is not None: assert value is not None - _t1847 = value.HasField("float_value") + _t1923 = value.HasField("float_value") else: - _t1847 = False - if _t1847: + _t1923 = False + if _t1923: assert value is not None return value.float_value else: - _t1848 = None + _t1924 = None return None def _try_extract_value_bytes(self, value: logic_pb2.Value | None) -> bytes | None: if value is not None: assert value is not None - _t1849 = value.HasField("string_value") + _t1925 = value.HasField("string_value") else: - _t1849 = False - if _t1849: + _t1925 = False + if _t1925: assert value is not None return value.string_value.encode() else: - _t1850 = None + _t1926 = None return None def _try_extract_value_uint128(self, value: logic_pb2.Value | None) -> logic_pb2.UInt128Value | None: if value is not None: assert value is not None - _t1851 = value.HasField("uint128_value") + _t1927 = value.HasField("uint128_value") else: - _t1851 = False - if _t1851: + _t1927 = False + if _t1927: assert value is not None return value.uint128_value else: - _t1852 = None + _t1928 = None return None def construct_csv_config(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.CSVConfig: config = dict(config_dict) - _t1853 = self._extract_value_int32(config.get("csv_header_row"), 1) - header_row = _t1853 - _t1854 = self._extract_value_int64(config.get("csv_skip"), 0) - skip = _t1854 - _t1855 = self._extract_value_string(config.get("csv_new_line"), "") - new_line = _t1855 - _t1856 = self._extract_value_string(config.get("csv_delimiter"), ",") - delimiter = _t1856 - _t1857 = self._extract_value_string(config.get("csv_quotechar"), '"') - quotechar = _t1857 - _t1858 = self._extract_value_string(config.get("csv_escapechar"), '"') - escapechar = _t1858 - _t1859 = self._extract_value_string(config.get("csv_comment"), "") - comment = _t1859 - _t1860 = self._extract_value_string_list(config.get("csv_missing_strings"), []) - missing_strings = _t1860 - _t1861 = self._extract_value_string(config.get("csv_decimal_separator"), ".") - decimal_separator = _t1861 - _t1862 = self._extract_value_string(config.get("csv_encoding"), "utf-8") - encoding = _t1862 - _t1863 = self._extract_value_string(config.get("csv_compression"), "auto") - compression = _t1863 - _t1864 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) - return _t1864 + _t1929 = self._extract_value_int32(config.get("csv_header_row"), 1) + header_row = _t1929 + _t1930 = self._extract_value_int64(config.get("csv_skip"), 0) + skip = _t1930 + _t1931 = self._extract_value_string(config.get("csv_new_line"), "") + new_line = _t1931 + _t1932 = self._extract_value_string(config.get("csv_delimiter"), ",") + delimiter = _t1932 + _t1933 = self._extract_value_string(config.get("csv_quotechar"), '"') + quotechar = _t1933 + _t1934 = self._extract_value_string(config.get("csv_escapechar"), '"') + escapechar = _t1934 + _t1935 = self._extract_value_string(config.get("csv_comment"), "") + comment = _t1935 + _t1936 = self._extract_value_string_list(config.get("csv_missing_strings"), []) + missing_strings = _t1936 + _t1937 = self._extract_value_string(config.get("csv_decimal_separator"), ".") + decimal_separator = _t1937 + _t1938 = self._extract_value_string(config.get("csv_encoding"), "utf-8") + encoding = _t1938 + _t1939 = self._extract_value_string(config.get("csv_compression"), "auto") + compression = _t1939 + _t1940 = logic_pb2.CSVConfig(header_row=header_row, skip=skip, new_line=new_line, delimiter=delimiter, quotechar=quotechar, escapechar=escapechar, comment=comment, missing_strings=missing_strings, decimal_separator=decimal_separator, encoding=encoding, compression=compression) + return _t1940 def construct_betree_info(self, key_types: Sequence[logic_pb2.Type], value_types: Sequence[logic_pb2.Type], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> logic_pb2.BeTreeInfo: config = dict(config_dict) - _t1865 = self._try_extract_value_float64(config.get("betree_config_epsilon")) - epsilon = _t1865 - _t1866 = self._try_extract_value_int64(config.get("betree_config_max_pivots")) - max_pivots = _t1866 - _t1867 = self._try_extract_value_int64(config.get("betree_config_max_deltas")) - max_deltas = _t1867 - _t1868 = self._try_extract_value_int64(config.get("betree_config_max_leaf")) - max_leaf = _t1868 - _t1869 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) - storage_config = _t1869 - _t1870 = self._try_extract_value_uint128(config.get("betree_locator_root_pageid")) - root_pageid = _t1870 - _t1871 = self._try_extract_value_bytes(config.get("betree_locator_inline_data")) - inline_data = _t1871 - _t1872 = self._try_extract_value_int64(config.get("betree_locator_element_count")) - element_count = _t1872 - _t1873 = self._try_extract_value_int64(config.get("betree_locator_tree_height")) - tree_height = _t1873 - _t1874 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) - relation_locator = _t1874 - _t1875 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) - return _t1875 + _t1941 = self._try_extract_value_float64(config.get("betree_config_epsilon")) + epsilon = _t1941 + _t1942 = self._try_extract_value_int64(config.get("betree_config_max_pivots")) + max_pivots = _t1942 + _t1943 = self._try_extract_value_int64(config.get("betree_config_max_deltas")) + max_deltas = _t1943 + _t1944 = self._try_extract_value_int64(config.get("betree_config_max_leaf")) + max_leaf = _t1944 + _t1945 = logic_pb2.BeTreeConfig(epsilon=epsilon, max_pivots=max_pivots, max_deltas=max_deltas, max_leaf=max_leaf) + storage_config = _t1945 + _t1946 = self._try_extract_value_uint128(config.get("betree_locator_root_pageid")) + root_pageid = _t1946 + _t1947 = self._try_extract_value_bytes(config.get("betree_locator_inline_data")) + inline_data = _t1947 + _t1948 = self._try_extract_value_int64(config.get("betree_locator_element_count")) + element_count = _t1948 + _t1949 = self._try_extract_value_int64(config.get("betree_locator_tree_height")) + tree_height = _t1949 + _t1950 = logic_pb2.BeTreeLocator(root_pageid=root_pageid, inline_data=inline_data, element_count=element_count, tree_height=tree_height) + relation_locator = _t1950 + _t1951 = logic_pb2.BeTreeInfo(key_types=key_types, value_types=value_types, storage_config=storage_config, relation_locator=relation_locator) + return _t1951 def default_configure(self) -> transactions_pb2.Configure: - _t1876 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1876 - _t1877 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1877 + _t1952 = transactions_pb2.IVMConfig(level=transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) + ivm_config = _t1952 + _t1953 = transactions_pb2.Configure(semantics_version=0, ivm_config=ivm_config) + return _t1953 def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.Configure: config = dict(config_dict) @@ -572,31 +572,31 @@ def construct_configure(self, config_dict: Sequence[tuple[str, logic_pb2.Value]] maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_ALL else: maintenance_level = transactions_pb2.MaintenanceLevel.MAINTENANCE_LEVEL_OFF - _t1878 = transactions_pb2.IVMConfig(level=maintenance_level) - ivm_config = _t1878 - _t1879 = self._extract_value_int64(config.get("semantics_version"), 0) - semantics_version = _t1879 - _t1880 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) - return _t1880 + _t1954 = transactions_pb2.IVMConfig(level=maintenance_level) + ivm_config = _t1954 + _t1955 = self._extract_value_int64(config.get("semantics_version"), 0) + semantics_version = _t1955 + _t1956 = transactions_pb2.Configure(semantics_version=semantics_version, ivm_config=ivm_config) + return _t1956 def export_csv_config(self, path: str, columns: Sequence[transactions_pb2.ExportCSVColumn], config_dict: Sequence[tuple[str, logic_pb2.Value]]) -> transactions_pb2.ExportCSVConfig: config = dict(config_dict) - _t1881 = self._extract_value_int64(config.get("partition_size"), 0) - partition_size = _t1881 - _t1882 = self._extract_value_string(config.get("compression"), "") - compression = _t1882 - _t1883 = self._extract_value_boolean(config.get("syntax_header_row"), True) - syntax_header_row = _t1883 - _t1884 = self._extract_value_string(config.get("syntax_missing_string"), "") - syntax_missing_string = _t1884 - _t1885 = self._extract_value_string(config.get("syntax_delim"), ",") - syntax_delim = _t1885 - _t1886 = self._extract_value_string(config.get("syntax_quotechar"), '"') - syntax_quotechar = _t1886 - _t1887 = self._extract_value_string(config.get("syntax_escapechar"), "\\") - syntax_escapechar = _t1887 - _t1888 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) - return _t1888 + _t1957 = self._extract_value_int64(config.get("partition_size"), 0) + partition_size = _t1957 + _t1958 = self._extract_value_string(config.get("compression"), "") + compression = _t1958 + _t1959 = self._extract_value_boolean(config.get("syntax_header_row"), True) + syntax_header_row = _t1959 + _t1960 = self._extract_value_string(config.get("syntax_missing_string"), "") + syntax_missing_string = _t1960 + _t1961 = self._extract_value_string(config.get("syntax_delim"), ",") + syntax_delim = _t1961 + _t1962 = self._extract_value_string(config.get("syntax_quotechar"), '"') + syntax_quotechar = _t1962 + _t1963 = self._extract_value_string(config.get("syntax_escapechar"), "\\") + syntax_escapechar = _t1963 + _t1964 = transactions_pb2.ExportCSVConfig(path=path, data_columns=columns, partition_size=partition_size, compression=compression, syntax_header_row=syntax_header_row, syntax_missing_string=syntax_missing_string, syntax_delim=syntax_delim, syntax_quotechar=syntax_quotechar, syntax_escapechar=syntax_escapechar) + return _t1964 # --- Parse methods --- @@ -606,19 +606,19 @@ def parse_transaction(self) -> transactions_pb2.Transaction: self.consume_literal("transaction") self.push_path(2) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("configure", 1)): - _t1237 = self.parse_configure() - _t1236 = _t1237 + _t1313 = self.parse_configure() + _t1312 = _t1313 else: - _t1236 = None - configure592 = _t1236 + _t1312 = None + configure592 = _t1312 self.pop_path() self.push_path(3) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("sync", 1)): - _t1239 = self.parse_sync() - _t1238 = _t1239 + _t1315 = self.parse_sync() + _t1314 = _t1315 else: - _t1238 = None - sync593 = _t1238 + _t1314 = None + sync593 = _t1314 self.pop_path() self.push_path(1) xs598 = [] @@ -626,8 +626,8 @@ def parse_transaction(self) -> transactions_pb2.Transaction: idx600 = 0 while cond599: self.push_path(idx600) - _t1240 = self.parse_epoch() - item601 = _t1240 + _t1316 = self.parse_epoch() + item601 = _t1316 self.pop_path() xs598.append(item601) idx600 = (idx600 + 1) @@ -635,9 +635,9 @@ def parse_transaction(self) -> transactions_pb2.Transaction: epochs597 = xs598 self.pop_path() self.consume_literal(")") - _t1241 = self.default_configure() - _t1242 = transactions_pb2.Transaction(epochs=epochs597, configure=(configure592 if configure592 is not None else _t1241), sync=sync593) - result603 = _t1242 + _t1317 = self.default_configure() + _t1318 = transactions_pb2.Transaction(epochs=epochs597, configure=(configure592 if configure592 is not None else _t1317), sync=sync593) + result603 = _t1318 self.record_span(span_start602) return result603 @@ -645,2893 +645,3087 @@ def parse_configure(self) -> transactions_pb2.Configure: span_start605 = self.span_start() self.consume_literal("(") self.consume_literal("configure") - _t1243 = self.parse_config_dict() - config_dict604 = _t1243 + _t1319 = self.parse_config_dict() + config_dict604 = _t1319 self.consume_literal(")") - _t1244 = self.construct_configure(config_dict604) - result606 = _t1244 + _t1320 = self.construct_configure(config_dict604) + result606 = _t1320 self.record_span(span_start605) return result606 def parse_config_dict(self) -> Sequence[tuple[str, logic_pb2.Value]]: - span_start611 = self.span_start() + span_start615 = self.span_start() self.consume_literal("{") - xs607 = [] - cond608 = self.match_lookahead_literal(":", 0) - while cond608: - _t1245 = self.parse_config_key_value() - item609 = _t1245 - xs607.append(item609) - cond608 = self.match_lookahead_literal(":", 0) - config_key_values610 = xs607 + xs611 = [] + cond612 = self.match_lookahead_literal(":", 0) + idx613 = 0 + while cond612: + self.push_path(idx613) + _t1321 = self.parse_config_key_value() + item614 = _t1321 + self.pop_path() + xs611.append(item614) + idx613 = (idx613 + 1) + cond612 = self.match_lookahead_literal(":", 0) + config_key_values610 = xs611 self.consume_literal("}") - result612 = config_key_values610 - self.record_span(span_start611) - return result612 + result616 = config_key_values610 + self.record_span(span_start615) + return result616 def parse_config_key_value(self) -> tuple[str, logic_pb2.Value]: - span_start615 = self.span_start() + span_start619 = self.span_start() self.consume_literal(":") - symbol613 = self.consume_terminal("SYMBOL") - _t1246 = self.parse_value() - value614 = _t1246 - result616 = (symbol613, value614,) - self.record_span(span_start615) - return result616 + symbol617 = self.consume_terminal("SYMBOL") + _t1322 = self.parse_value() + value618 = _t1322 + result620 = (symbol617, value618,) + self.record_span(span_start619) + return result620 def parse_value(self) -> logic_pb2.Value: - span_start627 = self.span_start() + span_start631 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1247 = 9 + _t1323 = 9 else: if self.match_lookahead_literal("missing", 0): - _t1248 = 8 + _t1324 = 8 else: if self.match_lookahead_literal("false", 0): - _t1249 = 9 + _t1325 = 9 else: if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("datetime", 1): - _t1251 = 1 + _t1327 = 1 else: if self.match_lookahead_literal("date", 1): - _t1252 = 0 + _t1328 = 0 else: - _t1252 = -1 - _t1251 = _t1252 - _t1250 = _t1251 + _t1328 = -1 + _t1327 = _t1328 + _t1326 = _t1327 else: if self.match_lookahead_terminal("UINT128", 0): - _t1253 = 5 + _t1329 = 5 else: if self.match_lookahead_terminal("STRING", 0): - _t1254 = 2 + _t1330 = 2 else: if self.match_lookahead_terminal("INT128", 0): - _t1255 = 6 + _t1331 = 6 else: if self.match_lookahead_terminal("INT", 0): - _t1256 = 3 + _t1332 = 3 else: if self.match_lookahead_terminal("FLOAT", 0): - _t1257 = 4 + _t1333 = 4 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t1258 = 7 + _t1334 = 7 else: - _t1258 = -1 - _t1257 = _t1258 - _t1256 = _t1257 - _t1255 = _t1256 - _t1254 = _t1255 - _t1253 = _t1254 - _t1250 = _t1253 - _t1249 = _t1250 - _t1248 = _t1249 - _t1247 = _t1248 - prediction617 = _t1247 - if prediction617 == 9: - _t1260 = self.parse_boolean_value() - boolean_value626 = _t1260 - _t1261 = logic_pb2.Value(boolean_value=boolean_value626) - _t1259 = _t1261 - else: - if prediction617 == 8: + _t1334 = -1 + _t1333 = _t1334 + _t1332 = _t1333 + _t1331 = _t1332 + _t1330 = _t1331 + _t1329 = _t1330 + _t1326 = _t1329 + _t1325 = _t1326 + _t1324 = _t1325 + _t1323 = _t1324 + prediction621 = _t1323 + if prediction621 == 9: + self.push_path(10) + _t1336 = self.parse_boolean_value() + boolean_value630 = _t1336 + self.pop_path() + _t1337 = logic_pb2.Value(boolean_value=boolean_value630) + _t1335 = _t1337 + else: + if prediction621 == 8: self.consume_literal("missing") - _t1263 = logic_pb2.MissingValue() - _t1264 = logic_pb2.Value(missing_value=_t1263) - _t1262 = _t1264 + _t1339 = logic_pb2.MissingValue() + _t1340 = logic_pb2.Value(missing_value=_t1339) + _t1338 = _t1340 else: - if prediction617 == 7: - decimal625 = self.consume_terminal("DECIMAL") - _t1266 = logic_pb2.Value(decimal_value=decimal625) - _t1265 = _t1266 + if prediction621 == 7: + decimal629 = self.consume_terminal("DECIMAL") + _t1342 = logic_pb2.Value(decimal_value=decimal629) + _t1341 = _t1342 else: - if prediction617 == 6: - int128624 = self.consume_terminal("INT128") - _t1268 = logic_pb2.Value(int128_value=int128624) - _t1267 = _t1268 + if prediction621 == 6: + int128628 = self.consume_terminal("INT128") + _t1344 = logic_pb2.Value(int128_value=int128628) + _t1343 = _t1344 else: - if prediction617 == 5: - uint128623 = self.consume_terminal("UINT128") - _t1270 = logic_pb2.Value(uint128_value=uint128623) - _t1269 = _t1270 + if prediction621 == 5: + uint128627 = self.consume_terminal("UINT128") + _t1346 = logic_pb2.Value(uint128_value=uint128627) + _t1345 = _t1346 else: - if prediction617 == 4: - float622 = self.consume_terminal("FLOAT") - _t1272 = logic_pb2.Value(float_value=float622) - _t1271 = _t1272 + if prediction621 == 4: + float626 = self.consume_terminal("FLOAT") + _t1348 = logic_pb2.Value(float_value=float626) + _t1347 = _t1348 else: - if prediction617 == 3: - int621 = self.consume_terminal("INT") - _t1274 = logic_pb2.Value(int_value=int621) - _t1273 = _t1274 + if prediction621 == 3: + int625 = self.consume_terminal("INT") + _t1350 = logic_pb2.Value(int_value=int625) + _t1349 = _t1350 else: - if prediction617 == 2: - string620 = self.consume_terminal("STRING") - _t1276 = logic_pb2.Value(string_value=string620) - _t1275 = _t1276 + if prediction621 == 2: + string624 = self.consume_terminal("STRING") + _t1352 = logic_pb2.Value(string_value=string624) + _t1351 = _t1352 else: - if prediction617 == 1: - _t1278 = self.parse_datetime() - datetime619 = _t1278 - _t1279 = logic_pb2.Value(datetime_value=datetime619) - _t1277 = _t1279 + if prediction621 == 1: + self.push_path(8) + _t1354 = self.parse_datetime() + datetime623 = _t1354 + self.pop_path() + _t1355 = logic_pb2.Value(datetime_value=datetime623) + _t1353 = _t1355 else: - if prediction617 == 0: - _t1281 = self.parse_date() - date618 = _t1281 - _t1282 = logic_pb2.Value(date_value=date618) - _t1280 = _t1282 + if prediction621 == 0: + self.push_path(7) + _t1357 = self.parse_date() + date622 = _t1357 + self.pop_path() + _t1358 = logic_pb2.Value(date_value=date622) + _t1356 = _t1358 else: raise ParseError("Unexpected token in value" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1277 = _t1280 - _t1275 = _t1277 - _t1273 = _t1275 - _t1271 = _t1273 - _t1269 = _t1271 - _t1267 = _t1269 - _t1265 = _t1267 - _t1262 = _t1265 - _t1259 = _t1262 - result628 = _t1259 - self.record_span(span_start627) - return result628 + _t1353 = _t1356 + _t1351 = _t1353 + _t1349 = _t1351 + _t1347 = _t1349 + _t1345 = _t1347 + _t1343 = _t1345 + _t1341 = _t1343 + _t1338 = _t1341 + _t1335 = _t1338 + result632 = _t1335 + self.record_span(span_start631) + return result632 def parse_date(self) -> logic_pb2.DateValue: - span_start632 = self.span_start() + span_start636 = self.span_start() self.consume_literal("(") self.consume_literal("date") self.push_path(1) - int629 = self.consume_terminal("INT") + int633 = self.consume_terminal("INT") self.pop_path() self.push_path(2) - int_3630 = self.consume_terminal("INT") + int_3634 = self.consume_terminal("INT") self.pop_path() self.push_path(3) - int_4631 = self.consume_terminal("INT") + int_4635 = self.consume_terminal("INT") self.pop_path() self.consume_literal(")") - _t1283 = logic_pb2.DateValue(year=int(int629), month=int(int_3630), day=int(int_4631)) - result633 = _t1283 - self.record_span(span_start632) - return result633 + _t1359 = logic_pb2.DateValue(year=int(int633), month=int(int_3634), day=int(int_4635)) + result637 = _t1359 + self.record_span(span_start636) + return result637 def parse_datetime(self) -> logic_pb2.DateTimeValue: - span_start641 = self.span_start() + span_start645 = self.span_start() self.consume_literal("(") self.consume_literal("datetime") self.push_path(1) - int634 = self.consume_terminal("INT") + int638 = self.consume_terminal("INT") self.pop_path() self.push_path(2) - int_3635 = self.consume_terminal("INT") + int_3639 = self.consume_terminal("INT") self.pop_path() self.push_path(3) - int_4636 = self.consume_terminal("INT") + int_4640 = self.consume_terminal("INT") self.pop_path() self.push_path(4) - int_5637 = self.consume_terminal("INT") + int_5641 = self.consume_terminal("INT") self.pop_path() self.push_path(5) - int_6638 = self.consume_terminal("INT") + int_6642 = self.consume_terminal("INT") self.pop_path() self.push_path(6) - int_7639 = self.consume_terminal("INT") + int_7643 = self.consume_terminal("INT") self.pop_path() self.push_path(7) if self.match_lookahead_terminal("INT", 0): - _t1284 = self.consume_terminal("INT") + _t1360 = self.consume_terminal("INT") else: - _t1284 = None - int_8640 = _t1284 + _t1360 = None + int_8644 = _t1360 self.pop_path() self.consume_literal(")") - _t1285 = logic_pb2.DateTimeValue(year=int(int634), month=int(int_3635), day=int(int_4636), hour=int(int_5637), minute=int(int_6638), second=int(int_7639), microsecond=int((int_8640 if int_8640 is not None else 0))) - result642 = _t1285 - self.record_span(span_start641) - return result642 + _t1361 = logic_pb2.DateTimeValue(year=int(int638), month=int(int_3639), day=int(int_4640), hour=int(int_5641), minute=int(int_6642), second=int(int_7643), microsecond=int((int_8644 if int_8644 is not None else 0))) + result646 = _t1361 + self.record_span(span_start645) + return result646 def parse_boolean_value(self) -> bool: - span_start644 = self.span_start() + span_start648 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1286 = 0 + _t1362 = 0 else: if self.match_lookahead_literal("false", 0): - _t1287 = 1 + _t1363 = 1 else: - _t1287 = -1 - _t1286 = _t1287 - prediction643 = _t1286 - if prediction643 == 1: + _t1363 = -1 + _t1362 = _t1363 + prediction647 = _t1362 + if prediction647 == 1: self.consume_literal("false") - _t1288 = False + _t1364 = False else: - if prediction643 == 0: + if prediction647 == 0: self.consume_literal("true") - _t1289 = True + _t1365 = True else: raise ParseError("Unexpected token in boolean_value" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1288 = _t1289 - result645 = _t1288 - self.record_span(span_start644) - return result645 + _t1364 = _t1365 + result649 = _t1364 + self.record_span(span_start648) + return result649 def parse_sync(self) -> transactions_pb2.Sync: - span_start654 = self.span_start() + span_start658 = self.span_start() self.consume_literal("(") self.consume_literal("sync") self.push_path(1) - xs650 = [] - cond651 = self.match_lookahead_literal(":", 0) - idx652 = 0 - while cond651: - self.push_path(idx652) - _t1290 = self.parse_fragment_id() - item653 = _t1290 + xs654 = [] + cond655 = self.match_lookahead_literal(":", 0) + idx656 = 0 + while cond655: + self.push_path(idx656) + _t1366 = self.parse_fragment_id() + item657 = _t1366 self.pop_path() - xs650.append(item653) - idx652 = (idx652 + 1) - cond651 = self.match_lookahead_literal(":", 0) - fragment_ids649 = xs650 + xs654.append(item657) + idx656 = (idx656 + 1) + cond655 = self.match_lookahead_literal(":", 0) + fragment_ids653 = xs654 self.pop_path() self.consume_literal(")") - _t1291 = transactions_pb2.Sync(fragments=fragment_ids649) - result655 = _t1291 - self.record_span(span_start654) - return result655 + _t1367 = transactions_pb2.Sync(fragments=fragment_ids653) + result659 = _t1367 + self.record_span(span_start658) + return result659 def parse_fragment_id(self) -> fragments_pb2.FragmentId: - span_start657 = self.span_start() + span_start661 = self.span_start() self.consume_literal(":") - symbol656 = self.consume_terminal("SYMBOL") - result658 = fragments_pb2.FragmentId(id=symbol656.encode()) - self.record_span(span_start657) - return result658 + symbol660 = self.consume_terminal("SYMBOL") + result662 = fragments_pb2.FragmentId(id=symbol660.encode()) + self.record_span(span_start661) + return result662 def parse_epoch(self) -> transactions_pb2.Epoch: - span_start661 = self.span_start() + span_start665 = self.span_start() self.consume_literal("(") self.consume_literal("epoch") self.push_path(1) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("writes", 1)): - _t1293 = self.parse_epoch_writes() - _t1292 = _t1293 + _t1369 = self.parse_epoch_writes() + _t1368 = _t1369 else: - _t1292 = None - epoch_writes659 = _t1292 + _t1368 = None + epoch_writes663 = _t1368 self.pop_path() self.push_path(2) if self.match_lookahead_literal("(", 0): - _t1295 = self.parse_epoch_reads() - _t1294 = _t1295 + _t1371 = self.parse_epoch_reads() + _t1370 = _t1371 else: - _t1294 = None - epoch_reads660 = _t1294 + _t1370 = None + epoch_reads664 = _t1370 self.pop_path() self.consume_literal(")") - _t1296 = transactions_pb2.Epoch(writes=(epoch_writes659 if epoch_writes659 is not None else []), reads=(epoch_reads660 if epoch_reads660 is not None else [])) - result662 = _t1296 - self.record_span(span_start661) - return result662 + _t1372 = transactions_pb2.Epoch(writes=(epoch_writes663 if epoch_writes663 is not None else []), reads=(epoch_reads664 if epoch_reads664 is not None else [])) + result666 = _t1372 + self.record_span(span_start665) + return result666 def parse_epoch_writes(self) -> Sequence[transactions_pb2.Write]: - span_start667 = self.span_start() + span_start675 = self.span_start() self.consume_literal("(") self.consume_literal("writes") - xs663 = [] - cond664 = self.match_lookahead_literal("(", 0) - while cond664: - _t1297 = self.parse_write() - item665 = _t1297 - xs663.append(item665) - cond664 = self.match_lookahead_literal("(", 0) - writes666 = xs663 - self.consume_literal(")") - result668 = writes666 - self.record_span(span_start667) - return result668 + xs671 = [] + cond672 = self.match_lookahead_literal("(", 0) + idx673 = 0 + while cond672: + self.push_path(idx673) + _t1373 = self.parse_write() + item674 = _t1373 + self.pop_path() + xs671.append(item674) + idx673 = (idx673 + 1) + cond672 = self.match_lookahead_literal("(", 0) + writes670 = xs671 + self.consume_literal(")") + result676 = writes670 + self.record_span(span_start675) + return result676 def parse_write(self) -> transactions_pb2.Write: - span_start674 = self.span_start() + span_start682 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("undefine", 1): - _t1299 = 1 + _t1375 = 1 else: if self.match_lookahead_literal("snapshot", 1): - _t1300 = 3 + _t1376 = 3 else: if self.match_lookahead_literal("define", 1): - _t1301 = 0 + _t1377 = 0 else: if self.match_lookahead_literal("context", 1): - _t1302 = 2 + _t1378 = 2 else: - _t1302 = -1 - _t1301 = _t1302 - _t1300 = _t1301 - _t1299 = _t1300 - _t1298 = _t1299 - else: - _t1298 = -1 - prediction669 = _t1298 - if prediction669 == 3: - _t1304 = self.parse_snapshot() - snapshot673 = _t1304 - _t1305 = transactions_pb2.Write(snapshot=snapshot673) - _t1303 = _t1305 - else: - if prediction669 == 2: - _t1307 = self.parse_context() - context672 = _t1307 - _t1308 = transactions_pb2.Write(context=context672) - _t1306 = _t1308 + _t1378 = -1 + _t1377 = _t1378 + _t1376 = _t1377 + _t1375 = _t1376 + _t1374 = _t1375 + else: + _t1374 = -1 + prediction677 = _t1374 + if prediction677 == 3: + self.push_path(5) + _t1380 = self.parse_snapshot() + snapshot681 = _t1380 + self.pop_path() + _t1381 = transactions_pb2.Write(snapshot=snapshot681) + _t1379 = _t1381 + else: + if prediction677 == 2: + self.push_path(3) + _t1383 = self.parse_context() + context680 = _t1383 + self.pop_path() + _t1384 = transactions_pb2.Write(context=context680) + _t1382 = _t1384 else: - if prediction669 == 1: - _t1310 = self.parse_undefine() - undefine671 = _t1310 - _t1311 = transactions_pb2.Write(undefine=undefine671) - _t1309 = _t1311 + if prediction677 == 1: + self.push_path(2) + _t1386 = self.parse_undefine() + undefine679 = _t1386 + self.pop_path() + _t1387 = transactions_pb2.Write(undefine=undefine679) + _t1385 = _t1387 else: - if prediction669 == 0: - _t1313 = self.parse_define() - define670 = _t1313 - _t1314 = transactions_pb2.Write(define=define670) - _t1312 = _t1314 + if prediction677 == 0: + self.push_path(1) + _t1389 = self.parse_define() + define678 = _t1389 + self.pop_path() + _t1390 = transactions_pb2.Write(define=define678) + _t1388 = _t1390 else: raise ParseError("Unexpected token in write" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1309 = _t1312 - _t1306 = _t1309 - _t1303 = _t1306 - result675 = _t1303 - self.record_span(span_start674) - return result675 + _t1385 = _t1388 + _t1382 = _t1385 + _t1379 = _t1382 + result683 = _t1379 + self.record_span(span_start682) + return result683 def parse_define(self) -> transactions_pb2.Define: - span_start677 = self.span_start() + span_start685 = self.span_start() self.consume_literal("(") self.consume_literal("define") self.push_path(1) - _t1315 = self.parse_fragment() - fragment676 = _t1315 + _t1391 = self.parse_fragment() + fragment684 = _t1391 self.pop_path() self.consume_literal(")") - _t1316 = transactions_pb2.Define(fragment=fragment676) - result678 = _t1316 - self.record_span(span_start677) - return result678 + _t1392 = transactions_pb2.Define(fragment=fragment684) + result686 = _t1392 + self.record_span(span_start685) + return result686 def parse_fragment(self) -> fragments_pb2.Fragment: - span_start684 = self.span_start() + span_start696 = self.span_start() self.consume_literal("(") self.consume_literal("fragment") - _t1317 = self.parse_new_fragment_id() - new_fragment_id679 = _t1317 - xs680 = [] - cond681 = self.match_lookahead_literal("(", 0) - while cond681: - _t1318 = self.parse_declaration() - item682 = _t1318 - xs680.append(item682) - cond681 = self.match_lookahead_literal("(", 0) - declarations683 = xs680 - self.consume_literal(")") - result685 = self.construct_fragment(new_fragment_id679, declarations683) - self.record_span(span_start684) - return result685 + _t1393 = self.parse_new_fragment_id() + new_fragment_id687 = _t1393 + self.push_path(2) + xs692 = [] + cond693 = self.match_lookahead_literal("(", 0) + idx694 = 0 + while cond693: + self.push_path(idx694) + _t1394 = self.parse_declaration() + item695 = _t1394 + self.pop_path() + xs692.append(item695) + idx694 = (idx694 + 1) + cond693 = self.match_lookahead_literal("(", 0) + declarations691 = xs692 + self.pop_path() + self.consume_literal(")") + result697 = self.construct_fragment(new_fragment_id687, declarations691) + self.record_span(span_start696) + return result697 def parse_new_fragment_id(self) -> fragments_pb2.FragmentId: - span_start687 = self.span_start() - _t1319 = self.parse_fragment_id() - fragment_id686 = _t1319 - self.start_fragment(fragment_id686) - result688 = fragment_id686 - self.record_span(span_start687) - return result688 + span_start699 = self.span_start() + _t1395 = self.parse_fragment_id() + fragment_id698 = _t1395 + self.start_fragment(fragment_id698) + result700 = fragment_id698 + self.record_span(span_start699) + return result700 def parse_declaration(self) -> logic_pb2.Declaration: - span_start694 = self.span_start() + span_start706 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t1321 = 3 + _t1397 = 3 else: if self.match_lookahead_literal("functional_dependency", 1): - _t1322 = 2 + _t1398 = 2 else: if self.match_lookahead_literal("def", 1): - _t1323 = 0 + _t1399 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t1324 = 3 + _t1400 = 3 else: if self.match_lookahead_literal("betree_relation", 1): - _t1325 = 3 + _t1401 = 3 else: if self.match_lookahead_literal("algorithm", 1): - _t1326 = 1 + _t1402 = 1 else: - _t1326 = -1 - _t1325 = _t1326 - _t1324 = _t1325 - _t1323 = _t1324 - _t1322 = _t1323 - _t1321 = _t1322 - _t1320 = _t1321 - else: - _t1320 = -1 - prediction689 = _t1320 - if prediction689 == 3: - _t1328 = self.parse_data() - data693 = _t1328 - _t1329 = logic_pb2.Declaration(data=data693) - _t1327 = _t1329 - else: - if prediction689 == 2: - _t1331 = self.parse_constraint() - constraint692 = _t1331 - _t1332 = logic_pb2.Declaration(constraint=constraint692) - _t1330 = _t1332 + _t1402 = -1 + _t1401 = _t1402 + _t1400 = _t1401 + _t1399 = _t1400 + _t1398 = _t1399 + _t1397 = _t1398 + _t1396 = _t1397 + else: + _t1396 = -1 + prediction701 = _t1396 + if prediction701 == 3: + self.push_path(4) + _t1404 = self.parse_data() + data705 = _t1404 + self.pop_path() + _t1405 = logic_pb2.Declaration(data=data705) + _t1403 = _t1405 + else: + if prediction701 == 2: + self.push_path(3) + _t1407 = self.parse_constraint() + constraint704 = _t1407 + self.pop_path() + _t1408 = logic_pb2.Declaration(constraint=constraint704) + _t1406 = _t1408 else: - if prediction689 == 1: - _t1334 = self.parse_algorithm() - algorithm691 = _t1334 - _t1335 = logic_pb2.Declaration(algorithm=algorithm691) - _t1333 = _t1335 + if prediction701 == 1: + self.push_path(2) + _t1410 = self.parse_algorithm() + algorithm703 = _t1410 + self.pop_path() + _t1411 = logic_pb2.Declaration(algorithm=algorithm703) + _t1409 = _t1411 else: - if prediction689 == 0: - _t1337 = self.parse_def() - def690 = _t1337 - _t1338 = logic_pb2.Declaration() - getattr(_t1338, 'def').CopyFrom(def690) - _t1336 = _t1338 + if prediction701 == 0: + self.push_path(1) + _t1413 = self.parse_def() + def702 = _t1413 + self.pop_path() + _t1414 = logic_pb2.Declaration() + getattr(_t1414, 'def').CopyFrom(def702) + _t1412 = _t1414 else: raise ParseError("Unexpected token in declaration" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1333 = _t1336 - _t1330 = _t1333 - _t1327 = _t1330 - result695 = _t1327 - self.record_span(span_start694) - return result695 + _t1409 = _t1412 + _t1406 = _t1409 + _t1403 = _t1406 + result707 = _t1403 + self.record_span(span_start706) + return result707 def parse_def(self) -> logic_pb2.Def: - span_start699 = self.span_start() + span_start711 = self.span_start() self.consume_literal("(") self.consume_literal("def") self.push_path(1) - _t1339 = self.parse_relation_id() - relation_id696 = _t1339 + _t1415 = self.parse_relation_id() + relation_id708 = _t1415 self.pop_path() self.push_path(2) - _t1340 = self.parse_abstraction() - abstraction697 = _t1340 + _t1416 = self.parse_abstraction() + abstraction709 = _t1416 self.pop_path() self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1342 = self.parse_attrs() - _t1341 = _t1342 + _t1418 = self.parse_attrs() + _t1417 = _t1418 else: - _t1341 = None - attrs698 = _t1341 + _t1417 = None + attrs710 = _t1417 self.pop_path() self.consume_literal(")") - _t1343 = logic_pb2.Def(name=relation_id696, body=abstraction697, attrs=(attrs698 if attrs698 is not None else [])) - result700 = _t1343 - self.record_span(span_start699) - return result700 + _t1419 = logic_pb2.Def(name=relation_id708, body=abstraction709, attrs=(attrs710 if attrs710 is not None else [])) + result712 = _t1419 + self.record_span(span_start711) + return result712 def parse_relation_id(self) -> logic_pb2.RelationId: - span_start704 = self.span_start() + span_start716 = self.span_start() if self.match_lookahead_literal(":", 0): - _t1344 = 0 + _t1420 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t1345 = 1 + _t1421 = 1 else: - _t1345 = -1 - _t1344 = _t1345 - prediction701 = _t1344 - if prediction701 == 1: - uint128703 = self.consume_terminal("UINT128") - _t1346 = logic_pb2.RelationId(id_low=uint128703.low, id_high=uint128703.high) - else: - if prediction701 == 0: + _t1421 = -1 + _t1420 = _t1421 + prediction713 = _t1420 + if prediction713 == 1: + uint128715 = self.consume_terminal("UINT128") + _t1422 = logic_pb2.RelationId(id_low=uint128715.low, id_high=uint128715.high) + else: + if prediction713 == 0: self.consume_literal(":") - symbol702 = self.consume_terminal("SYMBOL") - _t1347 = self.relation_id_from_string(symbol702) + symbol714 = self.consume_terminal("SYMBOL") + _t1423 = self.relation_id_from_string(symbol714) else: raise ParseError("Unexpected token in relation_id" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1346 = _t1347 - result705 = _t1346 - self.record_span(span_start704) - return result705 + _t1422 = _t1423 + result717 = _t1422 + self.record_span(span_start716) + return result717 def parse_abstraction(self) -> logic_pb2.Abstraction: - span_start708 = self.span_start() + span_start720 = self.span_start() self.consume_literal("(") - _t1348 = self.parse_bindings() - bindings706 = _t1348 + _t1424 = self.parse_bindings() + bindings718 = _t1424 self.push_path(2) - _t1349 = self.parse_formula() - formula707 = _t1349 + _t1425 = self.parse_formula() + formula719 = _t1425 self.pop_path() self.consume_literal(")") - _t1350 = logic_pb2.Abstraction(vars=(list(bindings706[0]) + list(bindings706[1] if bindings706[1] is not None else [])), value=formula707) - result709 = _t1350 - self.record_span(span_start708) - return result709 + _t1426 = logic_pb2.Abstraction(vars=(list(bindings718[0]) + list(bindings718[1] if bindings718[1] is not None else [])), value=formula719) + result721 = _t1426 + self.record_span(span_start720) + return result721 def parse_bindings(self) -> tuple[Sequence[logic_pb2.Binding], Sequence[logic_pb2.Binding]]: - span_start715 = self.span_start() + span_start731 = self.span_start() self.consume_literal("[") - xs710 = [] - cond711 = self.match_lookahead_terminal("SYMBOL", 0) - while cond711: - _t1351 = self.parse_binding() - item712 = _t1351 - xs710.append(item712) - cond711 = self.match_lookahead_terminal("SYMBOL", 0) - bindings713 = xs710 + xs726 = [] + cond727 = self.match_lookahead_terminal("SYMBOL", 0) + idx728 = 0 + while cond727: + self.push_path(idx728) + _t1427 = self.parse_binding() + item729 = _t1427 + self.pop_path() + xs726.append(item729) + idx728 = (idx728 + 1) + cond727 = self.match_lookahead_terminal("SYMBOL", 0) + bindings725 = xs726 if self.match_lookahead_literal("|", 0): - _t1353 = self.parse_value_bindings() - _t1352 = _t1353 + _t1429 = self.parse_value_bindings() + _t1428 = _t1429 else: - _t1352 = None - value_bindings714 = _t1352 + _t1428 = None + value_bindings730 = _t1428 self.consume_literal("]") - result716 = (bindings713, (value_bindings714 if value_bindings714 is not None else []),) - self.record_span(span_start715) - return result716 + result732 = (bindings725, (value_bindings730 if value_bindings730 is not None else []),) + self.record_span(span_start731) + return result732 def parse_binding(self) -> logic_pb2.Binding: - span_start719 = self.span_start() - symbol717 = self.consume_terminal("SYMBOL") + span_start735 = self.span_start() + symbol733 = self.consume_terminal("SYMBOL") self.consume_literal("::") self.push_path(2) - _t1354 = self.parse_type() - type718 = _t1354 + _t1430 = self.parse_type() + type734 = _t1430 self.pop_path() - _t1355 = logic_pb2.Var(name=symbol717) - _t1356 = logic_pb2.Binding(var=_t1355, type=type718) - result720 = _t1356 - self.record_span(span_start719) - return result720 + _t1431 = logic_pb2.Var(name=symbol733) + _t1432 = logic_pb2.Binding(var=_t1431, type=type734) + result736 = _t1432 + self.record_span(span_start735) + return result736 def parse_type(self) -> logic_pb2.Type: - span_start733 = self.span_start() + span_start749 = self.span_start() if self.match_lookahead_literal("UNKNOWN", 0): - _t1357 = 0 + _t1433 = 0 else: if self.match_lookahead_literal("UINT128", 0): - _t1358 = 4 + _t1434 = 4 else: if self.match_lookahead_literal("STRING", 0): - _t1359 = 1 + _t1435 = 1 else: if self.match_lookahead_literal("MISSING", 0): - _t1360 = 8 + _t1436 = 8 else: if self.match_lookahead_literal("INT128", 0): - _t1361 = 5 + _t1437 = 5 else: if self.match_lookahead_literal("INT", 0): - _t1362 = 2 + _t1438 = 2 else: if self.match_lookahead_literal("FLOAT", 0): - _t1363 = 3 + _t1439 = 3 else: if self.match_lookahead_literal("DATETIME", 0): - _t1364 = 7 + _t1440 = 7 else: if self.match_lookahead_literal("DATE", 0): - _t1365 = 6 + _t1441 = 6 else: if self.match_lookahead_literal("BOOLEAN", 0): - _t1366 = 10 + _t1442 = 10 else: if self.match_lookahead_literal("(", 0): - _t1367 = 9 + _t1443 = 9 else: - _t1367 = -1 - _t1366 = _t1367 - _t1365 = _t1366 - _t1364 = _t1365 - _t1363 = _t1364 - _t1362 = _t1363 - _t1361 = _t1362 - _t1360 = _t1361 - _t1359 = _t1360 - _t1358 = _t1359 - _t1357 = _t1358 - prediction721 = _t1357 - if prediction721 == 10: - _t1369 = self.parse_boolean_type() - boolean_type732 = _t1369 - _t1370 = logic_pb2.Type(boolean_type=boolean_type732) - _t1368 = _t1370 - else: - if prediction721 == 9: - _t1372 = self.parse_decimal_type() - decimal_type731 = _t1372 - _t1373 = logic_pb2.Type(decimal_type=decimal_type731) - _t1371 = _t1373 + _t1443 = -1 + _t1442 = _t1443 + _t1441 = _t1442 + _t1440 = _t1441 + _t1439 = _t1440 + _t1438 = _t1439 + _t1437 = _t1438 + _t1436 = _t1437 + _t1435 = _t1436 + _t1434 = _t1435 + _t1433 = _t1434 + prediction737 = _t1433 + if prediction737 == 10: + self.push_path(11) + _t1445 = self.parse_boolean_type() + boolean_type748 = _t1445 + self.pop_path() + _t1446 = logic_pb2.Type(boolean_type=boolean_type748) + _t1444 = _t1446 + else: + if prediction737 == 9: + self.push_path(10) + _t1448 = self.parse_decimal_type() + decimal_type747 = _t1448 + self.pop_path() + _t1449 = logic_pb2.Type(decimal_type=decimal_type747) + _t1447 = _t1449 else: - if prediction721 == 8: - _t1375 = self.parse_missing_type() - missing_type730 = _t1375 - _t1376 = logic_pb2.Type(missing_type=missing_type730) - _t1374 = _t1376 + if prediction737 == 8: + self.push_path(9) + _t1451 = self.parse_missing_type() + missing_type746 = _t1451 + self.pop_path() + _t1452 = logic_pb2.Type(missing_type=missing_type746) + _t1450 = _t1452 else: - if prediction721 == 7: - _t1378 = self.parse_datetime_type() - datetime_type729 = _t1378 - _t1379 = logic_pb2.Type(datetime_type=datetime_type729) - _t1377 = _t1379 + if prediction737 == 7: + self.push_path(8) + _t1454 = self.parse_datetime_type() + datetime_type745 = _t1454 + self.pop_path() + _t1455 = logic_pb2.Type(datetime_type=datetime_type745) + _t1453 = _t1455 else: - if prediction721 == 6: - _t1381 = self.parse_date_type() - date_type728 = _t1381 - _t1382 = logic_pb2.Type(date_type=date_type728) - _t1380 = _t1382 + if prediction737 == 6: + self.push_path(7) + _t1457 = self.parse_date_type() + date_type744 = _t1457 + self.pop_path() + _t1458 = logic_pb2.Type(date_type=date_type744) + _t1456 = _t1458 else: - if prediction721 == 5: - _t1384 = self.parse_int128_type() - int128_type727 = _t1384 - _t1385 = logic_pb2.Type(int128_type=int128_type727) - _t1383 = _t1385 + if prediction737 == 5: + self.push_path(6) + _t1460 = self.parse_int128_type() + int128_type743 = _t1460 + self.pop_path() + _t1461 = logic_pb2.Type(int128_type=int128_type743) + _t1459 = _t1461 else: - if prediction721 == 4: - _t1387 = self.parse_uint128_type() - uint128_type726 = _t1387 - _t1388 = logic_pb2.Type(uint128_type=uint128_type726) - _t1386 = _t1388 + if prediction737 == 4: + self.push_path(5) + _t1463 = self.parse_uint128_type() + uint128_type742 = _t1463 + self.pop_path() + _t1464 = logic_pb2.Type(uint128_type=uint128_type742) + _t1462 = _t1464 else: - if prediction721 == 3: - _t1390 = self.parse_float_type() - float_type725 = _t1390 - _t1391 = logic_pb2.Type(float_type=float_type725) - _t1389 = _t1391 + if prediction737 == 3: + self.push_path(4) + _t1466 = self.parse_float_type() + float_type741 = _t1466 + self.pop_path() + _t1467 = logic_pb2.Type(float_type=float_type741) + _t1465 = _t1467 else: - if prediction721 == 2: - _t1393 = self.parse_int_type() - int_type724 = _t1393 - _t1394 = logic_pb2.Type(int_type=int_type724) - _t1392 = _t1394 + if prediction737 == 2: + self.push_path(3) + _t1469 = self.parse_int_type() + int_type740 = _t1469 + self.pop_path() + _t1470 = logic_pb2.Type(int_type=int_type740) + _t1468 = _t1470 else: - if prediction721 == 1: - _t1396 = self.parse_string_type() - string_type723 = _t1396 - _t1397 = logic_pb2.Type(string_type=string_type723) - _t1395 = _t1397 + if prediction737 == 1: + self.push_path(2) + _t1472 = self.parse_string_type() + string_type739 = _t1472 + self.pop_path() + _t1473 = logic_pb2.Type(string_type=string_type739) + _t1471 = _t1473 else: - if prediction721 == 0: - _t1399 = self.parse_unspecified_type() - unspecified_type722 = _t1399 - _t1400 = logic_pb2.Type(unspecified_type=unspecified_type722) - _t1398 = _t1400 + if prediction737 == 0: + self.push_path(1) + _t1475 = self.parse_unspecified_type() + unspecified_type738 = _t1475 + self.pop_path() + _t1476 = logic_pb2.Type(unspecified_type=unspecified_type738) + _t1474 = _t1476 else: raise ParseError("Unexpected token in type" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1395 = _t1398 - _t1392 = _t1395 - _t1389 = _t1392 - _t1386 = _t1389 - _t1383 = _t1386 - _t1380 = _t1383 - _t1377 = _t1380 - _t1374 = _t1377 - _t1371 = _t1374 - _t1368 = _t1371 - result734 = _t1368 - self.record_span(span_start733) - return result734 + _t1471 = _t1474 + _t1468 = _t1471 + _t1465 = _t1468 + _t1462 = _t1465 + _t1459 = _t1462 + _t1456 = _t1459 + _t1453 = _t1456 + _t1450 = _t1453 + _t1447 = _t1450 + _t1444 = _t1447 + result750 = _t1444 + self.record_span(span_start749) + return result750 def parse_unspecified_type(self) -> logic_pb2.UnspecifiedType: - span_start735 = self.span_start() + span_start751 = self.span_start() self.consume_literal("UNKNOWN") - _t1401 = logic_pb2.UnspecifiedType() - result736 = _t1401 - self.record_span(span_start735) - return result736 + _t1477 = logic_pb2.UnspecifiedType() + result752 = _t1477 + self.record_span(span_start751) + return result752 def parse_string_type(self) -> logic_pb2.StringType: - span_start737 = self.span_start() + span_start753 = self.span_start() self.consume_literal("STRING") - _t1402 = logic_pb2.StringType() - result738 = _t1402 - self.record_span(span_start737) - return result738 + _t1478 = logic_pb2.StringType() + result754 = _t1478 + self.record_span(span_start753) + return result754 def parse_int_type(self) -> logic_pb2.IntType: - span_start739 = self.span_start() + span_start755 = self.span_start() self.consume_literal("INT") - _t1403 = logic_pb2.IntType() - result740 = _t1403 - self.record_span(span_start739) - return result740 + _t1479 = logic_pb2.IntType() + result756 = _t1479 + self.record_span(span_start755) + return result756 def parse_float_type(self) -> logic_pb2.FloatType: - span_start741 = self.span_start() + span_start757 = self.span_start() self.consume_literal("FLOAT") - _t1404 = logic_pb2.FloatType() - result742 = _t1404 - self.record_span(span_start741) - return result742 + _t1480 = logic_pb2.FloatType() + result758 = _t1480 + self.record_span(span_start757) + return result758 def parse_uint128_type(self) -> logic_pb2.UInt128Type: - span_start743 = self.span_start() + span_start759 = self.span_start() self.consume_literal("UINT128") - _t1405 = logic_pb2.UInt128Type() - result744 = _t1405 - self.record_span(span_start743) - return result744 + _t1481 = logic_pb2.UInt128Type() + result760 = _t1481 + self.record_span(span_start759) + return result760 def parse_int128_type(self) -> logic_pb2.Int128Type: - span_start745 = self.span_start() + span_start761 = self.span_start() self.consume_literal("INT128") - _t1406 = logic_pb2.Int128Type() - result746 = _t1406 - self.record_span(span_start745) - return result746 + _t1482 = logic_pb2.Int128Type() + result762 = _t1482 + self.record_span(span_start761) + return result762 def parse_date_type(self) -> logic_pb2.DateType: - span_start747 = self.span_start() + span_start763 = self.span_start() self.consume_literal("DATE") - _t1407 = logic_pb2.DateType() - result748 = _t1407 - self.record_span(span_start747) - return result748 + _t1483 = logic_pb2.DateType() + result764 = _t1483 + self.record_span(span_start763) + return result764 def parse_datetime_type(self) -> logic_pb2.DateTimeType: - span_start749 = self.span_start() + span_start765 = self.span_start() self.consume_literal("DATETIME") - _t1408 = logic_pb2.DateTimeType() - result750 = _t1408 - self.record_span(span_start749) - return result750 + _t1484 = logic_pb2.DateTimeType() + result766 = _t1484 + self.record_span(span_start765) + return result766 def parse_missing_type(self) -> logic_pb2.MissingType: - span_start751 = self.span_start() + span_start767 = self.span_start() self.consume_literal("MISSING") - _t1409 = logic_pb2.MissingType() - result752 = _t1409 - self.record_span(span_start751) - return result752 + _t1485 = logic_pb2.MissingType() + result768 = _t1485 + self.record_span(span_start767) + return result768 def parse_decimal_type(self) -> logic_pb2.DecimalType: - span_start755 = self.span_start() + span_start771 = self.span_start() self.consume_literal("(") self.consume_literal("DECIMAL") self.push_path(1) - int753 = self.consume_terminal("INT") + int769 = self.consume_terminal("INT") self.pop_path() self.push_path(2) - int_3754 = self.consume_terminal("INT") + int_3770 = self.consume_terminal("INT") self.pop_path() self.consume_literal(")") - _t1410 = logic_pb2.DecimalType(precision=int(int753), scale=int(int_3754)) - result756 = _t1410 - self.record_span(span_start755) - return result756 + _t1486 = logic_pb2.DecimalType(precision=int(int769), scale=int(int_3770)) + result772 = _t1486 + self.record_span(span_start771) + return result772 def parse_boolean_type(self) -> logic_pb2.BooleanType: - span_start757 = self.span_start() + span_start773 = self.span_start() self.consume_literal("BOOLEAN") - _t1411 = logic_pb2.BooleanType() - result758 = _t1411 - self.record_span(span_start757) - return result758 + _t1487 = logic_pb2.BooleanType() + result774 = _t1487 + self.record_span(span_start773) + return result774 def parse_value_bindings(self) -> Sequence[logic_pb2.Binding]: - span_start763 = self.span_start() + span_start783 = self.span_start() self.consume_literal("|") - xs759 = [] - cond760 = self.match_lookahead_terminal("SYMBOL", 0) - while cond760: - _t1412 = self.parse_binding() - item761 = _t1412 - xs759.append(item761) - cond760 = self.match_lookahead_terminal("SYMBOL", 0) - bindings762 = xs759 - result764 = bindings762 - self.record_span(span_start763) - return result764 + xs779 = [] + cond780 = self.match_lookahead_terminal("SYMBOL", 0) + idx781 = 0 + while cond780: + self.push_path(idx781) + _t1488 = self.parse_binding() + item782 = _t1488 + self.pop_path() + xs779.append(item782) + idx781 = (idx781 + 1) + cond780 = self.match_lookahead_terminal("SYMBOL", 0) + bindings778 = xs779 + result784 = bindings778 + self.record_span(span_start783) + return result784 def parse_formula(self) -> logic_pb2.Formula: - span_start779 = self.span_start() + span_start799 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("true", 1): - _t1414 = 0 + _t1490 = 0 else: if self.match_lookahead_literal("relatom", 1): - _t1415 = 11 + _t1491 = 11 else: if self.match_lookahead_literal("reduce", 1): - _t1416 = 3 + _t1492 = 3 else: if self.match_lookahead_literal("primitive", 1): - _t1417 = 10 + _t1493 = 10 else: if self.match_lookahead_literal("pragma", 1): - _t1418 = 9 + _t1494 = 9 else: if self.match_lookahead_literal("or", 1): - _t1419 = 5 + _t1495 = 5 else: if self.match_lookahead_literal("not", 1): - _t1420 = 6 + _t1496 = 6 else: if self.match_lookahead_literal("ffi", 1): - _t1421 = 7 + _t1497 = 7 else: if self.match_lookahead_literal("false", 1): - _t1422 = 1 + _t1498 = 1 else: if self.match_lookahead_literal("exists", 1): - _t1423 = 2 + _t1499 = 2 else: if self.match_lookahead_literal("cast", 1): - _t1424 = 12 + _t1500 = 12 else: if self.match_lookahead_literal("atom", 1): - _t1425 = 8 + _t1501 = 8 else: if self.match_lookahead_literal("and", 1): - _t1426 = 4 + _t1502 = 4 else: if self.match_lookahead_literal(">=", 1): - _t1427 = 10 + _t1503 = 10 else: if self.match_lookahead_literal(">", 1): - _t1428 = 10 + _t1504 = 10 else: if self.match_lookahead_literal("=", 1): - _t1429 = 10 + _t1505 = 10 else: if self.match_lookahead_literal("<=", 1): - _t1430 = 10 + _t1506 = 10 else: if self.match_lookahead_literal("<", 1): - _t1431 = 10 + _t1507 = 10 else: if self.match_lookahead_literal("/", 1): - _t1432 = 10 + _t1508 = 10 else: if self.match_lookahead_literal("-", 1): - _t1433 = 10 + _t1509 = 10 else: if self.match_lookahead_literal("+", 1): - _t1434 = 10 + _t1510 = 10 else: if self.match_lookahead_literal("*", 1): - _t1435 = 10 + _t1511 = 10 else: - _t1435 = -1 - _t1434 = _t1435 - _t1433 = _t1434 - _t1432 = _t1433 - _t1431 = _t1432 - _t1430 = _t1431 - _t1429 = _t1430 - _t1428 = _t1429 - _t1427 = _t1428 - _t1426 = _t1427 - _t1425 = _t1426 - _t1424 = _t1425 - _t1423 = _t1424 - _t1422 = _t1423 - _t1421 = _t1422 - _t1420 = _t1421 - _t1419 = _t1420 - _t1418 = _t1419 - _t1417 = _t1418 - _t1416 = _t1417 - _t1415 = _t1416 - _t1414 = _t1415 - _t1413 = _t1414 - else: - _t1413 = -1 - prediction765 = _t1413 - if prediction765 == 12: - _t1437 = self.parse_cast() - cast778 = _t1437 - _t1438 = logic_pb2.Formula(cast=cast778) - _t1436 = _t1438 - else: - if prediction765 == 11: - _t1440 = self.parse_rel_atom() - rel_atom777 = _t1440 - _t1441 = logic_pb2.Formula(rel_atom=rel_atom777) - _t1439 = _t1441 + _t1511 = -1 + _t1510 = _t1511 + _t1509 = _t1510 + _t1508 = _t1509 + _t1507 = _t1508 + _t1506 = _t1507 + _t1505 = _t1506 + _t1504 = _t1505 + _t1503 = _t1504 + _t1502 = _t1503 + _t1501 = _t1502 + _t1500 = _t1501 + _t1499 = _t1500 + _t1498 = _t1499 + _t1497 = _t1498 + _t1496 = _t1497 + _t1495 = _t1496 + _t1494 = _t1495 + _t1493 = _t1494 + _t1492 = _t1493 + _t1491 = _t1492 + _t1490 = _t1491 + _t1489 = _t1490 + else: + _t1489 = -1 + prediction785 = _t1489 + if prediction785 == 12: + self.push_path(11) + _t1513 = self.parse_cast() + cast798 = _t1513 + self.pop_path() + _t1514 = logic_pb2.Formula(cast=cast798) + _t1512 = _t1514 + else: + if prediction785 == 11: + self.push_path(10) + _t1516 = self.parse_rel_atom() + rel_atom797 = _t1516 + self.pop_path() + _t1517 = logic_pb2.Formula(rel_atom=rel_atom797) + _t1515 = _t1517 else: - if prediction765 == 10: - _t1443 = self.parse_primitive() - primitive776 = _t1443 - _t1444 = logic_pb2.Formula(primitive=primitive776) - _t1442 = _t1444 + if prediction785 == 10: + self.push_path(9) + _t1519 = self.parse_primitive() + primitive796 = _t1519 + self.pop_path() + _t1520 = logic_pb2.Formula(primitive=primitive796) + _t1518 = _t1520 else: - if prediction765 == 9: - _t1446 = self.parse_pragma() - pragma775 = _t1446 - _t1447 = logic_pb2.Formula(pragma=pragma775) - _t1445 = _t1447 + if prediction785 == 9: + self.push_path(8) + _t1522 = self.parse_pragma() + pragma795 = _t1522 + self.pop_path() + _t1523 = logic_pb2.Formula(pragma=pragma795) + _t1521 = _t1523 else: - if prediction765 == 8: - _t1449 = self.parse_atom() - atom774 = _t1449 - _t1450 = logic_pb2.Formula(atom=atom774) - _t1448 = _t1450 + if prediction785 == 8: + self.push_path(7) + _t1525 = self.parse_atom() + atom794 = _t1525 + self.pop_path() + _t1526 = logic_pb2.Formula(atom=atom794) + _t1524 = _t1526 else: - if prediction765 == 7: - _t1452 = self.parse_ffi() - ffi773 = _t1452 - _t1453 = logic_pb2.Formula(ffi=ffi773) - _t1451 = _t1453 + if prediction785 == 7: + self.push_path(6) + _t1528 = self.parse_ffi() + ffi793 = _t1528 + self.pop_path() + _t1529 = logic_pb2.Formula(ffi=ffi793) + _t1527 = _t1529 else: - if prediction765 == 6: - _t1455 = self.parse_not() - not772 = _t1455 - _t1456 = logic_pb2.Formula() - getattr(_t1456, 'not').CopyFrom(not772) - _t1454 = _t1456 + if prediction785 == 6: + self.push_path(5) + _t1531 = self.parse_not() + not792 = _t1531 + self.pop_path() + _t1532 = logic_pb2.Formula() + getattr(_t1532, 'not').CopyFrom(not792) + _t1530 = _t1532 else: - if prediction765 == 5: - _t1458 = self.parse_disjunction() - disjunction771 = _t1458 - _t1459 = logic_pb2.Formula(disjunction=disjunction771) - _t1457 = _t1459 + if prediction785 == 5: + self.push_path(4) + _t1534 = self.parse_disjunction() + disjunction791 = _t1534 + self.pop_path() + _t1535 = logic_pb2.Formula(disjunction=disjunction791) + _t1533 = _t1535 else: - if prediction765 == 4: - _t1461 = self.parse_conjunction() - conjunction770 = _t1461 - _t1462 = logic_pb2.Formula(conjunction=conjunction770) - _t1460 = _t1462 + if prediction785 == 4: + self.push_path(3) + _t1537 = self.parse_conjunction() + conjunction790 = _t1537 + self.pop_path() + _t1538 = logic_pb2.Formula(conjunction=conjunction790) + _t1536 = _t1538 else: - if prediction765 == 3: - _t1464 = self.parse_reduce() - reduce769 = _t1464 - _t1465 = logic_pb2.Formula(reduce=reduce769) - _t1463 = _t1465 + if prediction785 == 3: + self.push_path(2) + _t1540 = self.parse_reduce() + reduce789 = _t1540 + self.pop_path() + _t1541 = logic_pb2.Formula(reduce=reduce789) + _t1539 = _t1541 else: - if prediction765 == 2: - _t1467 = self.parse_exists() - exists768 = _t1467 - _t1468 = logic_pb2.Formula(exists=exists768) - _t1466 = _t1468 + if prediction785 == 2: + self.push_path(1) + _t1543 = self.parse_exists() + exists788 = _t1543 + self.pop_path() + _t1544 = logic_pb2.Formula(exists=exists788) + _t1542 = _t1544 else: - if prediction765 == 1: - _t1470 = self.parse_false() - false767 = _t1470 - _t1471 = logic_pb2.Formula(disjunction=false767) - _t1469 = _t1471 + if prediction785 == 1: + self.push_path(4) + _t1546 = self.parse_false() + false787 = _t1546 + self.pop_path() + _t1547 = logic_pb2.Formula(disjunction=false787) + _t1545 = _t1547 else: - if prediction765 == 0: - _t1473 = self.parse_true() - true766 = _t1473 - _t1474 = logic_pb2.Formula(conjunction=true766) - _t1472 = _t1474 + if prediction785 == 0: + self.push_path(3) + _t1549 = self.parse_true() + true786 = _t1549 + self.pop_path() + _t1550 = logic_pb2.Formula(conjunction=true786) + _t1548 = _t1550 else: raise ParseError("Unexpected token in formula" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1469 = _t1472 - _t1466 = _t1469 - _t1463 = _t1466 - _t1460 = _t1463 - _t1457 = _t1460 - _t1454 = _t1457 - _t1451 = _t1454 - _t1448 = _t1451 - _t1445 = _t1448 - _t1442 = _t1445 - _t1439 = _t1442 - _t1436 = _t1439 - result780 = _t1436 - self.record_span(span_start779) - return result780 + _t1545 = _t1548 + _t1542 = _t1545 + _t1539 = _t1542 + _t1536 = _t1539 + _t1533 = _t1536 + _t1530 = _t1533 + _t1527 = _t1530 + _t1524 = _t1527 + _t1521 = _t1524 + _t1518 = _t1521 + _t1515 = _t1518 + _t1512 = _t1515 + result800 = _t1512 + self.record_span(span_start799) + return result800 def parse_true(self) -> logic_pb2.Conjunction: - span_start781 = self.span_start() + span_start801 = self.span_start() self.consume_literal("(") self.consume_literal("true") self.consume_literal(")") - _t1475 = logic_pb2.Conjunction(args=[]) - result782 = _t1475 - self.record_span(span_start781) - return result782 + _t1551 = logic_pb2.Conjunction(args=[]) + result802 = _t1551 + self.record_span(span_start801) + return result802 def parse_false(self) -> logic_pb2.Disjunction: - span_start783 = self.span_start() + span_start803 = self.span_start() self.consume_literal("(") self.consume_literal("false") self.consume_literal(")") - _t1476 = logic_pb2.Disjunction(args=[]) - result784 = _t1476 - self.record_span(span_start783) - return result784 + _t1552 = logic_pb2.Disjunction(args=[]) + result804 = _t1552 + self.record_span(span_start803) + return result804 def parse_exists(self) -> logic_pb2.Exists: - span_start787 = self.span_start() + span_start807 = self.span_start() self.consume_literal("(") self.consume_literal("exists") - _t1477 = self.parse_bindings() - bindings785 = _t1477 - _t1478 = self.parse_formula() - formula786 = _t1478 + _t1553 = self.parse_bindings() + bindings805 = _t1553 + _t1554 = self.parse_formula() + formula806 = _t1554 self.consume_literal(")") - _t1479 = logic_pb2.Abstraction(vars=(list(bindings785[0]) + list(bindings785[1] if bindings785[1] is not None else [])), value=formula786) - _t1480 = logic_pb2.Exists(body=_t1479) - result788 = _t1480 - self.record_span(span_start787) - return result788 + _t1555 = logic_pb2.Abstraction(vars=(list(bindings805[0]) + list(bindings805[1] if bindings805[1] is not None else [])), value=formula806) + _t1556 = logic_pb2.Exists(body=_t1555) + result808 = _t1556 + self.record_span(span_start807) + return result808 def parse_reduce(self) -> logic_pb2.Reduce: - span_start792 = self.span_start() + span_start812 = self.span_start() self.consume_literal("(") self.consume_literal("reduce") self.push_path(1) - _t1481 = self.parse_abstraction() - abstraction789 = _t1481 + _t1557 = self.parse_abstraction() + abstraction809 = _t1557 self.pop_path() self.push_path(2) - _t1482 = self.parse_abstraction() - abstraction_3790 = _t1482 + _t1558 = self.parse_abstraction() + abstraction_3810 = _t1558 self.pop_path() self.push_path(3) - _t1483 = self.parse_terms() - terms791 = _t1483 + _t1559 = self.parse_terms() + terms811 = _t1559 self.pop_path() self.consume_literal(")") - _t1484 = logic_pb2.Reduce(op=abstraction789, body=abstraction_3790, terms=terms791) - result793 = _t1484 - self.record_span(span_start792) - return result793 + _t1560 = logic_pb2.Reduce(op=abstraction809, body=abstraction_3810, terms=terms811) + result813 = _t1560 + self.record_span(span_start812) + return result813 def parse_terms(self) -> Sequence[logic_pb2.Term]: - span_start798 = self.span_start() + span_start822 = self.span_start() self.consume_literal("(") self.consume_literal("terms") - xs794 = [] - cond795 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - while cond795: - _t1485 = self.parse_term() - item796 = _t1485 - xs794.append(item796) - cond795 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms797 = xs794 - self.consume_literal(")") - result799 = terms797 - self.record_span(span_start798) - return result799 + xs818 = [] + cond819 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx820 = 0 + while cond819: + self.push_path(idx820) + _t1561 = self.parse_term() + item821 = _t1561 + self.pop_path() + xs818.append(item821) + idx820 = (idx820 + 1) + cond819 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms817 = xs818 + self.consume_literal(")") + result823 = terms817 + self.record_span(span_start822) + return result823 def parse_term(self) -> logic_pb2.Term: - span_start803 = self.span_start() + span_start827 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1486 = 1 + _t1562 = 1 else: if self.match_lookahead_literal("missing", 0): - _t1487 = 1 + _t1563 = 1 else: if self.match_lookahead_literal("false", 0): - _t1488 = 1 + _t1564 = 1 else: if self.match_lookahead_literal("(", 0): - _t1489 = 1 + _t1565 = 1 else: if self.match_lookahead_terminal("UINT128", 0): - _t1490 = 1 + _t1566 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t1491 = 0 + _t1567 = 0 else: if self.match_lookahead_terminal("STRING", 0): - _t1492 = 1 + _t1568 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t1493 = 1 + _t1569 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t1494 = 1 + _t1570 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t1495 = 1 + _t1571 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t1496 = 1 + _t1572 = 1 else: - _t1496 = -1 - _t1495 = _t1496 - _t1494 = _t1495 - _t1493 = _t1494 - _t1492 = _t1493 - _t1491 = _t1492 - _t1490 = _t1491 - _t1489 = _t1490 - _t1488 = _t1489 - _t1487 = _t1488 - _t1486 = _t1487 - prediction800 = _t1486 - if prediction800 == 1: - _t1498 = self.parse_constant() - constant802 = _t1498 - _t1499 = logic_pb2.Term(constant=constant802) - _t1497 = _t1499 - else: - if prediction800 == 0: - _t1501 = self.parse_var() - var801 = _t1501 - _t1502 = logic_pb2.Term(var=var801) - _t1500 = _t1502 + _t1572 = -1 + _t1571 = _t1572 + _t1570 = _t1571 + _t1569 = _t1570 + _t1568 = _t1569 + _t1567 = _t1568 + _t1566 = _t1567 + _t1565 = _t1566 + _t1564 = _t1565 + _t1563 = _t1564 + _t1562 = _t1563 + prediction824 = _t1562 + if prediction824 == 1: + self.push_path(2) + _t1574 = self.parse_constant() + constant826 = _t1574 + self.pop_path() + _t1575 = logic_pb2.Term(constant=constant826) + _t1573 = _t1575 + else: + if prediction824 == 0: + self.push_path(1) + _t1577 = self.parse_var() + var825 = _t1577 + self.pop_path() + _t1578 = logic_pb2.Term(var=var825) + _t1576 = _t1578 else: raise ParseError("Unexpected token in term" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1497 = _t1500 - result804 = _t1497 - self.record_span(span_start803) - return result804 + _t1573 = _t1576 + result828 = _t1573 + self.record_span(span_start827) + return result828 def parse_var(self) -> logic_pb2.Var: - span_start806 = self.span_start() - symbol805 = self.consume_terminal("SYMBOL") - _t1503 = logic_pb2.Var(name=symbol805) - result807 = _t1503 - self.record_span(span_start806) - return result807 + span_start830 = self.span_start() + symbol829 = self.consume_terminal("SYMBOL") + _t1579 = logic_pb2.Var(name=symbol829) + result831 = _t1579 + self.record_span(span_start830) + return result831 def parse_constant(self) -> logic_pb2.Value: - span_start809 = self.span_start() - _t1504 = self.parse_value() - value808 = _t1504 - result810 = value808 - self.record_span(span_start809) - return result810 + span_start833 = self.span_start() + _t1580 = self.parse_value() + value832 = _t1580 + result834 = value832 + self.record_span(span_start833) + return result834 def parse_conjunction(self) -> logic_pb2.Conjunction: - span_start819 = self.span_start() + span_start843 = self.span_start() self.consume_literal("(") self.consume_literal("and") self.push_path(1) - xs815 = [] - cond816 = self.match_lookahead_literal("(", 0) - idx817 = 0 - while cond816: - self.push_path(idx817) - _t1505 = self.parse_formula() - item818 = _t1505 + xs839 = [] + cond840 = self.match_lookahead_literal("(", 0) + idx841 = 0 + while cond840: + self.push_path(idx841) + _t1581 = self.parse_formula() + item842 = _t1581 self.pop_path() - xs815.append(item818) - idx817 = (idx817 + 1) - cond816 = self.match_lookahead_literal("(", 0) - formulas814 = xs815 + xs839.append(item842) + idx841 = (idx841 + 1) + cond840 = self.match_lookahead_literal("(", 0) + formulas838 = xs839 self.pop_path() self.consume_literal(")") - _t1506 = logic_pb2.Conjunction(args=formulas814) - result820 = _t1506 - self.record_span(span_start819) - return result820 + _t1582 = logic_pb2.Conjunction(args=formulas838) + result844 = _t1582 + self.record_span(span_start843) + return result844 def parse_disjunction(self) -> logic_pb2.Disjunction: - span_start829 = self.span_start() + span_start853 = self.span_start() self.consume_literal("(") self.consume_literal("or") self.push_path(1) - xs825 = [] - cond826 = self.match_lookahead_literal("(", 0) - idx827 = 0 - while cond826: - self.push_path(idx827) - _t1507 = self.parse_formula() - item828 = _t1507 + xs849 = [] + cond850 = self.match_lookahead_literal("(", 0) + idx851 = 0 + while cond850: + self.push_path(idx851) + _t1583 = self.parse_formula() + item852 = _t1583 self.pop_path() - xs825.append(item828) - idx827 = (idx827 + 1) - cond826 = self.match_lookahead_literal("(", 0) - formulas824 = xs825 + xs849.append(item852) + idx851 = (idx851 + 1) + cond850 = self.match_lookahead_literal("(", 0) + formulas848 = xs849 self.pop_path() self.consume_literal(")") - _t1508 = logic_pb2.Disjunction(args=formulas824) - result830 = _t1508 - self.record_span(span_start829) - return result830 + _t1584 = logic_pb2.Disjunction(args=formulas848) + result854 = _t1584 + self.record_span(span_start853) + return result854 def parse_not(self) -> logic_pb2.Not: - span_start832 = self.span_start() + span_start856 = self.span_start() self.consume_literal("(") self.consume_literal("not") self.push_path(1) - _t1509 = self.parse_formula() - formula831 = _t1509 + _t1585 = self.parse_formula() + formula855 = _t1585 self.pop_path() self.consume_literal(")") - _t1510 = logic_pb2.Not(arg=formula831) - result833 = _t1510 - self.record_span(span_start832) - return result833 + _t1586 = logic_pb2.Not(arg=formula855) + result857 = _t1586 + self.record_span(span_start856) + return result857 def parse_ffi(self) -> logic_pb2.FFI: - span_start837 = self.span_start() + span_start861 = self.span_start() self.consume_literal("(") self.consume_literal("ffi") self.push_path(1) - _t1511 = self.parse_name() - name834 = _t1511 + _t1587 = self.parse_name() + name858 = _t1587 self.pop_path() self.push_path(2) - _t1512 = self.parse_ffi_args() - ffi_args835 = _t1512 + _t1588 = self.parse_ffi_args() + ffi_args859 = _t1588 self.pop_path() self.push_path(3) - _t1513 = self.parse_terms() - terms836 = _t1513 + _t1589 = self.parse_terms() + terms860 = _t1589 self.pop_path() self.consume_literal(")") - _t1514 = logic_pb2.FFI(name=name834, args=ffi_args835, terms=terms836) - result838 = _t1514 - self.record_span(span_start837) - return result838 + _t1590 = logic_pb2.FFI(name=name858, args=ffi_args859, terms=terms860) + result862 = _t1590 + self.record_span(span_start861) + return result862 def parse_name(self) -> str: - span_start840 = self.span_start() + span_start864 = self.span_start() self.consume_literal(":") - symbol839 = self.consume_terminal("SYMBOL") - result841 = symbol839 - self.record_span(span_start840) - return result841 + symbol863 = self.consume_terminal("SYMBOL") + result865 = symbol863 + self.record_span(span_start864) + return result865 def parse_ffi_args(self) -> Sequence[logic_pb2.Abstraction]: - span_start846 = self.span_start() + span_start874 = self.span_start() self.consume_literal("(") self.consume_literal("args") - xs842 = [] - cond843 = self.match_lookahead_literal("(", 0) - while cond843: - _t1515 = self.parse_abstraction() - item844 = _t1515 - xs842.append(item844) - cond843 = self.match_lookahead_literal("(", 0) - abstractions845 = xs842 - self.consume_literal(")") - result847 = abstractions845 - self.record_span(span_start846) - return result847 + xs870 = [] + cond871 = self.match_lookahead_literal("(", 0) + idx872 = 0 + while cond871: + self.push_path(idx872) + _t1591 = self.parse_abstraction() + item873 = _t1591 + self.pop_path() + xs870.append(item873) + idx872 = (idx872 + 1) + cond871 = self.match_lookahead_literal("(", 0) + abstractions869 = xs870 + self.consume_literal(")") + result875 = abstractions869 + self.record_span(span_start874) + return result875 def parse_atom(self) -> logic_pb2.Atom: - span_start857 = self.span_start() + span_start885 = self.span_start() self.consume_literal("(") self.consume_literal("atom") self.push_path(1) - _t1516 = self.parse_relation_id() - relation_id848 = _t1516 + _t1592 = self.parse_relation_id() + relation_id876 = _t1592 self.pop_path() self.push_path(2) - xs853 = [] - cond854 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - idx855 = 0 - while cond854: - self.push_path(idx855) - _t1517 = self.parse_term() - item856 = _t1517 + xs881 = [] + cond882 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx883 = 0 + while cond882: + self.push_path(idx883) + _t1593 = self.parse_term() + item884 = _t1593 self.pop_path() - xs853.append(item856) - idx855 = (idx855 + 1) - cond854 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms852 = xs853 + xs881.append(item884) + idx883 = (idx883 + 1) + cond882 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms880 = xs881 self.pop_path() self.consume_literal(")") - _t1518 = logic_pb2.Atom(name=relation_id848, terms=terms852) - result858 = _t1518 - self.record_span(span_start857) - return result858 + _t1594 = logic_pb2.Atom(name=relation_id876, terms=terms880) + result886 = _t1594 + self.record_span(span_start885) + return result886 def parse_pragma(self) -> logic_pb2.Pragma: - span_start868 = self.span_start() + span_start896 = self.span_start() self.consume_literal("(") self.consume_literal("pragma") self.push_path(1) - _t1519 = self.parse_name() - name859 = _t1519 + _t1595 = self.parse_name() + name887 = _t1595 self.pop_path() self.push_path(2) - xs864 = [] - cond865 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - idx866 = 0 - while cond865: - self.push_path(idx866) - _t1520 = self.parse_term() - item867 = _t1520 + xs892 = [] + cond893 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx894 = 0 + while cond893: + self.push_path(idx894) + _t1596 = self.parse_term() + item895 = _t1596 self.pop_path() - xs864.append(item867) - idx866 = (idx866 + 1) - cond865 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - terms863 = xs864 + xs892.append(item895) + idx894 = (idx894 + 1) + cond893 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + terms891 = xs892 self.pop_path() self.consume_literal(")") - _t1521 = logic_pb2.Pragma(name=name859, terms=terms863) - result869 = _t1521 - self.record_span(span_start868) - return result869 + _t1597 = logic_pb2.Pragma(name=name887, terms=terms891) + result897 = _t1597 + self.record_span(span_start896) + return result897 def parse_primitive(self) -> logic_pb2.Primitive: - span_start889 = self.span_start() + span_start917 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("primitive", 1): - _t1523 = 9 + _t1599 = 9 else: if self.match_lookahead_literal(">=", 1): - _t1524 = 4 + _t1600 = 4 else: if self.match_lookahead_literal(">", 1): - _t1525 = 3 + _t1601 = 3 else: if self.match_lookahead_literal("=", 1): - _t1526 = 0 + _t1602 = 0 else: if self.match_lookahead_literal("<=", 1): - _t1527 = 2 + _t1603 = 2 else: if self.match_lookahead_literal("<", 1): - _t1528 = 1 + _t1604 = 1 else: if self.match_lookahead_literal("/", 1): - _t1529 = 8 + _t1605 = 8 else: if self.match_lookahead_literal("-", 1): - _t1530 = 6 + _t1606 = 6 else: if self.match_lookahead_literal("+", 1): - _t1531 = 5 + _t1607 = 5 else: if self.match_lookahead_literal("*", 1): - _t1532 = 7 + _t1608 = 7 else: - _t1532 = -1 - _t1531 = _t1532 - _t1530 = _t1531 - _t1529 = _t1530 - _t1528 = _t1529 - _t1527 = _t1528 - _t1526 = _t1527 - _t1525 = _t1526 - _t1524 = _t1525 - _t1523 = _t1524 - _t1522 = _t1523 - else: - _t1522 = -1 - prediction870 = _t1522 - if prediction870 == 9: + _t1608 = -1 + _t1607 = _t1608 + _t1606 = _t1607 + _t1605 = _t1606 + _t1604 = _t1605 + _t1603 = _t1604 + _t1602 = _t1603 + _t1601 = _t1602 + _t1600 = _t1601 + _t1599 = _t1600 + _t1598 = _t1599 + else: + _t1598 = -1 + prediction898 = _t1598 + if prediction898 == 9: self.consume_literal("(") self.consume_literal("primitive") self.push_path(1) - _t1534 = self.parse_name() - name880 = _t1534 + _t1610 = self.parse_name() + name908 = _t1610 self.pop_path() self.push_path(2) - xs885 = [] - cond886 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - idx887 = 0 - while cond886: - self.push_path(idx887) - _t1535 = self.parse_rel_term() - item888 = _t1535 + xs913 = [] + cond914 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx915 = 0 + while cond914: + self.push_path(idx915) + _t1611 = self.parse_rel_term() + item916 = _t1611 self.pop_path() - xs885.append(item888) - idx887 = (idx887 + 1) - cond886 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - rel_terms884 = xs885 + xs913.append(item916) + idx915 = (idx915 + 1) + cond914 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + rel_terms912 = xs913 self.pop_path() self.consume_literal(")") - _t1536 = logic_pb2.Primitive(name=name880, terms=rel_terms884) - _t1533 = _t1536 + _t1612 = logic_pb2.Primitive(name=name908, terms=rel_terms912) + _t1609 = _t1612 else: - if prediction870 == 8: - _t1538 = self.parse_divide() - divide879 = _t1538 - _t1537 = divide879 + if prediction898 == 8: + _t1614 = self.parse_divide() + divide907 = _t1614 + _t1613 = divide907 else: - if prediction870 == 7: - _t1540 = self.parse_multiply() - multiply878 = _t1540 - _t1539 = multiply878 + if prediction898 == 7: + _t1616 = self.parse_multiply() + multiply906 = _t1616 + _t1615 = multiply906 else: - if prediction870 == 6: - _t1542 = self.parse_minus() - minus877 = _t1542 - _t1541 = minus877 + if prediction898 == 6: + _t1618 = self.parse_minus() + minus905 = _t1618 + _t1617 = minus905 else: - if prediction870 == 5: - _t1544 = self.parse_add() - add876 = _t1544 - _t1543 = add876 + if prediction898 == 5: + _t1620 = self.parse_add() + add904 = _t1620 + _t1619 = add904 else: - if prediction870 == 4: - _t1546 = self.parse_gt_eq() - gt_eq875 = _t1546 - _t1545 = gt_eq875 + if prediction898 == 4: + _t1622 = self.parse_gt_eq() + gt_eq903 = _t1622 + _t1621 = gt_eq903 else: - if prediction870 == 3: - _t1548 = self.parse_gt() - gt874 = _t1548 - _t1547 = gt874 + if prediction898 == 3: + _t1624 = self.parse_gt() + gt902 = _t1624 + _t1623 = gt902 else: - if prediction870 == 2: - _t1550 = self.parse_lt_eq() - lt_eq873 = _t1550 - _t1549 = lt_eq873 + if prediction898 == 2: + _t1626 = self.parse_lt_eq() + lt_eq901 = _t1626 + _t1625 = lt_eq901 else: - if prediction870 == 1: - _t1552 = self.parse_lt() - lt872 = _t1552 - _t1551 = lt872 + if prediction898 == 1: + _t1628 = self.parse_lt() + lt900 = _t1628 + _t1627 = lt900 else: - if prediction870 == 0: - _t1554 = self.parse_eq() - eq871 = _t1554 - _t1553 = eq871 + if prediction898 == 0: + _t1630 = self.parse_eq() + eq899 = _t1630 + _t1629 = eq899 else: raise ParseError("Unexpected token in primitive" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1551 = _t1553 - _t1549 = _t1551 - _t1547 = _t1549 - _t1545 = _t1547 - _t1543 = _t1545 - _t1541 = _t1543 - _t1539 = _t1541 - _t1537 = _t1539 - _t1533 = _t1537 - result890 = _t1533 - self.record_span(span_start889) - return result890 + _t1627 = _t1629 + _t1625 = _t1627 + _t1623 = _t1625 + _t1621 = _t1623 + _t1619 = _t1621 + _t1617 = _t1619 + _t1615 = _t1617 + _t1613 = _t1615 + _t1609 = _t1613 + result918 = _t1609 + self.record_span(span_start917) + return result918 def parse_eq(self) -> logic_pb2.Primitive: - span_start893 = self.span_start() + span_start921 = self.span_start() self.consume_literal("(") self.consume_literal("=") - _t1555 = self.parse_term() - term891 = _t1555 - _t1556 = self.parse_term() - term_3892 = _t1556 - self.consume_literal(")") - _t1557 = logic_pb2.RelTerm(term=term891) - _t1558 = logic_pb2.RelTerm(term=term_3892) - _t1559 = logic_pb2.Primitive(name="rel_primitive_eq", terms=[_t1557, _t1558]) - result894 = _t1559 - self.record_span(span_start893) - return result894 + _t1631 = self.parse_term() + term919 = _t1631 + _t1632 = self.parse_term() + term_3920 = _t1632 + self.consume_literal(")") + _t1633 = logic_pb2.RelTerm(term=term919) + _t1634 = logic_pb2.RelTerm(term=term_3920) + _t1635 = logic_pb2.Primitive(name="rel_primitive_eq", terms=[_t1633, _t1634]) + result922 = _t1635 + self.record_span(span_start921) + return result922 def parse_lt(self) -> logic_pb2.Primitive: - span_start897 = self.span_start() + span_start925 = self.span_start() self.consume_literal("(") self.consume_literal("<") - _t1560 = self.parse_term() - term895 = _t1560 - _t1561 = self.parse_term() - term_3896 = _t1561 - self.consume_literal(")") - _t1562 = logic_pb2.RelTerm(term=term895) - _t1563 = logic_pb2.RelTerm(term=term_3896) - _t1564 = logic_pb2.Primitive(name="rel_primitive_lt_monotype", terms=[_t1562, _t1563]) - result898 = _t1564 - self.record_span(span_start897) - return result898 + _t1636 = self.parse_term() + term923 = _t1636 + _t1637 = self.parse_term() + term_3924 = _t1637 + self.consume_literal(")") + _t1638 = logic_pb2.RelTerm(term=term923) + _t1639 = logic_pb2.RelTerm(term=term_3924) + _t1640 = logic_pb2.Primitive(name="rel_primitive_lt_monotype", terms=[_t1638, _t1639]) + result926 = _t1640 + self.record_span(span_start925) + return result926 def parse_lt_eq(self) -> logic_pb2.Primitive: - span_start901 = self.span_start() + span_start929 = self.span_start() self.consume_literal("(") self.consume_literal("<=") - _t1565 = self.parse_term() - term899 = _t1565 - _t1566 = self.parse_term() - term_3900 = _t1566 - self.consume_literal(")") - _t1567 = logic_pb2.RelTerm(term=term899) - _t1568 = logic_pb2.RelTerm(term=term_3900) - _t1569 = logic_pb2.Primitive(name="rel_primitive_lt_eq_monotype", terms=[_t1567, _t1568]) - result902 = _t1569 - self.record_span(span_start901) - return result902 + _t1641 = self.parse_term() + term927 = _t1641 + _t1642 = self.parse_term() + term_3928 = _t1642 + self.consume_literal(")") + _t1643 = logic_pb2.RelTerm(term=term927) + _t1644 = logic_pb2.RelTerm(term=term_3928) + _t1645 = logic_pb2.Primitive(name="rel_primitive_lt_eq_monotype", terms=[_t1643, _t1644]) + result930 = _t1645 + self.record_span(span_start929) + return result930 def parse_gt(self) -> logic_pb2.Primitive: - span_start905 = self.span_start() + span_start933 = self.span_start() self.consume_literal("(") self.consume_literal(">") - _t1570 = self.parse_term() - term903 = _t1570 - _t1571 = self.parse_term() - term_3904 = _t1571 - self.consume_literal(")") - _t1572 = logic_pb2.RelTerm(term=term903) - _t1573 = logic_pb2.RelTerm(term=term_3904) - _t1574 = logic_pb2.Primitive(name="rel_primitive_gt_monotype", terms=[_t1572, _t1573]) - result906 = _t1574 - self.record_span(span_start905) - return result906 + _t1646 = self.parse_term() + term931 = _t1646 + _t1647 = self.parse_term() + term_3932 = _t1647 + self.consume_literal(")") + _t1648 = logic_pb2.RelTerm(term=term931) + _t1649 = logic_pb2.RelTerm(term=term_3932) + _t1650 = logic_pb2.Primitive(name="rel_primitive_gt_monotype", terms=[_t1648, _t1649]) + result934 = _t1650 + self.record_span(span_start933) + return result934 def parse_gt_eq(self) -> logic_pb2.Primitive: - span_start909 = self.span_start() + span_start937 = self.span_start() self.consume_literal("(") self.consume_literal(">=") - _t1575 = self.parse_term() - term907 = _t1575 - _t1576 = self.parse_term() - term_3908 = _t1576 - self.consume_literal(")") - _t1577 = logic_pb2.RelTerm(term=term907) - _t1578 = logic_pb2.RelTerm(term=term_3908) - _t1579 = logic_pb2.Primitive(name="rel_primitive_gt_eq_monotype", terms=[_t1577, _t1578]) - result910 = _t1579 - self.record_span(span_start909) - return result910 + _t1651 = self.parse_term() + term935 = _t1651 + _t1652 = self.parse_term() + term_3936 = _t1652 + self.consume_literal(")") + _t1653 = logic_pb2.RelTerm(term=term935) + _t1654 = logic_pb2.RelTerm(term=term_3936) + _t1655 = logic_pb2.Primitive(name="rel_primitive_gt_eq_monotype", terms=[_t1653, _t1654]) + result938 = _t1655 + self.record_span(span_start937) + return result938 def parse_add(self) -> logic_pb2.Primitive: - span_start914 = self.span_start() + span_start942 = self.span_start() self.consume_literal("(") self.consume_literal("+") - _t1580 = self.parse_term() - term911 = _t1580 - _t1581 = self.parse_term() - term_3912 = _t1581 - _t1582 = self.parse_term() - term_4913 = _t1582 - self.consume_literal(")") - _t1583 = logic_pb2.RelTerm(term=term911) - _t1584 = logic_pb2.RelTerm(term=term_3912) - _t1585 = logic_pb2.RelTerm(term=term_4913) - _t1586 = logic_pb2.Primitive(name="rel_primitive_add_monotype", terms=[_t1583, _t1584, _t1585]) - result915 = _t1586 - self.record_span(span_start914) - return result915 + _t1656 = self.parse_term() + term939 = _t1656 + _t1657 = self.parse_term() + term_3940 = _t1657 + _t1658 = self.parse_term() + term_4941 = _t1658 + self.consume_literal(")") + _t1659 = logic_pb2.RelTerm(term=term939) + _t1660 = logic_pb2.RelTerm(term=term_3940) + _t1661 = logic_pb2.RelTerm(term=term_4941) + _t1662 = logic_pb2.Primitive(name="rel_primitive_add_monotype", terms=[_t1659, _t1660, _t1661]) + result943 = _t1662 + self.record_span(span_start942) + return result943 def parse_minus(self) -> logic_pb2.Primitive: - span_start919 = self.span_start() + span_start947 = self.span_start() self.consume_literal("(") self.consume_literal("-") - _t1587 = self.parse_term() - term916 = _t1587 - _t1588 = self.parse_term() - term_3917 = _t1588 - _t1589 = self.parse_term() - term_4918 = _t1589 - self.consume_literal(")") - _t1590 = logic_pb2.RelTerm(term=term916) - _t1591 = logic_pb2.RelTerm(term=term_3917) - _t1592 = logic_pb2.RelTerm(term=term_4918) - _t1593 = logic_pb2.Primitive(name="rel_primitive_subtract_monotype", terms=[_t1590, _t1591, _t1592]) - result920 = _t1593 - self.record_span(span_start919) - return result920 + _t1663 = self.parse_term() + term944 = _t1663 + _t1664 = self.parse_term() + term_3945 = _t1664 + _t1665 = self.parse_term() + term_4946 = _t1665 + self.consume_literal(")") + _t1666 = logic_pb2.RelTerm(term=term944) + _t1667 = logic_pb2.RelTerm(term=term_3945) + _t1668 = logic_pb2.RelTerm(term=term_4946) + _t1669 = logic_pb2.Primitive(name="rel_primitive_subtract_monotype", terms=[_t1666, _t1667, _t1668]) + result948 = _t1669 + self.record_span(span_start947) + return result948 def parse_multiply(self) -> logic_pb2.Primitive: - span_start924 = self.span_start() + span_start952 = self.span_start() self.consume_literal("(") self.consume_literal("*") - _t1594 = self.parse_term() - term921 = _t1594 - _t1595 = self.parse_term() - term_3922 = _t1595 - _t1596 = self.parse_term() - term_4923 = _t1596 - self.consume_literal(")") - _t1597 = logic_pb2.RelTerm(term=term921) - _t1598 = logic_pb2.RelTerm(term=term_3922) - _t1599 = logic_pb2.RelTerm(term=term_4923) - _t1600 = logic_pb2.Primitive(name="rel_primitive_multiply_monotype", terms=[_t1597, _t1598, _t1599]) - result925 = _t1600 - self.record_span(span_start924) - return result925 + _t1670 = self.parse_term() + term949 = _t1670 + _t1671 = self.parse_term() + term_3950 = _t1671 + _t1672 = self.parse_term() + term_4951 = _t1672 + self.consume_literal(")") + _t1673 = logic_pb2.RelTerm(term=term949) + _t1674 = logic_pb2.RelTerm(term=term_3950) + _t1675 = logic_pb2.RelTerm(term=term_4951) + _t1676 = logic_pb2.Primitive(name="rel_primitive_multiply_monotype", terms=[_t1673, _t1674, _t1675]) + result953 = _t1676 + self.record_span(span_start952) + return result953 def parse_divide(self) -> logic_pb2.Primitive: - span_start929 = self.span_start() + span_start957 = self.span_start() self.consume_literal("(") self.consume_literal("/") - _t1601 = self.parse_term() - term926 = _t1601 - _t1602 = self.parse_term() - term_3927 = _t1602 - _t1603 = self.parse_term() - term_4928 = _t1603 - self.consume_literal(")") - _t1604 = logic_pb2.RelTerm(term=term926) - _t1605 = logic_pb2.RelTerm(term=term_3927) - _t1606 = logic_pb2.RelTerm(term=term_4928) - _t1607 = logic_pb2.Primitive(name="rel_primitive_divide_monotype", terms=[_t1604, _t1605, _t1606]) - result930 = _t1607 - self.record_span(span_start929) - return result930 + _t1677 = self.parse_term() + term954 = _t1677 + _t1678 = self.parse_term() + term_3955 = _t1678 + _t1679 = self.parse_term() + term_4956 = _t1679 + self.consume_literal(")") + _t1680 = logic_pb2.RelTerm(term=term954) + _t1681 = logic_pb2.RelTerm(term=term_3955) + _t1682 = logic_pb2.RelTerm(term=term_4956) + _t1683 = logic_pb2.Primitive(name="rel_primitive_divide_monotype", terms=[_t1680, _t1681, _t1682]) + result958 = _t1683 + self.record_span(span_start957) + return result958 def parse_rel_term(self) -> logic_pb2.RelTerm: - span_start934 = self.span_start() + span_start962 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1608 = 1 + _t1684 = 1 else: if self.match_lookahead_literal("missing", 0): - _t1609 = 1 + _t1685 = 1 else: if self.match_lookahead_literal("false", 0): - _t1610 = 1 + _t1686 = 1 else: if self.match_lookahead_literal("(", 0): - _t1611 = 1 + _t1687 = 1 else: if self.match_lookahead_literal("#", 0): - _t1612 = 0 + _t1688 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t1613 = 1 + _t1689 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t1614 = 1 + _t1690 = 1 else: if self.match_lookahead_terminal("STRING", 0): - _t1615 = 1 + _t1691 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t1616 = 1 + _t1692 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t1617 = 1 + _t1693 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t1618 = 1 + _t1694 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t1619 = 1 + _t1695 = 1 else: - _t1619 = -1 - _t1618 = _t1619 - _t1617 = _t1618 - _t1616 = _t1617 - _t1615 = _t1616 - _t1614 = _t1615 - _t1613 = _t1614 - _t1612 = _t1613 - _t1611 = _t1612 - _t1610 = _t1611 - _t1609 = _t1610 - _t1608 = _t1609 - prediction931 = _t1608 - if prediction931 == 1: - _t1621 = self.parse_term() - term933 = _t1621 - _t1622 = logic_pb2.RelTerm(term=term933) - _t1620 = _t1622 - else: - if prediction931 == 0: - _t1624 = self.parse_specialized_value() - specialized_value932 = _t1624 - _t1625 = logic_pb2.RelTerm(specialized_value=specialized_value932) - _t1623 = _t1625 + _t1695 = -1 + _t1694 = _t1695 + _t1693 = _t1694 + _t1692 = _t1693 + _t1691 = _t1692 + _t1690 = _t1691 + _t1689 = _t1690 + _t1688 = _t1689 + _t1687 = _t1688 + _t1686 = _t1687 + _t1685 = _t1686 + _t1684 = _t1685 + prediction959 = _t1684 + if prediction959 == 1: + self.push_path(2) + _t1697 = self.parse_term() + term961 = _t1697 + self.pop_path() + _t1698 = logic_pb2.RelTerm(term=term961) + _t1696 = _t1698 + else: + if prediction959 == 0: + self.push_path(1) + _t1700 = self.parse_specialized_value() + specialized_value960 = _t1700 + self.pop_path() + _t1701 = logic_pb2.RelTerm(specialized_value=specialized_value960) + _t1699 = _t1701 else: raise ParseError("Unexpected token in rel_term" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1620 = _t1623 - result935 = _t1620 - self.record_span(span_start934) - return result935 + _t1696 = _t1699 + result963 = _t1696 + self.record_span(span_start962) + return result963 def parse_specialized_value(self) -> logic_pb2.Value: - span_start937 = self.span_start() + span_start965 = self.span_start() self.consume_literal("#") - _t1626 = self.parse_value() - value936 = _t1626 - result938 = value936 - self.record_span(span_start937) - return result938 + _t1702 = self.parse_value() + value964 = _t1702 + result966 = value964 + self.record_span(span_start965) + return result966 def parse_rel_atom(self) -> logic_pb2.RelAtom: - span_start948 = self.span_start() + span_start976 = self.span_start() self.consume_literal("(") self.consume_literal("relatom") self.push_path(3) - _t1627 = self.parse_name() - name939 = _t1627 + _t1703 = self.parse_name() + name967 = _t1703 self.pop_path() self.push_path(2) - xs944 = [] - cond945 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - idx946 = 0 - while cond945: - self.push_path(idx946) - _t1628 = self.parse_rel_term() - item947 = _t1628 + xs972 = [] + cond973 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx974 = 0 + while cond973: + self.push_path(idx974) + _t1704 = self.parse_rel_term() + item975 = _t1704 self.pop_path() - xs944.append(item947) - idx946 = (idx946 + 1) - cond945 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) - rel_terms943 = xs944 + xs972.append(item975) + idx974 = (idx974 + 1) + cond973 = (((((((((((self.match_lookahead_literal("#", 0) or self.match_lookahead_literal("(", 0)) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("SYMBOL", 0)) or self.match_lookahead_terminal("UINT128", 0)) + rel_terms971 = xs972 self.pop_path() self.consume_literal(")") - _t1629 = logic_pb2.RelAtom(name=name939, terms=rel_terms943) - result949 = _t1629 - self.record_span(span_start948) - return result949 + _t1705 = logic_pb2.RelAtom(name=name967, terms=rel_terms971) + result977 = _t1705 + self.record_span(span_start976) + return result977 def parse_cast(self) -> logic_pb2.Cast: - span_start952 = self.span_start() + span_start980 = self.span_start() self.consume_literal("(") self.consume_literal("cast") self.push_path(2) - _t1630 = self.parse_term() - term950 = _t1630 + _t1706 = self.parse_term() + term978 = _t1706 self.pop_path() self.push_path(3) - _t1631 = self.parse_term() - term_3951 = _t1631 + _t1707 = self.parse_term() + term_3979 = _t1707 self.pop_path() self.consume_literal(")") - _t1632 = logic_pb2.Cast(input=term950, result=term_3951) - result953 = _t1632 - self.record_span(span_start952) - return result953 + _t1708 = logic_pb2.Cast(input=term978, result=term_3979) + result981 = _t1708 + self.record_span(span_start980) + return result981 def parse_attrs(self) -> Sequence[logic_pb2.Attribute]: - span_start958 = self.span_start() + span_start990 = self.span_start() self.consume_literal("(") self.consume_literal("attrs") - xs954 = [] - cond955 = self.match_lookahead_literal("(", 0) - while cond955: - _t1633 = self.parse_attribute() - item956 = _t1633 - xs954.append(item956) - cond955 = self.match_lookahead_literal("(", 0) - attributes957 = xs954 - self.consume_literal(")") - result959 = attributes957 - self.record_span(span_start958) - return result959 + xs986 = [] + cond987 = self.match_lookahead_literal("(", 0) + idx988 = 0 + while cond987: + self.push_path(idx988) + _t1709 = self.parse_attribute() + item989 = _t1709 + self.pop_path() + xs986.append(item989) + idx988 = (idx988 + 1) + cond987 = self.match_lookahead_literal("(", 0) + attributes985 = xs986 + self.consume_literal(")") + result991 = attributes985 + self.record_span(span_start990) + return result991 def parse_attribute(self) -> logic_pb2.Attribute: - span_start969 = self.span_start() + span_start1001 = self.span_start() self.consume_literal("(") self.consume_literal("attribute") self.push_path(1) - _t1634 = self.parse_name() - name960 = _t1634 + _t1710 = self.parse_name() + name992 = _t1710 self.pop_path() self.push_path(2) - xs965 = [] - cond966 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) - idx967 = 0 - while cond966: - self.push_path(idx967) - _t1635 = self.parse_value() - item968 = _t1635 + xs997 = [] + cond998 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) + idx999 = 0 + while cond998: + self.push_path(idx999) + _t1711 = self.parse_value() + item1000 = _t1711 self.pop_path() - xs965.append(item968) - idx967 = (idx967 + 1) - cond966 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) - values964 = xs965 + xs997.append(item1000) + idx999 = (idx999 + 1) + cond998 = (((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("false", 0)) or self.match_lookahead_literal("missing", 0)) or self.match_lookahead_literal("true", 0)) or self.match_lookahead_terminal("DECIMAL", 0)) or self.match_lookahead_terminal("FLOAT", 0)) or self.match_lookahead_terminal("INT", 0)) or self.match_lookahead_terminal("INT128", 0)) or self.match_lookahead_terminal("STRING", 0)) or self.match_lookahead_terminal("UINT128", 0)) + values996 = xs997 self.pop_path() self.consume_literal(")") - _t1636 = logic_pb2.Attribute(name=name960, args=values964) - result970 = _t1636 - self.record_span(span_start969) - return result970 + _t1712 = logic_pb2.Attribute(name=name992, args=values996) + result1002 = _t1712 + self.record_span(span_start1001) + return result1002 def parse_algorithm(self) -> logic_pb2.Algorithm: - span_start980 = self.span_start() + span_start1012 = self.span_start() self.consume_literal("(") self.consume_literal("algorithm") self.push_path(1) - xs975 = [] - cond976 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - idx977 = 0 - while cond976: - self.push_path(idx977) - _t1637 = self.parse_relation_id() - item978 = _t1637 + xs1007 = [] + cond1008 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + idx1009 = 0 + while cond1008: + self.push_path(idx1009) + _t1713 = self.parse_relation_id() + item1010 = _t1713 self.pop_path() - xs975.append(item978) - idx977 = (idx977 + 1) - cond976 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - relation_ids974 = xs975 + xs1007.append(item1010) + idx1009 = (idx1009 + 1) + cond1008 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + relation_ids1006 = xs1007 self.pop_path() self.push_path(2) - _t1638 = self.parse_script() - script979 = _t1638 + _t1714 = self.parse_script() + script1011 = _t1714 self.pop_path() self.consume_literal(")") - _t1639 = logic_pb2.Algorithm(body=script979) - getattr(_t1639, 'global').extend(relation_ids974) - result981 = _t1639 - self.record_span(span_start980) - return result981 + _t1715 = logic_pb2.Algorithm(body=script1011) + getattr(_t1715, 'global').extend(relation_ids1006) + result1013 = _t1715 + self.record_span(span_start1012) + return result1013 def parse_script(self) -> logic_pb2.Script: - span_start990 = self.span_start() + span_start1022 = self.span_start() self.consume_literal("(") self.consume_literal("script") self.push_path(1) - xs986 = [] - cond987 = self.match_lookahead_literal("(", 0) - idx988 = 0 - while cond987: - self.push_path(idx988) - _t1640 = self.parse_construct() - item989 = _t1640 + xs1018 = [] + cond1019 = self.match_lookahead_literal("(", 0) + idx1020 = 0 + while cond1019: + self.push_path(idx1020) + _t1716 = self.parse_construct() + item1021 = _t1716 self.pop_path() - xs986.append(item989) - idx988 = (idx988 + 1) - cond987 = self.match_lookahead_literal("(", 0) - constructs985 = xs986 + xs1018.append(item1021) + idx1020 = (idx1020 + 1) + cond1019 = self.match_lookahead_literal("(", 0) + constructs1017 = xs1018 self.pop_path() self.consume_literal(")") - _t1641 = logic_pb2.Script(constructs=constructs985) - result991 = _t1641 - self.record_span(span_start990) - return result991 + _t1717 = logic_pb2.Script(constructs=constructs1017) + result1023 = _t1717 + self.record_span(span_start1022) + return result1023 def parse_construct(self) -> logic_pb2.Construct: - span_start995 = self.span_start() + span_start1027 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1643 = 1 + _t1719 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1644 = 1 + _t1720 = 1 else: if self.match_lookahead_literal("monoid", 1): - _t1645 = 1 + _t1721 = 1 else: if self.match_lookahead_literal("loop", 1): - _t1646 = 0 + _t1722 = 0 else: if self.match_lookahead_literal("break", 1): - _t1647 = 1 + _t1723 = 1 else: if self.match_lookahead_literal("assign", 1): - _t1648 = 1 + _t1724 = 1 else: - _t1648 = -1 - _t1647 = _t1648 - _t1646 = _t1647 - _t1645 = _t1646 - _t1644 = _t1645 - _t1643 = _t1644 - _t1642 = _t1643 - else: - _t1642 = -1 - prediction992 = _t1642 - if prediction992 == 1: - _t1650 = self.parse_instruction() - instruction994 = _t1650 - _t1651 = logic_pb2.Construct(instruction=instruction994) - _t1649 = _t1651 - else: - if prediction992 == 0: - _t1653 = self.parse_loop() - loop993 = _t1653 - _t1654 = logic_pb2.Construct(loop=loop993) - _t1652 = _t1654 + _t1724 = -1 + _t1723 = _t1724 + _t1722 = _t1723 + _t1721 = _t1722 + _t1720 = _t1721 + _t1719 = _t1720 + _t1718 = _t1719 + else: + _t1718 = -1 + prediction1024 = _t1718 + if prediction1024 == 1: + self.push_path(2) + _t1726 = self.parse_instruction() + instruction1026 = _t1726 + self.pop_path() + _t1727 = logic_pb2.Construct(instruction=instruction1026) + _t1725 = _t1727 + else: + if prediction1024 == 0: + self.push_path(1) + _t1729 = self.parse_loop() + loop1025 = _t1729 + self.pop_path() + _t1730 = logic_pb2.Construct(loop=loop1025) + _t1728 = _t1730 else: raise ParseError("Unexpected token in construct" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1649 = _t1652 - result996 = _t1649 - self.record_span(span_start995) - return result996 + _t1725 = _t1728 + result1028 = _t1725 + self.record_span(span_start1027) + return result1028 def parse_loop(self) -> logic_pb2.Loop: - span_start999 = self.span_start() + span_start1031 = self.span_start() self.consume_literal("(") self.consume_literal("loop") self.push_path(1) - _t1655 = self.parse_init() - init997 = _t1655 + _t1731 = self.parse_init() + init1029 = _t1731 self.pop_path() self.push_path(2) - _t1656 = self.parse_script() - script998 = _t1656 + _t1732 = self.parse_script() + script1030 = _t1732 self.pop_path() self.consume_literal(")") - _t1657 = logic_pb2.Loop(init=init997, body=script998) - result1000 = _t1657 - self.record_span(span_start999) - return result1000 + _t1733 = logic_pb2.Loop(init=init1029, body=script1030) + result1032 = _t1733 + self.record_span(span_start1031) + return result1032 def parse_init(self) -> Sequence[logic_pb2.Instruction]: - span_start1005 = self.span_start() + span_start1041 = self.span_start() self.consume_literal("(") self.consume_literal("init") - xs1001 = [] - cond1002 = self.match_lookahead_literal("(", 0) - while cond1002: - _t1658 = self.parse_instruction() - item1003 = _t1658 - xs1001.append(item1003) - cond1002 = self.match_lookahead_literal("(", 0) - instructions1004 = xs1001 - self.consume_literal(")") - result1006 = instructions1004 - self.record_span(span_start1005) - return result1006 + xs1037 = [] + cond1038 = self.match_lookahead_literal("(", 0) + idx1039 = 0 + while cond1038: + self.push_path(idx1039) + _t1734 = self.parse_instruction() + item1040 = _t1734 + self.pop_path() + xs1037.append(item1040) + idx1039 = (idx1039 + 1) + cond1038 = self.match_lookahead_literal("(", 0) + instructions1036 = xs1037 + self.consume_literal(")") + result1042 = instructions1036 + self.record_span(span_start1041) + return result1042 def parse_instruction(self) -> logic_pb2.Instruction: - span_start1013 = self.span_start() + span_start1049 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1660 = 1 + _t1736 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1661 = 4 + _t1737 = 4 else: if self.match_lookahead_literal("monoid", 1): - _t1662 = 3 + _t1738 = 3 else: if self.match_lookahead_literal("break", 1): - _t1663 = 2 + _t1739 = 2 else: if self.match_lookahead_literal("assign", 1): - _t1664 = 0 + _t1740 = 0 else: - _t1664 = -1 - _t1663 = _t1664 - _t1662 = _t1663 - _t1661 = _t1662 - _t1660 = _t1661 - _t1659 = _t1660 - else: - _t1659 = -1 - prediction1007 = _t1659 - if prediction1007 == 4: - _t1666 = self.parse_monus_def() - monus_def1012 = _t1666 - _t1667 = logic_pb2.Instruction(monus_def=monus_def1012) - _t1665 = _t1667 - else: - if prediction1007 == 3: - _t1669 = self.parse_monoid_def() - monoid_def1011 = _t1669 - _t1670 = logic_pb2.Instruction(monoid_def=monoid_def1011) - _t1668 = _t1670 + _t1740 = -1 + _t1739 = _t1740 + _t1738 = _t1739 + _t1737 = _t1738 + _t1736 = _t1737 + _t1735 = _t1736 + else: + _t1735 = -1 + prediction1043 = _t1735 + if prediction1043 == 4: + self.push_path(6) + _t1742 = self.parse_monus_def() + monus_def1048 = _t1742 + self.pop_path() + _t1743 = logic_pb2.Instruction(monus_def=monus_def1048) + _t1741 = _t1743 + else: + if prediction1043 == 3: + self.push_path(5) + _t1745 = self.parse_monoid_def() + monoid_def1047 = _t1745 + self.pop_path() + _t1746 = logic_pb2.Instruction(monoid_def=monoid_def1047) + _t1744 = _t1746 else: - if prediction1007 == 2: - _t1672 = self.parse_break() - break1010 = _t1672 - _t1673 = logic_pb2.Instruction() - getattr(_t1673, 'break').CopyFrom(break1010) - _t1671 = _t1673 + if prediction1043 == 2: + self.push_path(3) + _t1748 = self.parse_break() + break1046 = _t1748 + self.pop_path() + _t1749 = logic_pb2.Instruction() + getattr(_t1749, 'break').CopyFrom(break1046) + _t1747 = _t1749 else: - if prediction1007 == 1: - _t1675 = self.parse_upsert() - upsert1009 = _t1675 - _t1676 = logic_pb2.Instruction(upsert=upsert1009) - _t1674 = _t1676 + if prediction1043 == 1: + self.push_path(2) + _t1751 = self.parse_upsert() + upsert1045 = _t1751 + self.pop_path() + _t1752 = logic_pb2.Instruction(upsert=upsert1045) + _t1750 = _t1752 else: - if prediction1007 == 0: - _t1678 = self.parse_assign() - assign1008 = _t1678 - _t1679 = logic_pb2.Instruction(assign=assign1008) - _t1677 = _t1679 + if prediction1043 == 0: + self.push_path(1) + _t1754 = self.parse_assign() + assign1044 = _t1754 + self.pop_path() + _t1755 = logic_pb2.Instruction(assign=assign1044) + _t1753 = _t1755 else: raise ParseError("Unexpected token in instruction" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1674 = _t1677 - _t1671 = _t1674 - _t1668 = _t1671 - _t1665 = _t1668 - result1014 = _t1665 - self.record_span(span_start1013) - return result1014 + _t1750 = _t1753 + _t1747 = _t1750 + _t1744 = _t1747 + _t1741 = _t1744 + result1050 = _t1741 + self.record_span(span_start1049) + return result1050 def parse_assign(self) -> logic_pb2.Assign: - span_start1018 = self.span_start() + span_start1054 = self.span_start() self.consume_literal("(") self.consume_literal("assign") self.push_path(1) - _t1680 = self.parse_relation_id() - relation_id1015 = _t1680 + _t1756 = self.parse_relation_id() + relation_id1051 = _t1756 self.pop_path() self.push_path(2) - _t1681 = self.parse_abstraction() - abstraction1016 = _t1681 + _t1757 = self.parse_abstraction() + abstraction1052 = _t1757 self.pop_path() self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1683 = self.parse_attrs() - _t1682 = _t1683 + _t1759 = self.parse_attrs() + _t1758 = _t1759 else: - _t1682 = None - attrs1017 = _t1682 + _t1758 = None + attrs1053 = _t1758 self.pop_path() self.consume_literal(")") - _t1684 = logic_pb2.Assign(name=relation_id1015, body=abstraction1016, attrs=(attrs1017 if attrs1017 is not None else [])) - result1019 = _t1684 - self.record_span(span_start1018) - return result1019 + _t1760 = logic_pb2.Assign(name=relation_id1051, body=abstraction1052, attrs=(attrs1053 if attrs1053 is not None else [])) + result1055 = _t1760 + self.record_span(span_start1054) + return result1055 def parse_upsert(self) -> logic_pb2.Upsert: - span_start1023 = self.span_start() + span_start1059 = self.span_start() self.consume_literal("(") self.consume_literal("upsert") self.push_path(1) - _t1685 = self.parse_relation_id() - relation_id1020 = _t1685 + _t1761 = self.parse_relation_id() + relation_id1056 = _t1761 self.pop_path() - _t1686 = self.parse_abstraction_with_arity() - abstraction_with_arity1021 = _t1686 + _t1762 = self.parse_abstraction_with_arity() + abstraction_with_arity1057 = _t1762 self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1688 = self.parse_attrs() - _t1687 = _t1688 + _t1764 = self.parse_attrs() + _t1763 = _t1764 else: - _t1687 = None - attrs1022 = _t1687 + _t1763 = None + attrs1058 = _t1763 self.pop_path() self.consume_literal(")") - _t1689 = logic_pb2.Upsert(name=relation_id1020, body=abstraction_with_arity1021[0], attrs=(attrs1022 if attrs1022 is not None else []), value_arity=abstraction_with_arity1021[1]) - result1024 = _t1689 - self.record_span(span_start1023) - return result1024 + _t1765 = logic_pb2.Upsert(name=relation_id1056, body=abstraction_with_arity1057[0], attrs=(attrs1058 if attrs1058 is not None else []), value_arity=abstraction_with_arity1057[1]) + result1060 = _t1765 + self.record_span(span_start1059) + return result1060 def parse_abstraction_with_arity(self) -> tuple[logic_pb2.Abstraction, int]: - span_start1027 = self.span_start() + span_start1063 = self.span_start() self.consume_literal("(") - _t1690 = self.parse_bindings() - bindings1025 = _t1690 - _t1691 = self.parse_formula() - formula1026 = _t1691 + _t1766 = self.parse_bindings() + bindings1061 = _t1766 + _t1767 = self.parse_formula() + formula1062 = _t1767 self.consume_literal(")") - _t1692 = logic_pb2.Abstraction(vars=(list(bindings1025[0]) + list(bindings1025[1] if bindings1025[1] is not None else [])), value=formula1026) - result1028 = (_t1692, len(bindings1025[1]),) - self.record_span(span_start1027) - return result1028 + _t1768 = logic_pb2.Abstraction(vars=(list(bindings1061[0]) + list(bindings1061[1] if bindings1061[1] is not None else [])), value=formula1062) + result1064 = (_t1768, len(bindings1061[1]),) + self.record_span(span_start1063) + return result1064 def parse_break(self) -> logic_pb2.Break: - span_start1032 = self.span_start() + span_start1068 = self.span_start() self.consume_literal("(") self.consume_literal("break") self.push_path(1) - _t1693 = self.parse_relation_id() - relation_id1029 = _t1693 + _t1769 = self.parse_relation_id() + relation_id1065 = _t1769 self.pop_path() self.push_path(2) - _t1694 = self.parse_abstraction() - abstraction1030 = _t1694 + _t1770 = self.parse_abstraction() + abstraction1066 = _t1770 self.pop_path() self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1696 = self.parse_attrs() - _t1695 = _t1696 + _t1772 = self.parse_attrs() + _t1771 = _t1772 else: - _t1695 = None - attrs1031 = _t1695 + _t1771 = None + attrs1067 = _t1771 self.pop_path() self.consume_literal(")") - _t1697 = logic_pb2.Break(name=relation_id1029, body=abstraction1030, attrs=(attrs1031 if attrs1031 is not None else [])) - result1033 = _t1697 - self.record_span(span_start1032) - return result1033 + _t1773 = logic_pb2.Break(name=relation_id1065, body=abstraction1066, attrs=(attrs1067 if attrs1067 is not None else [])) + result1069 = _t1773 + self.record_span(span_start1068) + return result1069 def parse_monoid_def(self) -> logic_pb2.MonoidDef: - span_start1038 = self.span_start() + span_start1074 = self.span_start() self.consume_literal("(") self.consume_literal("monoid") self.push_path(1) - _t1698 = self.parse_monoid() - monoid1034 = _t1698 + _t1774 = self.parse_monoid() + monoid1070 = _t1774 self.pop_path() self.push_path(2) - _t1699 = self.parse_relation_id() - relation_id1035 = _t1699 + _t1775 = self.parse_relation_id() + relation_id1071 = _t1775 self.pop_path() - _t1700 = self.parse_abstraction_with_arity() - abstraction_with_arity1036 = _t1700 + _t1776 = self.parse_abstraction_with_arity() + abstraction_with_arity1072 = _t1776 self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1702 = self.parse_attrs() - _t1701 = _t1702 + _t1778 = self.parse_attrs() + _t1777 = _t1778 else: - _t1701 = None - attrs1037 = _t1701 + _t1777 = None + attrs1073 = _t1777 self.pop_path() self.consume_literal(")") - _t1703 = logic_pb2.MonoidDef(monoid=monoid1034, name=relation_id1035, body=abstraction_with_arity1036[0], attrs=(attrs1037 if attrs1037 is not None else []), value_arity=abstraction_with_arity1036[1]) - result1039 = _t1703 - self.record_span(span_start1038) - return result1039 + _t1779 = logic_pb2.MonoidDef(monoid=monoid1070, name=relation_id1071, body=abstraction_with_arity1072[0], attrs=(attrs1073 if attrs1073 is not None else []), value_arity=abstraction_with_arity1072[1]) + result1075 = _t1779 + self.record_span(span_start1074) + return result1075 def parse_monoid(self) -> logic_pb2.Monoid: - span_start1045 = self.span_start() + span_start1081 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("sum", 1): - _t1705 = 3 + _t1781 = 3 else: if self.match_lookahead_literal("or", 1): - _t1706 = 0 + _t1782 = 0 else: if self.match_lookahead_literal("min", 1): - _t1707 = 1 + _t1783 = 1 else: if self.match_lookahead_literal("max", 1): - _t1708 = 2 + _t1784 = 2 else: - _t1708 = -1 - _t1707 = _t1708 - _t1706 = _t1707 - _t1705 = _t1706 - _t1704 = _t1705 - else: - _t1704 = -1 - prediction1040 = _t1704 - if prediction1040 == 3: - _t1710 = self.parse_sum_monoid() - sum_monoid1044 = _t1710 - _t1711 = logic_pb2.Monoid(sum_monoid=sum_monoid1044) - _t1709 = _t1711 - else: - if prediction1040 == 2: - _t1713 = self.parse_max_monoid() - max_monoid1043 = _t1713 - _t1714 = logic_pb2.Monoid(max_monoid=max_monoid1043) - _t1712 = _t1714 + _t1784 = -1 + _t1783 = _t1784 + _t1782 = _t1783 + _t1781 = _t1782 + _t1780 = _t1781 + else: + _t1780 = -1 + prediction1076 = _t1780 + if prediction1076 == 3: + self.push_path(4) + _t1786 = self.parse_sum_monoid() + sum_monoid1080 = _t1786 + self.pop_path() + _t1787 = logic_pb2.Monoid(sum_monoid=sum_monoid1080) + _t1785 = _t1787 + else: + if prediction1076 == 2: + self.push_path(3) + _t1789 = self.parse_max_monoid() + max_monoid1079 = _t1789 + self.pop_path() + _t1790 = logic_pb2.Monoid(max_monoid=max_monoid1079) + _t1788 = _t1790 else: - if prediction1040 == 1: - _t1716 = self.parse_min_monoid() - min_monoid1042 = _t1716 - _t1717 = logic_pb2.Monoid(min_monoid=min_monoid1042) - _t1715 = _t1717 + if prediction1076 == 1: + self.push_path(2) + _t1792 = self.parse_min_monoid() + min_monoid1078 = _t1792 + self.pop_path() + _t1793 = logic_pb2.Monoid(min_monoid=min_monoid1078) + _t1791 = _t1793 else: - if prediction1040 == 0: - _t1719 = self.parse_or_monoid() - or_monoid1041 = _t1719 - _t1720 = logic_pb2.Monoid(or_monoid=or_monoid1041) - _t1718 = _t1720 + if prediction1076 == 0: + self.push_path(1) + _t1795 = self.parse_or_monoid() + or_monoid1077 = _t1795 + self.pop_path() + _t1796 = logic_pb2.Monoid(or_monoid=or_monoid1077) + _t1794 = _t1796 else: raise ParseError("Unexpected token in monoid" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1715 = _t1718 - _t1712 = _t1715 - _t1709 = _t1712 - result1046 = _t1709 - self.record_span(span_start1045) - return result1046 + _t1791 = _t1794 + _t1788 = _t1791 + _t1785 = _t1788 + result1082 = _t1785 + self.record_span(span_start1081) + return result1082 def parse_or_monoid(self) -> logic_pb2.OrMonoid: - span_start1047 = self.span_start() + span_start1083 = self.span_start() self.consume_literal("(") self.consume_literal("or") self.consume_literal(")") - _t1721 = logic_pb2.OrMonoid() - result1048 = _t1721 - self.record_span(span_start1047) - return result1048 + _t1797 = logic_pb2.OrMonoid() + result1084 = _t1797 + self.record_span(span_start1083) + return result1084 def parse_min_monoid(self) -> logic_pb2.MinMonoid: - span_start1050 = self.span_start() + span_start1086 = self.span_start() self.consume_literal("(") self.consume_literal("min") self.push_path(1) - _t1722 = self.parse_type() - type1049 = _t1722 + _t1798 = self.parse_type() + type1085 = _t1798 self.pop_path() self.consume_literal(")") - _t1723 = logic_pb2.MinMonoid(type=type1049) - result1051 = _t1723 - self.record_span(span_start1050) - return result1051 + _t1799 = logic_pb2.MinMonoid(type=type1085) + result1087 = _t1799 + self.record_span(span_start1086) + return result1087 def parse_max_monoid(self) -> logic_pb2.MaxMonoid: - span_start1053 = self.span_start() + span_start1089 = self.span_start() self.consume_literal("(") self.consume_literal("max") self.push_path(1) - _t1724 = self.parse_type() - type1052 = _t1724 + _t1800 = self.parse_type() + type1088 = _t1800 self.pop_path() self.consume_literal(")") - _t1725 = logic_pb2.MaxMonoid(type=type1052) - result1054 = _t1725 - self.record_span(span_start1053) - return result1054 + _t1801 = logic_pb2.MaxMonoid(type=type1088) + result1090 = _t1801 + self.record_span(span_start1089) + return result1090 def parse_sum_monoid(self) -> logic_pb2.SumMonoid: - span_start1056 = self.span_start() + span_start1092 = self.span_start() self.consume_literal("(") self.consume_literal("sum") self.push_path(1) - _t1726 = self.parse_type() - type1055 = _t1726 + _t1802 = self.parse_type() + type1091 = _t1802 self.pop_path() self.consume_literal(")") - _t1727 = logic_pb2.SumMonoid(type=type1055) - result1057 = _t1727 - self.record_span(span_start1056) - return result1057 + _t1803 = logic_pb2.SumMonoid(type=type1091) + result1093 = _t1803 + self.record_span(span_start1092) + return result1093 def parse_monus_def(self) -> logic_pb2.MonusDef: - span_start1062 = self.span_start() + span_start1098 = self.span_start() self.consume_literal("(") self.consume_literal("monus") self.push_path(1) - _t1728 = self.parse_monoid() - monoid1058 = _t1728 + _t1804 = self.parse_monoid() + monoid1094 = _t1804 self.pop_path() self.push_path(2) - _t1729 = self.parse_relation_id() - relation_id1059 = _t1729 + _t1805 = self.parse_relation_id() + relation_id1095 = _t1805 self.pop_path() - _t1730 = self.parse_abstraction_with_arity() - abstraction_with_arity1060 = _t1730 + _t1806 = self.parse_abstraction_with_arity() + abstraction_with_arity1096 = _t1806 self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1732 = self.parse_attrs() - _t1731 = _t1732 + _t1808 = self.parse_attrs() + _t1807 = _t1808 else: - _t1731 = None - attrs1061 = _t1731 + _t1807 = None + attrs1097 = _t1807 self.pop_path() self.consume_literal(")") - _t1733 = logic_pb2.MonusDef(monoid=monoid1058, name=relation_id1059, body=abstraction_with_arity1060[0], attrs=(attrs1061 if attrs1061 is not None else []), value_arity=abstraction_with_arity1060[1]) - result1063 = _t1733 - self.record_span(span_start1062) - return result1063 + _t1809 = logic_pb2.MonusDef(monoid=monoid1094, name=relation_id1095, body=abstraction_with_arity1096[0], attrs=(attrs1097 if attrs1097 is not None else []), value_arity=abstraction_with_arity1096[1]) + result1099 = _t1809 + self.record_span(span_start1098) + return result1099 def parse_constraint(self) -> logic_pb2.Constraint: - span_start1068 = self.span_start() + span_start1104 = self.span_start() self.consume_literal("(") self.consume_literal("functional_dependency") self.push_path(2) - _t1734 = self.parse_relation_id() - relation_id1064 = _t1734 - self.pop_path() - _t1735 = self.parse_abstraction() - abstraction1065 = _t1735 - _t1736 = self.parse_functional_dependency_keys() - functional_dependency_keys1066 = _t1736 - _t1737 = self.parse_functional_dependency_values() - functional_dependency_values1067 = _t1737 - self.consume_literal(")") - _t1738 = logic_pb2.FunctionalDependency(guard=abstraction1065, keys=functional_dependency_keys1066, values=functional_dependency_values1067) - _t1739 = logic_pb2.Constraint(name=relation_id1064, functional_dependency=_t1738) - result1069 = _t1739 - self.record_span(span_start1068) - return result1069 + _t1810 = self.parse_relation_id() + relation_id1100 = _t1810 + self.pop_path() + _t1811 = self.parse_abstraction() + abstraction1101 = _t1811 + _t1812 = self.parse_functional_dependency_keys() + functional_dependency_keys1102 = _t1812 + _t1813 = self.parse_functional_dependency_values() + functional_dependency_values1103 = _t1813 + self.consume_literal(")") + _t1814 = logic_pb2.FunctionalDependency(guard=abstraction1101, keys=functional_dependency_keys1102, values=functional_dependency_values1103) + _t1815 = logic_pb2.Constraint(name=relation_id1100, functional_dependency=_t1814) + result1105 = _t1815 + self.record_span(span_start1104) + return result1105 def parse_functional_dependency_keys(self) -> Sequence[logic_pb2.Var]: - span_start1074 = self.span_start() + span_start1114 = self.span_start() self.consume_literal("(") self.consume_literal("keys") - xs1070 = [] - cond1071 = self.match_lookahead_terminal("SYMBOL", 0) - while cond1071: - _t1740 = self.parse_var() - item1072 = _t1740 - xs1070.append(item1072) - cond1071 = self.match_lookahead_terminal("SYMBOL", 0) - vars1073 = xs1070 - self.consume_literal(")") - result1075 = vars1073 - self.record_span(span_start1074) - return result1075 + xs1110 = [] + cond1111 = self.match_lookahead_terminal("SYMBOL", 0) + idx1112 = 0 + while cond1111: + self.push_path(idx1112) + _t1816 = self.parse_var() + item1113 = _t1816 + self.pop_path() + xs1110.append(item1113) + idx1112 = (idx1112 + 1) + cond1111 = self.match_lookahead_terminal("SYMBOL", 0) + vars1109 = xs1110 + self.consume_literal(")") + result1115 = vars1109 + self.record_span(span_start1114) + return result1115 def parse_functional_dependency_values(self) -> Sequence[logic_pb2.Var]: - span_start1080 = self.span_start() + span_start1124 = self.span_start() self.consume_literal("(") self.consume_literal("values") - xs1076 = [] - cond1077 = self.match_lookahead_terminal("SYMBOL", 0) - while cond1077: - _t1741 = self.parse_var() - item1078 = _t1741 - xs1076.append(item1078) - cond1077 = self.match_lookahead_terminal("SYMBOL", 0) - vars1079 = xs1076 - self.consume_literal(")") - result1081 = vars1079 - self.record_span(span_start1080) - return result1081 + xs1120 = [] + cond1121 = self.match_lookahead_terminal("SYMBOL", 0) + idx1122 = 0 + while cond1121: + self.push_path(idx1122) + _t1817 = self.parse_var() + item1123 = _t1817 + self.pop_path() + xs1120.append(item1123) + idx1122 = (idx1122 + 1) + cond1121 = self.match_lookahead_terminal("SYMBOL", 0) + vars1119 = xs1120 + self.consume_literal(")") + result1125 = vars1119 + self.record_span(span_start1124) + return result1125 def parse_data(self) -> logic_pb2.Data: - span_start1086 = self.span_start() + span_start1130 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t1743 = 0 + _t1819 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t1744 = 2 + _t1820 = 2 else: if self.match_lookahead_literal("betree_relation", 1): - _t1745 = 1 + _t1821 = 1 else: - _t1745 = -1 - _t1744 = _t1745 - _t1743 = _t1744 - _t1742 = _t1743 - else: - _t1742 = -1 - prediction1082 = _t1742 - if prediction1082 == 2: - _t1747 = self.parse_csv_data() - csv_data1085 = _t1747 - _t1748 = logic_pb2.Data(csv_data=csv_data1085) - _t1746 = _t1748 - else: - if prediction1082 == 1: - _t1750 = self.parse_betree_relation() - betree_relation1084 = _t1750 - _t1751 = logic_pb2.Data(betree_relation=betree_relation1084) - _t1749 = _t1751 + _t1821 = -1 + _t1820 = _t1821 + _t1819 = _t1820 + _t1818 = _t1819 + else: + _t1818 = -1 + prediction1126 = _t1818 + if prediction1126 == 2: + self.push_path(3) + _t1823 = self.parse_csv_data() + csv_data1129 = _t1823 + self.pop_path() + _t1824 = logic_pb2.Data(csv_data=csv_data1129) + _t1822 = _t1824 + else: + if prediction1126 == 1: + self.push_path(2) + _t1826 = self.parse_betree_relation() + betree_relation1128 = _t1826 + self.pop_path() + _t1827 = logic_pb2.Data(betree_relation=betree_relation1128) + _t1825 = _t1827 else: - if prediction1082 == 0: - _t1753 = self.parse_rel_edb() - rel_edb1083 = _t1753 - _t1754 = logic_pb2.Data(rel_edb=rel_edb1083) - _t1752 = _t1754 + if prediction1126 == 0: + self.push_path(1) + _t1829 = self.parse_rel_edb() + rel_edb1127 = _t1829 + self.pop_path() + _t1830 = logic_pb2.Data(rel_edb=rel_edb1127) + _t1828 = _t1830 else: raise ParseError("Unexpected token in data" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1749 = _t1752 - _t1746 = _t1749 - result1087 = _t1746 - self.record_span(span_start1086) - return result1087 + _t1825 = _t1828 + _t1822 = _t1825 + result1131 = _t1822 + self.record_span(span_start1130) + return result1131 def parse_rel_edb(self) -> logic_pb2.RelEDB: - span_start1091 = self.span_start() + span_start1135 = self.span_start() self.consume_literal("(") self.consume_literal("rel_edb") self.push_path(1) - _t1755 = self.parse_relation_id() - relation_id1088 = _t1755 + _t1831 = self.parse_relation_id() + relation_id1132 = _t1831 self.pop_path() self.push_path(2) - _t1756 = self.parse_rel_edb_path() - rel_edb_path1089 = _t1756 + _t1832 = self.parse_rel_edb_path() + rel_edb_path1133 = _t1832 self.pop_path() self.push_path(3) - _t1757 = self.parse_rel_edb_types() - rel_edb_types1090 = _t1757 + _t1833 = self.parse_rel_edb_types() + rel_edb_types1134 = _t1833 self.pop_path() self.consume_literal(")") - _t1758 = logic_pb2.RelEDB(target_id=relation_id1088, path=rel_edb_path1089, types=rel_edb_types1090) - result1092 = _t1758 - self.record_span(span_start1091) - return result1092 + _t1834 = logic_pb2.RelEDB(target_id=relation_id1132, path=rel_edb_path1133, types=rel_edb_types1134) + result1136 = _t1834 + self.record_span(span_start1135) + return result1136 def parse_rel_edb_path(self) -> Sequence[str]: - span_start1097 = self.span_start() + span_start1145 = self.span_start() self.consume_literal("[") - xs1093 = [] - cond1094 = self.match_lookahead_terminal("STRING", 0) - while cond1094: - item1095 = self.consume_terminal("STRING") - xs1093.append(item1095) - cond1094 = self.match_lookahead_terminal("STRING", 0) - strings1096 = xs1093 + xs1141 = [] + cond1142 = self.match_lookahead_terminal("STRING", 0) + idx1143 = 0 + while cond1142: + self.push_path(idx1143) + item1144 = self.consume_terminal("STRING") + self.pop_path() + xs1141.append(item1144) + idx1143 = (idx1143 + 1) + cond1142 = self.match_lookahead_terminal("STRING", 0) + strings1140 = xs1141 self.consume_literal("]") - result1098 = strings1096 - self.record_span(span_start1097) - return result1098 + result1146 = strings1140 + self.record_span(span_start1145) + return result1146 def parse_rel_edb_types(self) -> Sequence[logic_pb2.Type]: - span_start1103 = self.span_start() + span_start1155 = self.span_start() self.consume_literal("[") - xs1099 = [] - cond1100 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond1100: - _t1759 = self.parse_type() - item1101 = _t1759 - xs1099.append(item1101) - cond1100 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types1102 = xs1099 + xs1151 = [] + cond1152 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + idx1153 = 0 + while cond1152: + self.push_path(idx1153) + _t1835 = self.parse_type() + item1154 = _t1835 + self.pop_path() + xs1151.append(item1154) + idx1153 = (idx1153 + 1) + cond1152 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1150 = xs1151 self.consume_literal("]") - result1104 = types1102 - self.record_span(span_start1103) - return result1104 + result1156 = types1150 + self.record_span(span_start1155) + return result1156 def parse_betree_relation(self) -> logic_pb2.BeTreeRelation: - span_start1107 = self.span_start() + span_start1159 = self.span_start() self.consume_literal("(") self.consume_literal("betree_relation") self.push_path(1) - _t1760 = self.parse_relation_id() - relation_id1105 = _t1760 + _t1836 = self.parse_relation_id() + relation_id1157 = _t1836 self.pop_path() self.push_path(2) - _t1761 = self.parse_betree_info() - betree_info1106 = _t1761 + _t1837 = self.parse_betree_info() + betree_info1158 = _t1837 self.pop_path() self.consume_literal(")") - _t1762 = logic_pb2.BeTreeRelation(name=relation_id1105, relation_info=betree_info1106) - result1108 = _t1762 - self.record_span(span_start1107) - return result1108 + _t1838 = logic_pb2.BeTreeRelation(name=relation_id1157, relation_info=betree_info1158) + result1160 = _t1838 + self.record_span(span_start1159) + return result1160 def parse_betree_info(self) -> logic_pb2.BeTreeInfo: - span_start1112 = self.span_start() + span_start1164 = self.span_start() self.consume_literal("(") self.consume_literal("betree_info") - _t1763 = self.parse_betree_info_key_types() - betree_info_key_types1109 = _t1763 - _t1764 = self.parse_betree_info_value_types() - betree_info_value_types1110 = _t1764 - _t1765 = self.parse_config_dict() - config_dict1111 = _t1765 - self.consume_literal(")") - _t1766 = self.construct_betree_info(betree_info_key_types1109, betree_info_value_types1110, config_dict1111) - result1113 = _t1766 - self.record_span(span_start1112) - return result1113 + _t1839 = self.parse_betree_info_key_types() + betree_info_key_types1161 = _t1839 + _t1840 = self.parse_betree_info_value_types() + betree_info_value_types1162 = _t1840 + _t1841 = self.parse_config_dict() + config_dict1163 = _t1841 + self.consume_literal(")") + _t1842 = self.construct_betree_info(betree_info_key_types1161, betree_info_value_types1162, config_dict1163) + result1165 = _t1842 + self.record_span(span_start1164) + return result1165 def parse_betree_info_key_types(self) -> Sequence[logic_pb2.Type]: - span_start1118 = self.span_start() + span_start1174 = self.span_start() self.consume_literal("(") self.consume_literal("key_types") - xs1114 = [] - cond1115 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond1115: - _t1767 = self.parse_type() - item1116 = _t1767 - xs1114.append(item1116) - cond1115 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types1117 = xs1114 - self.consume_literal(")") - result1119 = types1117 - self.record_span(span_start1118) - return result1119 + xs1170 = [] + cond1171 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + idx1172 = 0 + while cond1171: + self.push_path(idx1172) + _t1843 = self.parse_type() + item1173 = _t1843 + self.pop_path() + xs1170.append(item1173) + idx1172 = (idx1172 + 1) + cond1171 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1169 = xs1170 + self.consume_literal(")") + result1175 = types1169 + self.record_span(span_start1174) + return result1175 def parse_betree_info_value_types(self) -> Sequence[logic_pb2.Type]: - span_start1124 = self.span_start() + span_start1184 = self.span_start() self.consume_literal("(") self.consume_literal("value_types") - xs1120 = [] - cond1121 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - while cond1121: - _t1768 = self.parse_type() - item1122 = _t1768 - xs1120.append(item1122) - cond1121 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types1123 = xs1120 + xs1180 = [] + cond1181 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + idx1182 = 0 + while cond1181: + self.push_path(idx1182) + _t1844 = self.parse_type() + item1183 = _t1844 + self.pop_path() + xs1180.append(item1183) + idx1182 = (idx1182 + 1) + cond1181 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1179 = xs1180 self.consume_literal(")") - result1125 = types1123 - self.record_span(span_start1124) - return result1125 + result1185 = types1179 + self.record_span(span_start1184) + return result1185 def parse_csv_data(self) -> logic_pb2.CSVData: - span_start1130 = self.span_start() + span_start1190 = self.span_start() self.consume_literal("(") self.consume_literal("csv_data") self.push_path(1) - _t1769 = self.parse_csvlocator() - csvlocator1126 = _t1769 + _t1845 = self.parse_csvlocator() + csvlocator1186 = _t1845 self.pop_path() self.push_path(2) - _t1770 = self.parse_csv_config() - csv_config1127 = _t1770 + _t1846 = self.parse_csv_config() + csv_config1187 = _t1846 self.pop_path() self.push_path(3) - _t1771 = self.parse_csv_columns() - csv_columns1128 = _t1771 + _t1847 = self.parse_csv_columns() + csv_columns1188 = _t1847 self.pop_path() self.push_path(4) - _t1772 = self.parse_csv_asof() - csv_asof1129 = _t1772 + _t1848 = self.parse_csv_asof() + csv_asof1189 = _t1848 self.pop_path() self.consume_literal(")") - _t1773 = logic_pb2.CSVData(locator=csvlocator1126, config=csv_config1127, columns=csv_columns1128, asof=csv_asof1129) - result1131 = _t1773 - self.record_span(span_start1130) - return result1131 + _t1849 = logic_pb2.CSVData(locator=csvlocator1186, config=csv_config1187, columns=csv_columns1188, asof=csv_asof1189) + result1191 = _t1849 + self.record_span(span_start1190) + return result1191 def parse_csvlocator(self) -> logic_pb2.CSVLocator: - span_start1134 = self.span_start() + span_start1194 = self.span_start() self.consume_literal("(") self.consume_literal("csv_locator") self.push_path(1) if (self.match_lookahead_literal("(", 0) and self.match_lookahead_literal("paths", 1)): - _t1775 = self.parse_csv_locator_paths() - _t1774 = _t1775 + _t1851 = self.parse_csv_locator_paths() + _t1850 = _t1851 else: - _t1774 = None - csv_locator_paths1132 = _t1774 + _t1850 = None + csv_locator_paths1192 = _t1850 self.pop_path() self.push_path(2) if self.match_lookahead_literal("(", 0): - _t1777 = self.parse_csv_locator_inline_data() - _t1776 = _t1777 + _t1853 = self.parse_csv_locator_inline_data() + _t1852 = _t1853 else: - _t1776 = None - csv_locator_inline_data1133 = _t1776 + _t1852 = None + csv_locator_inline_data1193 = _t1852 self.pop_path() self.consume_literal(")") - _t1778 = logic_pb2.CSVLocator(paths=(csv_locator_paths1132 if csv_locator_paths1132 is not None else []), inline_data=(csv_locator_inline_data1133 if csv_locator_inline_data1133 is not None else "").encode()) - result1135 = _t1778 - self.record_span(span_start1134) - return result1135 + _t1854 = logic_pb2.CSVLocator(paths=(csv_locator_paths1192 if csv_locator_paths1192 is not None else []), inline_data=(csv_locator_inline_data1193 if csv_locator_inline_data1193 is not None else "").encode()) + result1195 = _t1854 + self.record_span(span_start1194) + return result1195 def parse_csv_locator_paths(self) -> Sequence[str]: - span_start1140 = self.span_start() + span_start1204 = self.span_start() self.consume_literal("(") self.consume_literal("paths") - xs1136 = [] - cond1137 = self.match_lookahead_terminal("STRING", 0) - while cond1137: - item1138 = self.consume_terminal("STRING") - xs1136.append(item1138) - cond1137 = self.match_lookahead_terminal("STRING", 0) - strings1139 = xs1136 - self.consume_literal(")") - result1141 = strings1139 - self.record_span(span_start1140) - return result1141 + xs1200 = [] + cond1201 = self.match_lookahead_terminal("STRING", 0) + idx1202 = 0 + while cond1201: + self.push_path(idx1202) + item1203 = self.consume_terminal("STRING") + self.pop_path() + xs1200.append(item1203) + idx1202 = (idx1202 + 1) + cond1201 = self.match_lookahead_terminal("STRING", 0) + strings1199 = xs1200 + self.consume_literal(")") + result1205 = strings1199 + self.record_span(span_start1204) + return result1205 def parse_csv_locator_inline_data(self) -> str: - span_start1143 = self.span_start() + span_start1207 = self.span_start() self.consume_literal("(") self.consume_literal("inline_data") - string1142 = self.consume_terminal("STRING") + string1206 = self.consume_terminal("STRING") self.consume_literal(")") - result1144 = string1142 - self.record_span(span_start1143) - return result1144 + result1208 = string1206 + self.record_span(span_start1207) + return result1208 def parse_csv_config(self) -> logic_pb2.CSVConfig: - span_start1146 = self.span_start() + span_start1210 = self.span_start() self.consume_literal("(") self.consume_literal("csv_config") - _t1779 = self.parse_config_dict() - config_dict1145 = _t1779 + _t1855 = self.parse_config_dict() + config_dict1209 = _t1855 self.consume_literal(")") - _t1780 = self.construct_csv_config(config_dict1145) - result1147 = _t1780 - self.record_span(span_start1146) - return result1147 + _t1856 = self.construct_csv_config(config_dict1209) + result1211 = _t1856 + self.record_span(span_start1210) + return result1211 def parse_csv_columns(self) -> Sequence[logic_pb2.CSVColumn]: - span_start1152 = self.span_start() + span_start1220 = self.span_start() self.consume_literal("(") self.consume_literal("columns") - xs1148 = [] - cond1149 = self.match_lookahead_literal("(", 0) - while cond1149: - _t1781 = self.parse_csv_column() - item1150 = _t1781 - xs1148.append(item1150) - cond1149 = self.match_lookahead_literal("(", 0) - csv_columns1151 = xs1148 - self.consume_literal(")") - result1153 = csv_columns1151 - self.record_span(span_start1152) - return result1153 + xs1216 = [] + cond1217 = self.match_lookahead_literal("(", 0) + idx1218 = 0 + while cond1217: + self.push_path(idx1218) + _t1857 = self.parse_csv_column() + item1219 = _t1857 + self.pop_path() + xs1216.append(item1219) + idx1218 = (idx1218 + 1) + cond1217 = self.match_lookahead_literal("(", 0) + csv_columns1215 = xs1216 + self.consume_literal(")") + result1221 = csv_columns1215 + self.record_span(span_start1220) + return result1221 def parse_csv_column(self) -> logic_pb2.CSVColumn: - span_start1164 = self.span_start() + span_start1232 = self.span_start() self.consume_literal("(") self.consume_literal("column") self.push_path(1) - string1154 = self.consume_terminal("STRING") + string1222 = self.consume_terminal("STRING") self.pop_path() self.push_path(2) - _t1782 = self.parse_relation_id() - relation_id1155 = _t1782 + _t1858 = self.parse_relation_id() + relation_id1223 = _t1858 self.pop_path() self.consume_literal("[") self.push_path(3) - xs1160 = [] - cond1161 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - idx1162 = 0 - while cond1161: - self.push_path(idx1162) - _t1783 = self.parse_type() - item1163 = _t1783 + xs1228 = [] + cond1229 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + idx1230 = 0 + while cond1229: + self.push_path(idx1230) + _t1859 = self.parse_type() + item1231 = _t1859 self.pop_path() - xs1160.append(item1163) - idx1162 = (idx1162 + 1) - cond1161 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) - types1159 = xs1160 + xs1228.append(item1231) + idx1230 = (idx1230 + 1) + cond1229 = ((((((((((self.match_lookahead_literal("(", 0) or self.match_lookahead_literal("BOOLEAN", 0)) or self.match_lookahead_literal("DATE", 0)) or self.match_lookahead_literal("DATETIME", 0)) or self.match_lookahead_literal("FLOAT", 0)) or self.match_lookahead_literal("INT", 0)) or self.match_lookahead_literal("INT128", 0)) or self.match_lookahead_literal("MISSING", 0)) or self.match_lookahead_literal("STRING", 0)) or self.match_lookahead_literal("UINT128", 0)) or self.match_lookahead_literal("UNKNOWN", 0)) + types1227 = xs1228 self.pop_path() self.consume_literal("]") self.consume_literal(")") - _t1784 = logic_pb2.CSVColumn(column_name=string1154, target_id=relation_id1155, types=types1159) - result1165 = _t1784 - self.record_span(span_start1164) - return result1165 + _t1860 = logic_pb2.CSVColumn(column_name=string1222, target_id=relation_id1223, types=types1227) + result1233 = _t1860 + self.record_span(span_start1232) + return result1233 def parse_csv_asof(self) -> str: - span_start1167 = self.span_start() + span_start1235 = self.span_start() self.consume_literal("(") self.consume_literal("asof") - string1166 = self.consume_terminal("STRING") + string1234 = self.consume_terminal("STRING") self.consume_literal(")") - result1168 = string1166 - self.record_span(span_start1167) - return result1168 + result1236 = string1234 + self.record_span(span_start1235) + return result1236 def parse_undefine(self) -> transactions_pb2.Undefine: - span_start1170 = self.span_start() + span_start1238 = self.span_start() self.consume_literal("(") self.consume_literal("undefine") self.push_path(1) - _t1785 = self.parse_fragment_id() - fragment_id1169 = _t1785 + _t1861 = self.parse_fragment_id() + fragment_id1237 = _t1861 self.pop_path() self.consume_literal(")") - _t1786 = transactions_pb2.Undefine(fragment_id=fragment_id1169) - result1171 = _t1786 - self.record_span(span_start1170) - return result1171 + _t1862 = transactions_pb2.Undefine(fragment_id=fragment_id1237) + result1239 = _t1862 + self.record_span(span_start1238) + return result1239 def parse_context(self) -> transactions_pb2.Context: - span_start1180 = self.span_start() + span_start1248 = self.span_start() self.consume_literal("(") self.consume_literal("context") self.push_path(1) - xs1176 = [] - cond1177 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - idx1178 = 0 - while cond1177: - self.push_path(idx1178) - _t1787 = self.parse_relation_id() - item1179 = _t1787 + xs1244 = [] + cond1245 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + idx1246 = 0 + while cond1245: + self.push_path(idx1246) + _t1863 = self.parse_relation_id() + item1247 = _t1863 self.pop_path() - xs1176.append(item1179) - idx1178 = (idx1178 + 1) - cond1177 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) - relation_ids1175 = xs1176 + xs1244.append(item1247) + idx1246 = (idx1246 + 1) + cond1245 = (self.match_lookahead_literal(":", 0) or self.match_lookahead_terminal("UINT128", 0)) + relation_ids1243 = xs1244 self.pop_path() self.consume_literal(")") - _t1788 = transactions_pb2.Context(relations=relation_ids1175) - result1181 = _t1788 - self.record_span(span_start1180) - return result1181 + _t1864 = transactions_pb2.Context(relations=relation_ids1243) + result1249 = _t1864 + self.record_span(span_start1248) + return result1249 def parse_snapshot(self) -> transactions_pb2.Snapshot: - span_start1184 = self.span_start() + span_start1252 = self.span_start() self.consume_literal("(") self.consume_literal("snapshot") self.push_path(1) - _t1789 = self.parse_rel_edb_path() - rel_edb_path1182 = _t1789 + _t1865 = self.parse_rel_edb_path() + rel_edb_path1250 = _t1865 self.pop_path() self.push_path(2) - _t1790 = self.parse_relation_id() - relation_id1183 = _t1790 + _t1866 = self.parse_relation_id() + relation_id1251 = _t1866 self.pop_path() self.consume_literal(")") - _t1791 = transactions_pb2.Snapshot(destination_path=rel_edb_path1182, source_relation=relation_id1183) - result1185 = _t1791 - self.record_span(span_start1184) - return result1185 + _t1867 = transactions_pb2.Snapshot(destination_path=rel_edb_path1250, source_relation=relation_id1251) + result1253 = _t1867 + self.record_span(span_start1252) + return result1253 def parse_epoch_reads(self) -> Sequence[transactions_pb2.Read]: - span_start1190 = self.span_start() + span_start1262 = self.span_start() self.consume_literal("(") self.consume_literal("reads") - xs1186 = [] - cond1187 = self.match_lookahead_literal("(", 0) - while cond1187: - _t1792 = self.parse_read() - item1188 = _t1792 - xs1186.append(item1188) - cond1187 = self.match_lookahead_literal("(", 0) - reads1189 = xs1186 - self.consume_literal(")") - result1191 = reads1189 - self.record_span(span_start1190) - return result1191 + xs1258 = [] + cond1259 = self.match_lookahead_literal("(", 0) + idx1260 = 0 + while cond1259: + self.push_path(idx1260) + _t1868 = self.parse_read() + item1261 = _t1868 + self.pop_path() + xs1258.append(item1261) + idx1260 = (idx1260 + 1) + cond1259 = self.match_lookahead_literal("(", 0) + reads1257 = xs1258 + self.consume_literal(")") + result1263 = reads1257 + self.record_span(span_start1262) + return result1263 def parse_read(self) -> transactions_pb2.Read: - span_start1198 = self.span_start() + span_start1270 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("what_if", 1): - _t1794 = 2 + _t1870 = 2 else: if self.match_lookahead_literal("output", 1): - _t1795 = 1 + _t1871 = 1 else: if self.match_lookahead_literal("export", 1): - _t1796 = 4 + _t1872 = 4 else: if self.match_lookahead_literal("demand", 1): - _t1797 = 0 + _t1873 = 0 else: if self.match_lookahead_literal("abort", 1): - _t1798 = 3 + _t1874 = 3 else: - _t1798 = -1 - _t1797 = _t1798 - _t1796 = _t1797 - _t1795 = _t1796 - _t1794 = _t1795 - _t1793 = _t1794 - else: - _t1793 = -1 - prediction1192 = _t1793 - if prediction1192 == 4: - _t1800 = self.parse_export() - export1197 = _t1800 - _t1801 = transactions_pb2.Read(export=export1197) - _t1799 = _t1801 - else: - if prediction1192 == 3: - _t1803 = self.parse_abort() - abort1196 = _t1803 - _t1804 = transactions_pb2.Read(abort=abort1196) - _t1802 = _t1804 + _t1874 = -1 + _t1873 = _t1874 + _t1872 = _t1873 + _t1871 = _t1872 + _t1870 = _t1871 + _t1869 = _t1870 + else: + _t1869 = -1 + prediction1264 = _t1869 + if prediction1264 == 4: + self.push_path(5) + _t1876 = self.parse_export() + export1269 = _t1876 + self.pop_path() + _t1877 = transactions_pb2.Read(export=export1269) + _t1875 = _t1877 + else: + if prediction1264 == 3: + self.push_path(4) + _t1879 = self.parse_abort() + abort1268 = _t1879 + self.pop_path() + _t1880 = transactions_pb2.Read(abort=abort1268) + _t1878 = _t1880 else: - if prediction1192 == 2: - _t1806 = self.parse_what_if() - what_if1195 = _t1806 - _t1807 = transactions_pb2.Read(what_if=what_if1195) - _t1805 = _t1807 + if prediction1264 == 2: + self.push_path(3) + _t1882 = self.parse_what_if() + what_if1267 = _t1882 + self.pop_path() + _t1883 = transactions_pb2.Read(what_if=what_if1267) + _t1881 = _t1883 else: - if prediction1192 == 1: - _t1809 = self.parse_output() - output1194 = _t1809 - _t1810 = transactions_pb2.Read(output=output1194) - _t1808 = _t1810 + if prediction1264 == 1: + self.push_path(2) + _t1885 = self.parse_output() + output1266 = _t1885 + self.pop_path() + _t1886 = transactions_pb2.Read(output=output1266) + _t1884 = _t1886 else: - if prediction1192 == 0: - _t1812 = self.parse_demand() - demand1193 = _t1812 - _t1813 = transactions_pb2.Read(demand=demand1193) - _t1811 = _t1813 + if prediction1264 == 0: + self.push_path(1) + _t1888 = self.parse_demand() + demand1265 = _t1888 + self.pop_path() + _t1889 = transactions_pb2.Read(demand=demand1265) + _t1887 = _t1889 else: raise ParseError("Unexpected token in read" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t1808 = _t1811 - _t1805 = _t1808 - _t1802 = _t1805 - _t1799 = _t1802 - result1199 = _t1799 - self.record_span(span_start1198) - return result1199 + _t1884 = _t1887 + _t1881 = _t1884 + _t1878 = _t1881 + _t1875 = _t1878 + result1271 = _t1875 + self.record_span(span_start1270) + return result1271 def parse_demand(self) -> transactions_pb2.Demand: - span_start1201 = self.span_start() + span_start1273 = self.span_start() self.consume_literal("(") self.consume_literal("demand") self.push_path(1) - _t1814 = self.parse_relation_id() - relation_id1200 = _t1814 + _t1890 = self.parse_relation_id() + relation_id1272 = _t1890 self.pop_path() self.consume_literal(")") - _t1815 = transactions_pb2.Demand(relation_id=relation_id1200) - result1202 = _t1815 - self.record_span(span_start1201) - return result1202 + _t1891 = transactions_pb2.Demand(relation_id=relation_id1272) + result1274 = _t1891 + self.record_span(span_start1273) + return result1274 def parse_output(self) -> transactions_pb2.Output: - span_start1205 = self.span_start() + span_start1277 = self.span_start() self.consume_literal("(") self.consume_literal("output") self.push_path(1) - _t1816 = self.parse_name() - name1203 = _t1816 + _t1892 = self.parse_name() + name1275 = _t1892 self.pop_path() self.push_path(2) - _t1817 = self.parse_relation_id() - relation_id1204 = _t1817 + _t1893 = self.parse_relation_id() + relation_id1276 = _t1893 self.pop_path() self.consume_literal(")") - _t1818 = transactions_pb2.Output(name=name1203, relation_id=relation_id1204) - result1206 = _t1818 - self.record_span(span_start1205) - return result1206 + _t1894 = transactions_pb2.Output(name=name1275, relation_id=relation_id1276) + result1278 = _t1894 + self.record_span(span_start1277) + return result1278 def parse_what_if(self) -> transactions_pb2.WhatIf: - span_start1209 = self.span_start() + span_start1281 = self.span_start() self.consume_literal("(") self.consume_literal("what_if") self.push_path(1) - _t1819 = self.parse_name() - name1207 = _t1819 + _t1895 = self.parse_name() + name1279 = _t1895 self.pop_path() self.push_path(2) - _t1820 = self.parse_epoch() - epoch1208 = _t1820 + _t1896 = self.parse_epoch() + epoch1280 = _t1896 self.pop_path() self.consume_literal(")") - _t1821 = transactions_pb2.WhatIf(branch=name1207, epoch=epoch1208) - result1210 = _t1821 - self.record_span(span_start1209) - return result1210 + _t1897 = transactions_pb2.WhatIf(branch=name1279, epoch=epoch1280) + result1282 = _t1897 + self.record_span(span_start1281) + return result1282 def parse_abort(self) -> transactions_pb2.Abort: - span_start1213 = self.span_start() + span_start1285 = self.span_start() self.consume_literal("(") self.consume_literal("abort") self.push_path(1) if (self.match_lookahead_literal(":", 0) and self.match_lookahead_terminal("SYMBOL", 1)): - _t1823 = self.parse_name() - _t1822 = _t1823 + _t1899 = self.parse_name() + _t1898 = _t1899 else: - _t1822 = None - name1211 = _t1822 + _t1898 = None + name1283 = _t1898 self.pop_path() self.push_path(2) - _t1824 = self.parse_relation_id() - relation_id1212 = _t1824 + _t1900 = self.parse_relation_id() + relation_id1284 = _t1900 self.pop_path() self.consume_literal(")") - _t1825 = transactions_pb2.Abort(name=(name1211 if name1211 is not None else "abort"), relation_id=relation_id1212) - result1214 = _t1825 - self.record_span(span_start1213) - return result1214 + _t1901 = transactions_pb2.Abort(name=(name1283 if name1283 is not None else "abort"), relation_id=relation_id1284) + result1286 = _t1901 + self.record_span(span_start1285) + return result1286 def parse_export(self) -> transactions_pb2.Export: - span_start1216 = self.span_start() + span_start1288 = self.span_start() self.consume_literal("(") self.consume_literal("export") self.push_path(1) - _t1826 = self.parse_export_csv_config() - export_csv_config1215 = _t1826 + _t1902 = self.parse_export_csv_config() + export_csv_config1287 = _t1902 self.pop_path() self.consume_literal(")") - _t1827 = transactions_pb2.Export(csv_config=export_csv_config1215) - result1217 = _t1827 - self.record_span(span_start1216) - return result1217 + _t1903 = transactions_pb2.Export(csv_config=export_csv_config1287) + result1289 = _t1903 + self.record_span(span_start1288) + return result1289 def parse_export_csv_config(self) -> transactions_pb2.ExportCSVConfig: - span_start1221 = self.span_start() + span_start1293 = self.span_start() self.consume_literal("(") self.consume_literal("export_csv_config") - _t1828 = self.parse_export_csv_path() - export_csv_path1218 = _t1828 - _t1829 = self.parse_export_csv_columns() - export_csv_columns1219 = _t1829 - _t1830 = self.parse_config_dict() - config_dict1220 = _t1830 - self.consume_literal(")") - _t1831 = self.export_csv_config(export_csv_path1218, export_csv_columns1219, config_dict1220) - result1222 = _t1831 - self.record_span(span_start1221) - return result1222 + _t1904 = self.parse_export_csv_path() + export_csv_path1290 = _t1904 + _t1905 = self.parse_export_csv_columns() + export_csv_columns1291 = _t1905 + _t1906 = self.parse_config_dict() + config_dict1292 = _t1906 + self.consume_literal(")") + _t1907 = self.export_csv_config(export_csv_path1290, export_csv_columns1291, config_dict1292) + result1294 = _t1907 + self.record_span(span_start1293) + return result1294 def parse_export_csv_path(self) -> str: - span_start1224 = self.span_start() + span_start1296 = self.span_start() self.consume_literal("(") self.consume_literal("path") - string1223 = self.consume_terminal("STRING") + string1295 = self.consume_terminal("STRING") self.consume_literal(")") - result1225 = string1223 - self.record_span(span_start1224) - return result1225 + result1297 = string1295 + self.record_span(span_start1296) + return result1297 def parse_export_csv_columns(self) -> Sequence[transactions_pb2.ExportCSVColumn]: - span_start1230 = self.span_start() + span_start1306 = self.span_start() self.consume_literal("(") self.consume_literal("columns") - xs1226 = [] - cond1227 = self.match_lookahead_literal("(", 0) - while cond1227: - _t1832 = self.parse_export_csv_column() - item1228 = _t1832 - xs1226.append(item1228) - cond1227 = self.match_lookahead_literal("(", 0) - export_csv_columns1229 = xs1226 - self.consume_literal(")") - result1231 = export_csv_columns1229 - self.record_span(span_start1230) - return result1231 + xs1302 = [] + cond1303 = self.match_lookahead_literal("(", 0) + idx1304 = 0 + while cond1303: + self.push_path(idx1304) + _t1908 = self.parse_export_csv_column() + item1305 = _t1908 + self.pop_path() + xs1302.append(item1305) + idx1304 = (idx1304 + 1) + cond1303 = self.match_lookahead_literal("(", 0) + export_csv_columns1301 = xs1302 + self.consume_literal(")") + result1307 = export_csv_columns1301 + self.record_span(span_start1306) + return result1307 def parse_export_csv_column(self) -> transactions_pb2.ExportCSVColumn: - span_start1234 = self.span_start() + span_start1310 = self.span_start() self.consume_literal("(") self.consume_literal("column") self.push_path(1) - string1232 = self.consume_terminal("STRING") + string1308 = self.consume_terminal("STRING") self.pop_path() self.push_path(2) - _t1833 = self.parse_relation_id() - relation_id1233 = _t1833 + _t1909 = self.parse_relation_id() + relation_id1309 = _t1909 self.pop_path() self.consume_literal(")") - _t1834 = transactions_pb2.ExportCSVColumn(column_name=string1232, column_data=relation_id1233) - result1235 = _t1834 - self.record_span(span_start1234) - return result1235 + _t1910 = transactions_pb2.ExportCSVColumn(column_name=string1308, column_data=relation_id1309) + result1311 = _t1910 + self.record_span(span_start1310) + return result1311 def parse(input_str: str) -> tuple[Any, dict[tuple[int, ...], Span]]: diff --git a/sdks/python/src/lqp/proto_validator.py b/sdks/python/src/lqp/proto_validator.py index 0a33fc50..0faf3dac 100644 --- a/sdks/python/src/lqp/proto_validator.py +++ b/sdks/python/src/lqp/proto_validator.py @@ -200,14 +200,37 @@ def unwrap_data(data: logic_pb2.Data) -> Message | None: class ProtoVisitor: - def __init__(self): + def __init__( + self, + provenance: dict[tuple[int, ...], Any] | None = None, + filename: str | None = None, + ): self.original_names: dict[tuple[int, int], str] = {} self._visit_cache: dict[str, Any] = {} + self._provenance = provenance or {} + self._filename = filename or "" + self._path: list[int] = [] def get_original_name(self, rid: logic_pb2.RelationId) -> str: key = relation_id_key(rid) return self.original_names.get(key, relation_id_hex(rid)) + def _location_str(self) -> str: + """Return ' at file:line:col' for the current path, or '' if unavailable.""" + path = tuple(self._path) + # Try current path, then progressively shorter prefixes. + while len(path) >= 0: + span = self._provenance.get(path) + if span is not None: + loc = span.start + if self._filename: + return f" at {self._filename}:{loc.line}:{loc.column}" + return f" at {loc.line}:{loc.column}" + if not path: + break + path = path[:-1] + return "" + def _resolve_visitor(self, type_name: str): method = self._visit_cache.get(type_name) if method is None: @@ -226,6 +249,17 @@ def visit(self, node: Message, *args: Any) -> None: if unwrapper is not None: inner = unwrapper(node) # type: ignore[arg-type] if inner is not None: + # Push the field number of the active oneof variant. + descriptor: Descriptor = node.DESCRIPTOR # type: ignore[assignment] + for field_desc in descriptor.fields: + if ( + node.HasField(field_desc.name) + and getattr(node, field_desc.name) is inner + ): + self._path.append(field_desc.number) + self.visit(inner, *args) + self._path.pop() + return self.visit(inner, *args) return @@ -236,20 +270,26 @@ def generic_visit(self, node: Message, *args: Any) -> None: for field_desc in descriptor.fields: value = getattr(node, field_desc.name) if field_desc.label == FieldDescriptor.LABEL_REPEATED: - for item in value: + for i, item in enumerate(value): if isinstance(item, Message): + self._path.append(field_desc.number) + self._path.append(i) self.visit(item, *args) + self._path.pop() + self._path.pop() elif field_desc.message_type is not None and node.HasField(field_desc.name): if isinstance(value, Message): + self._path.append(field_desc.number) self.visit(value, *args) + self._path.pop() # --- Validation visitors --- class UnusedVariableVisitor(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.scopes: list[tuple[set[str], set[str]]] = [] self.visit(txn) @@ -262,7 +302,9 @@ def _mark_var_used(self, var_name: str): if var_name in declared: used.add(var_name) return - raise ValidationError(f"Undeclared variable used: '{var_name}'") + raise ValidationError( + f"Undeclared variable used{self._location_str()}: '{var_name}'" + ) def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): self.scopes.append((set(), set())) @@ -287,8 +329,8 @@ def visit_FunctionalDependency( class ShadowedVariableFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.visit(txn) def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): @@ -296,14 +338,16 @@ def visit_Abstraction(self, node: logic_pb2.Abstraction, *args: Any): for binding in node.vars: name = binding.var.name if name in in_scope_names: - raise ValidationError(f"Shadowed variable: '{name}'") + raise ValidationError( + f"Shadowed variable{self._location_str()}: '{name}'" + ) new_scope = in_scope_names | {b.var.name for b in node.vars} self.visit(node.value, new_scope) class DuplicateRelationIdFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.seen_ids: dict[tuple[int, int], tuple[int, bytes | None]] = {} self.curr_epoch: int = 0 self.curr_fragment: bytes | None = None @@ -319,12 +363,12 @@ def _check_relation_id(self, rid: logic_pb2.RelationId): if self.curr_fragment != seen_frag: original_name = self.get_original_name(rid) raise ValidationError( - f"Duplicate declaration across fragments: '{original_name}'" + f"Duplicate declaration across fragments{self._location_str()}: '{original_name}'" ) elif self.curr_epoch == seen_epoch: original_name = self.get_original_name(rid) raise ValidationError( - f"Duplicate declaration within fragment in epoch: '{original_name}'" + f"Duplicate declaration within fragment in epoch{self._location_str()}: '{original_name}'" ) self.seen_ids[key] = (self.curr_epoch, self.curr_fragment) @@ -342,14 +386,16 @@ def visit_Algorithm(self, node: logic_pb2.Algorithm, *args: Any): key = relation_id_key(rid) if key in self.seen_ids: original_name = self.get_original_name(rid) - raise ValidationError(f"Duplicate declaration: '{original_name}'") + raise ValidationError( + f"Duplicate declaration{self._location_str()}: '{original_name}'" + ) else: self.seen_ids[key] = (self.curr_epoch, self.curr_fragment) class DuplicateFragmentDefinitionFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.seen_ids: set[bytes] = set() self.visit(txn) @@ -361,7 +407,9 @@ def visit_Define(self, node: transactions_pb2.Define, *args: Any): frag_id = node.fragment.id.id if frag_id in self.seen_ids: id_str = frag_id.decode("utf-8") - raise ValidationError(f"Duplicate fragment within an epoch: '{id_str}'") + raise ValidationError( + f"Duplicate fragment within an epoch{self._location_str()}: '{id_str}'" + ) else: self.seen_ids.add(frag_id) @@ -420,8 +468,8 @@ class State: relation_types: dict[tuple[int, int], list[str]] var_types: dict[str, str] - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) global_defs = AtomTypeChecker.collect_global_defs(txn) relation_types = {} for _, node in global_defs: @@ -484,7 +532,7 @@ def visit_Atom(self, node: logic_pb2.Atom, *args: Any): if atom_arity != relation_arity: original_name = self.get_original_name(node.name) raise ValidationError( - f"Incorrect arity for '{original_name}' atom: " + f"Incorrect arity for '{original_name}' atom{self._location_str()}: " f"expected {relation_arity} term{'' if relation_arity == 1 else 's'}, got {atom_arity}" ) @@ -502,14 +550,14 @@ def visit_Atom(self, node: logic_pb2.Atom, *args: Any): original_name = self.get_original_name(node.name) pretty_term = proto_term_str(term) raise ValidationError( - f"Incorrect type for '{original_name}' atom at index {i} ('{pretty_term}'): " + f"Incorrect type for '{original_name}' atom at index {i} ('{pretty_term}'){self._location_str()}: " f"expected {expected_type} term, got {term_type}" ) class LoopyBadBreakFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.visit(txn) def visit_Loop(self, node: logic_pb2.Loop, *args: Any): @@ -518,13 +566,13 @@ def visit_Loop(self, node: logic_pb2.Loop, *args: Any): brk = getattr(instr_wrapper, "break") original_name = self.get_original_name(brk.name) raise ValidationError( - f"Break rule found outside of body: '{original_name}'" + f"Break rule found outside of body{self._location_str()}: '{original_name}'" ) class LoopyBadGlobalFinder(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.globals: set[tuple[int, int]] = set() self.init: set[tuple[int, int]] = set() self.visit(txn) @@ -574,20 +622,22 @@ def visit_Loop(self, node: logic_pb2.Loop, *args: Any): if key in self.globals and key not in self.init: original_name = self.get_original_name(actual.name) # type: ignore[union-attr] raise ValidationError( - f"Global rule found in body: '{original_name}'" + f"Global rule found in body{self._location_str()}: '{original_name}'" ) class LoopyUpdatesShouldBeAtoms(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.visit(txn) def _check_atom_body(self, node: Message, instr_type_name: str): formula = node.body.value # type: ignore[union-attr] which = formula.WhichOneof("formula_type") if which != "atom": - raise ValidationError(f"{instr_type_name} must have an Atom as its value") + raise ValidationError( + f"{instr_type_name}{self._location_str()} must have an Atom as its value" + ) def visit_Upsert(self, node: logic_pb2.Upsert, *args: Any): self._check_atom_body(node, "Upsert") @@ -600,8 +650,8 @@ def visit_MonusDef(self, node: logic_pb2.MonusDef, *args: Any): class CSVConfigChecker(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) global_defs = AtomTypeChecker.collect_global_defs(txn) self.relation_types: dict[tuple[int, int], list[str]] = {} for _, node in global_defs: @@ -612,23 +662,24 @@ def __init__(self, txn: transactions_pb2.Transaction): self.visit(txn) def visit_ExportCSVConfig(self, node: transactions_pb2.ExportCSVConfig, *args: Any): + loc = self._location_str() if node.HasField("syntax_delim") and len(node.syntax_delim) != 1: raise ValidationError( - f"CSV delimiter should be a single character, got '{node.syntax_delim}'" + f"CSV delimiter should be a single character{loc}, got '{node.syntax_delim}'" ) if node.HasField("syntax_quotechar") and len(node.syntax_quotechar) != 1: raise ValidationError( - f"CSV quotechar should be a single character, got '{node.syntax_quotechar}'" + f"CSV quotechar should be a single character{loc}, got '{node.syntax_quotechar}'" ) if node.HasField("syntax_escapechar") and len(node.syntax_escapechar) != 1: raise ValidationError( - f"CSV escapechar should be a single character, got '{node.syntax_escapechar}'" + f"CSV escapechar should be a single character{loc}, got '{node.syntax_escapechar}'" ) valid_compressions = {"", "gzip"} if node.HasField("compression") and node.compression not in valid_compressions: raise ValidationError( - f"CSV compression should be one of {valid_compressions}, got '{node.compression}'" + f"CSV compression should be one of {valid_compressions}{loc}, got '{node.compression}'" ) column_0_key_types: list[str] | None = None @@ -641,7 +692,7 @@ def visit_ExportCSVConfig(self, node: transactions_pb2.ExportCSVConfig, *args: A column_types = self.relation_types[key] if len(column_types) < 1: raise ValidationError( - f"Data column relation must have at least one column, " + f"Data column relation must have at least one column{loc}, " f"got zero columns in '{self.get_original_name(column.column_data)}'" ) key_types = column_types[:-1] @@ -651,15 +702,15 @@ def visit_ExportCSVConfig(self, node: transactions_pb2.ExportCSVConfig, *args: A else: if column_0_key_types != key_types: raise ValidationError( - f"All data columns in ExportCSVConfig must have the same key types. " + f"All data columns in ExportCSVConfig{loc} must have the same key types. " f"Got '{column_0_name}' with key types {[str(t) for t in column_0_key_types]} " f"and '{self.get_original_name(column.column_data)}' with key types {[str(t) for t in key_types]}." ) class FDVarsChecker(ProtoVisitor): - def __init__(self, txn: transactions_pb2.Transaction): - super().__init__() + def __init__(self, txn: transactions_pb2.Transaction, **kwargs: Any): + super().__init__(**kwargs) self.visit(txn) def visit_FunctionalDependency( @@ -669,12 +720,12 @@ def visit_FunctionalDependency( for var in node.keys: if var.name not in guard_var_names: raise ValidationError( - f"Key variable '{var.name}' not declared in guard" + f"Key variable '{var.name}' not declared in guard{self._location_str()}" ) for var in node.values: if var.name not in guard_var_names: raise ValidationError( - f"Value variable '{var.name}' not declared in guard" + f"Value variable '{var.name}' not declared in guard{self._location_str()}" ) @@ -695,11 +746,24 @@ def visit_FunctionalDependency( ] -def validate_proto(txn: transactions_pb2.Transaction) -> None: - """Validate a protobuf Transaction message.""" +def validate_proto( + txn: transactions_pb2.Transaction, + provenance: dict[tuple[int, ...], Any] | None = None, + filename: str | None = None, +) -> None: + """Validate a protobuf Transaction message. + + If provenance and filename are provided, error messages will include + source locations (e.g. 'at file.lqp:10:5'). + """ + kwargs: dict[str, Any] = {} + if provenance is not None: + kwargs["provenance"] = provenance + if filename is not None: + kwargs["filename"] = filename for name, validator_cls in _VALIDATORS: try: - validator_cls(txn) + validator_cls(txn, **kwargs) except ValidationError: raise except Exception as e: diff --git a/sdks/python/tests/test_proto_validator.py b/sdks/python/tests/test_proto_validator.py index 7f5bb613..44125540 100644 --- a/sdks/python/tests/test_proto_validator.py +++ b/sdks/python/tests/test_proto_validator.py @@ -1,4 +1,5 @@ import os +import re import pytest @@ -17,8 +18,8 @@ def test_validate_proto_lqp_inputs(input_file): with open(input_file) as f: content = f.read() - txn_proto, _ = parse(content) - validate_proto(txn_proto) + txn_proto, provenance = parse(content) + validate_proto(txn_proto, provenance=provenance) @pytest.mark.parametrize( @@ -29,8 +30,8 @@ def test_valid_proto_validator_files(validator_file): file_path = VALIDATOR_DIR / validator_file with open(file_path) as f: content = f.read() - txn_proto, _ = parse(content) - validate_proto(txn_proto) + txn_proto, provenance = parse(content) + validate_proto(txn_proto, provenance=provenance, filename=validator_file) @pytest.mark.parametrize( @@ -45,11 +46,38 @@ def test_proto_validator_failure_files(validator_file): return with open(file_path) as f: content = f.read() - txn_proto, _ = parse(content) + txn_proto, provenance = parse(content) with pytest.raises(ValidationError) as exc_info: - validate_proto(txn_proto) + validate_proto(txn_proto, provenance=provenance, filename=validator_file) error_message = str(exc_info.value) stripped_expected = strip_source_location(expected_error) - assert stripped_expected in error_message, ( + stripped_actual = strip_source_location(error_message) + assert stripped_expected in stripped_actual, ( f"Expected '{stripped_expected}' in error message: '{error_message}'" ) + + +@pytest.mark.parametrize( + "validator_file", + sorted(f for f in os.listdir(VALIDATOR_DIR) if f.startswith("fail_")), +) +def test_proto_validator_error_has_location(validator_file): + """Verify that errors include source location when provenance is provided.""" + file_path = VALIDATOR_DIR / validator_file + expected_error = extract_expected_error(file_path) + if not expected_error: + pytest.skip(f"No expected error comment found in {validator_file}") + return + # Skip files whose expected error doesn't include a location. + if not re.search(r"at\s+\S+:\d+:\d+", expected_error): + pytest.skip(f"Expected error has no location: {validator_file}") + return + with open(file_path) as f: + content = f.read() + txn_proto, provenance = parse(content) + with pytest.raises(ValidationError) as exc_info: + validate_proto(txn_proto, provenance=provenance, filename=validator_file) + error_message = str(exc_info.value) + assert re.search(r"at\s+\S+:\d+:\d+", error_message), ( + f"Error message missing location: '{error_message}'" + )