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..4479aad7 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 ProtoField, ProtoMessage from .target import ( Assign, BaseType, @@ -100,6 +101,8 @@ ListExpr, ListType, Lit, + NewMessage, + OneOf, ParseNonterminal, ParseNonterminalDef, Seq, @@ -131,29 +134,154 @@ class AmbiguousGrammarError(Exception): pass +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, 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 proto fields. + + 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 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 {} + rt = action.return_type + if not isinstance(rt, MessageType): + return {} + 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 + + +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 +299,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 +310,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 +510,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 +523,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() @@ -422,19 +544,32 @@ 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): 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 +587,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->proto field mapping for provenance + param_proto_fields: dict[int, ProtoField] = {} + if action is not None and proto_messages is not None: + param_proto_fields = _build_param_proto_fields(action, proto_messages) + exprs = [] arg_vars = [] elems = list(rhs_elements(rhs)) @@ -473,7 +623,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 +639,90 @@ def _generate_parse_rhs_ir_sequence( ) var_name = gensym("arg") var = Var(var_name, elem.target_type()) - exprs.append(Assign(var, elem_ir)) + 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, None, proto_messages + ) + exprs.extend(stmts) + 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) 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 | None, + proto_messages: dict[tuple[str, str], ProtoMessage] | None = None, +) -> list[TargetExpr]: + """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")) + 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]), + ), + ), + ) + 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/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..17bc5bc9 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 stop location. +type Span struct {{ + Start Location + Stop 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), + Stop: 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..65506098 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 + stop::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..8ca8f78f 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 stop location.""" + + __slots__ = ("start", "stop") + + def __init__(self, start: Location, stop: Location): + self.start = start + self.stop = stop + + def __repr__(self) -> str: + 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.stop == other.stop + + def __hash__(self) -> int: + return hash((self.start, self.stop)) + + 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..935ba554 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 stop location. +type Span struct { + Start Location + Stop 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,36 +339,99 @@ 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), + Stop: 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 { idx := p.pos + k 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 _t1922 interface{} if (value != nil && hasProtoField(value, "int_value")) { return int32(value.GetIntValue()) } - _ = _t1322 + _ = _t1922 return int32(default_) } func (p *Parser) _extract_value_int64(value *pb.Value, default_ int64) int64 { - var _t1323 interface{} + var _t1923 interface{} if (value != nil && hasProtoField(value, "int_value")) { return value.GetIntValue() } - _ = _t1323 + _ = _t1923 return default_ } func (p *Parser) _extract_value_string(value *pb.Value, default_ string) string { - var _t1324 interface{} + var _t1924 interface{} if (value != nil && hasProtoField(value, "string_value")) { return value.GetStringValue() } - _ = _t1324 + _ = _t1924 return default_ } func (p *Parser) _extract_value_boolean(value *pb.Value, default_ bool) bool { - var _t1325 interface{} + var _t1925 interface{} if (value != nil && hasProtoField(value, "boolean_value")) { return value.GetBooleanValue() } - _ = _t1325 + _ = _t1925 return default_ } func (p *Parser) _extract_value_string_list(value *pb.Value, default_ []string) []string { - var _t1326 interface{} + var _t1926 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []string{value.GetStringValue()} } - _ = _t1326 + _ = _t1926 return default_ } func (p *Parser) _try_extract_value_int64(value *pb.Value) *int64 { - var _t1327 interface{} + var _t1927 interface{} if (value != nil && hasProtoField(value, "int_value")) { return ptr(value.GetIntValue()) } - _ = _t1327 + _ = _t1927 return nil } func (p *Parser) _try_extract_value_float64(value *pb.Value) *float64 { - var _t1328 interface{} + var _t1928 interface{} if (value != nil && hasProtoField(value, "float_value")) { return ptr(value.GetFloatValue()) } - _ = _t1328 + _ = _t1928 return nil } func (p *Parser) _try_extract_value_bytes(value *pb.Value) []byte { - var _t1329 interface{} + var _t1929 interface{} if (value != nil && hasProtoField(value, "string_value")) { return []byte(value.GetStringValue()) } - _ = _t1329 + _ = _t1929 return nil } func (p *Parser) _try_extract_value_uint128(value *pb.Value) *pb.UInt128Value { - var _t1330 interface{} + var _t1930 interface{} if (value != nil && hasProtoField(value, "uint128_value")) { return value.GetUint128Value() } - _ = _t1330 + _ = _t1930 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 + _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) - _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)} + _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 { - _t1352.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} + _t1952.Location = &pb.BeTreeLocator_RootPageid{RootPageid: root_pageid} } else { - _t1352.Location = &pb.BeTreeLocator_InlineData{InlineData: inline_data} + _t1952.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 := _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 { - _t1354 := &pb.IVMConfig{Level: pb.MaintenanceLevel_MAINTENANCE_LEVEL_OFF} - ivm_config := _t1354 - _t1355 := &pb.Configure{SemanticsVersion: 0, IvmConfig: ivm_config} - return _t1355 + _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 { @@ -689,3060 +770,3852 @@ 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 + _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) - _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 + _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 --- 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 _t1312 *pb.Configure if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("configure", 1)) { - _t713 := p.parse_configure() - _t712 = _t713 + _t1313 := p.parse_configure() + _t1312 = _t1313 } - configure356 := _t712 - var _t714 *pb.Sync + configure592 := _t1312 + p.popPath() + p.pushPath(int(3)) + var _t1314 *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 + _t1315 := p.parse_sync() + _t1314 = _t1315 + } + sync593 := _t1314 + p.popPath() + p.pushPath(int(1)) + xs598 := []*pb.Epoch{} + cond599 := p.matchLookaheadLiteral("(", 0) + idx600 := 0 + for cond599 { + p.pushPath(int(idx600)) + _t1316 := p.parse_epoch() + item601 := _t1316 + 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 + _t1317 := p.default_configure() + _t1318 := configure592 + if configure592 == nil { + _t1318 = _t1317 } - _t719 := &pb.Transaction{Epochs: epochs361, Configure: _t718, Sync: sync357} - return _t719 + _t1319 := &pb.Transaction{Epochs: epochs597, Configure: _t1318, Sync: sync593} + result603 := _t1319 + 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 + _t1320 := p.parse_config_dict() + config_dict604 := _t1320 p.consumeLiteral(")") - _t721 := p.construct_configure(config_dict362) - return _t721 + _t1321 := p.construct_configure(config_dict604) + result606 := _t1321 + p.recordSpan(int(span_start605)) + return result606 } func (p *Parser) parse_config_dict() [][]interface{} { + span_start615 := 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 + 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("}") - return config_key_values366 + result616 := config_key_values610 + p.recordSpan(int(span_start615)) + return result616 } func (p *Parser) parse_config_key_value() []interface{} { + span_start619 := int64(p.spanStart()) p.consumeLiteral(":") - symbol367 := p.consumeTerminal("SYMBOL").Value.str - _t723 := p.parse_value() - value368 := _t723 - return []interface{}{symbol367, value368} + 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 { - var _t724 int64 + span_start631 := int64(p.spanStart()) + var _t1324 int64 if p.matchLookaheadLiteral("true", 0) { - _t724 = 9 + _t1324 = 9 } else { - var _t725 int64 + var _t1325 int64 if p.matchLookaheadLiteral("missing", 0) { - _t725 = 8 + _t1325 = 8 } else { - var _t726 int64 + var _t1326 int64 if p.matchLookaheadLiteral("false", 0) { - _t726 = 9 + _t1326 = 9 } else { - var _t727 int64 + var _t1327 int64 if p.matchLookaheadLiteral("(", 0) { - var _t728 int64 + var _t1328 int64 if p.matchLookaheadLiteral("datetime", 1) { - _t728 = 1 + _t1328 = 1 } else { - var _t729 int64 + var _t1329 int64 if p.matchLookaheadLiteral("date", 1) { - _t729 = 0 + _t1329 = 0 } else { - _t729 = -1 + _t1329 = -1 } - _t728 = _t729 + _t1328 = _t1329 } - _t727 = _t728 + _t1327 = _t1328 } else { - var _t730 int64 + var _t1330 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t730 = 5 + _t1330 = 5 } else { - var _t731 int64 + var _t1331 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t731 = 2 + _t1331 = 2 } else { - var _t732 int64 + var _t1332 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t732 = 6 + _t1332 = 6 } else { - var _t733 int64 + var _t1333 int64 if p.matchLookaheadTerminal("INT", 0) { - _t733 = 3 + _t1333 = 3 } else { - var _t734 int64 + var _t1334 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t734 = 4 + _t1334 = 4 } else { - var _t735 int64 + var _t1335 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t735 = 7 + _t1335 = 7 } else { - _t735 = -1 + _t1335 = -1 } - _t734 = _t735 + _t1334 = _t1335 } - _t733 = _t734 + _t1333 = _t1334 } - _t732 = _t733 + _t1332 = _t1333 } - _t731 = _t732 + _t1331 = _t1332 } - _t730 = _t731 + _t1330 = _t1331 } - _t727 = _t730 + _t1327 = _t1330 } - _t726 = _t727 + _t1326 = _t1327 } - _t725 = _t726 + _t1325 = _t1326 } - _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 + _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 _t739 *pb.Value - if prediction369 == 8 { + var _t1339 *pb.Value + if prediction621 == 8 { p.consumeLiteral("missing") - _t740 := &pb.MissingValue{} - _t741 := &pb.Value{} - _t741.Value = &pb.Value_MissingValue{MissingValue: _t740} - _t739 = _t741 + _t1340 := &pb.MissingValue{} + _t1341 := &pb.Value{} + _t1341.Value = &pb.Value_MissingValue{MissingValue: _t1340} + _t1339 = _t1341 } 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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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)}) } - _t754 = _t757 + _t1354 = _t1357 } - _t752 = _t754 + _t1352 = _t1354 } - _t750 = _t752 + _t1350 = _t1352 } - _t748 = _t750 + _t1348 = _t1350 } - _t746 = _t748 + _t1346 = _t1348 } - _t744 = _t746 + _t1344 = _t1346 } - _t742 = _t744 + _t1342 = _t1344 } - _t739 = _t742 + _t1339 = _t1342 } - _t736 = _t739 + _t1336 = _t1339 } - return _t736 + result632 := _t1336 + p.recordSpan(int(span_start631)) + return result632 } func (p *Parser) parse_date() *pb.DateValue { + span_start636 := 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)) + int633 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3634 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(3)) + int_4635 := 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 + _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_start645 := 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)) + int638 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3639 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(3)) + int_4640 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(4)) + int_5641 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(5)) + int_6642 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(6)) + int_7643 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(7)) + var _t1361 *int64 if p.matchLookaheadTerminal("INT", 0) { - _t761 = ptr(p.consumeTerminal("INT").Value.i64) + _t1361 = ptr(p.consumeTerminal("INT").Value.i64) } - int_8388 := _t761 + int_8644 := _t1361 + 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 + _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 { - var _t763 int64 + span_start648 := int64(p.spanStart()) + var _t1363 int64 if p.matchLookaheadLiteral("true", 0) { - _t763 = 0 + _t1363 = 0 } else { - var _t764 int64 + var _t1364 int64 if p.matchLookaheadLiteral("false", 0) { - _t764 = 1 + _t1364 = 1 } else { - _t764 = -1 + _t1364 = -1 } - _t763 = _t764 + _t1363 = _t1364 } - prediction389 := _t763 - var _t765 bool - if prediction389 == 1 { + prediction647 := _t1363 + var _t1365 bool + if prediction647 == 1 { p.consumeLiteral("false") - _t765 = false + _t1365 = false } else { - var _t766 bool - if prediction389 == 0 { + var _t1366 bool + if prediction647 == 0 { p.consumeLiteral("true") - _t766 = 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)}) } - _t765 = _t766 + _t1365 = _t1366 } - return _t765 + result649 := _t1365 + p.recordSpan(int(span_start648)) + return result649 } func (p *Parser) parse_sync() *pb.Sync { + span_start658 := 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)) + xs654 := []*pb.FragmentId{} + cond655 := p.matchLookaheadLiteral(":", 0) + idx656 := 0 + for cond655 { + p.pushPath(int(idx656)) + _t1367 := p.parse_fragment_id() + item657 := _t1367 + p.popPath() + xs654 = append(xs654, item657) + idx656 = (idx656 + 1) + cond655 = p.matchLookaheadLiteral(":", 0) + } + fragment_ids653 := xs654 + p.popPath() p.consumeLiteral(")") - _t768 := &pb.Sync{Fragments: fragment_ids393} - return _t768 + _t1368 := &pb.Sync{Fragments: fragment_ids653} + result659 := _t1368 + p.recordSpan(int(span_start658)) + return result659 } func (p *Parser) parse_fragment_id() *pb.FragmentId { + span_start661 := int64(p.spanStart()) p.consumeLiteral(":") - symbol394 := p.consumeTerminal("SYMBOL").Value.str - return &pb.FragmentId{Id: []byte(symbol394)} + 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_start665 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("epoch") - var _t769 []*pb.Write + p.pushPath(int(1)) + var _t1369 []*pb.Write if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("writes", 1)) { - _t770 := p.parse_epoch_writes() - _t769 = _t770 + _t1370 := p.parse_epoch_writes() + _t1369 = _t1370 } - epoch_writes395 := _t769 - var _t771 []*pb.Read + epoch_writes663 := _t1369 + p.popPath() + p.pushPath(int(2)) + var _t1371 []*pb.Read if p.matchLookaheadLiteral("(", 0) { - _t772 := p.parse_epoch_reads() - _t771 = _t772 + _t1372 := p.parse_epoch_reads() + _t1371 = _t1372 } - epoch_reads396 := _t771 + epoch_reads664 := _t1371 + p.popPath() p.consumeLiteral(")") - _t773 := epoch_writes395 - if epoch_writes395 == nil { - _t773 = []*pb.Write{} + _t1373 := epoch_writes663 + if epoch_writes663 == nil { + _t1373 = []*pb.Write{} } - _t774 := epoch_reads396 - if epoch_reads396 == nil { - _t774 = []*pb.Read{} + _t1374 := epoch_reads664 + if epoch_reads664 == nil { + _t1374 = []*pb.Read{} } - _t775 := &pb.Epoch{Writes: _t773, Reads: _t774} - return _t775 + _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_start675 := 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 + 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(")") - return writes400 + result676 := writes670 + p.recordSpan(int(span_start675)) + return result676 } func (p *Parser) parse_write() *pb.Write { - var _t777 int64 + span_start682 := int64(p.spanStart()) + var _t1377 int64 if p.matchLookaheadLiteral("(", 0) { - var _t778 int64 + var _t1378 int64 if p.matchLookaheadLiteral("undefine", 1) { - _t778 = 1 + _t1378 = 1 } else { - var _t779 int64 + var _t1379 int64 if p.matchLookaheadLiteral("snapshot", 1) { - _t779 = 3 + _t1379 = 3 } else { - var _t780 int64 + var _t1380 int64 if p.matchLookaheadLiteral("define", 1) { - _t780 = 0 + _t1380 = 0 } else { - var _t781 int64 + var _t1381 int64 if p.matchLookaheadLiteral("context", 1) { - _t781 = 2 + _t1381 = 2 } else { - _t781 = -1 + _t1381 = -1 } - _t780 = _t781 + _t1380 = _t1381 } - _t779 = _t780 + _t1379 = _t1380 } - _t778 = _t779 + _t1378 = _t1379 } - _t777 = _t778 + _t1377 = _t1378 } 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 + _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 _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 _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 _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 _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 _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 _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)}) } - _t788 = _t791 + _t1388 = _t1391 } - _t785 = _t788 + _t1385 = _t1388 } - _t782 = _t785 + _t1382 = _t1385 } - return _t782 + result683 := _t1382 + p.recordSpan(int(span_start682)) + return result683 } func (p *Parser) parse_define() *pb.Define { + span_start685 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("define") - _t794 := p.parse_fragment() - fragment406 := _t794 + p.pushPath(int(1)) + _t1394 := p.parse_fragment() + fragment684 := _t1394 + p.popPath() p.consumeLiteral(")") - _t795 := &pb.Define{Fragment: fragment406} - return _t795 + _t1395 := &pb.Define{Fragment: fragment684} + result686 := _t1395 + p.recordSpan(int(span_start685)) + return result686 } func (p *Parser) parse_fragment() *pb.Fragment { + span_start696 := 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 + _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(")") - return p.constructFragment(new_fragment_id407, declarations411) + result697 := p.constructFragment(new_fragment_id687, declarations691) + p.recordSpan(int(span_start696)) + return result697 } 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_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 { - var _t799 int64 + span_start706 := int64(p.spanStart()) + var _t1399 int64 if p.matchLookaheadLiteral("(", 0) { - var _t800 int64 + var _t1400 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t800 = 3 + _t1400 = 3 } else { - var _t801 int64 + var _t1401 int64 if p.matchLookaheadLiteral("functional_dependency", 1) { - _t801 = 2 + _t1401 = 2 } else { - var _t802 int64 + var _t1402 int64 if p.matchLookaheadLiteral("def", 1) { - _t802 = 0 + _t1402 = 0 } else { - var _t803 int64 + var _t1403 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t803 = 3 + _t1403 = 3 } else { - var _t804 int64 + var _t1404 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t804 = 3 + _t1404 = 3 } else { - var _t805 int64 + var _t1405 int64 if p.matchLookaheadLiteral("algorithm", 1) { - _t805 = 1 + _t1405 = 1 } else { - _t805 = -1 + _t1405 = -1 } - _t804 = _t805 + _t1404 = _t1405 } - _t803 = _t804 + _t1403 = _t1404 } - _t802 = _t803 + _t1402 = _t1403 } - _t801 = _t802 + _t1401 = _t1402 } - _t800 = _t801 + _t1400 = _t1401 } - _t799 = _t800 + _t1399 = _t1400 } 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 + _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 _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 _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 _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 _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 _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 _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)}) } - _t812 = _t815 + _t1412 = _t1415 } - _t809 = _t812 + _t1409 = _t1412 } - _t806 = _t809 + _t1406 = _t1409 } - return _t806 + result707 := _t1406 + p.recordSpan(int(span_start706)) + return result707 } func (p *Parser) parse_def() *pb.Def { + span_start711 := 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)) + _t1418 := p.parse_relation_id() + relation_id708 := _t1418 + p.popPath() + p.pushPath(int(2)) + _t1419 := p.parse_abstraction() + abstraction709 := _t1419 + p.popPath() + p.pushPath(int(3)) + var _t1420 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t821 := p.parse_attrs() - _t820 = _t821 + _t1421 := p.parse_attrs() + _t1420 = _t1421 } - attrs420 := _t820 + attrs710 := _t1420 + p.popPath() p.consumeLiteral(")") - _t822 := attrs420 - if attrs420 == nil { - _t822 = []*pb.Attribute{} + _t1422 := attrs710 + if attrs710 == nil { + _t1422 = []*pb.Attribute{} } - _t823 := &pb.Def{Name: relation_id418, Body: abstraction419, Attrs: _t822} - return _t823 + _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 { - var _t824 int64 + span_start716 := int64(p.spanStart()) + var _t1424 int64 if p.matchLookaheadLiteral(":", 0) { - _t824 = 0 + _t1424 = 0 } else { - var _t825 int64 + var _t1425 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t825 = 1 + _t1425 = 1 } else { - _t825 = -1 + _t1425 = -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} + _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 _t827 *pb.RelationId - if prediction421 == 0 { + var _t1427 *pb.RelationId + if prediction713 == 0 { p.consumeLiteral(":") - symbol422 := p.consumeTerminal("SYMBOL").Value.str - _t827 = p.relationIdFromString(symbol422) + 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)}) } - _t826 = _t827 + _t1426 = _t1427 } - return _t826 + result717 := _t1426 + p.recordSpan(int(span_start716)) + return result717 } func (p *Parser) parse_abstraction() *pb.Abstraction { + span_start720 := int64(p.spanStart()) p.consumeLiteral("(") - _t828 := p.parse_bindings() - bindings424 := _t828 - _t829 := p.parse_formula() - formula425 := _t829 + _t1428 := p.parse_bindings() + bindings718 := _t1428 + p.pushPath(int(2)) + _t1429 := p.parse_formula() + formula719 := _t1429 + p.popPath() p.consumeLiteral(")") - _t830 := &pb.Abstraction{Vars: listConcat(bindings424[0].([]*pb.Binding), bindings424[1].([]*pb.Binding)), Value: formula425} - return _t830 + _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_start731 := 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 + 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) { - _t833 := p.parse_value_bindings() - _t832 = _t833 + _t1433 := p.parse_value_bindings() + _t1432 = _t1433 } - value_bindings430 := _t832 + value_bindings730 := _t1432 p.consumeLiteral("]") - _t834 := value_bindings430 - if value_bindings430 == nil { - _t834 = []*pb.Binding{} + _t1434 := value_bindings730 + if value_bindings730 == nil { + _t1434 = []*pb.Binding{} } - return []interface{}{bindings429, _t834} + result732 := []interface{}{bindings725, _t1434} + p.recordSpan(int(span_start731)) + return result732 } func (p *Parser) parse_binding() *pb.Binding { - symbol431 := p.consumeTerminal("SYMBOL").Value.str + span_start735 := int64(p.spanStart()) + symbol733 := 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)) + _t1435 := p.parse_type() + type734 := _t1435 + p.popPath() + _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 { - var _t838 int64 + span_start749 := int64(p.spanStart()) + var _t1438 int64 if p.matchLookaheadLiteral("UNKNOWN", 0) { - _t838 = 0 + _t1438 = 0 } else { - var _t839 int64 + var _t1439 int64 if p.matchLookaheadLiteral("UINT128", 0) { - _t839 = 4 + _t1439 = 4 } else { - var _t840 int64 + var _t1440 int64 if p.matchLookaheadLiteral("STRING", 0) { - _t840 = 1 + _t1440 = 1 } else { - var _t841 int64 + var _t1441 int64 if p.matchLookaheadLiteral("MISSING", 0) { - _t841 = 8 + _t1441 = 8 } else { - var _t842 int64 + var _t1442 int64 if p.matchLookaheadLiteral("INT128", 0) { - _t842 = 5 + _t1442 = 5 } else { - var _t843 int64 + var _t1443 int64 if p.matchLookaheadLiteral("INT", 0) { - _t843 = 2 + _t1443 = 2 } else { - var _t844 int64 + var _t1444 int64 if p.matchLookaheadLiteral("FLOAT", 0) { - _t844 = 3 + _t1444 = 3 } else { - var _t845 int64 + var _t1445 int64 if p.matchLookaheadLiteral("DATETIME", 0) { - _t845 = 7 + _t1445 = 7 } else { - var _t846 int64 + var _t1446 int64 if p.matchLookaheadLiteral("DATE", 0) { - _t846 = 6 + _t1446 = 6 } else { - var _t847 int64 + var _t1447 int64 if p.matchLookaheadLiteral("BOOLEAN", 0) { - _t847 = 10 + _t1447 = 10 } else { - var _t848 int64 + var _t1448 int64 if p.matchLookaheadLiteral("(", 0) { - _t848 = 9 + _t1448 = 9 } else { - _t848 = -1 + _t1448 = -1 } - _t847 = _t848 + _t1447 = _t1448 } - _t846 = _t847 + _t1446 = _t1447 } - _t845 = _t846 + _t1445 = _t1446 } - _t844 = _t845 + _t1444 = _t1445 } - _t843 = _t844 + _t1443 = _t1444 } - _t842 = _t843 + _t1442 = _t1443 } - _t841 = _t842 + _t1441 = _t1442 } - _t840 = _t841 + _t1440 = _t1441 } - _t839 = _t840 + _t1439 = _t1440 } - _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 + _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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)}) } - _t876 = _t879 + _t1476 = _t1479 } - _t873 = _t876 + _t1473 = _t1476 } - _t870 = _t873 + _t1470 = _t1473 } - _t867 = _t870 + _t1467 = _t1470 } - _t864 = _t867 + _t1464 = _t1467 } - _t861 = _t864 + _t1461 = _t1464 } - _t858 = _t861 + _t1458 = _t1461 } - _t855 = _t858 + _t1455 = _t1458 } - _t852 = _t855 + _t1452 = _t1455 } - _t849 = _t852 + _t1449 = _t1452 } - return _t849 + result750 := _t1449 + p.recordSpan(int(span_start749)) + return result750 } func (p *Parser) parse_unspecified_type() *pb.UnspecifiedType { + span_start751 := int64(p.spanStart()) p.consumeLiteral("UNKNOWN") - _t882 := &pb.UnspecifiedType{} - return _t882 + _t1482 := &pb.UnspecifiedType{} + result752 := _t1482 + p.recordSpan(int(span_start751)) + return result752 } func (p *Parser) parse_string_type() *pb.StringType { + span_start753 := int64(p.spanStart()) p.consumeLiteral("STRING") - _t883 := &pb.StringType{} - return _t883 + _t1483 := &pb.StringType{} + result754 := _t1483 + p.recordSpan(int(span_start753)) + return result754 } func (p *Parser) parse_int_type() *pb.IntType { + span_start755 := int64(p.spanStart()) p.consumeLiteral("INT") - _t884 := &pb.IntType{} - return _t884 + _t1484 := &pb.IntType{} + result756 := _t1484 + p.recordSpan(int(span_start755)) + return result756 } func (p *Parser) parse_float_type() *pb.FloatType { + span_start757 := int64(p.spanStart()) p.consumeLiteral("FLOAT") - _t885 := &pb.FloatType{} - return _t885 + _t1485 := &pb.FloatType{} + result758 := _t1485 + p.recordSpan(int(span_start757)) + return result758 } func (p *Parser) parse_uint128_type() *pb.UInt128Type { + span_start759 := int64(p.spanStart()) p.consumeLiteral("UINT128") - _t886 := &pb.UInt128Type{} - return _t886 + _t1486 := &pb.UInt128Type{} + result760 := _t1486 + p.recordSpan(int(span_start759)) + return result760 } func (p *Parser) parse_int128_type() *pb.Int128Type { + span_start761 := int64(p.spanStart()) p.consumeLiteral("INT128") - _t887 := &pb.Int128Type{} - return _t887 + _t1487 := &pb.Int128Type{} + result762 := _t1487 + p.recordSpan(int(span_start761)) + return result762 } func (p *Parser) parse_date_type() *pb.DateType { + span_start763 := int64(p.spanStart()) p.consumeLiteral("DATE") - _t888 := &pb.DateType{} - return _t888 + _t1488 := &pb.DateType{} + result764 := _t1488 + p.recordSpan(int(span_start763)) + return result764 } func (p *Parser) parse_datetime_type() *pb.DateTimeType { + span_start765 := int64(p.spanStart()) p.consumeLiteral("DATETIME") - _t889 := &pb.DateTimeType{} - return _t889 + _t1489 := &pb.DateTimeType{} + result766 := _t1489 + p.recordSpan(int(span_start765)) + return result766 } func (p *Parser) parse_missing_type() *pb.MissingType { + span_start767 := int64(p.spanStart()) p.consumeLiteral("MISSING") - _t890 := &pb.MissingType{} - return _t890 + _t1490 := &pb.MissingType{} + result768 := _t1490 + p.recordSpan(int(span_start767)) + return result768 } func (p *Parser) parse_decimal_type() *pb.DecimalType { + span_start771 := 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)) + int769 := p.consumeTerminal("INT").Value.i64 + p.popPath() + p.pushPath(int(2)) + int_3770 := p.consumeTerminal("INT").Value.i64 + p.popPath() p.consumeLiteral(")") - _t891 := &pb.DecimalType{Precision: int32(int445), Scale: int32(int_3446)} - return _t891 + _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_start773 := int64(p.spanStart()) p.consumeLiteral("BOOLEAN") - _t892 := &pb.BooleanType{} - return _t892 + _t1492 := &pb.BooleanType{} + result774 := _t1492 + p.recordSpan(int(span_start773)) + return result774 } func (p *Parser) parse_value_bindings() []*pb.Binding { + span_start783 := 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) - } - bindings450 := xs447 - return bindings450 + 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 { - var _t894 int64 + span_start799 := int64(p.spanStart()) + var _t1494 int64 if p.matchLookaheadLiteral("(", 0) { - var _t895 int64 + var _t1495 int64 if p.matchLookaheadLiteral("true", 1) { - _t895 = 0 + _t1495 = 0 } else { - var _t896 int64 + var _t1496 int64 if p.matchLookaheadLiteral("relatom", 1) { - _t896 = 11 + _t1496 = 11 } else { - var _t897 int64 + var _t1497 int64 if p.matchLookaheadLiteral("reduce", 1) { - _t897 = 3 + _t1497 = 3 } else { - var _t898 int64 + var _t1498 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t898 = 10 + _t1498 = 10 } else { - var _t899 int64 + var _t1499 int64 if p.matchLookaheadLiteral("pragma", 1) { - _t899 = 9 + _t1499 = 9 } else { - var _t900 int64 + var _t1500 int64 if p.matchLookaheadLiteral("or", 1) { - _t900 = 5 + _t1500 = 5 } else { - var _t901 int64 + var _t1501 int64 if p.matchLookaheadLiteral("not", 1) { - _t901 = 6 + _t1501 = 6 } else { - var _t902 int64 + var _t1502 int64 if p.matchLookaheadLiteral("ffi", 1) { - _t902 = 7 + _t1502 = 7 } else { - var _t903 int64 + var _t1503 int64 if p.matchLookaheadLiteral("false", 1) { - _t903 = 1 + _t1503 = 1 } else { - var _t904 int64 + var _t1504 int64 if p.matchLookaheadLiteral("exists", 1) { - _t904 = 2 + _t1504 = 2 } else { - var _t905 int64 + var _t1505 int64 if p.matchLookaheadLiteral("cast", 1) { - _t905 = 12 + _t1505 = 12 } else { - var _t906 int64 + var _t1506 int64 if p.matchLookaheadLiteral("atom", 1) { - _t906 = 8 + _t1506 = 8 } else { - var _t907 int64 + var _t1507 int64 if p.matchLookaheadLiteral("and", 1) { - _t907 = 4 + _t1507 = 4 } else { - var _t908 int64 + var _t1508 int64 if p.matchLookaheadLiteral(">=", 1) { - _t908 = 10 + _t1508 = 10 } else { - var _t909 int64 + var _t1509 int64 if p.matchLookaheadLiteral(">", 1) { - _t909 = 10 + _t1509 = 10 } else { - var _t910 int64 + var _t1510 int64 if p.matchLookaheadLiteral("=", 1) { - _t910 = 10 + _t1510 = 10 } else { - var _t911 int64 + var _t1511 int64 if p.matchLookaheadLiteral("<=", 1) { - _t911 = 10 + _t1511 = 10 } else { - var _t912 int64 + var _t1512 int64 if p.matchLookaheadLiteral("<", 1) { - _t912 = 10 + _t1512 = 10 } else { - var _t913 int64 + var _t1513 int64 if p.matchLookaheadLiteral("/", 1) { - _t913 = 10 + _t1513 = 10 } else { - var _t914 int64 + var _t1514 int64 if p.matchLookaheadLiteral("-", 1) { - _t914 = 10 + _t1514 = 10 } else { - var _t915 int64 + var _t1515 int64 if p.matchLookaheadLiteral("+", 1) { - _t915 = 10 + _t1515 = 10 } else { - var _t916 int64 + var _t1516 int64 if p.matchLookaheadLiteral("*", 1) { - _t916 = 10 + _t1516 = 10 } else { - _t916 = -1 + _t1516 = -1 } - _t915 = _t916 + _t1515 = _t1516 } - _t914 = _t915 + _t1514 = _t1515 } - _t913 = _t914 + _t1513 = _t1514 } - _t912 = _t913 + _t1512 = _t1513 } - _t911 = _t912 + _t1511 = _t1512 } - _t910 = _t911 + _t1510 = _t1511 } - _t909 = _t910 + _t1509 = _t1510 } - _t908 = _t909 + _t1508 = _t1509 } - _t907 = _t908 + _t1507 = _t1508 } - _t906 = _t907 + _t1506 = _t1507 } - _t905 = _t906 + _t1505 = _t1506 } - _t904 = _t905 + _t1504 = _t1505 } - _t903 = _t904 + _t1503 = _t1504 } - _t902 = _t903 + _t1502 = _t1503 } - _t901 = _t902 + _t1501 = _t1502 } - _t900 = _t901 + _t1500 = _t1501 } - _t899 = _t900 + _t1499 = _t1500 } - _t898 = _t899 + _t1498 = _t1499 } - _t897 = _t898 + _t1497 = _t1498 } - _t896 = _t897 + _t1496 = _t1497 } - _t895 = _t896 + _t1495 = _t1496 } - _t894 = _t895 + _t1494 = _t1495 } 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 + _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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 _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)}) } - _t950 = _t953 + _t1550 = _t1553 } - _t947 = _t950 + _t1547 = _t1550 } - _t944 = _t947 + _t1544 = _t1547 } - _t941 = _t944 + _t1541 = _t1544 } - _t938 = _t941 + _t1538 = _t1541 } - _t935 = _t938 + _t1535 = _t1538 } - _t932 = _t935 + _t1532 = _t1535 } - _t929 = _t932 + _t1529 = _t1532 } - _t926 = _t929 + _t1526 = _t1529 } - _t923 = _t926 + _t1523 = _t1526 } - _t920 = _t923 + _t1520 = _t1523 } - _t917 = _t920 + _t1517 = _t1520 } - return _t917 + result800 := _t1517 + p.recordSpan(int(span_start799)) + return result800 } func (p *Parser) parse_true() *pb.Conjunction { + span_start801 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("true") p.consumeLiteral(")") - _t956 := &pb.Conjunction{Args: []*pb.Formula{}} - return _t956 + _t1556 := &pb.Conjunction{Args: []*pb.Formula{}} + result802 := _t1556 + p.recordSpan(int(span_start801)) + return result802 } func (p *Parser) parse_false() *pb.Disjunction { + span_start803 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("false") p.consumeLiteral(")") - _t957 := &pb.Disjunction{Args: []*pb.Formula{}} - return _t957 + _t1557 := &pb.Disjunction{Args: []*pb.Formula{}} + result804 := _t1557 + p.recordSpan(int(span_start803)) + return result804 } func (p *Parser) parse_exists() *pb.Exists { + span_start807 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("exists") - _t958 := p.parse_bindings() - bindings465 := _t958 - _t959 := p.parse_formula() - formula466 := _t959 + _t1558 := p.parse_bindings() + bindings805 := _t1558 + _t1559 := p.parse_formula() + formula806 := _t1559 p.consumeLiteral(")") - _t960 := &pb.Abstraction{Vars: listConcat(bindings465[0].([]*pb.Binding), bindings465[1].([]*pb.Binding)), Value: formula466} - _t961 := &pb.Exists{Body: _t960} - return _t961 + _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_start812 := 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)) + _t1562 := p.parse_abstraction() + abstraction809 := _t1562 + p.popPath() + p.pushPath(int(2)) + _t1563 := p.parse_abstraction() + abstraction_3810 := _t1563 + p.popPath() + p.pushPath(int(3)) + _t1564 := p.parse_terms() + terms811 := _t1564 + p.popPath() p.consumeLiteral(")") - _t965 := &pb.Reduce{Op: abstraction467, Body: abstraction_3468, Terms: terms469} - return _t965 + _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_start822 := 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 + 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(")") - return terms473 + result823 := terms817 + p.recordSpan(int(span_start822)) + return result823 } func (p *Parser) parse_term() *pb.Term { - var _t967 int64 + span_start827 := int64(p.spanStart()) + var _t1567 int64 if p.matchLookaheadLiteral("true", 0) { - _t967 = 1 + _t1567 = 1 } else { - var _t968 int64 + var _t1568 int64 if p.matchLookaheadLiteral("missing", 0) { - _t968 = 1 + _t1568 = 1 } else { - var _t969 int64 + var _t1569 int64 if p.matchLookaheadLiteral("false", 0) { - _t969 = 1 + _t1569 = 1 } else { - var _t970 int64 + var _t1570 int64 if p.matchLookaheadLiteral("(", 0) { - _t970 = 1 + _t1570 = 1 } else { - var _t971 int64 + var _t1571 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t971 = 1 + _t1571 = 1 } else { - var _t972 int64 + var _t1572 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t972 = 0 + _t1572 = 0 } else { - var _t973 int64 + var _t1573 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t973 = 1 + _t1573 = 1 } else { - var _t974 int64 + var _t1574 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t974 = 1 + _t1574 = 1 } else { - var _t975 int64 + var _t1575 int64 if p.matchLookaheadTerminal("INT", 0) { - _t975 = 1 + _t1575 = 1 } else { - var _t976 int64 + var _t1576 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t976 = 1 + _t1576 = 1 } else { - var _t977 int64 + var _t1577 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t977 = 1 + _t1577 = 1 } else { - _t977 = -1 + _t1577 = -1 } - _t976 = _t977 + _t1576 = _t1577 } - _t975 = _t976 + _t1575 = _t1576 } - _t974 = _t975 + _t1574 = _t1575 } - _t973 = _t974 + _t1573 = _t1574 } - _t972 = _t973 + _t1572 = _t1573 } - _t971 = _t972 + _t1571 = _t1572 } - _t970 = _t971 + _t1570 = _t1571 } - _t969 = _t970 + _t1569 = _t1570 } - _t968 = _t969 + _t1568 = _t1569 } - _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 + _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 _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 _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)}) } - _t978 = _t981 + _t1578 = _t1581 } - return _t978 + result828 := _t1578 + p.recordSpan(int(span_start827)) + return result828 } func (p *Parser) parse_var() *pb.Var { - symbol477 := p.consumeTerminal("SYMBOL").Value.str - _t984 := &pb.Var{Name: symbol477} - return _t984 + 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 { - _t985 := p.parse_value() - value478 := _t985 - return value478 + 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_start843 := 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)) + xs839 := []*pb.Formula{} + cond840 := p.matchLookaheadLiteral("(", 0) + idx841 := 0 + for cond840 { + p.pushPath(int(idx841)) + _t1586 := p.parse_formula() + item842 := _t1586 + p.popPath() + xs839 = append(xs839, item842) + idx841 = (idx841 + 1) + cond840 = p.matchLookaheadLiteral("(", 0) + } + formulas838 := xs839 + p.popPath() p.consumeLiteral(")") - _t987 := &pb.Conjunction{Args: formulas482} - return _t987 + _t1587 := &pb.Conjunction{Args: formulas838} + result844 := _t1587 + p.recordSpan(int(span_start843)) + return result844 } func (p *Parser) parse_disjunction() *pb.Disjunction { + span_start853 := 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)) + xs849 := []*pb.Formula{} + cond850 := p.matchLookaheadLiteral("(", 0) + idx851 := 0 + for cond850 { + p.pushPath(int(idx851)) + _t1588 := p.parse_formula() + item852 := _t1588 + p.popPath() + xs849 = append(xs849, item852) + idx851 = (idx851 + 1) + cond850 = p.matchLookaheadLiteral("(", 0) + } + formulas848 := xs849 + p.popPath() p.consumeLiteral(")") - _t989 := &pb.Disjunction{Args: formulas486} - return _t989 + _t1589 := &pb.Disjunction{Args: formulas848} + result854 := _t1589 + p.recordSpan(int(span_start853)) + return result854 } func (p *Parser) parse_not() *pb.Not { + span_start856 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("not") - _t990 := p.parse_formula() - formula487 := _t990 + p.pushPath(int(1)) + _t1590 := p.parse_formula() + formula855 := _t1590 + p.popPath() p.consumeLiteral(")") - _t991 := &pb.Not{Arg: formula487} - return _t991 + _t1591 := &pb.Not{Arg: formula855} + result857 := _t1591 + p.recordSpan(int(span_start856)) + return result857 } func (p *Parser) parse_ffi() *pb.FFI { + span_start861 := 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)) + _t1592 := p.parse_name() + name858 := _t1592 + p.popPath() + p.pushPath(int(2)) + _t1593 := p.parse_ffi_args() + ffi_args859 := _t1593 + p.popPath() + p.pushPath(int(3)) + _t1594 := p.parse_terms() + terms860 := _t1594 + p.popPath() p.consumeLiteral(")") - _t995 := &pb.FFI{Name: name488, Args: ffi_args489, Terms: terms490} - return _t995 + _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_start864 := int64(p.spanStart()) p.consumeLiteral(":") - symbol491 := p.consumeTerminal("SYMBOL").Value.str - return symbol491 + symbol863 := p.consumeTerminal("SYMBOL").Value.str + result865 := symbol863 + p.recordSpan(int(span_start864)) + return result865 } func (p *Parser) parse_ffi_args() []*pb.Abstraction { + span_start874 := 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 + 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(")") - return abstractions495 + result875 := abstractions869 + p.recordSpan(int(span_start874)) + return result875 } func (p *Parser) parse_atom() *pb.Atom { + span_start885 := 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)) + _t1597 := p.parse_relation_id() + relation_id876 := _t1597 + p.popPath() + p.pushPath(int(2)) + 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() + 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)) + } + terms880 := xs881 + p.popPath() p.consumeLiteral(")") - _t999 := &pb.Atom{Name: relation_id496, Terms: terms500} - return _t999 + _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_start896 := 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)) + _t1600 := p.parse_name() + name887 := _t1600 + p.popPath() + p.pushPath(int(2)) + 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() + 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)) + } + terms891 := xs892 + p.popPath() p.consumeLiteral(")") - _t1002 := &pb.Pragma{Name: name501, Terms: terms505} - return _t1002 + _t1602 := &pb.Pragma{Name: name887, Terms: terms891} + result897 := _t1602 + p.recordSpan(int(span_start896)) + return result897 } func (p *Parser) parse_primitive() *pb.Primitive { - var _t1003 int64 + span_start917 := int64(p.spanStart()) + var _t1603 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1004 int64 + var _t1604 int64 if p.matchLookaheadLiteral("primitive", 1) { - _t1004 = 9 + _t1604 = 9 } else { - var _t1005 int64 + var _t1605 int64 if p.matchLookaheadLiteral(">=", 1) { - _t1005 = 4 + _t1605 = 4 } else { - var _t1006 int64 + var _t1606 int64 if p.matchLookaheadLiteral(">", 1) { - _t1006 = 3 + _t1606 = 3 } else { - var _t1007 int64 + var _t1607 int64 if p.matchLookaheadLiteral("=", 1) { - _t1007 = 0 + _t1607 = 0 } else { - var _t1008 int64 + var _t1608 int64 if p.matchLookaheadLiteral("<=", 1) { - _t1008 = 2 + _t1608 = 2 } else { - var _t1009 int64 + var _t1609 int64 if p.matchLookaheadLiteral("<", 1) { - _t1009 = 1 + _t1609 = 1 } else { - var _t1010 int64 + var _t1610 int64 if p.matchLookaheadLiteral("/", 1) { - _t1010 = 8 + _t1610 = 8 } else { - var _t1011 int64 + var _t1611 int64 if p.matchLookaheadLiteral("-", 1) { - _t1011 = 6 + _t1611 = 6 } else { - var _t1012 int64 + var _t1612 int64 if p.matchLookaheadLiteral("+", 1) { - _t1012 = 5 + _t1612 = 5 } else { - var _t1013 int64 + var _t1613 int64 if p.matchLookaheadLiteral("*", 1) { - _t1013 = 7 + _t1613 = 7 } else { - _t1013 = -1 + _t1613 = -1 } - _t1012 = _t1013 + _t1612 = _t1613 } - _t1011 = _t1012 + _t1611 = _t1612 } - _t1010 = _t1011 + _t1610 = _t1611 } - _t1009 = _t1010 + _t1609 = _t1610 } - _t1008 = _t1009 + _t1608 = _t1609 } - _t1007 = _t1008 + _t1607 = _t1608 } - _t1006 = _t1007 + _t1606 = _t1607 } - _t1005 = _t1006 + _t1605 = _t1606 } - _t1004 = _t1005 + _t1604 = _t1605 } - _t1003 = _t1004 + _t1603 = _t1604 } else { - _t1003 = -1 + _t1603 = -1 } - prediction506 := _t1003 - var _t1014 *pb.Primitive - if prediction506 == 9 { + prediction898 := _t1603 + var _t1614 *pb.Primitive + if prediction898 == 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)) + _t1615 := p.parse_name() + name908 := _t1615 + p.popPath() + p.pushPath(int(2)) + 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() + 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_terms520 := xs517 + rel_terms912 := xs913 + p.popPath() p.consumeLiteral(")") - _t1017 := &pb.Primitive{Name: name516, Terms: rel_terms520} - _t1014 = _t1017 + _t1617 := &pb.Primitive{Name: name908, Terms: rel_terms912} + _t1614 = _t1617 } else { - var _t1018 *pb.Primitive - if prediction506 == 8 { - _t1019 := p.parse_divide() - divide515 := _t1019 - _t1018 = divide515 + var _t1618 *pb.Primitive + if prediction898 == 8 { + _t1619 := p.parse_divide() + divide907 := _t1619 + _t1618 = divide907 } else { - var _t1020 *pb.Primitive - if prediction506 == 7 { - _t1021 := p.parse_multiply() - multiply514 := _t1021 - _t1020 = multiply514 + var _t1620 *pb.Primitive + if prediction898 == 7 { + _t1621 := p.parse_multiply() + multiply906 := _t1621 + _t1620 = multiply906 } else { - var _t1022 *pb.Primitive - if prediction506 == 6 { - _t1023 := p.parse_minus() - minus513 := _t1023 - _t1022 = minus513 + var _t1622 *pb.Primitive + if prediction898 == 6 { + _t1623 := p.parse_minus() + minus905 := _t1623 + _t1622 = minus905 } else { - var _t1024 *pb.Primitive - if prediction506 == 5 { - _t1025 := p.parse_add() - add512 := _t1025 - _t1024 = add512 + var _t1624 *pb.Primitive + if prediction898 == 5 { + _t1625 := p.parse_add() + add904 := _t1625 + _t1624 = add904 } else { - var _t1026 *pb.Primitive - if prediction506 == 4 { - _t1027 := p.parse_gt_eq() - gt_eq511 := _t1027 - _t1026 = gt_eq511 + var _t1626 *pb.Primitive + if prediction898 == 4 { + _t1627 := p.parse_gt_eq() + gt_eq903 := _t1627 + _t1626 = gt_eq903 } else { - var _t1028 *pb.Primitive - if prediction506 == 3 { - _t1029 := p.parse_gt() - gt510 := _t1029 - _t1028 = gt510 + var _t1628 *pb.Primitive + if prediction898 == 3 { + _t1629 := p.parse_gt() + gt902 := _t1629 + _t1628 = gt902 } else { - var _t1030 *pb.Primitive - if prediction506 == 2 { - _t1031 := p.parse_lt_eq() - lt_eq509 := _t1031 - _t1030 = lt_eq509 + var _t1630 *pb.Primitive + if prediction898 == 2 { + _t1631 := p.parse_lt_eq() + lt_eq901 := _t1631 + _t1630 = lt_eq901 } else { - var _t1032 *pb.Primitive - if prediction506 == 1 { - _t1033 := p.parse_lt() - lt508 := _t1033 - _t1032 = lt508 + var _t1632 *pb.Primitive + if prediction898 == 1 { + _t1633 := p.parse_lt() + lt900 := _t1633 + _t1632 = lt900 } else { - var _t1034 *pb.Primitive - if prediction506 == 0 { - _t1035 := p.parse_eq() - eq507 := _t1035 - _t1034 = eq507 + 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)}) } - _t1032 = _t1034 + _t1632 = _t1634 } - _t1030 = _t1032 + _t1630 = _t1632 } - _t1028 = _t1030 + _t1628 = _t1630 } - _t1026 = _t1028 + _t1626 = _t1628 } - _t1024 = _t1026 + _t1624 = _t1626 } - _t1022 = _t1024 + _t1622 = _t1624 } - _t1020 = _t1022 + _t1620 = _t1622 } - _t1018 = _t1020 + _t1618 = _t1620 } - _t1014 = _t1018 + _t1614 = _t1618 } - return _t1014 + result918 := _t1614 + p.recordSpan(int(span_start917)) + return result918 } func (p *Parser) parse_eq() *pb.Primitive { + span_start921 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("=") - _t1036 := p.parse_term() - term521 := _t1036 - _t1037 := p.parse_term() - term_3522 := _t1037 + _t1636 := p.parse_term() + term919 := _t1636 + _t1637 := p.parse_term() + term_3920 := _t1637 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 + _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_start925 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<") - _t1041 := p.parse_term() - term523 := _t1041 - _t1042 := p.parse_term() - term_3524 := _t1042 + _t1641 := p.parse_term() + term923 := _t1641 + _t1642 := p.parse_term() + term_3924 := _t1642 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 + _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_start929 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("<=") - _t1046 := p.parse_term() - term525 := _t1046 - _t1047 := p.parse_term() - term_3526 := _t1047 + _t1646 := p.parse_term() + term927 := _t1646 + _t1647 := p.parse_term() + term_3928 := _t1647 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 + _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_start933 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">") - _t1051 := p.parse_term() - term527 := _t1051 - _t1052 := p.parse_term() - term_3528 := _t1052 + _t1651 := p.parse_term() + term931 := _t1651 + _t1652 := p.parse_term() + term_3932 := _t1652 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 + _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_start937 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral(">=") - _t1056 := p.parse_term() - term529 := _t1056 - _t1057 := p.parse_term() - term_3530 := _t1057 + _t1656 := p.parse_term() + term935 := _t1656 + _t1657 := p.parse_term() + term_3936 := _t1657 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 + _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_start942 := 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 + _t1661 := p.parse_term() + term939 := _t1661 + _t1662 := p.parse_term() + term_3940 := _t1662 + _t1663 := p.parse_term() + term_4941 := _t1663 + p.consumeLiteral(")") + _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_start947 := 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 + _t1668 := p.parse_term() + term944 := _t1668 + _t1669 := p.parse_term() + term_3945 := _t1669 + _t1670 := p.parse_term() + term_4946 := _t1670 + p.consumeLiteral(")") + _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_start952 := 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 + _t1675 := p.parse_term() + term949 := _t1675 + _t1676 := p.parse_term() + term_3950 := _t1676 + _t1677 := p.parse_term() + term_4951 := _t1677 + p.consumeLiteral(")") + _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_start957 := 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 + _t1682 := p.parse_term() + term954 := _t1682 + _t1683 := p.parse_term() + term_3955 := _t1683 + _t1684 := p.parse_term() + term_4956 := _t1684 + p.consumeLiteral(")") + _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 { - var _t1089 int64 + span_start962 := int64(p.spanStart()) + var _t1689 int64 if p.matchLookaheadLiteral("true", 0) { - _t1089 = 1 + _t1689 = 1 } else { - var _t1090 int64 + var _t1690 int64 if p.matchLookaheadLiteral("missing", 0) { - _t1090 = 1 + _t1690 = 1 } else { - var _t1091 int64 + var _t1691 int64 if p.matchLookaheadLiteral("false", 0) { - _t1091 = 1 + _t1691 = 1 } else { - var _t1092 int64 + var _t1692 int64 if p.matchLookaheadLiteral("(", 0) { - _t1092 = 1 + _t1692 = 1 } else { - var _t1093 int64 + var _t1693 int64 if p.matchLookaheadLiteral("#", 0) { - _t1093 = 0 + _t1693 = 0 } else { - var _t1094 int64 + var _t1694 int64 if p.matchLookaheadTerminal("UINT128", 0) { - _t1094 = 1 + _t1694 = 1 } else { - var _t1095 int64 + var _t1695 int64 if p.matchLookaheadTerminal("SYMBOL", 0) { - _t1095 = 1 + _t1695 = 1 } else { - var _t1096 int64 + var _t1696 int64 if p.matchLookaheadTerminal("STRING", 0) { - _t1096 = 1 + _t1696 = 1 } else { - var _t1097 int64 + var _t1697 int64 if p.matchLookaheadTerminal("INT128", 0) { - _t1097 = 1 + _t1697 = 1 } else { - var _t1098 int64 + var _t1698 int64 if p.matchLookaheadTerminal("INT", 0) { - _t1098 = 1 + _t1698 = 1 } else { - var _t1099 int64 + var _t1699 int64 if p.matchLookaheadTerminal("FLOAT", 0) { - _t1099 = 1 + _t1699 = 1 } else { - var _t1100 int64 + var _t1700 int64 if p.matchLookaheadTerminal("DECIMAL", 0) { - _t1100 = 1 + _t1700 = 1 } else { - _t1100 = -1 + _t1700 = -1 } - _t1099 = _t1100 + _t1699 = _t1700 } - _t1098 = _t1099 + _t1698 = _t1699 } - _t1097 = _t1098 + _t1697 = _t1698 } - _t1096 = _t1097 + _t1696 = _t1697 } - _t1095 = _t1096 + _t1695 = _t1696 } - _t1094 = _t1095 + _t1694 = _t1695 } - _t1093 = _t1094 + _t1693 = _t1694 } - _t1092 = _t1093 + _t1692 = _t1693 } - _t1091 = _t1092 + _t1691 = _t1692 } - _t1090 = _t1091 + _t1690 = _t1691 } - _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 + _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 _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 _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)}) } - _t1101 = _t1104 + _t1701 = _t1704 } - return _t1101 + result963 := _t1701 + p.recordSpan(int(span_start962)) + return result963 } func (p *Parser) parse_specialized_value() *pb.Value { + span_start965 := int64(p.spanStart()) p.consumeLiteral("#") - _t1107 := p.parse_value() - value546 := _t1107 - return value546 + _t1707 := p.parse_value() + value964 := _t1707 + result966 := value964 + p.recordSpan(int(span_start965)) + return result966 } func (p *Parser) parse_rel_atom() *pb.RelAtom { + span_start976 := 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)) + _t1708 := p.parse_name() + name967 := _t1708 + p.popPath() + p.pushPath(int(2)) + 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() + 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_terms971 := xs972 + p.popPath() p.consumeLiteral(")") - _t1110 := &pb.RelAtom{Name: name547, Terms: rel_terms551} - return _t1110 + _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_start980 := 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)) + _t1711 := p.parse_term() + term978 := _t1711 + p.popPath() + p.pushPath(int(3)) + _t1712 := p.parse_term() + term_3979 := _t1712 + p.popPath() p.consumeLiteral(")") - _t1113 := &pb.Cast{Input: term552, Result: term_3553} - return _t1113 + _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_start990 := 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 + 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(")") - return attributes557 + result991 := attributes985 + p.recordSpan(int(span_start990)) + return result991 } func (p *Parser) parse_attribute() *pb.Attribute { + span_start1001 := 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)) + _t1715 := p.parse_name() + name992 := _t1715 + p.popPath() + p.pushPath(int(2)) + 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() + 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)) + } + values996 := xs997 + p.popPath() p.consumeLiteral(")") - _t1117 := &pb.Attribute{Name: name558, Args: values562} - return _t1117 + _t1717 := &pb.Attribute{Name: name992, Args: values996} + result1002 := _t1717 + p.recordSpan(int(span_start1001)) + return result1002 } func (p *Parser) parse_algorithm() *pb.Algorithm { + span_start1012 := 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)) + 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() + xs1007 = append(xs1007, item1010) + idx1009 = (idx1009 + 1) + cond1008 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + relation_ids1006 := xs1007 + p.popPath() + p.pushPath(int(2)) + _t1719 := p.parse_script() + script1011 := _t1719 + p.popPath() p.consumeLiteral(")") - _t1120 := &pb.Algorithm{Global: relation_ids566, Body: script567} - return _t1120 + _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_start1022 := 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)) + xs1018 := []*pb.Construct{} + cond1019 := p.matchLookaheadLiteral("(", 0) + idx1020 := 0 + for cond1019 { + p.pushPath(int(idx1020)) + _t1721 := p.parse_construct() + item1021 := _t1721 + p.popPath() + xs1018 = append(xs1018, item1021) + idx1020 = (idx1020 + 1) + cond1019 = p.matchLookaheadLiteral("(", 0) + } + constructs1017 := xs1018 + p.popPath() p.consumeLiteral(")") - _t1122 := &pb.Script{Constructs: constructs571} - return _t1122 + _t1722 := &pb.Script{Constructs: constructs1017} + result1023 := _t1722 + p.recordSpan(int(span_start1022)) + return result1023 } func (p *Parser) parse_construct() *pb.Construct { - var _t1123 int64 + span_start1027 := int64(p.spanStart()) + var _t1723 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1124 int64 + var _t1724 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1124 = 1 + _t1724 = 1 } else { - var _t1125 int64 + var _t1725 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1125 = 1 + _t1725 = 1 } else { - var _t1126 int64 + var _t1726 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1126 = 1 + _t1726 = 1 } else { - var _t1127 int64 + var _t1727 int64 if p.matchLookaheadLiteral("loop", 1) { - _t1127 = 0 + _t1727 = 0 } else { - var _t1128 int64 + var _t1728 int64 if p.matchLookaheadLiteral("break", 1) { - _t1128 = 1 + _t1728 = 1 } else { - var _t1129 int64 + var _t1729 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1129 = 1 + _t1729 = 1 } else { - _t1129 = -1 + _t1729 = -1 } - _t1128 = _t1129 + _t1728 = _t1729 } - _t1127 = _t1128 + _t1727 = _t1728 } - _t1126 = _t1127 + _t1726 = _t1727 } - _t1125 = _t1126 + _t1725 = _t1726 } - _t1124 = _t1125 + _t1724 = _t1725 } - _t1123 = _t1124 + _t1723 = _t1724 } 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 + _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 _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 _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)}) } - _t1130 = _t1133 + _t1730 = _t1733 } - return _t1130 + result1028 := _t1730 + p.recordSpan(int(span_start1027)) + return result1028 } func (p *Parser) parse_loop() *pb.Loop { + span_start1031 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("loop") - _t1136 := p.parse_init() - init575 := _t1136 - _t1137 := p.parse_script() - script576 := _t1137 + p.pushPath(int(1)) + _t1736 := p.parse_init() + init1029 := _t1736 + p.popPath() + p.pushPath(int(2)) + _t1737 := p.parse_script() + script1030 := _t1737 + p.popPath() p.consumeLiteral(")") - _t1138 := &pb.Loop{Init: init575, Body: script576} - return _t1138 + _t1738 := &pb.Loop{Init: init1029, Body: script1030} + result1032 := _t1738 + p.recordSpan(int(span_start1031)) + return result1032 } func (p *Parser) parse_init() []*pb.Instruction { + span_start1041 := 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 + 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(")") - return instructions580 + result1042 := instructions1036 + p.recordSpan(int(span_start1041)) + return result1042 } func (p *Parser) parse_instruction() *pb.Instruction { - var _t1140 int64 + span_start1049 := int64(p.spanStart()) + var _t1740 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1141 int64 + var _t1741 int64 if p.matchLookaheadLiteral("upsert", 1) { - _t1141 = 1 + _t1741 = 1 } else { - var _t1142 int64 + var _t1742 int64 if p.matchLookaheadLiteral("monus", 1) { - _t1142 = 4 + _t1742 = 4 } else { - var _t1143 int64 + var _t1743 int64 if p.matchLookaheadLiteral("monoid", 1) { - _t1143 = 3 + _t1743 = 3 } else { - var _t1144 int64 + var _t1744 int64 if p.matchLookaheadLiteral("break", 1) { - _t1144 = 2 + _t1744 = 2 } else { - var _t1145 int64 + var _t1745 int64 if p.matchLookaheadLiteral("assign", 1) { - _t1145 = 0 + _t1745 = 0 } else { - _t1145 = -1 + _t1745 = -1 } - _t1144 = _t1145 + _t1744 = _t1745 } - _t1143 = _t1144 + _t1743 = _t1744 } - _t1142 = _t1143 + _t1742 = _t1743 } - _t1141 = _t1142 + _t1741 = _t1742 } - _t1140 = _t1141 + _t1740 = _t1741 } 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 + _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 _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 _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 _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 _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 _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 _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 _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 _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)}) } - _t1155 = _t1158 + _t1755 = _t1758 } - _t1152 = _t1155 + _t1752 = _t1755 } - _t1149 = _t1152 + _t1749 = _t1752 } - _t1146 = _t1149 + _t1746 = _t1749 } - return _t1146 + result1050 := _t1746 + p.recordSpan(int(span_start1049)) + return result1050 } func (p *Parser) parse_assign() *pb.Assign { + span_start1054 := 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)) + _t1761 := p.parse_relation_id() + relation_id1051 := _t1761 + p.popPath() + p.pushPath(int(2)) + _t1762 := p.parse_abstraction() + abstraction1052 := _t1762 + p.popPath() + p.pushPath(int(3)) + var _t1763 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1164 := p.parse_attrs() - _t1163 = _t1164 + _t1764 := p.parse_attrs() + _t1763 = _t1764 } - attrs589 := _t1163 + attrs1053 := _t1763 + p.popPath() p.consumeLiteral(")") - _t1165 := attrs589 - if attrs589 == nil { - _t1165 = []*pb.Attribute{} + _t1765 := attrs1053 + if attrs1053 == nil { + _t1765 = []*pb.Attribute{} } - _t1166 := &pb.Assign{Name: relation_id587, Body: abstraction588, Attrs: _t1165} - return _t1166 + _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_start1059 := 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)) + _t1767 := p.parse_relation_id() + relation_id1056 := _t1767 + p.popPath() + _t1768 := p.parse_abstraction_with_arity() + abstraction_with_arity1057 := _t1768 + p.pushPath(int(3)) + var _t1769 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1170 := p.parse_attrs() - _t1169 = _t1170 + _t1770 := p.parse_attrs() + _t1769 = _t1770 } - attrs592 := _t1169 + attrs1058 := _t1769 + p.popPath() p.consumeLiteral(")") - _t1171 := attrs592 - if attrs592 == nil { - _t1171 = []*pb.Attribute{} + _t1771 := attrs1058 + if attrs1058 == nil { + _t1771 = []*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 + _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_start1063 := int64(p.spanStart()) p.consumeLiteral("(") - _t1173 := p.parse_bindings() - bindings593 := _t1173 - _t1174 := p.parse_formula() - formula594 := _t1174 + _t1773 := p.parse_bindings() + bindings1061 := _t1773 + _t1774 := p.parse_formula() + formula1062 := _t1774 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)))} + _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_start1068 := 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)) + _t1776 := p.parse_relation_id() + relation_id1065 := _t1776 + p.popPath() + p.pushPath(int(2)) + _t1777 := p.parse_abstraction() + abstraction1066 := _t1777 + p.popPath() + p.pushPath(int(3)) + var _t1778 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1179 := p.parse_attrs() - _t1178 = _t1179 + _t1779 := p.parse_attrs() + _t1778 = _t1779 } - attrs597 := _t1178 + attrs1067 := _t1778 + p.popPath() p.consumeLiteral(")") - _t1180 := attrs597 - if attrs597 == nil { - _t1180 = []*pb.Attribute{} + _t1780 := attrs1067 + if attrs1067 == nil { + _t1780 = []*pb.Attribute{} } - _t1181 := &pb.Break{Name: relation_id595, Body: abstraction596, Attrs: _t1180} - return _t1181 + _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_start1074 := 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)) + _t1782 := p.parse_monoid() + monoid1070 := _t1782 + p.popPath() + p.pushPath(int(2)) + _t1783 := p.parse_relation_id() + relation_id1071 := _t1783 + p.popPath() + _t1784 := p.parse_abstraction_with_arity() + abstraction_with_arity1072 := _t1784 + p.pushPath(int(4)) + var _t1785 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1186 := p.parse_attrs() - _t1185 = _t1186 + _t1786 := p.parse_attrs() + _t1785 = _t1786 } - attrs601 := _t1185 + attrs1073 := _t1785 + p.popPath() p.consumeLiteral(")") - _t1187 := attrs601 - if attrs601 == nil { - _t1187 = []*pb.Attribute{} + _t1787 := attrs1073 + if attrs1073 == nil { + _t1787 = []*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 + _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 { - var _t1189 int64 + span_start1081 := int64(p.spanStart()) + var _t1789 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1190 int64 + var _t1790 int64 if p.matchLookaheadLiteral("sum", 1) { - _t1190 = 3 + _t1790 = 3 } else { - var _t1191 int64 + var _t1791 int64 if p.matchLookaheadLiteral("or", 1) { - _t1191 = 0 + _t1791 = 0 } else { - var _t1192 int64 + var _t1792 int64 if p.matchLookaheadLiteral("min", 1) { - _t1192 = 1 + _t1792 = 1 } else { - var _t1193 int64 + var _t1793 int64 if p.matchLookaheadLiteral("max", 1) { - _t1193 = 2 + _t1793 = 2 } else { - _t1193 = -1 + _t1793 = -1 } - _t1192 = _t1193 + _t1792 = _t1793 } - _t1191 = _t1192 + _t1791 = _t1792 } - _t1190 = _t1191 + _t1790 = _t1791 } - _t1189 = _t1190 + _t1789 = _t1790 } 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 + _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 _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 _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 _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 _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 _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 _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)}) } - _t1200 = _t1203 + _t1800 = _t1803 } - _t1197 = _t1200 + _t1797 = _t1800 } - _t1194 = _t1197 + _t1794 = _t1797 } - return _t1194 + result1082 := _t1794 + p.recordSpan(int(span_start1081)) + return result1082 } func (p *Parser) parse_or_monoid() *pb.OrMonoid { + span_start1083 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("or") p.consumeLiteral(")") - _t1206 := &pb.OrMonoid{} - return _t1206 + _t1806 := &pb.OrMonoid{} + result1084 := _t1806 + p.recordSpan(int(span_start1083)) + return result1084 } func (p *Parser) parse_min_monoid() *pb.MinMonoid { + span_start1086 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("min") - _t1207 := p.parse_type() - type607 := _t1207 + p.pushPath(int(1)) + _t1807 := p.parse_type() + type1085 := _t1807 + p.popPath() p.consumeLiteral(")") - _t1208 := &pb.MinMonoid{Type: type607} - return _t1208 + _t1808 := &pb.MinMonoid{Type: type1085} + result1087 := _t1808 + p.recordSpan(int(span_start1086)) + return result1087 } func (p *Parser) parse_max_monoid() *pb.MaxMonoid { + span_start1089 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("max") - _t1209 := p.parse_type() - type608 := _t1209 + p.pushPath(int(1)) + _t1809 := p.parse_type() + type1088 := _t1809 + p.popPath() p.consumeLiteral(")") - _t1210 := &pb.MaxMonoid{Type: type608} - return _t1210 + _t1810 := &pb.MaxMonoid{Type: type1088} + result1090 := _t1810 + p.recordSpan(int(span_start1089)) + return result1090 } func (p *Parser) parse_sum_monoid() *pb.SumMonoid { + span_start1092 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("sum") - _t1211 := p.parse_type() - type609 := _t1211 + p.pushPath(int(1)) + _t1811 := p.parse_type() + type1091 := _t1811 + p.popPath() p.consumeLiteral(")") - _t1212 := &pb.SumMonoid{Type: type609} - return _t1212 + _t1812 := &pb.SumMonoid{Type: type1091} + result1093 := _t1812 + p.recordSpan(int(span_start1092)) + return result1093 } func (p *Parser) parse_monus_def() *pb.MonusDef { + span_start1098 := 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)) + _t1813 := p.parse_monoid() + monoid1094 := _t1813 + p.popPath() + p.pushPath(int(2)) + _t1814 := p.parse_relation_id() + relation_id1095 := _t1814 + p.popPath() + _t1815 := p.parse_abstraction_with_arity() + abstraction_with_arity1096 := _t1815 + p.pushPath(int(4)) + var _t1816 []*pb.Attribute if p.matchLookaheadLiteral("(", 0) { - _t1217 := p.parse_attrs() - _t1216 = _t1217 + _t1817 := p.parse_attrs() + _t1816 = _t1817 } - attrs613 := _t1216 + attrs1097 := _t1816 + p.popPath() p.consumeLiteral(")") - _t1218 := attrs613 - if attrs613 == nil { - _t1218 = []*pb.Attribute{} + _t1818 := attrs1097 + if attrs1097 == nil { + _t1818 = []*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 + _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_start1104 := 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)) + _t1820 := p.parse_relation_id() + relation_id1100 := _t1820 + p.popPath() + _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(")") - _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 + _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_start1114 := 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 + 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(")") - return vars621 + result1115 := vars1109 + p.recordSpan(int(span_start1114)) + return result1115 } func (p *Parser) parse_functional_dependency_values() []*pb.Var { + span_start1124 := 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 + 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(")") - return vars625 + result1125 := vars1119 + p.recordSpan(int(span_start1124)) + return result1125 } func (p *Parser) parse_data() *pb.Data { - var _t1228 int64 + span_start1130 := int64(p.spanStart()) + var _t1828 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1229 int64 + var _t1829 int64 if p.matchLookaheadLiteral("rel_edb", 1) { - _t1229 = 0 + _t1829 = 0 } else { - var _t1230 int64 + var _t1830 int64 if p.matchLookaheadLiteral("csv_data", 1) { - _t1230 = 2 + _t1830 = 2 } else { - var _t1231 int64 + var _t1831 int64 if p.matchLookaheadLiteral("betree_relation", 1) { - _t1231 = 1 + _t1831 = 1 } else { - _t1231 = -1 + _t1831 = -1 } - _t1230 = _t1231 + _t1830 = _t1831 } - _t1229 = _t1230 + _t1829 = _t1830 } - _t1228 = _t1229 + _t1828 = _t1829 } 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 + _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 _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 _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 _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 _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)}) } - _t1235 = _t1238 + _t1835 = _t1838 } - _t1232 = _t1235 + _t1832 = _t1835 } - return _t1232 + result1131 := _t1832 + p.recordSpan(int(span_start1130)) + return result1131 } func (p *Parser) parse_rel_edb() *pb.RelEDB { + span_start1135 := 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)) + _t1841 := p.parse_relation_id() + relation_id1132 := _t1841 + p.popPath() + p.pushPath(int(2)) + _t1842 := p.parse_rel_edb_path() + rel_edb_path1133 := _t1842 + p.popPath() + p.pushPath(int(3)) + _t1843 := p.parse_rel_edb_types() + rel_edb_types1134 := _t1843 + p.popPath() p.consumeLiteral(")") - _t1244 := &pb.RelEDB{TargetId: relation_id630, Path: rel_edb_path631, Types: rel_edb_types632} - return _t1244 + _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_start1145 := 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 + 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("]") - return strings636 + result1146 := strings1140 + p.recordSpan(int(span_start1145)) + return result1146 } func (p *Parser) parse_rel_edb_types() []*pb.Type { + span_start1155 := 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 + 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("]") - return types640 + result1156 := types1150 + p.recordSpan(int(span_start1155)) + return result1156 } func (p *Parser) parse_betree_relation() *pb.BeTreeRelation { + span_start1159 := 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)) + _t1846 := p.parse_relation_id() + relation_id1157 := _t1846 + p.popPath() + p.pushPath(int(2)) + _t1847 := p.parse_betree_info() + betree_info1158 := _t1847 + p.popPath() p.consumeLiteral(")") - _t1248 := &pb.BeTreeRelation{Name: relation_id641, RelationInfo: betree_info642} - return _t1248 + _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_start1164 := 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 + _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(")") - _t1252 := p.construct_betree_info(betree_info_key_types643, betree_info_value_types644, config_dict645) - return _t1252 + _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_start1174 := 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 + 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(")") - return types649 + result1175 := types1169 + p.recordSpan(int(span_start1174)) + return result1175 } func (p *Parser) parse_betree_info_value_types() []*pb.Type { + span_start1184 := 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 + 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)) + } + types1179 := xs1180 p.consumeLiteral(")") - return types653 + result1185 := types1179 + p.recordSpan(int(span_start1184)) + return result1185 } func (p *Parser) parse_csv_data() *pb.CSVData { + span_start1190 := 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)) + _t1855 := p.parse_csvlocator() + csvlocator1186 := _t1855 + p.popPath() + p.pushPath(int(2)) + _t1856 := p.parse_csv_config() + csv_config1187 := _t1856 + p.popPath() + p.pushPath(int(3)) + _t1857 := p.parse_csv_columns() + csv_columns1188 := _t1857 + p.popPath() + p.pushPath(int(4)) + _t1858 := p.parse_csv_asof() + csv_asof1189 := _t1858 + p.popPath() p.consumeLiteral(")") - _t1259 := &pb.CSVData{Locator: csvlocator654, Config: csv_config655, Columns: csv_columns656, Asof: csv_asof657} - return _t1259 + _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_start1194 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_locator") - var _t1260 []string + p.pushPath(int(1)) + var _t1860 []string if (p.matchLookaheadLiteral("(", 0) && p.matchLookaheadLiteral("paths", 1)) { - _t1261 := p.parse_csv_locator_paths() - _t1260 = _t1261 + _t1861 := p.parse_csv_locator_paths() + _t1860 = _t1861 } - csv_locator_paths658 := _t1260 - var _t1262 *string + csv_locator_paths1192 := _t1860 + p.popPath() + p.pushPath(int(2)) + var _t1862 *string if p.matchLookaheadLiteral("(", 0) { - _t1263 := p.parse_csv_locator_inline_data() - _t1262 = ptr(_t1263) + _t1863 := p.parse_csv_locator_inline_data() + _t1862 = ptr(_t1863) } - csv_locator_inline_data659 := _t1262 + csv_locator_inline_data1193 := _t1862 + p.popPath() p.consumeLiteral(")") - _t1264 := csv_locator_paths658 - if csv_locator_paths658 == nil { - _t1264 = []string{} + _t1864 := csv_locator_paths1192 + if csv_locator_paths1192 == nil { + _t1864 = []string{} } - _t1265 := &pb.CSVLocator{Paths: _t1264, InlineData: []byte(deref(csv_locator_inline_data659, ""))} - return _t1265 + _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_start1204 := 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 + 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(")") - return strings663 + result1205 := strings1199 + p.recordSpan(int(span_start1204)) + return result1205 } func (p *Parser) parse_csv_locator_inline_data() string { + span_start1207 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("inline_data") - string664 := p.consumeTerminal("STRING").Value.str + string1206 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string664 + result1208 := string1206 + p.recordSpan(int(span_start1207)) + return result1208 } func (p *Parser) parse_csv_config() *pb.CSVConfig { + span_start1210 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("csv_config") - _t1266 := p.parse_config_dict() - config_dict665 := _t1266 + _t1866 := p.parse_config_dict() + config_dict1209 := _t1866 p.consumeLiteral(")") - _t1267 := p.construct_csv_config(config_dict665) - return _t1267 + _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_start1220 := 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 + 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(")") - return csv_columns669 + result1221 := csv_columns1215 + p.recordSpan(int(span_start1220)) + return result1221 } func (p *Parser) parse_csv_column() *pb.CSVColumn { + span_start1232 := 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)) + string1222 := p.consumeTerminal("STRING").Value.str + p.popPath() + p.pushPath(int(2)) + _t1869 := p.parse_relation_id() + relation_id1223 := _t1869 + 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)) + 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() + 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)) + } + types1227 := xs1228 + p.popPath() p.consumeLiteral("]") p.consumeLiteral(")") - _t1271 := &pb.CSVColumn{ColumnName: string670, TargetId: relation_id671, Types: types675} - return _t1271 + _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_start1235 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("asof") - string676 := p.consumeTerminal("STRING").Value.str + string1234 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string676 + result1236 := string1234 + p.recordSpan(int(span_start1235)) + return result1236 } func (p *Parser) parse_undefine() *pb.Undefine { + span_start1238 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("undefine") - _t1272 := p.parse_fragment_id() - fragment_id677 := _t1272 + p.pushPath(int(1)) + _t1872 := p.parse_fragment_id() + fragment_id1237 := _t1872 + p.popPath() p.consumeLiteral(")") - _t1273 := &pb.Undefine{FragmentId: fragment_id677} - return _t1273 + _t1873 := &pb.Undefine{FragmentId: fragment_id1237} + result1239 := _t1873 + p.recordSpan(int(span_start1238)) + return result1239 } func (p *Parser) parse_context() *pb.Context { + span_start1248 := 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)) + 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() + xs1244 = append(xs1244, item1247) + idx1246 = (idx1246 + 1) + cond1245 = (p.matchLookaheadLiteral(":", 0) || p.matchLookaheadTerminal("UINT128", 0)) + } + relation_ids1243 := xs1244 + p.popPath() p.consumeLiteral(")") - _t1275 := &pb.Context{Relations: relation_ids681} - return _t1275 + _t1875 := &pb.Context{Relations: relation_ids1243} + result1249 := _t1875 + p.recordSpan(int(span_start1248)) + return result1249 } func (p *Parser) parse_snapshot() *pb.Snapshot { + span_start1252 := 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)) + _t1876 := p.parse_rel_edb_path() + rel_edb_path1250 := _t1876 + p.popPath() + p.pushPath(int(2)) + _t1877 := p.parse_relation_id() + relation_id1251 := _t1877 + p.popPath() p.consumeLiteral(")") - _t1278 := &pb.Snapshot{DestinationPath: rel_edb_path682, SourceRelation: relation_id683} - return _t1278 + _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_start1262 := 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 + 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(")") - return reads687 + result1263 := reads1257 + p.recordSpan(int(span_start1262)) + return result1263 } func (p *Parser) parse_read() *pb.Read { - var _t1280 int64 + span_start1270 := int64(p.spanStart()) + var _t1880 int64 if p.matchLookaheadLiteral("(", 0) { - var _t1281 int64 + var _t1881 int64 if p.matchLookaheadLiteral("what_if", 1) { - _t1281 = 2 + _t1881 = 2 } else { - var _t1282 int64 + var _t1882 int64 if p.matchLookaheadLiteral("output", 1) { - _t1282 = 1 + _t1882 = 1 } else { - var _t1283 int64 + var _t1883 int64 if p.matchLookaheadLiteral("export", 1) { - _t1283 = 4 + _t1883 = 4 } else { - var _t1284 int64 + var _t1884 int64 if p.matchLookaheadLiteral("demand", 1) { - _t1284 = 0 + _t1884 = 0 } else { - var _t1285 int64 + var _t1885 int64 if p.matchLookaheadLiteral("abort", 1) { - _t1285 = 3 + _t1885 = 3 } else { - _t1285 = -1 + _t1885 = -1 } - _t1284 = _t1285 + _t1884 = _t1885 } - _t1283 = _t1284 + _t1883 = _t1884 } - _t1282 = _t1283 + _t1882 = _t1883 } - _t1281 = _t1282 + _t1881 = _t1882 } - _t1280 = _t1281 + _t1880 = _t1881 } 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 + _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 _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 _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 _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 _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 _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 _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 _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 _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)}) } - _t1295 = _t1298 + _t1895 = _t1898 } - _t1292 = _t1295 + _t1892 = _t1895 } - _t1289 = _t1292 + _t1889 = _t1892 } - _t1286 = _t1289 + _t1886 = _t1889 } - return _t1286 + result1271 := _t1886 + p.recordSpan(int(span_start1270)) + return result1271 } func (p *Parser) parse_demand() *pb.Demand { + span_start1273 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("demand") - _t1301 := p.parse_relation_id() - relation_id694 := _t1301 + p.pushPath(int(1)) + _t1901 := p.parse_relation_id() + relation_id1272 := _t1901 + p.popPath() p.consumeLiteral(")") - _t1302 := &pb.Demand{RelationId: relation_id694} - return _t1302 + _t1902 := &pb.Demand{RelationId: relation_id1272} + result1274 := _t1902 + p.recordSpan(int(span_start1273)) + return result1274 } func (p *Parser) parse_output() *pb.Output { + span_start1277 := 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)) + _t1903 := p.parse_name() + name1275 := _t1903 + p.popPath() + p.pushPath(int(2)) + _t1904 := p.parse_relation_id() + relation_id1276 := _t1904 + p.popPath() p.consumeLiteral(")") - _t1305 := &pb.Output{Name: name695, RelationId: relation_id696} - return _t1305 + _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_start1281 := 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)) + _t1906 := p.parse_name() + name1279 := _t1906 + p.popPath() + p.pushPath(int(2)) + _t1907 := p.parse_epoch() + epoch1280 := _t1907 + p.popPath() p.consumeLiteral(")") - _t1308 := &pb.WhatIf{Branch: name697, Epoch: epoch698} - return _t1308 + _t1908 := &pb.WhatIf{Branch: name1279, Epoch: epoch1280} + result1282 := _t1908 + p.recordSpan(int(span_start1281)) + return result1282 } func (p *Parser) parse_abort() *pb.Abort { + span_start1285 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("abort") - var _t1309 *string + p.pushPath(int(1)) + var _t1909 *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 + _t1910 := p.parse_name() + _t1909 = ptr(_t1910) + } + name1283 := _t1909 + p.popPath() + p.pushPath(int(2)) + _t1911 := p.parse_relation_id() + relation_id1284 := _t1911 + p.popPath() p.consumeLiteral(")") - _t1312 := &pb.Abort{Name: deref(name699, "abort"), RelationId: relation_id700} - return _t1312 + _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_start1288 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("export") - _t1313 := p.parse_export_csv_config() - export_csv_config701 := _t1313 + p.pushPath(int(1)) + _t1913 := p.parse_export_csv_config() + export_csv_config1287 := _t1913 + p.popPath() p.consumeLiteral(")") - _t1314 := &pb.Export{} - _t1314.ExportConfig = &pb.Export_CsvConfig{CsvConfig: export_csv_config701} - return _t1314 + _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_start1293 := 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 + _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(")") - _t1318 := p.export_csv_config(export_csv_path702, export_csv_columns703, config_dict704) - return _t1318 + _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_start1296 := int64(p.spanStart()) p.consumeLiteral("(") p.consumeLiteral("path") - string705 := p.consumeTerminal("STRING").Value.str + string1295 := p.consumeTerminal("STRING").Value.str p.consumeLiteral(")") - return string705 + result1297 := string1295 + p.recordSpan(int(span_start1296)) + return result1297 } func (p *Parser) parse_export_csv_columns() []*pb.ExportCSVColumn { + span_start1306 := 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 + 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(")") - return export_csv_columns709 + result1307 := export_csv_columns1301 + p.recordSpan(int(span_start1306)) + return result1307 } func (p *Parser) parse_export_csv_column() *pb.ExportCSVColumn { + span_start1310 := 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)) + string1308 := p.consumeTerminal("STRING").Value.str + p.popPath() + p.pushPath(int(2)) + _t1920 := p.parse_relation_id() + relation_id1309 := _t1920 + p.popPath() p.consumeLiteral(")") - _t1321 := &pb.ExportCSVColumn{ColumnName: string710, ColumnData: relation_id711} - return _t1321 + _t1921 := &pb.ExportCSVColumn{ColumnName: string1308, ColumnData: relation_id1309} + result1311 := _t1921 + p.recordSpan(int(span_start1310)) + return result1311 } -// 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 +4627,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/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/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..492fe258 --- /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.Stop.Offset { + t.Errorf("Bad span at path %q: start %d > end %d", + path, span.Start.Offset, span.Stop.Offset) + } + if span.Start.Line > span.Stop.Line { + t.Errorf("Bad line ordering at path %q: start %d > end %d", + path, span.Start.Line, span.Stop.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..7f337825 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 + stop::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 + _t1911 = 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 + _t1912 = 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 + _t1913 = 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 + _t1914 = 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 + _t1915 = 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 + _t1916 = 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 + _t1917 = 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 + _t1918 = 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 + _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) - _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 + _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) - _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 + _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 - _t1343 = Proto.IVMConfig(level=Proto.MaintenanceLevel.MAINTENANCE_LEVEL_OFF) - ivm_config = _t1343 - _t1344 = Proto.Configure(semantics_version=0, ivm_config=ivm_config) - return _t1344 + _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 @@ -462,2739 +519,3531 @@ 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 + _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) - _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 + _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 --- 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 + _t1313 = parse_configure(parser) + _t1312 = _t1313 else - _t712 = nothing + _t1312 = nothing end - configure356 = _t712 + configure592 = _t1312 + 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 + _t1315 = parse_sync(parser) + _t1314 = _t1315 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) + _t1314 = nothing end - epochs361 = xs358 - consume_literal!(parser, ")") - _t717 = default_configure(parser) - _t718 = Proto.Transaction(epochs=epochs361, configure=(!isnothing(configure356) ? configure356 : _t717), sync=sync357) - return _t718 + sync593 = _t1314 + pop_path!(parser) + push_path!(parser, 1) + xs598 = Proto.Epoch[] + cond599 = match_lookahead_literal(parser, "(", 0) + idx600 = 0 + while cond599 + push_path!(parser, idx600) + _t1316 = parse_epoch(parser) + item601 = _t1316 + pop_path!(parser) + push!(xs598, item601) + idx600 = (idx600 + 1) + cond599 = match_lookahead_literal(parser, "(", 0) + end + epochs597 = xs598 + pop_path!(parser) + consume_literal!(parser, ")") + _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 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 + _t1319 = parse_config_dict(parser) + config_dict604 = _t1319 consume_literal!(parser, ")") - _t720 = construct_configure(parser, config_dict362) - return _t720 + _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_start615 = 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 + 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, "}") - return config_key_values366 + result616 = config_key_values610 + record_span!(parser, span_start615) + return result616 end function parse_config_key_value(parser::ParserState)::Tuple{String, Proto.Value} + span_start619 = span_start(parser) consume_literal!(parser, ":") - symbol367 = consume_terminal!(parser, "SYMBOL") - _t722 = parse_value(parser) - value368 = _t722 - return (symbol367, value368,) + 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_start631 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t723 = 9 + _t1323 = 9 else if match_lookahead_literal(parser, "missing", 0) - _t724 = 8 + _t1324 = 8 else if match_lookahead_literal(parser, "false", 0) - _t725 = 9 + _t1325 = 9 else if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "datetime", 1) - _t727 = 1 + _t1327 = 1 else if match_lookahead_literal(parser, "date", 1) - _t728 = 0 + _t1328 = 0 else - _t728 = -1 + _t1328 = -1 end - _t727 = _t728 + _t1327 = _t1328 end - _t726 = _t727 + _t1326 = _t1327 else if match_lookahead_terminal(parser, "UINT128", 0) - _t729 = 5 + _t1329 = 5 else if match_lookahead_terminal(parser, "STRING", 0) - _t730 = 2 + _t1330 = 2 else if match_lookahead_terminal(parser, "INT128", 0) - _t731 = 6 + _t1331 = 6 else if match_lookahead_terminal(parser, "INT", 0) - _t732 = 3 + _t1332 = 3 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t733 = 4 + _t1333 = 4 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t734 = 7 + _t1334 = 7 else - _t734 = -1 + _t1334 = -1 end - _t733 = _t734 + _t1333 = _t1334 end - _t732 = _t733 + _t1332 = _t1333 end - _t731 = _t732 + _t1331 = _t1332 end - _t730 = _t731 + _t1330 = _t1331 end - _t729 = _t730 + _t1329 = _t1330 end - _t726 = _t729 + _t1326 = _t1329 end - _t725 = _t726 + _t1325 = _t1326 end - _t724 = _t725 + _t1324 = _t1325 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 + _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 prediction369 == 8 + if prediction621 == 8 consume_literal!(parser, "missing") - _t739 = Proto.MissingValue() - _t740 = Proto.Value(value=OneOf(:missing_value, _t739)) - _t738 = _t740 + _t1339 = Proto.MissingValue() + _t1340 = Proto.Value(value=OneOf(:missing_value, _t1339)) + _t1338 = _t1340 else - if prediction369 == 7 - decimal377 = consume_terminal!(parser, "DECIMAL") - _t742 = Proto.Value(value=OneOf(:decimal_value, decimal377)) - _t741 = _t742 + if prediction621 == 7 + decimal629 = consume_terminal!(parser, "DECIMAL") + _t1342 = Proto.Value(value=OneOf(:decimal_value, decimal629)) + _t1341 = _t1342 else - if prediction369 == 6 - int128376 = consume_terminal!(parser, "INT128") - _t744 = Proto.Value(value=OneOf(:int128_value, int128376)) - _t743 = _t744 + if prediction621 == 6 + int128628 = consume_terminal!(parser, "INT128") + _t1344 = Proto.Value(value=OneOf(:int128_value, int128628)) + _t1343 = _t1344 else - if prediction369 == 5 - uint128375 = consume_terminal!(parser, "UINT128") - _t746 = Proto.Value(value=OneOf(:uint128_value, uint128375)) - _t745 = _t746 + if prediction621 == 5 + uint128627 = consume_terminal!(parser, "UINT128") + _t1346 = Proto.Value(value=OneOf(:uint128_value, uint128627)) + _t1345 = _t1346 else - if prediction369 == 4 - float374 = consume_terminal!(parser, "FLOAT") - _t748 = Proto.Value(value=OneOf(:float_value, float374)) - _t747 = _t748 + if prediction621 == 4 + float626 = consume_terminal!(parser, "FLOAT") + _t1348 = Proto.Value(value=OneOf(:float_value, float626)) + _t1347 = _t1348 else - if prediction369 == 3 - int373 = consume_terminal!(parser, "INT") - _t750 = Proto.Value(value=OneOf(:int_value, int373)) - _t749 = _t750 + if prediction621 == 3 + int625 = consume_terminal!(parser, "INT") + _t1350 = Proto.Value(value=OneOf(:int_value, int625)) + _t1349 = _t1350 else - if prediction369 == 2 - string372 = consume_terminal!(parser, "STRING") - _t752 = Proto.Value(value=OneOf(:string_value, string372)) - _t751 = _t752 + if prediction621 == 2 + string624 = consume_terminal!(parser, "STRING") + _t1352 = Proto.Value(value=OneOf(:string_value, string624)) + _t1351 = _t1352 else - if prediction369 == 1 - _t754 = parse_datetime(parser) - datetime371 = _t754 - _t755 = Proto.Value(value=OneOf(:datetime_value, datetime371)) - _t753 = _t755 + 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 prediction369 == 0 - _t757 = parse_date(parser) - date370 = _t757 - _t758 = Proto.Value(value=OneOf(:date_value, date370)) - _t756 = _t758 + 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 - _t753 = _t756 + _t1353 = _t1356 end - _t751 = _t753 + _t1351 = _t1353 end - _t749 = _t751 + _t1349 = _t1351 end - _t747 = _t749 + _t1347 = _t1349 end - _t745 = _t747 + _t1345 = _t1347 end - _t743 = _t745 + _t1343 = _t1345 end - _t741 = _t743 + _t1341 = _t1343 end - _t738 = _t741 + _t1338 = _t1341 end - _t735 = _t738 + _t1335 = _t1338 end - return _t735 + result632 = _t1335 + record_span!(parser, span_start631) + return result632 end function parse_date(parser::ParserState)::Proto.DateValue + span_start636 = 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) + int633 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3634 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_4635 = consume_terminal!(parser, "INT") + pop_path!(parser) + consume_literal!(parser, ")") + _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_start645 = 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) + int638 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3639 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 3) + int_4640 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 4) + int_5641 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 5) + int_6642 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 6) + int_7643 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 7) if match_lookahead_terminal(parser, "INT", 0) - _t760 = consume_terminal!(parser, "INT") + _t1360 = consume_terminal!(parser, "INT") else - _t760 = nothing + _t1360 = nothing end - int_8388 = _t760 + int_8644 = _t1360 + 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 + _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_start648 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t762 = 0 + _t1362 = 0 else if match_lookahead_literal(parser, "false", 0) - _t763 = 1 + _t1363 = 1 else - _t763 = -1 + _t1363 = -1 end - _t762 = _t763 + _t1362 = _t1363 end - prediction389 = _t762 - if prediction389 == 1 + prediction647 = _t1362 + if prediction647 == 1 consume_literal!(parser, "false") - _t764 = false + _t1364 = false else - if prediction389 == 0 + if prediction647 == 0 consume_literal!(parser, "true") - _t765 = true + _t1365 = true else throw(ParseError("Unexpected token in boolean_value" * ": " * string(lookahead(parser, 0)))) end - _t764 = _t765 + _t1364 = _t1365 end - return _t764 + result649 = _t1364 + record_span!(parser, span_start648) + return result649 end function parse_sync(parser::ParserState)::Proto.Sync + span_start658 = 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) - end - fragment_ids393 = xs390 - consume_literal!(parser, ")") - _t767 = Proto.Sync(fragments=fragment_ids393) - return _t767 + push_path!(parser, 1) + 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!(xs654, item657) + idx656 = (idx656 + 1) + cond655 = match_lookahead_literal(parser, ":", 0) + end + fragment_ids653 = xs654 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start661 = span_start(parser) consume_literal!(parser, ":") - symbol394 = consume_terminal!(parser, "SYMBOL") - return Proto.FragmentId(Vector{UInt8}(symbol394)) + 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_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)) - _t769 = parse_epoch_writes(parser) - _t768 = _t769 + _t1369 = parse_epoch_writes(parser) + _t1368 = _t1369 else - _t768 = nothing + _t1368 = nothing end - epoch_writes395 = _t768 + epoch_writes663 = _t1368 + pop_path!(parser) + push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t771 = parse_epoch_reads(parser) - _t770 = _t771 + _t1371 = parse_epoch_reads(parser) + _t1370 = _t1371 else - _t770 = nothing + _t1370 = nothing end - epoch_reads396 = _t770 + epoch_reads664 = _t1370 + 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 + _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_start675 = 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) + 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 - writes400 = xs397 + writes670 = xs671 consume_literal!(parser, ")") - return writes400 + result676 = writes670 + record_span!(parser, span_start675) + return result676 end function parse_write(parser::ParserState)::Proto.Write + span_start682 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "undefine", 1) - _t775 = 1 + _t1375 = 1 else if match_lookahead_literal(parser, "snapshot", 1) - _t776 = 3 + _t1376 = 3 else if match_lookahead_literal(parser, "define", 1) - _t777 = 0 + _t1377 = 0 else if match_lookahead_literal(parser, "context", 1) - _t778 = 2 + _t1378 = 2 else - _t778 = -1 + _t1378 = -1 end - _t777 = _t778 + _t1377 = _t1378 end - _t776 = _t777 + _t1376 = _t1377 end - _t775 = _t776 + _t1375 = _t1376 end - _t774 = _t775 + _t1374 = _t1375 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 + _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 prediction401 == 2 - _t783 = parse_context(parser) - context404 = _t783 - _t784 = Proto.Write(write_type=OneOf(:context, context404)) - _t782 = _t784 + 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 prediction401 == 1 - _t786 = parse_undefine(parser) - undefine403 = _t786 - _t787 = Proto.Write(write_type=OneOf(:undefine, undefine403)) - _t785 = _t787 + 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 prediction401 == 0 - _t789 = parse_define(parser) - define402 = _t789 - _t790 = Proto.Write(write_type=OneOf(:define, define402)) - _t788 = _t790 + 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 - _t785 = _t788 + _t1385 = _t1388 end - _t782 = _t785 + _t1382 = _t1385 end - _t779 = _t782 + _t1379 = _t1382 end - return _t779 + result683 = _t1379 + record_span!(parser, span_start682) + return result683 end function parse_define(parser::ParserState)::Proto.Define + span_start685 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "define") - _t791 = parse_fragment(parser) - fragment406 = _t791 + push_path!(parser, 1) + _t1391 = parse_fragment(parser) + fragment684 = _t1391 + pop_path!(parser) consume_literal!(parser, ")") - _t792 = Proto.Define(fragment=fragment406) - return _t792 + _t1392 = Proto.Define(fragment=fragment684) + result686 = _t1392 + record_span!(parser, span_start685) + return result686 end function parse_fragment(parser::ParserState)::Proto.Fragment + span_start696 = 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) - end - declarations411 = xs408 - consume_literal!(parser, ")") - return construct_fragment(parser, new_fragment_id407, declarations411) + _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 + declarations691 = xs692 + pop_path!(parser) + consume_literal!(parser, ")") + 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 - _t795 = parse_fragment_id(parser) - fragment_id412 = _t795 - start_fragment!(parser, fragment_id412) - return fragment_id412 + 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_start706 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t797 = 3 + _t1397 = 3 else if match_lookahead_literal(parser, "functional_dependency", 1) - _t798 = 2 + _t1398 = 2 else if match_lookahead_literal(parser, "def", 1) - _t799 = 0 + _t1399 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t800 = 3 + _t1400 = 3 else if match_lookahead_literal(parser, "betree_relation", 1) - _t801 = 3 + _t1401 = 3 else if match_lookahead_literal(parser, "algorithm", 1) - _t802 = 1 + _t1402 = 1 else - _t802 = -1 + _t1402 = -1 end - _t801 = _t802 + _t1401 = _t1402 end - _t800 = _t801 + _t1400 = _t1401 end - _t799 = _t800 + _t1399 = _t1400 end - _t798 = _t799 + _t1398 = _t1399 end - _t797 = _t798 + _t1397 = _t1398 end - _t796 = _t797 + _t1396 = _t1397 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 + _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 prediction413 == 2 - _t807 = parse_constraint(parser) - constraint416 = _t807 - _t808 = Proto.Declaration(declaration_type=OneOf(:constraint, constraint416)) - _t806 = _t808 + 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 prediction413 == 1 - _t810 = parse_algorithm(parser) - algorithm415 = _t810 - _t811 = Proto.Declaration(declaration_type=OneOf(:algorithm, algorithm415)) - _t809 = _t811 + 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 prediction413 == 0 - _t813 = parse_def(parser) - def414 = _t813 - _t814 = Proto.Declaration(declaration_type=OneOf(:def, def414)) - _t812 = _t814 + 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 - _t809 = _t812 + _t1409 = _t1412 end - _t806 = _t809 + _t1406 = _t1409 end - _t803 = _t806 + _t1403 = _t1406 end - return _t803 + result707 = _t1403 + record_span!(parser, span_start706) + return result707 end function parse_def(parser::ParserState)::Proto.Def + span_start711 = 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) + _t1415 = parse_relation_id(parser) + relation_id708 = _t1415 + pop_path!(parser) + push_path!(parser, 2) + _t1416 = parse_abstraction(parser) + abstraction709 = _t1416 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t818 = parse_attrs(parser) - _t817 = _t818 + _t1418 = parse_attrs(parser) + _t1417 = _t1418 else - _t817 = nothing + _t1417 = nothing end - attrs420 = _t817 + attrs710 = _t1417 + pop_path!(parser) consume_literal!(parser, ")") - _t819 = Proto.Def(name=relation_id418, body=abstraction419, attrs=(!isnothing(attrs420) ? attrs420 : Proto.Attribute[])) - return _t819 + _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_start716 = span_start(parser) if match_lookahead_literal(parser, ":", 0) - _t820 = 0 + _t1420 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t821 = 1 + _t1421 = 1 else - _t821 = -1 + _t1421 = -1 end - _t820 = _t821 + _t1420 = _t1421 end - prediction421 = _t820 - if prediction421 == 1 - uint128423 = consume_terminal!(parser, "UINT128") - _t822 = Proto.RelationId(uint128423.low, uint128423.high) + prediction713 = _t1420 + if prediction713 == 1 + uint128715 = consume_terminal!(parser, "UINT128") + _t1422 = Proto.RelationId(uint128715.low, uint128715.high) else - if prediction421 == 0 + if prediction713 == 0 consume_literal!(parser, ":") - symbol422 = consume_terminal!(parser, "SYMBOL") - _t823 = relation_id_from_string(parser, symbol422) + 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 - _t822 = _t823 + _t1422 = _t1423 end - return _t822 + result717 = _t1422 + record_span!(parser, span_start716) + return result717 end function parse_abstraction(parser::ParserState)::Proto.Abstraction + span_start720 = span_start(parser) consume_literal!(parser, "(") - _t824 = parse_bindings(parser) - bindings424 = _t824 - _t825 = parse_formula(parser) - formula425 = _t825 + _t1424 = parse_bindings(parser) + bindings718 = _t1424 + push_path!(parser, 2) + _t1425 = parse_formula(parser) + formula719 = _t1425 + pop_path!(parser) consume_literal!(parser, ")") - _t826 = Proto.Abstraction(vars=vcat(bindings424[1], !isnothing(bindings424[2]) ? bindings424[2] : []), value=formula425) - return _t826 + _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_start731 = 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 + 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) - _t829 = parse_value_bindings(parser) - _t828 = _t829 + _t1429 = parse_value_bindings(parser) + _t1428 = _t1429 else - _t828 = nothing + _t1428 = nothing end - value_bindings430 = _t828 + value_bindings730 = _t1428 consume_literal!(parser, "]") - return (bindings429, (!isnothing(value_bindings430) ? value_bindings430 : Proto.Binding[]),) + result732 = (bindings725, (!isnothing(value_bindings730) ? value_bindings730 : Proto.Binding[]),) + record_span!(parser, span_start731) + return result732 end function parse_binding(parser::ParserState)::Proto.Binding - symbol431 = consume_terminal!(parser, "SYMBOL") + span_start735 = span_start(parser) + symbol733 = 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) + _t1430 = parse_type(parser) + type734 = _t1430 + pop_path!(parser) + _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_start749 = span_start(parser) if match_lookahead_literal(parser, "UNKNOWN", 0) - _t833 = 0 + _t1433 = 0 else if match_lookahead_literal(parser, "UINT128", 0) - _t834 = 4 + _t1434 = 4 else if match_lookahead_literal(parser, "STRING", 0) - _t835 = 1 + _t1435 = 1 else if match_lookahead_literal(parser, "MISSING", 0) - _t836 = 8 + _t1436 = 8 else if match_lookahead_literal(parser, "INT128", 0) - _t837 = 5 + _t1437 = 5 else if match_lookahead_literal(parser, "INT", 0) - _t838 = 2 + _t1438 = 2 else if match_lookahead_literal(parser, "FLOAT", 0) - _t839 = 3 + _t1439 = 3 else if match_lookahead_literal(parser, "DATETIME", 0) - _t840 = 7 + _t1440 = 7 else if match_lookahead_literal(parser, "DATE", 0) - _t841 = 6 + _t1441 = 6 else if match_lookahead_literal(parser, "BOOLEAN", 0) - _t842 = 10 + _t1442 = 10 else if match_lookahead_literal(parser, "(", 0) - _t843 = 9 + _t1443 = 9 else - _t843 = -1 + _t1443 = -1 end - _t842 = _t843 + _t1442 = _t1443 end - _t841 = _t842 + _t1441 = _t1442 end - _t840 = _t841 + _t1440 = _t1441 end - _t839 = _t840 + _t1439 = _t1440 end - _t838 = _t839 + _t1438 = _t1439 end - _t837 = _t838 + _t1437 = _t1438 end - _t836 = _t837 + _t1436 = _t1437 end - _t835 = _t836 + _t1435 = _t1436 end - _t834 = _t835 + _t1434 = _t1435 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 + _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 prediction433 == 9 - _t848 = parse_decimal_type(parser) - decimal_type443 = _t848 - _t849 = Proto.var"#Type"(var"#type"=OneOf(:decimal_type, decimal_type443)) - _t847 = _t849 + 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 prediction433 == 8 - _t851 = parse_missing_type(parser) - missing_type442 = _t851 - _t852 = Proto.var"#Type"(var"#type"=OneOf(:missing_type, missing_type442)) - _t850 = _t852 + 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 prediction433 == 7 - _t854 = parse_datetime_type(parser) - datetime_type441 = _t854 - _t855 = Proto.var"#Type"(var"#type"=OneOf(:datetime_type, datetime_type441)) - _t853 = _t855 + 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 prediction433 == 6 - _t857 = parse_date_type(parser) - date_type440 = _t857 - _t858 = Proto.var"#Type"(var"#type"=OneOf(:date_type, date_type440)) - _t856 = _t858 + 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 prediction433 == 5 - _t860 = parse_int128_type(parser) - int128_type439 = _t860 - _t861 = Proto.var"#Type"(var"#type"=OneOf(:int128_type, int128_type439)) - _t859 = _t861 + 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 prediction433 == 4 - _t863 = parse_uint128_type(parser) - uint128_type438 = _t863 - _t864 = Proto.var"#Type"(var"#type"=OneOf(:uint128_type, uint128_type438)) - _t862 = _t864 + 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 prediction433 == 3 - _t866 = parse_float_type(parser) - float_type437 = _t866 - _t867 = Proto.var"#Type"(var"#type"=OneOf(:float_type, float_type437)) - _t865 = _t867 + 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 prediction433 == 2 - _t869 = parse_int_type(parser) - int_type436 = _t869 - _t870 = Proto.var"#Type"(var"#type"=OneOf(:int_type, int_type436)) - _t868 = _t870 + 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 prediction433 == 1 - _t872 = parse_string_type(parser) - string_type435 = _t872 - _t873 = Proto.var"#Type"(var"#type"=OneOf(:string_type, string_type435)) - _t871 = _t873 + 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 prediction433 == 0 - _t875 = parse_unspecified_type(parser) - unspecified_type434 = _t875 - _t876 = Proto.var"#Type"(var"#type"=OneOf(:unspecified_type, unspecified_type434)) - _t874 = _t876 + 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 - _t871 = _t874 + _t1471 = _t1474 end - _t868 = _t871 + _t1468 = _t1471 end - _t865 = _t868 + _t1465 = _t1468 end - _t862 = _t865 + _t1462 = _t1465 end - _t859 = _t862 + _t1459 = _t1462 end - _t856 = _t859 + _t1456 = _t1459 end - _t853 = _t856 + _t1453 = _t1456 end - _t850 = _t853 + _t1450 = _t1453 end - _t847 = _t850 + _t1447 = _t1450 end - _t844 = _t847 + _t1444 = _t1447 end - return _t844 + result750 = _t1444 + record_span!(parser, span_start749) + return result750 end function parse_unspecified_type(parser::ParserState)::Proto.UnspecifiedType + span_start751 = span_start(parser) consume_literal!(parser, "UNKNOWN") - _t877 = Proto.UnspecifiedType() - return _t877 + _t1477 = Proto.UnspecifiedType() + result752 = _t1477 + record_span!(parser, span_start751) + return result752 end function parse_string_type(parser::ParserState)::Proto.StringType + span_start753 = span_start(parser) consume_literal!(parser, "STRING") - _t878 = Proto.StringType() - return _t878 + _t1478 = Proto.StringType() + result754 = _t1478 + record_span!(parser, span_start753) + return result754 end function parse_int_type(parser::ParserState)::Proto.IntType + span_start755 = span_start(parser) consume_literal!(parser, "INT") - _t879 = Proto.IntType() - return _t879 + _t1479 = Proto.IntType() + result756 = _t1479 + record_span!(parser, span_start755) + return result756 end function parse_float_type(parser::ParserState)::Proto.FloatType + span_start757 = span_start(parser) consume_literal!(parser, "FLOAT") - _t880 = Proto.FloatType() - return _t880 + _t1480 = Proto.FloatType() + result758 = _t1480 + record_span!(parser, span_start757) + return result758 end function parse_uint128_type(parser::ParserState)::Proto.UInt128Type + span_start759 = span_start(parser) consume_literal!(parser, "UINT128") - _t881 = Proto.UInt128Type() - return _t881 + _t1481 = Proto.UInt128Type() + result760 = _t1481 + record_span!(parser, span_start759) + return result760 end function parse_int128_type(parser::ParserState)::Proto.Int128Type + span_start761 = span_start(parser) consume_literal!(parser, "INT128") - _t882 = Proto.Int128Type() - return _t882 + _t1482 = Proto.Int128Type() + result762 = _t1482 + record_span!(parser, span_start761) + return result762 end function parse_date_type(parser::ParserState)::Proto.DateType + span_start763 = span_start(parser) consume_literal!(parser, "DATE") - _t883 = Proto.DateType() - return _t883 + _t1483 = Proto.DateType() + result764 = _t1483 + record_span!(parser, span_start763) + return result764 end function parse_datetime_type(parser::ParserState)::Proto.DateTimeType + span_start765 = span_start(parser) consume_literal!(parser, "DATETIME") - _t884 = Proto.DateTimeType() - return _t884 + _t1484 = Proto.DateTimeType() + result766 = _t1484 + record_span!(parser, span_start765) + return result766 end function parse_missing_type(parser::ParserState)::Proto.MissingType + span_start767 = span_start(parser) consume_literal!(parser, "MISSING") - _t885 = Proto.MissingType() - return _t885 + _t1485 = Proto.MissingType() + result768 = _t1485 + record_span!(parser, span_start767) + return result768 end function parse_decimal_type(parser::ParserState)::Proto.DecimalType + span_start771 = 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) + int769 = consume_terminal!(parser, "INT") + pop_path!(parser) + push_path!(parser, 2) + int_3770 = consume_terminal!(parser, "INT") + pop_path!(parser) consume_literal!(parser, ")") - _t886 = Proto.DecimalType(precision=Int32(int445), scale=Int32(int_3446)) - return _t886 + _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_start773 = span_start(parser) consume_literal!(parser, "BOOLEAN") - _t887 = Proto.BooleanType() - return _t887 + _t1487 = Proto.BooleanType() + result774 = _t1487 + record_span!(parser, span_start773) + return result774 end function parse_value_bindings(parser::ParserState)::Vector{Proto.Binding} + span_start783 = 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) - end - bindings450 = xs447 - return bindings450 + 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_start799 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "true", 1) - _t890 = 0 + _t1490 = 0 else if match_lookahead_literal(parser, "relatom", 1) - _t891 = 11 + _t1491 = 11 else if match_lookahead_literal(parser, "reduce", 1) - _t892 = 3 + _t1492 = 3 else if match_lookahead_literal(parser, "primitive", 1) - _t893 = 10 + _t1493 = 10 else if match_lookahead_literal(parser, "pragma", 1) - _t894 = 9 + _t1494 = 9 else if match_lookahead_literal(parser, "or", 1) - _t895 = 5 + _t1495 = 5 else if match_lookahead_literal(parser, "not", 1) - _t896 = 6 + _t1496 = 6 else if match_lookahead_literal(parser, "ffi", 1) - _t897 = 7 + _t1497 = 7 else if match_lookahead_literal(parser, "false", 1) - _t898 = 1 + _t1498 = 1 else if match_lookahead_literal(parser, "exists", 1) - _t899 = 2 + _t1499 = 2 else if match_lookahead_literal(parser, "cast", 1) - _t900 = 12 + _t1500 = 12 else if match_lookahead_literal(parser, "atom", 1) - _t901 = 8 + _t1501 = 8 else if match_lookahead_literal(parser, "and", 1) - _t902 = 4 + _t1502 = 4 else if match_lookahead_literal(parser, ">=", 1) - _t903 = 10 + _t1503 = 10 else if match_lookahead_literal(parser, ">", 1) - _t904 = 10 + _t1504 = 10 else if match_lookahead_literal(parser, "=", 1) - _t905 = 10 + _t1505 = 10 else if match_lookahead_literal(parser, "<=", 1) - _t906 = 10 + _t1506 = 10 else if match_lookahead_literal(parser, "<", 1) - _t907 = 10 + _t1507 = 10 else if match_lookahead_literal(parser, "/", 1) - _t908 = 10 + _t1508 = 10 else if match_lookahead_literal(parser, "-", 1) - _t909 = 10 + _t1509 = 10 else if match_lookahead_literal(parser, "+", 1) - _t910 = 10 + _t1510 = 10 else if match_lookahead_literal(parser, "*", 1) - _t911 = 10 + _t1511 = 10 else - _t911 = -1 + _t1511 = -1 end - _t910 = _t911 + _t1510 = _t1511 end - _t909 = _t910 + _t1509 = _t1510 end - _t908 = _t909 + _t1508 = _t1509 end - _t907 = _t908 + _t1507 = _t1508 end - _t906 = _t907 + _t1506 = _t1507 end - _t905 = _t906 + _t1505 = _t1506 end - _t904 = _t905 + _t1504 = _t1505 end - _t903 = _t904 + _t1503 = _t1504 end - _t902 = _t903 + _t1502 = _t1503 end - _t901 = _t902 + _t1501 = _t1502 end - _t900 = _t901 + _t1500 = _t1501 end - _t899 = _t900 + _t1499 = _t1500 end - _t898 = _t899 + _t1498 = _t1499 end - _t897 = _t898 + _t1497 = _t1498 end - _t896 = _t897 + _t1496 = _t1497 end - _t895 = _t896 + _t1495 = _t1496 end - _t894 = _t895 + _t1494 = _t1495 end - _t893 = _t894 + _t1493 = _t1494 end - _t892 = _t893 + _t1492 = _t1493 end - _t891 = _t892 + _t1491 = _t1492 end - _t890 = _t891 + _t1490 = _t1491 end - _t889 = _t890 + _t1489 = _t1490 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 + _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 prediction451 == 11 - _t916 = parse_rel_atom(parser) - rel_atom463 = _t916 - _t917 = Proto.Formula(formula_type=OneOf(:rel_atom, rel_atom463)) - _t915 = _t917 + 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 prediction451 == 10 - _t919 = parse_primitive(parser) - primitive462 = _t919 - _t920 = Proto.Formula(formula_type=OneOf(:primitive, primitive462)) - _t918 = _t920 + 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 prediction451 == 9 - _t922 = parse_pragma(parser) - pragma461 = _t922 - _t923 = Proto.Formula(formula_type=OneOf(:pragma, pragma461)) - _t921 = _t923 + 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 prediction451 == 8 - _t925 = parse_atom(parser) - atom460 = _t925 - _t926 = Proto.Formula(formula_type=OneOf(:atom, atom460)) - _t924 = _t926 + 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 prediction451 == 7 - _t928 = parse_ffi(parser) - ffi459 = _t928 - _t929 = Proto.Formula(formula_type=OneOf(:ffi, ffi459)) - _t927 = _t929 + 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 prediction451 == 6 - _t931 = parse_not(parser) - not458 = _t931 - _t932 = Proto.Formula(formula_type=OneOf(:not, not458)) - _t930 = _t932 + 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 prediction451 == 5 - _t934 = parse_disjunction(parser) - disjunction457 = _t934 - _t935 = Proto.Formula(formula_type=OneOf(:disjunction, disjunction457)) - _t933 = _t935 + 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 prediction451 == 4 - _t937 = parse_conjunction(parser) - conjunction456 = _t937 - _t938 = Proto.Formula(formula_type=OneOf(:conjunction, conjunction456)) - _t936 = _t938 + 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 prediction451 == 3 - _t940 = parse_reduce(parser) - reduce455 = _t940 - _t941 = Proto.Formula(formula_type=OneOf(:reduce, reduce455)) - _t939 = _t941 + 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 prediction451 == 2 - _t943 = parse_exists(parser) - exists454 = _t943 - _t944 = Proto.Formula(formula_type=OneOf(:exists, exists454)) - _t942 = _t944 + 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 prediction451 == 1 - _t946 = parse_false(parser) - false453 = _t946 - _t947 = Proto.Formula(formula_type=OneOf(:disjunction, false453)) - _t945 = _t947 + 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 prediction451 == 0 - _t949 = parse_true(parser) - true452 = _t949 - _t950 = Proto.Formula(formula_type=OneOf(:conjunction, true452)) - _t948 = _t950 + 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 - _t945 = _t948 + _t1545 = _t1548 end - _t942 = _t945 + _t1542 = _t1545 end - _t939 = _t942 + _t1539 = _t1542 end - _t936 = _t939 + _t1536 = _t1539 end - _t933 = _t936 + _t1533 = _t1536 end - _t930 = _t933 + _t1530 = _t1533 end - _t927 = _t930 + _t1527 = _t1530 end - _t924 = _t927 + _t1524 = _t1527 end - _t921 = _t924 + _t1521 = _t1524 end - _t918 = _t921 + _t1518 = _t1521 end - _t915 = _t918 + _t1515 = _t1518 end - _t912 = _t915 + _t1512 = _t1515 end - return _t912 + result800 = _t1512 + record_span!(parser, span_start799) + return result800 end function parse_true(parser::ParserState)::Proto.Conjunction + span_start801 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "true") consume_literal!(parser, ")") - _t951 = Proto.Conjunction(args=Proto.Formula[]) - return _t951 + _t1551 = Proto.Conjunction(args=Proto.Formula[]) + result802 = _t1551 + record_span!(parser, span_start801) + return result802 end function parse_false(parser::ParserState)::Proto.Disjunction + span_start803 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "false") consume_literal!(parser, ")") - _t952 = Proto.Disjunction(args=Proto.Formula[]) - return _t952 + _t1552 = Proto.Disjunction(args=Proto.Formula[]) + result804 = _t1552 + record_span!(parser, span_start803) + return result804 end function parse_exists(parser::ParserState)::Proto.Exists + span_start807 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "exists") - _t953 = parse_bindings(parser) - bindings465 = _t953 - _t954 = parse_formula(parser) - formula466 = _t954 + _t1553 = parse_bindings(parser) + bindings805 = _t1553 + _t1554 = parse_formula(parser) + formula806 = _t1554 consume_literal!(parser, ")") - _t955 = Proto.Abstraction(vars=vcat(bindings465[1], !isnothing(bindings465[2]) ? bindings465[2] : []), value=formula466) - _t956 = Proto.Exists(body=_t955) - return _t956 + _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_start812 = 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) + _t1557 = parse_abstraction(parser) + abstraction809 = _t1557 + pop_path!(parser) + push_path!(parser, 2) + _t1558 = parse_abstraction(parser) + abstraction_3810 = _t1558 + pop_path!(parser) + push_path!(parser, 3) + _t1559 = parse_terms(parser) + terms811 = _t1559 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start822 = 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)) + 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 - terms473 = xs470 + terms817 = xs818 consume_literal!(parser, ")") - return terms473 + result823 = terms817 + record_span!(parser, span_start822) + return result823 end function parse_term(parser::ParserState)::Proto.Term + span_start827 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t962 = 1 + _t1562 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t963 = 1 + _t1563 = 1 else if match_lookahead_literal(parser, "false", 0) - _t964 = 1 + _t1564 = 1 else if match_lookahead_literal(parser, "(", 0) - _t965 = 1 + _t1565 = 1 else if match_lookahead_terminal(parser, "UINT128", 0) - _t966 = 1 + _t1566 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t967 = 0 + _t1567 = 0 else if match_lookahead_terminal(parser, "STRING", 0) - _t968 = 1 + _t1568 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t969 = 1 + _t1569 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t970 = 1 + _t1570 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t971 = 1 + _t1571 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t972 = 1 + _t1572 = 1 else - _t972 = -1 + _t1572 = -1 end - _t971 = _t972 + _t1571 = _t1572 end - _t970 = _t971 + _t1570 = _t1571 end - _t969 = _t970 + _t1569 = _t1570 end - _t968 = _t969 + _t1568 = _t1569 end - _t967 = _t968 + _t1567 = _t1568 end - _t966 = _t967 + _t1566 = _t1567 end - _t965 = _t966 + _t1565 = _t1566 end - _t964 = _t965 + _t1564 = _t1565 end - _t963 = _t964 + _t1563 = _t1564 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 + _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 prediction474 == 0 - _t977 = parse_var(parser) - var475 = _t977 - _t978 = Proto.Term(term_type=OneOf(:var, var475)) - _t976 = _t978 + 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 - _t973 = _t976 + _t1573 = _t1576 end - return _t973 + result828 = _t1573 + record_span!(parser, span_start827) + return result828 end function parse_var(parser::ParserState)::Proto.Var - symbol477 = consume_terminal!(parser, "SYMBOL") - _t979 = Proto.Var(name=symbol477) - return _t979 + 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 - _t980 = parse_value(parser) - value478 = _t980 - return value478 + 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_start843 = 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) + 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!(xs839, item842) + idx841 = (idx841 + 1) + cond840 = match_lookahead_literal(parser, "(", 0) + end + formulas838 = xs839 + pop_path!(parser) + consume_literal!(parser, ")") + _t1582 = Proto.Conjunction(args=formulas838) + result844 = _t1582 + record_span!(parser, span_start843) + return result844 end function parse_disjunction(parser::ParserState)::Proto.Disjunction + span_start853 = 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) + 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!(xs849, item852) + idx851 = (idx851 + 1) + cond850 = match_lookahead_literal(parser, "(", 0) + end + formulas848 = xs849 + pop_path!(parser) + consume_literal!(parser, ")") + _t1584 = Proto.Disjunction(args=formulas848) + result854 = _t1584 + record_span!(parser, span_start853) + return result854 end function parse_not(parser::ParserState)::Proto.Not + span_start856 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "not") - _t985 = parse_formula(parser) - formula487 = _t985 + push_path!(parser, 1) + _t1585 = parse_formula(parser) + formula855 = _t1585 + pop_path!(parser) consume_literal!(parser, ")") - _t986 = Proto.Not(arg=formula487) - return _t986 + _t1586 = Proto.Not(arg=formula855) + result857 = _t1586 + record_span!(parser, span_start856) + return result857 end function parse_ffi(parser::ParserState)::Proto.FFI + span_start861 = 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) + _t1587 = parse_name(parser) + name858 = _t1587 + pop_path!(parser) + push_path!(parser, 2) + _t1588 = parse_ffi_args(parser) + ffi_args859 = _t1588 + pop_path!(parser) + push_path!(parser, 3) + _t1589 = parse_terms(parser) + terms860 = _t1589 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start864 = span_start(parser) consume_literal!(parser, ":") - symbol491 = consume_terminal!(parser, "SYMBOL") - return symbol491 + 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_start874 = 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) + 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 - abstractions495 = xs492 + abstractions869 = xs870 consume_literal!(parser, ")") - return abstractions495 + result875 = abstractions869 + record_span!(parser, span_start874) + return result875 end function parse_atom(parser::ParserState)::Proto.Atom + span_start885 = 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) + _t1592 = parse_relation_id(parser) + relation_id876 = _t1592 + pop_path!(parser) + push_path!(parser, 2) + 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!(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 + terms880 = xs881 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start896 = 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) + _t1595 = parse_name(parser) + name887 = _t1595 + pop_path!(parser) + push_path!(parser, 2) + 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!(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 + terms891 = xs892 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start917 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "primitive", 1) - _t999 = 9 + _t1599 = 9 else if match_lookahead_literal(parser, ">=", 1) - _t1000 = 4 + _t1600 = 4 else if match_lookahead_literal(parser, ">", 1) - _t1001 = 3 + _t1601 = 3 else if match_lookahead_literal(parser, "=", 1) - _t1002 = 0 + _t1602 = 0 else if match_lookahead_literal(parser, "<=", 1) - _t1003 = 2 + _t1603 = 2 else if match_lookahead_literal(parser, "<", 1) - _t1004 = 1 + _t1604 = 1 else if match_lookahead_literal(parser, "/", 1) - _t1005 = 8 + _t1605 = 8 else if match_lookahead_literal(parser, "-", 1) - _t1006 = 6 + _t1606 = 6 else if match_lookahead_literal(parser, "+", 1) - _t1007 = 5 + _t1607 = 5 else if match_lookahead_literal(parser, "*", 1) - _t1008 = 7 + _t1608 = 7 else - _t1008 = -1 + _t1608 = -1 end - _t1007 = _t1008 + _t1607 = _t1608 end - _t1006 = _t1007 + _t1606 = _t1607 end - _t1005 = _t1006 + _t1605 = _t1606 end - _t1004 = _t1005 + _t1604 = _t1605 end - _t1003 = _t1004 + _t1603 = _t1604 end - _t1002 = _t1003 + _t1602 = _t1603 end - _t1001 = _t1002 + _t1601 = _t1602 end - _t1000 = _t1001 + _t1600 = _t1601 end - _t999 = _t1000 + _t1599 = _t1600 end - _t998 = _t999 + _t1598 = _t1599 else - _t998 = -1 + _t1598 = -1 end - prediction506 = _t998 - if prediction506 == 9 + prediction898 = _t1598 + if prediction898 == 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) + _t1610 = parse_name(parser) + name908 = _t1610 + pop_path!(parser) + push_path!(parser, 2) + 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!(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_terms520 = xs517 + rel_terms912 = xs913 + pop_path!(parser) consume_literal!(parser, ")") - _t1012 = Proto.Primitive(name=name516, terms=rel_terms520) - _t1009 = _t1012 + _t1612 = Proto.Primitive(name=name908, terms=rel_terms912) + _t1609 = _t1612 else - if prediction506 == 8 - _t1014 = parse_divide(parser) - divide515 = _t1014 - _t1013 = divide515 + if prediction898 == 8 + _t1614 = parse_divide(parser) + divide907 = _t1614 + _t1613 = divide907 else - if prediction506 == 7 - _t1016 = parse_multiply(parser) - multiply514 = _t1016 - _t1015 = multiply514 + if prediction898 == 7 + _t1616 = parse_multiply(parser) + multiply906 = _t1616 + _t1615 = multiply906 else - if prediction506 == 6 - _t1018 = parse_minus(parser) - minus513 = _t1018 - _t1017 = minus513 + if prediction898 == 6 + _t1618 = parse_minus(parser) + minus905 = _t1618 + _t1617 = minus905 else - if prediction506 == 5 - _t1020 = parse_add(parser) - add512 = _t1020 - _t1019 = add512 + if prediction898 == 5 + _t1620 = parse_add(parser) + add904 = _t1620 + _t1619 = add904 else - if prediction506 == 4 - _t1022 = parse_gt_eq(parser) - gt_eq511 = _t1022 - _t1021 = gt_eq511 + if prediction898 == 4 + _t1622 = parse_gt_eq(parser) + gt_eq903 = _t1622 + _t1621 = gt_eq903 else - if prediction506 == 3 - _t1024 = parse_gt(parser) - gt510 = _t1024 - _t1023 = gt510 + if prediction898 == 3 + _t1624 = parse_gt(parser) + gt902 = _t1624 + _t1623 = gt902 else - if prediction506 == 2 - _t1026 = parse_lt_eq(parser) - lt_eq509 = _t1026 - _t1025 = lt_eq509 + if prediction898 == 2 + _t1626 = parse_lt_eq(parser) + lt_eq901 = _t1626 + _t1625 = lt_eq901 else - if prediction506 == 1 - _t1028 = parse_lt(parser) - lt508 = _t1028 - _t1027 = lt508 + if prediction898 == 1 + _t1628 = parse_lt(parser) + lt900 = _t1628 + _t1627 = lt900 else - if prediction506 == 0 - _t1030 = parse_eq(parser) - eq507 = _t1030 - _t1029 = eq507 + if prediction898 == 0 + _t1630 = parse_eq(parser) + eq899 = _t1630 + _t1629 = eq899 else throw(ParseError("Unexpected token in primitive" * ": " * string(lookahead(parser, 0)))) end - _t1027 = _t1029 + _t1627 = _t1629 end - _t1025 = _t1027 + _t1625 = _t1627 end - _t1023 = _t1025 + _t1623 = _t1625 end - _t1021 = _t1023 + _t1621 = _t1623 end - _t1019 = _t1021 + _t1619 = _t1621 end - _t1017 = _t1019 + _t1617 = _t1619 end - _t1015 = _t1017 + _t1615 = _t1617 end - _t1013 = _t1015 + _t1613 = _t1615 end - _t1009 = _t1013 + _t1609 = _t1613 end - return _t1009 + result918 = _t1609 + record_span!(parser, span_start917) + return result918 end function parse_eq(parser::ParserState)::Proto.Primitive + span_start921 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "=") - _t1031 = parse_term(parser) - term521 = _t1031 - _t1032 = parse_term(parser) - term_3522 = _t1032 + _t1631 = parse_term(parser) + term919 = _t1631 + _t1632 = parse_term(parser) + term_3920 = _t1632 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 + _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_start925 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<") - _t1036 = parse_term(parser) - term523 = _t1036 - _t1037 = parse_term(parser) - term_3524 = _t1037 + _t1636 = parse_term(parser) + term923 = _t1636 + _t1637 = parse_term(parser) + term_3924 = _t1637 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 + _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_start929 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "<=") - _t1041 = parse_term(parser) - term525 = _t1041 - _t1042 = parse_term(parser) - term_3526 = _t1042 + _t1641 = parse_term(parser) + term927 = _t1641 + _t1642 = parse_term(parser) + term_3928 = _t1642 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 + _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_start933 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">") - _t1046 = parse_term(parser) - term527 = _t1046 - _t1047 = parse_term(parser) - term_3528 = _t1047 + _t1646 = parse_term(parser) + term931 = _t1646 + _t1647 = parse_term(parser) + term_3932 = _t1647 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 + _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_start937 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, ">=") - _t1051 = parse_term(parser) - term529 = _t1051 - _t1052 = parse_term(parser) - term_3530 = _t1052 + _t1651 = parse_term(parser) + term935 = _t1651 + _t1652 = parse_term(parser) + term_3936 = _t1652 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 + _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_start942 = 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 + _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_start947 = 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 + _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_start952 = 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 + _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_start957 = 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 + _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_start962 = span_start(parser) if match_lookahead_literal(parser, "true", 0) - _t1084 = 1 + _t1684 = 1 else if match_lookahead_literal(parser, "missing", 0) - _t1085 = 1 + _t1685 = 1 else if match_lookahead_literal(parser, "false", 0) - _t1086 = 1 + _t1686 = 1 else if match_lookahead_literal(parser, "(", 0) - _t1087 = 1 + _t1687 = 1 else if match_lookahead_literal(parser, "#", 0) - _t1088 = 0 + _t1688 = 0 else if match_lookahead_terminal(parser, "UINT128", 0) - _t1089 = 1 + _t1689 = 1 else if match_lookahead_terminal(parser, "SYMBOL", 0) - _t1090 = 1 + _t1690 = 1 else if match_lookahead_terminal(parser, "STRING", 0) - _t1091 = 1 + _t1691 = 1 else if match_lookahead_terminal(parser, "INT128", 0) - _t1092 = 1 + _t1692 = 1 else if match_lookahead_terminal(parser, "INT", 0) - _t1093 = 1 + _t1693 = 1 else if match_lookahead_terminal(parser, "FLOAT", 0) - _t1094 = 1 + _t1694 = 1 else if match_lookahead_terminal(parser, "DECIMAL", 0) - _t1095 = 1 + _t1695 = 1 else - _t1095 = -1 + _t1695 = -1 end - _t1094 = _t1095 + _t1694 = _t1695 end - _t1093 = _t1094 + _t1693 = _t1694 end - _t1092 = _t1093 + _t1692 = _t1693 end - _t1091 = _t1092 + _t1691 = _t1692 end - _t1090 = _t1091 + _t1690 = _t1691 end - _t1089 = _t1090 + _t1689 = _t1690 end - _t1088 = _t1089 + _t1688 = _t1689 end - _t1087 = _t1088 + _t1687 = _t1688 end - _t1086 = _t1087 + _t1686 = _t1687 end - _t1085 = _t1086 + _t1685 = _t1686 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 + _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 prediction543 == 0 - _t1100 = parse_specialized_value(parser) - specialized_value544 = _t1100 - _t1101 = Proto.RelTerm(rel_term_type=OneOf(:specialized_value, specialized_value544)) - _t1099 = _t1101 + 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 - _t1096 = _t1099 + _t1696 = _t1699 end - return _t1096 + result963 = _t1696 + record_span!(parser, span_start962) + return result963 end function parse_specialized_value(parser::ParserState)::Proto.Value + span_start965 = span_start(parser) consume_literal!(parser, "#") - _t1102 = parse_value(parser) - value546 = _t1102 - return value546 + _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_start976 = 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) + _t1703 = parse_name(parser) + name967 = _t1703 + pop_path!(parser) + push_path!(parser, 2) + 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!(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_terms971 = xs972 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start980 = 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) + _t1706 = parse_term(parser) + term978 = _t1706 + pop_path!(parser) + push_path!(parser, 3) + _t1707 = parse_term(parser) + term_3979 = _t1707 + pop_path!(parser) consume_literal!(parser, ")") - _t1108 = Proto.Cast(input=term552, result=term_3553) - return _t1108 + _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_start990 = 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) + 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 - attributes557 = xs554 + attributes985 = xs986 consume_literal!(parser, ")") - return attributes557 + result991 = attributes985 + record_span!(parser, span_start990) + return result991 end function parse_attribute(parser::ParserState)::Proto.Attribute + span_start1001 = 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) + _t1710 = parse_name(parser) + name992 = _t1710 + pop_path!(parser) + push_path!(parser, 2) + 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!(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 + values996 = xs997 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start1012 = 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) + 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!(xs1007, item1010) + idx1009 = (idx1009 + 1) + cond1008 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + end + relation_ids1006 = xs1007 + pop_path!(parser) + push_path!(parser, 2) + _t1714 = parse_script(parser) + script1011 = _t1714 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start1022 = 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) + 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!(xs1018, item1021) + idx1020 = (idx1020 + 1) + cond1019 = match_lookahead_literal(parser, "(", 0) + end + constructs1017 = xs1018 + pop_path!(parser) + consume_literal!(parser, ")") + _t1717 = Proto.Script(constructs=constructs1017) + result1023 = _t1717 + record_span!(parser, span_start1022) + return result1023 end function parse_construct(parser::ParserState)::Proto.Construct + span_start1027 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1119 = 1 + _t1719 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1120 = 1 + _t1720 = 1 else if match_lookahead_literal(parser, "monoid", 1) - _t1121 = 1 + _t1721 = 1 else if match_lookahead_literal(parser, "loop", 1) - _t1122 = 0 + _t1722 = 0 else if match_lookahead_literal(parser, "break", 1) - _t1123 = 1 + _t1723 = 1 else if match_lookahead_literal(parser, "assign", 1) - _t1124 = 1 + _t1724 = 1 else - _t1124 = -1 + _t1724 = -1 end - _t1123 = _t1124 + _t1723 = _t1724 end - _t1122 = _t1123 + _t1722 = _t1723 end - _t1121 = _t1122 + _t1721 = _t1722 end - _t1120 = _t1121 + _t1720 = _t1721 end - _t1119 = _t1120 + _t1719 = _t1720 end - _t1118 = _t1119 + _t1718 = _t1719 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 + _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 prediction572 == 0 - _t1129 = parse_loop(parser) - loop573 = _t1129 - _t1130 = Proto.Construct(construct_type=OneOf(:loop, loop573)) - _t1128 = _t1130 + 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 - _t1125 = _t1128 + _t1725 = _t1728 end - return _t1125 + result1028 = _t1725 + record_span!(parser, span_start1027) + return result1028 end function parse_loop(parser::ParserState)::Proto.Loop + span_start1031 = 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) + _t1731 = parse_init(parser) + init1029 = _t1731 + pop_path!(parser) + push_path!(parser, 2) + _t1732 = parse_script(parser) + script1030 = _t1732 + pop_path!(parser) consume_literal!(parser, ")") - _t1133 = Proto.Loop(init=init575, body=script576) - return _t1133 + _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_start1041 = 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) + 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 - instructions580 = xs577 + instructions1036 = xs1037 consume_literal!(parser, ")") - return instructions580 + result1042 = instructions1036 + record_span!(parser, span_start1041) + return result1042 end function parse_instruction(parser::ParserState)::Proto.Instruction + span_start1049 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "upsert", 1) - _t1136 = 1 + _t1736 = 1 else if match_lookahead_literal(parser, "monus", 1) - _t1137 = 4 + _t1737 = 4 else if match_lookahead_literal(parser, "monoid", 1) - _t1138 = 3 + _t1738 = 3 else if match_lookahead_literal(parser, "break", 1) - _t1139 = 2 + _t1739 = 2 else if match_lookahead_literal(parser, "assign", 1) - _t1140 = 0 + _t1740 = 0 else - _t1140 = -1 + _t1740 = -1 end - _t1139 = _t1140 + _t1739 = _t1740 end - _t1138 = _t1139 + _t1738 = _t1739 end - _t1137 = _t1138 + _t1737 = _t1738 end - _t1136 = _t1137 + _t1736 = _t1737 end - _t1135 = _t1136 + _t1735 = _t1736 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 + _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 prediction581 == 3 - _t1145 = parse_monoid_def(parser) - monoid_def585 = _t1145 - _t1146 = Proto.Instruction(instr_type=OneOf(:monoid_def, monoid_def585)) - _t1144 = _t1146 + 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 prediction581 == 2 - _t1148 = parse_break(parser) - break584 = _t1148 - _t1149 = Proto.Instruction(instr_type=OneOf(:var"#break", break584)) - _t1147 = _t1149 + 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 prediction581 == 1 - _t1151 = parse_upsert(parser) - upsert583 = _t1151 - _t1152 = Proto.Instruction(instr_type=OneOf(:upsert, upsert583)) - _t1150 = _t1152 + 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 prediction581 == 0 - _t1154 = parse_assign(parser) - assign582 = _t1154 - _t1155 = Proto.Instruction(instr_type=OneOf(:assign, assign582)) - _t1153 = _t1155 + 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 - _t1150 = _t1153 + _t1750 = _t1753 end - _t1147 = _t1150 + _t1747 = _t1750 end - _t1144 = _t1147 + _t1744 = _t1747 end - _t1141 = _t1144 + _t1741 = _t1744 end - return _t1141 + result1050 = _t1741 + record_span!(parser, span_start1049) + return result1050 end function parse_assign(parser::ParserState)::Proto.Assign + span_start1054 = 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) + _t1756 = parse_relation_id(parser) + relation_id1051 = _t1756 + pop_path!(parser) + push_path!(parser, 2) + _t1757 = parse_abstraction(parser) + abstraction1052 = _t1757 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1159 = parse_attrs(parser) - _t1158 = _t1159 + _t1759 = parse_attrs(parser) + _t1758 = _t1759 else - _t1158 = nothing + _t1758 = nothing end - attrs589 = _t1158 + attrs1053 = _t1758 + pop_path!(parser) consume_literal!(parser, ")") - _t1160 = Proto.Assign(name=relation_id587, body=abstraction588, attrs=(!isnothing(attrs589) ? attrs589 : Proto.Attribute[])) - return _t1160 + _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_start1059 = 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) + _t1761 = parse_relation_id(parser) + relation_id1056 = _t1761 + pop_path!(parser) + _t1762 = parse_abstraction_with_arity(parser) + abstraction_with_arity1057 = _t1762 + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1164 = parse_attrs(parser) - _t1163 = _t1164 + _t1764 = parse_attrs(parser) + _t1763 = _t1764 else - _t1163 = nothing + _t1763 = nothing end - attrs592 = _t1163 + attrs1058 = _t1763 + 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 + _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_start1063 = span_start(parser) consume_literal!(parser, "(") - _t1166 = parse_bindings(parser) - bindings593 = _t1166 - _t1167 = parse_formula(parser) - formula594 = _t1167 + _t1766 = parse_bindings(parser) + bindings1061 = _t1766 + _t1767 = parse_formula(parser) + formula1062 = _t1767 consume_literal!(parser, ")") - _t1168 = Proto.Abstraction(vars=vcat(bindings593[1], !isnothing(bindings593[2]) ? bindings593[2] : []), value=formula594) - return (_t1168, length(bindings593[2]),) + _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_start1068 = 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) + _t1769 = parse_relation_id(parser) + relation_id1065 = _t1769 + pop_path!(parser) + push_path!(parser, 2) + _t1770 = parse_abstraction(parser) + abstraction1066 = _t1770 + pop_path!(parser) + push_path!(parser, 3) if match_lookahead_literal(parser, "(", 0) - _t1172 = parse_attrs(parser) - _t1171 = _t1172 + _t1772 = parse_attrs(parser) + _t1771 = _t1772 else - _t1171 = nothing + _t1771 = nothing end - attrs597 = _t1171 + attrs1067 = _t1771 + pop_path!(parser) consume_literal!(parser, ")") - _t1173 = Proto.Break(name=relation_id595, body=abstraction596, attrs=(!isnothing(attrs597) ? attrs597 : Proto.Attribute[])) - return _t1173 + _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_start1074 = 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) + _t1774 = parse_monoid(parser) + monoid1070 = _t1774 + pop_path!(parser) + push_path!(parser, 2) + _t1775 = parse_relation_id(parser) + relation_id1071 = _t1775 + pop_path!(parser) + _t1776 = parse_abstraction_with_arity(parser) + abstraction_with_arity1072 = _t1776 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1178 = parse_attrs(parser) - _t1177 = _t1178 + _t1778 = parse_attrs(parser) + _t1777 = _t1778 else - _t1177 = nothing + _t1777 = nothing end - attrs601 = _t1177 + attrs1073 = _t1777 + 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 + _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_start1081 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "sum", 1) - _t1181 = 3 + _t1781 = 3 else if match_lookahead_literal(parser, "or", 1) - _t1182 = 0 + _t1782 = 0 else if match_lookahead_literal(parser, "min", 1) - _t1183 = 1 + _t1783 = 1 else if match_lookahead_literal(parser, "max", 1) - _t1184 = 2 + _t1784 = 2 else - _t1184 = -1 + _t1784 = -1 end - _t1183 = _t1184 + _t1783 = _t1784 end - _t1182 = _t1183 + _t1782 = _t1783 end - _t1181 = _t1182 + _t1781 = _t1782 end - _t1180 = _t1181 + _t1780 = _t1781 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 + _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 prediction602 == 2 - _t1189 = parse_max_monoid(parser) - max_monoid605 = _t1189 - _t1190 = Proto.Monoid(value=OneOf(:max_monoid, max_monoid605)) - _t1188 = _t1190 + 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 prediction602 == 1 - _t1192 = parse_min_monoid(parser) - min_monoid604 = _t1192 - _t1193 = Proto.Monoid(value=OneOf(:min_monoid, min_monoid604)) - _t1191 = _t1193 + 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 prediction602 == 0 - _t1195 = parse_or_monoid(parser) - or_monoid603 = _t1195 - _t1196 = Proto.Monoid(value=OneOf(:or_monoid, or_monoid603)) - _t1194 = _t1196 + 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 - _t1191 = _t1194 + _t1791 = _t1794 end - _t1188 = _t1191 + _t1788 = _t1791 end - _t1185 = _t1188 + _t1785 = _t1788 end - return _t1185 + result1082 = _t1785 + record_span!(parser, span_start1081) + return result1082 end function parse_or_monoid(parser::ParserState)::Proto.OrMonoid + span_start1083 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "or") consume_literal!(parser, ")") - _t1197 = Proto.OrMonoid() - return _t1197 + _t1797 = Proto.OrMonoid() + result1084 = _t1797 + record_span!(parser, span_start1083) + return result1084 end function parse_min_monoid(parser::ParserState)::Proto.MinMonoid + span_start1086 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "min") - _t1198 = parse_type(parser) - type607 = _t1198 + push_path!(parser, 1) + _t1798 = parse_type(parser) + type1085 = _t1798 + pop_path!(parser) consume_literal!(parser, ")") - _t1199 = Proto.MinMonoid(var"#type"=type607) - return _t1199 + _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_start1089 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "max") - _t1200 = parse_type(parser) - type608 = _t1200 + push_path!(parser, 1) + _t1800 = parse_type(parser) + type1088 = _t1800 + pop_path!(parser) consume_literal!(parser, ")") - _t1201 = Proto.MaxMonoid(var"#type"=type608) - return _t1201 + _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_start1092 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "sum") - _t1202 = parse_type(parser) - type609 = _t1202 + push_path!(parser, 1) + _t1802 = parse_type(parser) + type1091 = _t1802 + pop_path!(parser) consume_literal!(parser, ")") - _t1203 = Proto.SumMonoid(var"#type"=type609) - return _t1203 + _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_start1098 = 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) + _t1804 = parse_monoid(parser) + monoid1094 = _t1804 + pop_path!(parser) + push_path!(parser, 2) + _t1805 = parse_relation_id(parser) + relation_id1095 = _t1805 + pop_path!(parser) + _t1806 = parse_abstraction_with_arity(parser) + abstraction_with_arity1096 = _t1806 + push_path!(parser, 4) if match_lookahead_literal(parser, "(", 0) - _t1208 = parse_attrs(parser) - _t1207 = _t1208 + _t1808 = parse_attrs(parser) + _t1807 = _t1808 else - _t1207 = nothing + _t1807 = nothing end - attrs613 = _t1207 + attrs1097 = _t1807 + 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 + _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_start1104 = 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) + _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_start1114 = 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) + 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 - vars621 = xs618 + vars1109 = xs1110 consume_literal!(parser, ")") - return vars621 + result1115 = vars1109 + record_span!(parser, span_start1114) + return result1115 end function parse_functional_dependency_values(parser::ParserState)::Vector{Proto.Var} + span_start1124 = 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) + 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 - vars625 = xs622 + vars1119 = xs1120 consume_literal!(parser, ")") - return vars625 + result1125 = vars1119 + record_span!(parser, span_start1124) + return result1125 end function parse_data(parser::ParserState)::Proto.Data + span_start1130 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "rel_edb", 1) - _t1219 = 0 + _t1819 = 0 else if match_lookahead_literal(parser, "csv_data", 1) - _t1220 = 2 + _t1820 = 2 else if match_lookahead_literal(parser, "betree_relation", 1) - _t1221 = 1 + _t1821 = 1 else - _t1221 = -1 + _t1821 = -1 end - _t1220 = _t1221 + _t1820 = _t1821 end - _t1219 = _t1220 + _t1819 = _t1820 end - _t1218 = _t1219 + _t1818 = _t1819 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 + _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 prediction626 == 1 - _t1226 = parse_betree_relation(parser) - betree_relation628 = _t1226 - _t1227 = Proto.Data(data_type=OneOf(:betree_relation, betree_relation628)) - _t1225 = _t1227 + 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 prediction626 == 0 - _t1229 = parse_rel_edb(parser) - rel_edb627 = _t1229 - _t1230 = Proto.Data(data_type=OneOf(:rel_edb, rel_edb627)) - _t1228 = _t1230 + 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 - _t1225 = _t1228 + _t1825 = _t1828 end - _t1222 = _t1225 + _t1822 = _t1825 end - return _t1222 + result1131 = _t1822 + record_span!(parser, span_start1130) + return result1131 end function parse_rel_edb(parser::ParserState)::Proto.RelEDB + span_start1135 = 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) + _t1831 = parse_relation_id(parser) + relation_id1132 = _t1831 + pop_path!(parser) + push_path!(parser, 2) + _t1832 = parse_rel_edb_path(parser) + rel_edb_path1133 = _t1832 + pop_path!(parser) + push_path!(parser, 3) + _t1833 = parse_rel_edb_types(parser) + rel_edb_types1134 = _t1833 + pop_path!(parser) + consume_literal!(parser, ")") + _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_start1145 = 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 + 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, "]") - return strings636 + result1146 = strings1140 + record_span!(parser, span_start1145) + return result1146 end function parse_rel_edb_types(parser::ParserState)::Vector{Proto.var"#Type"} + span_start1155 = 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 + 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, "]") - return types640 + result1156 = types1150 + record_span!(parser, span_start1155) + return result1156 end function parse_betree_relation(parser::ParserState)::Proto.BeTreeRelation + span_start1159 = 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) + _t1836 = parse_relation_id(parser) + relation_id1157 = _t1836 + pop_path!(parser) + push_path!(parser, 2) + _t1837 = parse_betree_info(parser) + betree_info1158 = _t1837 + pop_path!(parser) consume_literal!(parser, ")") - _t1238 = Proto.BeTreeRelation(name=relation_id641, relation_info=betree_info642) - return _t1238 + _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_start1164 = 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 + _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, ")") - _t1242 = construct_betree_info(parser, betree_info_key_types643, betree_info_value_types644, config_dict645) - return _t1242 + _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_start1174 = 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)) + 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 - types649 = xs646 + types1169 = xs1170 consume_literal!(parser, ")") - return types649 + result1175 = types1169 + record_span!(parser, span_start1174) + return result1175 end function parse_betree_info_value_types(parser::ParserState)::Vector{Proto.var"#Type"} + span_start1184 = 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)) + 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 - types653 = xs650 + types1179 = xs1180 consume_literal!(parser, ")") - return types653 + result1185 = types1179 + record_span!(parser, span_start1184) + return result1185 end function parse_csv_data(parser::ParserState)::Proto.CSVData + span_start1190 = 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) + _t1845 = parse_csvlocator(parser) + csvlocator1186 = _t1845 + pop_path!(parser) + push_path!(parser, 2) + _t1846 = parse_csv_config(parser) + csv_config1187 = _t1846 + pop_path!(parser) + push_path!(parser, 3) + _t1847 = parse_csv_columns(parser) + csv_columns1188 = _t1847 + pop_path!(parser) + push_path!(parser, 4) + _t1848 = parse_csv_asof(parser) + csv_asof1189 = _t1848 + pop_path!(parser) + consume_literal!(parser, ")") + _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_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)) - _t1251 = parse_csv_locator_paths(parser) - _t1250 = _t1251 + _t1851 = parse_csv_locator_paths(parser) + _t1850 = _t1851 else - _t1250 = nothing + _t1850 = nothing end - csv_locator_paths658 = _t1250 + csv_locator_paths1192 = _t1850 + pop_path!(parser) + push_path!(parser, 2) if match_lookahead_literal(parser, "(", 0) - _t1253 = parse_csv_locator_inline_data(parser) - _t1252 = _t1253 + _t1853 = parse_csv_locator_inline_data(parser) + _t1852 = _t1853 else - _t1252 = nothing + _t1852 = nothing end - csv_locator_inline_data659 = _t1252 + csv_locator_inline_data1193 = _t1852 + 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 + _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_start1204 = 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) + 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 - strings663 = xs660 + strings1199 = xs1200 consume_literal!(parser, ")") - return strings663 + result1205 = strings1199 + record_span!(parser, span_start1204) + return result1205 end function parse_csv_locator_inline_data(parser::ParserState)::String + span_start1207 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "inline_data") - string664 = consume_terminal!(parser, "STRING") + string1206 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string664 + result1208 = string1206 + record_span!(parser, span_start1207) + return result1208 end function parse_csv_config(parser::ParserState)::Proto.CSVConfig + span_start1210 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "csv_config") - _t1255 = parse_config_dict(parser) - config_dict665 = _t1255 + _t1855 = parse_config_dict(parser) + config_dict1209 = _t1855 consume_literal!(parser, ")") - _t1256 = construct_csv_config(parser, config_dict665) - return _t1256 + _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_start1220 = 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) + 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_columns669 = xs666 + csv_columns1215 = xs1216 consume_literal!(parser, ")") - return csv_columns669 + result1221 = csv_columns1215 + record_span!(parser, span_start1220) + return result1221 end function parse_csv_column(parser::ParserState)::Proto.CSVColumn + span_start1232 = 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) + string1222 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1858 = parse_relation_id(parser) + relation_id1223 = _t1858 + 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) + 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!(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 + types1227 = xs1228 + pop_path!(parser) consume_literal!(parser, "]") consume_literal!(parser, ")") - _t1260 = Proto.CSVColumn(column_name=string670, target_id=relation_id671, types=types675) - return _t1260 + _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_start1235 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "asof") - string676 = consume_terminal!(parser, "STRING") + string1234 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string676 + result1236 = string1234 + record_span!(parser, span_start1235) + return result1236 end function parse_undefine(parser::ParserState)::Proto.Undefine + span_start1238 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "undefine") - _t1261 = parse_fragment_id(parser) - fragment_id677 = _t1261 + push_path!(parser, 1) + _t1861 = parse_fragment_id(parser) + fragment_id1237 = _t1861 + pop_path!(parser) consume_literal!(parser, ")") - _t1262 = Proto.Undefine(fragment_id=fragment_id677) - return _t1262 + _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_start1248 = 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) + 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!(xs1244, item1247) + idx1246 = (idx1246 + 1) + cond1245 = (match_lookahead_literal(parser, ":", 0) || match_lookahead_terminal(parser, "UINT128", 0)) + end + relation_ids1243 = xs1244 + pop_path!(parser) + consume_literal!(parser, ")") + _t1864 = Proto.Context(relations=relation_ids1243) + result1249 = _t1864 + record_span!(parser, span_start1248) + return result1249 end function parse_snapshot(parser::ParserState)::Proto.Snapshot + span_start1252 = 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) + _t1865 = parse_rel_edb_path(parser) + rel_edb_path1250 = _t1865 + pop_path!(parser) + push_path!(parser, 2) + _t1866 = parse_relation_id(parser) + relation_id1251 = _t1866 + pop_path!(parser) consume_literal!(parser, ")") - _t1267 = Proto.Snapshot(destination_path=rel_edb_path682, source_relation=relation_id683) - return _t1267 + _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_start1262 = 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) + 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 - reads687 = xs684 + reads1257 = xs1258 consume_literal!(parser, ")") - return reads687 + result1263 = reads1257 + record_span!(parser, span_start1262) + return result1263 end function parse_read(parser::ParserState)::Proto.Read + span_start1270 = span_start(parser) if match_lookahead_literal(parser, "(", 0) if match_lookahead_literal(parser, "what_if", 1) - _t1270 = 2 + _t1870 = 2 else if match_lookahead_literal(parser, "output", 1) - _t1271 = 1 + _t1871 = 1 else if match_lookahead_literal(parser, "export", 1) - _t1272 = 4 + _t1872 = 4 else if match_lookahead_literal(parser, "demand", 1) - _t1273 = 0 + _t1873 = 0 else if match_lookahead_literal(parser, "abort", 1) - _t1274 = 3 + _t1874 = 3 else - _t1274 = -1 + _t1874 = -1 end - _t1273 = _t1274 + _t1873 = _t1874 end - _t1272 = _t1273 + _t1872 = _t1873 end - _t1271 = _t1272 + _t1871 = _t1872 end - _t1270 = _t1271 + _t1870 = _t1871 end - _t1269 = _t1270 + _t1869 = _t1870 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 + _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 prediction688 == 3 - _t1279 = parse_abort(parser) - abort692 = _t1279 - _t1280 = Proto.Read(read_type=OneOf(:abort, abort692)) - _t1278 = _t1280 + 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 prediction688 == 2 - _t1282 = parse_what_if(parser) - what_if691 = _t1282 - _t1283 = Proto.Read(read_type=OneOf(:what_if, what_if691)) - _t1281 = _t1283 + 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 prediction688 == 1 - _t1285 = parse_output(parser) - output690 = _t1285 - _t1286 = Proto.Read(read_type=OneOf(:output, output690)) - _t1284 = _t1286 + 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 prediction688 == 0 - _t1288 = parse_demand(parser) - demand689 = _t1288 - _t1289 = Proto.Read(read_type=OneOf(:demand, demand689)) - _t1287 = _t1289 + 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 - _t1284 = _t1287 + _t1884 = _t1887 end - _t1281 = _t1284 + _t1881 = _t1884 end - _t1278 = _t1281 + _t1878 = _t1881 end - _t1275 = _t1278 + _t1875 = _t1878 end - return _t1275 + result1271 = _t1875 + record_span!(parser, span_start1270) + return result1271 end function parse_demand(parser::ParserState)::Proto.Demand + span_start1273 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "demand") - _t1290 = parse_relation_id(parser) - relation_id694 = _t1290 + push_path!(parser, 1) + _t1890 = parse_relation_id(parser) + relation_id1272 = _t1890 + pop_path!(parser) consume_literal!(parser, ")") - _t1291 = Proto.Demand(relation_id=relation_id694) - return _t1291 + _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_start1277 = 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) + _t1892 = parse_name(parser) + name1275 = _t1892 + pop_path!(parser) + push_path!(parser, 2) + _t1893 = parse_relation_id(parser) + relation_id1276 = _t1893 + pop_path!(parser) consume_literal!(parser, ")") - _t1294 = Proto.Output(name=name695, relation_id=relation_id696) - return _t1294 + _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_start1281 = 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) + _t1895 = parse_name(parser) + name1279 = _t1895 + pop_path!(parser) + push_path!(parser, 2) + _t1896 = parse_epoch(parser) + epoch1280 = _t1896 + pop_path!(parser) consume_literal!(parser, ")") - _t1297 = Proto.WhatIf(branch=name697, epoch=epoch698) - return _t1297 + _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_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)) - _t1299 = parse_name(parser) - _t1298 = _t1299 + _t1899 = parse_name(parser) + _t1898 = _t1899 else - _t1298 = nothing + _t1898 = nothing end - name699 = _t1298 - _t1300 = parse_relation_id(parser) - relation_id700 = _t1300 + name1283 = _t1898 + pop_path!(parser) + push_path!(parser, 2) + _t1900 = parse_relation_id(parser) + relation_id1284 = _t1900 + pop_path!(parser) consume_literal!(parser, ")") - _t1301 = Proto.Abort(name=(!isnothing(name699) ? name699 : "abort"), relation_id=relation_id700) - return _t1301 + _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_start1288 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "export") - _t1302 = parse_export_csv_config(parser) - export_csv_config701 = _t1302 + push_path!(parser, 1) + _t1902 = parse_export_csv_config(parser) + export_csv_config1287 = _t1902 + pop_path!(parser) consume_literal!(parser, ")") - _t1303 = Proto.Export(export_config=OneOf(:csv_config, export_csv_config701)) - return _t1303 + _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_start1293 = 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 + _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, ")") - _t1307 = export_csv_config(parser, export_csv_path702, export_csv_columns703, config_dict704) - return _t1307 + _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_start1296 = span_start(parser) consume_literal!(parser, "(") consume_literal!(parser, "path") - string705 = consume_terminal!(parser, "STRING") + string1295 = consume_terminal!(parser, "STRING") consume_literal!(parser, ")") - return string705 + result1297 = string1295 + record_span!(parser, span_start1296) + return result1297 end function parse_export_csv_columns(parser::ParserState)::Vector{Proto.ExportCSVColumn} + span_start1306 = 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) + 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_columns709 = xs706 + export_csv_columns1301 = xs1302 consume_literal!(parser, ")") - return export_csv_columns709 + result1307 = export_csv_columns1301 + record_span!(parser, span_start1306) + return result1307 end function parse_export_csv_column(parser::ParserState)::Proto.ExportCSVColumn + span_start1310 = 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) + string1308 = consume_terminal!(parser, "STRING") + pop_path!(parser) + push_path!(parser, 2) + _t1909 = parse_relation_id(parser) + relation_id1309 = _t1909 + pop_path!(parser) consume_literal!(parser, ")") - _t1310 = Proto.ExportCSVColumn(column_name=string710, column_data=relation_id711) - return _t1310 + _t1910 = Proto.ExportCSVColumn(column_name=string1308, column_data=relation_id1309) + result1311 = _t1910 + record_span!(parser, span_start1310) + return result1311 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 +4052,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/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/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..849f6768 --- /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 <= span.stop.offset + @test span.start.line <= span.stop.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 root_span.stop isa Location +end diff --git a/sdks/python/src/lqp/cli.py b/sdks/python/src/lqp/cli.py index 767eeea8..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 2c023fb0..15473fe8 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 stop location.""" + + __slots__ = ("start", "stop") + + def __init__(self, start: Location, stop: Location): + self.start = start + self.stop = stop + + def __repr__(self) -> str: + 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.stop == other.stop + + def __hash__(self) -> int: + return hash((self.start, self.stop)) + + 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") + _t1911 = value.HasField("int_value") else: - _t1311 = False - if _t1311: + _t1911 = False + if _t1911: assert value is not None return int(value.int_value) else: - _t1312 = None + _t1912 = 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") + _t1913 = value.HasField("int_value") else: - _t1313 = False - if _t1313: + _t1913 = False + if _t1913: assert value is not None return value.int_value else: - _t1314 = None + _t1914 = 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") + _t1915 = value.HasField("string_value") else: - _t1315 = False - if _t1315: + _t1915 = False + if _t1915: assert value is not None return value.string_value else: - _t1316 = None + _t1916 = 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") + _t1917 = value.HasField("boolean_value") else: - _t1317 = False - if _t1317: + _t1917 = False + if _t1917: assert value is not None return value.boolean_value else: - _t1318 = None + _t1918 = 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") + _t1919 = value.HasField("string_value") else: - _t1319 = False - if _t1319: + _t1919 = False + if _t1919: assert value is not None return [value.string_value] else: - _t1320 = None + _t1920 = 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") + _t1921 = value.HasField("int_value") else: - _t1321 = False - if _t1321: + _t1921 = False + if _t1921: assert value is not None return value.int_value else: - _t1322 = None + _t1922 = 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") + _t1923 = value.HasField("float_value") else: - _t1323 = False - if _t1323: + _t1923 = False + if _t1923: assert value is not None return value.float_value else: - _t1324 = None + _t1924 = 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") + _t1925 = value.HasField("string_value") else: - _t1325 = False - if _t1325: + _t1925 = False + if _t1925: assert value is not None return value.string_value.encode() else: - _t1326 = None + _t1926 = 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") + _t1927 = value.HasField("uint128_value") else: - _t1327 = False - if _t1327: + _t1927 = False + if _t1927: assert value is not None return value.uint128_value else: - _t1328 = 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) - _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 + _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) - _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 + _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: - _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 + _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) @@ -485,2378 +572,3170 @@ 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 + _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) - _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 + _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 --- 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 + _t1313 = self.parse_configure() + _t1312 = _t1313 else: - _t712 = None - configure356 = _t712 + _t1312 = None + configure592 = _t1312 + 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 + _t1315 = self.parse_sync() + _t1314 = _t1315 + else: + _t1314 = None + sync593 = _t1314 + self.pop_path() + self.push_path(1) + xs598 = [] + cond599 = self.match_lookahead_literal("(", 0) + idx600 = 0 + while cond599: + self.push_path(idx600) + _t1316 = self.parse_epoch() + item601 = _t1316 + self.pop_path() + xs598.append(item601) + idx600 = (idx600 + 1) + cond599 = self.match_lookahead_literal("(", 0) + epochs597 = xs598 + self.pop_path() + self.consume_literal(")") + _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 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 + _t1319 = self.parse_config_dict() + config_dict604 = _t1319 self.consume_literal(")") - _t720 = self.construct_configure(config_dict362) - return _t720 + _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_start615 = 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 + 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("}") - return config_key_values366 + result616 = config_key_values610 + self.record_span(span_start615) + return result616 def parse_config_key_value(self) -> tuple[str, logic_pb2.Value]: + span_start619 = self.span_start() self.consume_literal(":") - symbol367 = self.consume_terminal("SYMBOL") - _t722 = self.parse_value() - value368 = _t722 - return (symbol367, value368,) + 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_start631 = self.span_start() if self.match_lookahead_literal("true", 0): - _t723 = 9 + _t1323 = 9 else: if self.match_lookahead_literal("missing", 0): - _t724 = 8 + _t1324 = 8 else: if self.match_lookahead_literal("false", 0): - _t725 = 9 + _t1325 = 9 else: if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("datetime", 1): - _t727 = 1 + _t1327 = 1 else: if self.match_lookahead_literal("date", 1): - _t728 = 0 + _t1328 = 0 else: - _t728 = -1 - _t727 = _t728 - _t726 = _t727 + _t1328 = -1 + _t1327 = _t1328 + _t1326 = _t1327 else: if self.match_lookahead_terminal("UINT128", 0): - _t729 = 5 + _t1329 = 5 else: if self.match_lookahead_terminal("STRING", 0): - _t730 = 2 + _t1330 = 2 else: if self.match_lookahead_terminal("INT128", 0): - _t731 = 6 + _t1331 = 6 else: if self.match_lookahead_terminal("INT", 0): - _t732 = 3 + _t1332 = 3 else: if self.match_lookahead_terminal("FLOAT", 0): - _t733 = 4 + _t1333 = 4 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t734 = 7 + _t1334 = 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: + _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") - _t739 = logic_pb2.MissingValue() - _t740 = logic_pb2.Value(missing_value=_t739) - _t738 = _t740 + _t1339 = logic_pb2.MissingValue() + _t1340 = logic_pb2.Value(missing_value=_t1339) + _t1338 = _t1340 else: - if prediction369 == 7: - decimal377 = self.consume_terminal("DECIMAL") - _t742 = logic_pb2.Value(decimal_value=decimal377) - _t741 = _t742 + if prediction621 == 7: + decimal629 = self.consume_terminal("DECIMAL") + _t1342 = logic_pb2.Value(decimal_value=decimal629) + _t1341 = _t1342 else: - if prediction369 == 6: - int128376 = self.consume_terminal("INT128") - _t744 = logic_pb2.Value(int128_value=int128376) - _t743 = _t744 + if prediction621 == 6: + int128628 = self.consume_terminal("INT128") + _t1344 = logic_pb2.Value(int128_value=int128628) + _t1343 = _t1344 else: - if prediction369 == 5: - uint128375 = self.consume_terminal("UINT128") - _t746 = logic_pb2.Value(uint128_value=uint128375) - _t745 = _t746 + if prediction621 == 5: + uint128627 = self.consume_terminal("UINT128") + _t1346 = logic_pb2.Value(uint128_value=uint128627) + _t1345 = _t1346 else: - if prediction369 == 4: - float374 = self.consume_terminal("FLOAT") - _t748 = logic_pb2.Value(float_value=float374) - _t747 = _t748 + if prediction621 == 4: + float626 = self.consume_terminal("FLOAT") + _t1348 = logic_pb2.Value(float_value=float626) + _t1347 = _t1348 else: - if prediction369 == 3: - int373 = self.consume_terminal("INT") - _t750 = logic_pb2.Value(int_value=int373) - _t749 = _t750 + if prediction621 == 3: + int625 = self.consume_terminal("INT") + _t1350 = logic_pb2.Value(int_value=int625) + _t1349 = _t1350 else: - if prediction369 == 2: - string372 = self.consume_terminal("STRING") - _t752 = logic_pb2.Value(string_value=string372) - _t751 = _t752 + if prediction621 == 2: + string624 = self.consume_terminal("STRING") + _t1352 = logic_pb2.Value(string_value=string624) + _t1351 = _t1352 else: - if prediction369 == 1: - _t754 = self.parse_datetime() - datetime371 = _t754 - _t755 = logic_pb2.Value(datetime_value=datetime371) - _t753 = _t755 + 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 prediction369 == 0: - _t757 = self.parse_date() - date370 = _t757 - _t758 = logic_pb2.Value(date_value=date370) - _t756 = _t758 + 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}`") - _t753 = _t756 - _t751 = _t753 - _t749 = _t751 - _t747 = _t749 - _t745 = _t747 - _t743 = _t745 - _t741 = _t743 - _t738 = _t741 - _t735 = _t738 - return _t735 + _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_start636 = 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) + int633 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3634 = self.consume_terminal("INT") + self.pop_path() + self.push_path(3) + int_4635 = self.consume_terminal("INT") + self.pop_path() + self.consume_literal(")") + _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_start645 = 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) + int638 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3639 = self.consume_terminal("INT") + self.pop_path() + self.push_path(3) + int_4640 = self.consume_terminal("INT") + self.pop_path() + self.push_path(4) + int_5641 = self.consume_terminal("INT") + self.pop_path() + self.push_path(5) + int_6642 = self.consume_terminal("INT") + self.pop_path() + self.push_path(6) + int_7643 = self.consume_terminal("INT") + self.pop_path() + self.push_path(7) if self.match_lookahead_terminal("INT", 0): - _t760 = self.consume_terminal("INT") + _t1360 = self.consume_terminal("INT") else: - _t760 = None - int_8388 = _t760 + _t1360 = None + int_8644 = _t1360 + 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 + _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_start648 = self.span_start() if self.match_lookahead_literal("true", 0): - _t762 = 0 + _t1362 = 0 else: if self.match_lookahead_literal("false", 0): - _t763 = 1 + _t1363 = 1 else: - _t763 = -1 - _t762 = _t763 - prediction389 = _t762 - if prediction389 == 1: + _t1363 = -1 + _t1362 = _t1363 + prediction647 = _t1362 + if prediction647 == 1: self.consume_literal("false") - _t764 = False + _t1364 = False else: - if prediction389 == 0: + if prediction647 == 0: self.consume_literal("true") - _t765 = True + _t1365 = True else: raise ParseError("Unexpected token in boolean_value" + f": {self.lookahead(0).type}=`{self.lookahead(0).value}`") - _t764 = _t765 - return _t764 + _t1364 = _t1365 + result649 = _t1364 + self.record_span(span_start648) + return result649 def parse_sync(self) -> transactions_pb2.Sync: + span_start658 = 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) + 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() + xs654.append(item657) + idx656 = (idx656 + 1) + cond655 = self.match_lookahead_literal(":", 0) + fragment_ids653 = xs654 + self.pop_path() + self.consume_literal(")") + _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_start661 = self.span_start() self.consume_literal(":") - symbol394 = self.consume_terminal("SYMBOL") - return fragments_pb2.FragmentId(id=symbol394.encode()) + 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_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)): - _t769 = self.parse_epoch_writes() - _t768 = _t769 + _t1369 = self.parse_epoch_writes() + _t1368 = _t1369 else: - _t768 = None - epoch_writes395 = _t768 + _t1368 = None + epoch_writes663 = _t1368 + self.pop_path() + self.push_path(2) if self.match_lookahead_literal("(", 0): - _t771 = self.parse_epoch_reads() - _t770 = _t771 + _t1371 = self.parse_epoch_reads() + _t1370 = _t1371 else: - _t770 = None - epoch_reads396 = _t770 + _t1370 = None + epoch_reads664 = _t1370 + 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 + _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_start675 = 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 + 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_start682 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("undefine", 1): - _t775 = 1 + _t1375 = 1 else: if self.match_lookahead_literal("snapshot", 1): - _t776 = 3 + _t1376 = 3 else: if self.match_lookahead_literal("define", 1): - _t777 = 0 + _t1377 = 0 else: if self.match_lookahead_literal("context", 1): - _t778 = 2 + _t1378 = 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 + _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 prediction401 == 1: - _t786 = self.parse_undefine() - undefine403 = _t786 - _t787 = transactions_pb2.Write(undefine=undefine403) - _t785 = _t787 + 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 prediction401 == 0: - _t789 = self.parse_define() - define402 = _t789 - _t790 = transactions_pb2.Write(define=define402) - _t788 = _t790 + 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}`") - _t785 = _t788 - _t782 = _t785 - _t779 = _t782 - return _t779 + _t1385 = _t1388 + _t1382 = _t1385 + _t1379 = _t1382 + result683 = _t1379 + self.record_span(span_start682) + return result683 def parse_define(self) -> transactions_pb2.Define: + span_start685 = self.span_start() self.consume_literal("(") self.consume_literal("define") - _t791 = self.parse_fragment() - fragment406 = _t791 + self.push_path(1) + _t1391 = self.parse_fragment() + fragment684 = _t1391 + self.pop_path() self.consume_literal(")") - _t792 = transactions_pb2.Define(fragment=fragment406) - return _t792 + _t1392 = transactions_pb2.Define(fragment=fragment684) + result686 = _t1392 + self.record_span(span_start685) + return result686 def parse_fragment(self) -> fragments_pb2.Fragment: + span_start696 = 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) + _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: - _t795 = self.parse_fragment_id() - fragment_id412 = _t795 - self.start_fragment(fragment_id412) - return fragment_id412 + 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_start706 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t797 = 3 + _t1397 = 3 else: if self.match_lookahead_literal("functional_dependency", 1): - _t798 = 2 + _t1398 = 2 else: if self.match_lookahead_literal("def", 1): - _t799 = 0 + _t1399 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t800 = 3 + _t1400 = 3 else: if self.match_lookahead_literal("betree_relation", 1): - _t801 = 3 + _t1401 = 3 else: if self.match_lookahead_literal("algorithm", 1): - _t802 = 1 + _t1402 = 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 + _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 prediction413 == 1: - _t810 = self.parse_algorithm() - algorithm415 = _t810 - _t811 = logic_pb2.Declaration(algorithm=algorithm415) - _t809 = _t811 + 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 prediction413 == 0: - _t813 = self.parse_def() - def414 = _t813 - _t814 = logic_pb2.Declaration() - getattr(_t814, 'def').CopyFrom(def414) - _t812 = _t814 + 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}`") - _t809 = _t812 - _t806 = _t809 - _t803 = _t806 - return _t803 + _t1409 = _t1412 + _t1406 = _t1409 + _t1403 = _t1406 + result707 = _t1403 + self.record_span(span_start706) + return result707 def parse_def(self) -> logic_pb2.Def: + span_start711 = 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) + _t1415 = self.parse_relation_id() + relation_id708 = _t1415 + self.pop_path() + self.push_path(2) + _t1416 = self.parse_abstraction() + abstraction709 = _t1416 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t818 = self.parse_attrs() - _t817 = _t818 + _t1418 = self.parse_attrs() + _t1417 = _t1418 else: - _t817 = None - attrs420 = _t817 + _t1417 = None + attrs710 = _t1417 + 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 + _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_start716 = self.span_start() if self.match_lookahead_literal(":", 0): - _t820 = 0 + _t1420 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t821 = 1 + _t1421 = 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: + _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(":") - symbol422 = self.consume_terminal("SYMBOL") - _t823 = self.relation_id_from_string(symbol422) + 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}`") - _t822 = _t823 - return _t822 + _t1422 = _t1423 + result717 = _t1422 + self.record_span(span_start716) + return result717 def parse_abstraction(self) -> logic_pb2.Abstraction: + span_start720 = self.span_start() self.consume_literal("(") - _t824 = self.parse_bindings() - bindings424 = _t824 - _t825 = self.parse_formula() - formula425 = _t825 + _t1424 = self.parse_bindings() + bindings718 = _t1424 + self.push_path(2) + _t1425 = self.parse_formula() + formula719 = _t1425 + 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 + _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_start731 = 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 + 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): - _t829 = self.parse_value_bindings() - _t828 = _t829 + _t1429 = self.parse_value_bindings() + _t1428 = _t1429 else: - _t828 = None - value_bindings430 = _t828 + _t1428 = None + value_bindings730 = _t1428 self.consume_literal("]") - return (bindings429, (value_bindings430 if value_bindings430 is not None else []),) + 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: - symbol431 = self.consume_terminal("SYMBOL") + span_start735 = self.span_start() + symbol733 = 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) + _t1430 = self.parse_type() + type734 = _t1430 + self.pop_path() + _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_start749 = self.span_start() if self.match_lookahead_literal("UNKNOWN", 0): - _t833 = 0 + _t1433 = 0 else: if self.match_lookahead_literal("UINT128", 0): - _t834 = 4 + _t1434 = 4 else: if self.match_lookahead_literal("STRING", 0): - _t835 = 1 + _t1435 = 1 else: if self.match_lookahead_literal("MISSING", 0): - _t836 = 8 + _t1436 = 8 else: if self.match_lookahead_literal("INT128", 0): - _t837 = 5 + _t1437 = 5 else: if self.match_lookahead_literal("INT", 0): - _t838 = 2 + _t1438 = 2 else: if self.match_lookahead_literal("FLOAT", 0): - _t839 = 3 + _t1439 = 3 else: if self.match_lookahead_literal("DATETIME", 0): - _t840 = 7 + _t1440 = 7 else: if self.match_lookahead_literal("DATE", 0): - _t841 = 6 + _t1441 = 6 else: if self.match_lookahead_literal("BOOLEAN", 0): - _t842 = 10 + _t1442 = 10 else: if self.match_lookahead_literal("(", 0): - _t843 = 9 + _t1443 = 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 + _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 prediction433 == 8: - _t851 = self.parse_missing_type() - missing_type442 = _t851 - _t852 = logic_pb2.Type(missing_type=missing_type442) - _t850 = _t852 + 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 prediction433 == 7: - _t854 = self.parse_datetime_type() - datetime_type441 = _t854 - _t855 = logic_pb2.Type(datetime_type=datetime_type441) - _t853 = _t855 + 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 prediction433 == 6: - _t857 = self.parse_date_type() - date_type440 = _t857 - _t858 = logic_pb2.Type(date_type=date_type440) - _t856 = _t858 + 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 prediction433 == 5: - _t860 = self.parse_int128_type() - int128_type439 = _t860 - _t861 = logic_pb2.Type(int128_type=int128_type439) - _t859 = _t861 + 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 prediction433 == 4: - _t863 = self.parse_uint128_type() - uint128_type438 = _t863 - _t864 = logic_pb2.Type(uint128_type=uint128_type438) - _t862 = _t864 + 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 prediction433 == 3: - _t866 = self.parse_float_type() - float_type437 = _t866 - _t867 = logic_pb2.Type(float_type=float_type437) - _t865 = _t867 + 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 prediction433 == 2: - _t869 = self.parse_int_type() - int_type436 = _t869 - _t870 = logic_pb2.Type(int_type=int_type436) - _t868 = _t870 + 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 prediction433 == 1: - _t872 = self.parse_string_type() - string_type435 = _t872 - _t873 = logic_pb2.Type(string_type=string_type435) - _t871 = _t873 + 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 prediction433 == 0: - _t875 = self.parse_unspecified_type() - unspecified_type434 = _t875 - _t876 = logic_pb2.Type(unspecified_type=unspecified_type434) - _t874 = _t876 + 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}`") - _t871 = _t874 - _t868 = _t871 - _t865 = _t868 - _t862 = _t865 - _t859 = _t862 - _t856 = _t859 - _t853 = _t856 - _t850 = _t853 - _t847 = _t850 - _t844 = _t847 - return _t844 + _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_start751 = self.span_start() self.consume_literal("UNKNOWN") - _t877 = logic_pb2.UnspecifiedType() - return _t877 + _t1477 = logic_pb2.UnspecifiedType() + result752 = _t1477 + self.record_span(span_start751) + return result752 def parse_string_type(self) -> logic_pb2.StringType: + span_start753 = self.span_start() self.consume_literal("STRING") - _t878 = logic_pb2.StringType() - return _t878 + _t1478 = logic_pb2.StringType() + result754 = _t1478 + self.record_span(span_start753) + return result754 def parse_int_type(self) -> logic_pb2.IntType: + span_start755 = self.span_start() self.consume_literal("INT") - _t879 = logic_pb2.IntType() - return _t879 + _t1479 = logic_pb2.IntType() + result756 = _t1479 + self.record_span(span_start755) + return result756 def parse_float_type(self) -> logic_pb2.FloatType: + span_start757 = self.span_start() self.consume_literal("FLOAT") - _t880 = logic_pb2.FloatType() - return _t880 + _t1480 = logic_pb2.FloatType() + result758 = _t1480 + self.record_span(span_start757) + return result758 def parse_uint128_type(self) -> logic_pb2.UInt128Type: + span_start759 = self.span_start() self.consume_literal("UINT128") - _t881 = logic_pb2.UInt128Type() - return _t881 + _t1481 = logic_pb2.UInt128Type() + result760 = _t1481 + self.record_span(span_start759) + return result760 def parse_int128_type(self) -> logic_pb2.Int128Type: + span_start761 = self.span_start() self.consume_literal("INT128") - _t882 = logic_pb2.Int128Type() - return _t882 + _t1482 = logic_pb2.Int128Type() + result762 = _t1482 + self.record_span(span_start761) + return result762 def parse_date_type(self) -> logic_pb2.DateType: + span_start763 = self.span_start() self.consume_literal("DATE") - _t883 = logic_pb2.DateType() - return _t883 + _t1483 = logic_pb2.DateType() + result764 = _t1483 + self.record_span(span_start763) + return result764 def parse_datetime_type(self) -> logic_pb2.DateTimeType: + span_start765 = self.span_start() self.consume_literal("DATETIME") - _t884 = logic_pb2.DateTimeType() - return _t884 + _t1484 = logic_pb2.DateTimeType() + result766 = _t1484 + self.record_span(span_start765) + return result766 def parse_missing_type(self) -> logic_pb2.MissingType: + span_start767 = self.span_start() self.consume_literal("MISSING") - _t885 = logic_pb2.MissingType() - return _t885 + _t1485 = logic_pb2.MissingType() + result768 = _t1485 + self.record_span(span_start767) + return result768 def parse_decimal_type(self) -> logic_pb2.DecimalType: + span_start771 = 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) + int769 = self.consume_terminal("INT") + self.pop_path() + self.push_path(2) + int_3770 = self.consume_terminal("INT") + self.pop_path() + self.consume_literal(")") + _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_start773 = self.span_start() self.consume_literal("BOOLEAN") - _t887 = logic_pb2.BooleanType() - return _t887 + _t1487 = logic_pb2.BooleanType() + result774 = _t1487 + self.record_span(span_start773) + return result774 def parse_value_bindings(self) -> Sequence[logic_pb2.Binding]: + span_start783 = 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 + 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_start799 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("true", 1): - _t890 = 0 + _t1490 = 0 else: if self.match_lookahead_literal("relatom", 1): - _t891 = 11 + _t1491 = 11 else: if self.match_lookahead_literal("reduce", 1): - _t892 = 3 + _t1492 = 3 else: if self.match_lookahead_literal("primitive", 1): - _t893 = 10 + _t1493 = 10 else: if self.match_lookahead_literal("pragma", 1): - _t894 = 9 + _t1494 = 9 else: if self.match_lookahead_literal("or", 1): - _t895 = 5 + _t1495 = 5 else: if self.match_lookahead_literal("not", 1): - _t896 = 6 + _t1496 = 6 else: if self.match_lookahead_literal("ffi", 1): - _t897 = 7 + _t1497 = 7 else: if self.match_lookahead_literal("false", 1): - _t898 = 1 + _t1498 = 1 else: if self.match_lookahead_literal("exists", 1): - _t899 = 2 + _t1499 = 2 else: if self.match_lookahead_literal("cast", 1): - _t900 = 12 + _t1500 = 12 else: if self.match_lookahead_literal("atom", 1): - _t901 = 8 + _t1501 = 8 else: if self.match_lookahead_literal("and", 1): - _t902 = 4 + _t1502 = 4 else: if self.match_lookahead_literal(">=", 1): - _t903 = 10 + _t1503 = 10 else: if self.match_lookahead_literal(">", 1): - _t904 = 10 + _t1504 = 10 else: if self.match_lookahead_literal("=", 1): - _t905 = 10 + _t1505 = 10 else: if self.match_lookahead_literal("<=", 1): - _t906 = 10 + _t1506 = 10 else: if self.match_lookahead_literal("<", 1): - _t907 = 10 + _t1507 = 10 else: if self.match_lookahead_literal("/", 1): - _t908 = 10 + _t1508 = 10 else: if self.match_lookahead_literal("-", 1): - _t909 = 10 + _t1509 = 10 else: if self.match_lookahead_literal("+", 1): - _t910 = 10 + _t1510 = 10 else: if self.match_lookahead_literal("*", 1): - _t911 = 10 + _t1511 = 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 + _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 prediction451 == 10: - _t919 = self.parse_primitive() - primitive462 = _t919 - _t920 = logic_pb2.Formula(primitive=primitive462) - _t918 = _t920 + 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 prediction451 == 9: - _t922 = self.parse_pragma() - pragma461 = _t922 - _t923 = logic_pb2.Formula(pragma=pragma461) - _t921 = _t923 + 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 prediction451 == 8: - _t925 = self.parse_atom() - atom460 = _t925 - _t926 = logic_pb2.Formula(atom=atom460) - _t924 = _t926 + 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 prediction451 == 7: - _t928 = self.parse_ffi() - ffi459 = _t928 - _t929 = logic_pb2.Formula(ffi=ffi459) - _t927 = _t929 + 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 prediction451 == 6: - _t931 = self.parse_not() - not458 = _t931 - _t932 = logic_pb2.Formula() - getattr(_t932, 'not').CopyFrom(not458) - _t930 = _t932 + 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 prediction451 == 5: - _t934 = self.parse_disjunction() - disjunction457 = _t934 - _t935 = logic_pb2.Formula(disjunction=disjunction457) - _t933 = _t935 + 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 prediction451 == 4: - _t937 = self.parse_conjunction() - conjunction456 = _t937 - _t938 = logic_pb2.Formula(conjunction=conjunction456) - _t936 = _t938 + 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 prediction451 == 3: - _t940 = self.parse_reduce() - reduce455 = _t940 - _t941 = logic_pb2.Formula(reduce=reduce455) - _t939 = _t941 + 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 prediction451 == 2: - _t943 = self.parse_exists() - exists454 = _t943 - _t944 = logic_pb2.Formula(exists=exists454) - _t942 = _t944 + 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 prediction451 == 1: - _t946 = self.parse_false() - false453 = _t946 - _t947 = logic_pb2.Formula(disjunction=false453) - _t945 = _t947 + 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 prediction451 == 0: - _t949 = self.parse_true() - true452 = _t949 - _t950 = logic_pb2.Formula(conjunction=true452) - _t948 = _t950 + 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}`") - _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 + _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_start801 = self.span_start() self.consume_literal("(") self.consume_literal("true") self.consume_literal(")") - _t951 = logic_pb2.Conjunction(args=[]) - return _t951 + _t1551 = logic_pb2.Conjunction(args=[]) + result802 = _t1551 + self.record_span(span_start801) + return result802 def parse_false(self) -> logic_pb2.Disjunction: + span_start803 = self.span_start() self.consume_literal("(") self.consume_literal("false") self.consume_literal(")") - _t952 = logic_pb2.Disjunction(args=[]) - return _t952 + _t1552 = logic_pb2.Disjunction(args=[]) + result804 = _t1552 + self.record_span(span_start803) + return result804 def parse_exists(self) -> logic_pb2.Exists: + span_start807 = self.span_start() self.consume_literal("(") self.consume_literal("exists") - _t953 = self.parse_bindings() - bindings465 = _t953 - _t954 = self.parse_formula() - formula466 = _t954 + _t1553 = self.parse_bindings() + bindings805 = _t1553 + _t1554 = self.parse_formula() + formula806 = _t1554 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 + _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_start812 = 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) + _t1557 = self.parse_abstraction() + abstraction809 = _t1557 + self.pop_path() + self.push_path(2) + _t1558 = self.parse_abstraction() + abstraction_3810 = _t1558 + self.pop_path() + self.push_path(3) + _t1559 = self.parse_terms() + terms811 = _t1559 + self.pop_path() + self.consume_literal(")") + _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_start822 = 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 + 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_start827 = self.span_start() if self.match_lookahead_literal("true", 0): - _t962 = 1 + _t1562 = 1 else: if self.match_lookahead_literal("missing", 0): - _t963 = 1 + _t1563 = 1 else: if self.match_lookahead_literal("false", 0): - _t964 = 1 + _t1564 = 1 else: if self.match_lookahead_literal("(", 0): - _t965 = 1 + _t1565 = 1 else: if self.match_lookahead_terminal("UINT128", 0): - _t966 = 1 + _t1566 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t967 = 0 + _t1567 = 0 else: if self.match_lookahead_terminal("STRING", 0): - _t968 = 1 + _t1568 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t969 = 1 + _t1569 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t970 = 1 + _t1570 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t971 = 1 + _t1571 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t972 = 1 + _t1572 = 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 + _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}`") - _t973 = _t976 - return _t973 + _t1573 = _t1576 + result828 = _t1573 + self.record_span(span_start827) + return result828 def parse_var(self) -> logic_pb2.Var: - symbol477 = self.consume_terminal("SYMBOL") - _t979 = logic_pb2.Var(name=symbol477) - return _t979 + 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: - _t980 = self.parse_value() - value478 = _t980 - return value478 + 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_start843 = 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) + xs839 = [] + cond840 = self.match_lookahead_literal("(", 0) + idx841 = 0 + while cond840: + self.push_path(idx841) + _t1581 = self.parse_formula() + item842 = _t1581 + self.pop_path() + xs839.append(item842) + idx841 = (idx841 + 1) + cond840 = self.match_lookahead_literal("(", 0) + formulas838 = xs839 + self.pop_path() + self.consume_literal(")") + _t1582 = logic_pb2.Conjunction(args=formulas838) + result844 = _t1582 + self.record_span(span_start843) + return result844 def parse_disjunction(self) -> logic_pb2.Disjunction: + span_start853 = 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) + xs849 = [] + cond850 = self.match_lookahead_literal("(", 0) + idx851 = 0 + while cond850: + self.push_path(idx851) + _t1583 = self.parse_formula() + item852 = _t1583 + self.pop_path() + xs849.append(item852) + idx851 = (idx851 + 1) + cond850 = self.match_lookahead_literal("(", 0) + formulas848 = xs849 + self.pop_path() + self.consume_literal(")") + _t1584 = logic_pb2.Disjunction(args=formulas848) + result854 = _t1584 + self.record_span(span_start853) + return result854 def parse_not(self) -> logic_pb2.Not: + span_start856 = self.span_start() self.consume_literal("(") self.consume_literal("not") - _t985 = self.parse_formula() - formula487 = _t985 + self.push_path(1) + _t1585 = self.parse_formula() + formula855 = _t1585 + self.pop_path() self.consume_literal(")") - _t986 = logic_pb2.Not(arg=formula487) - return _t986 + _t1586 = logic_pb2.Not(arg=formula855) + result857 = _t1586 + self.record_span(span_start856) + return result857 def parse_ffi(self) -> logic_pb2.FFI: + span_start861 = 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) + _t1587 = self.parse_name() + name858 = _t1587 + self.pop_path() + self.push_path(2) + _t1588 = self.parse_ffi_args() + ffi_args859 = _t1588 + self.pop_path() + self.push_path(3) + _t1589 = self.parse_terms() + terms860 = _t1589 + self.pop_path() + self.consume_literal(")") + _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_start864 = self.span_start() self.consume_literal(":") - symbol491 = self.consume_terminal("SYMBOL") - return symbol491 + symbol863 = self.consume_terminal("SYMBOL") + result865 = symbol863 + self.record_span(span_start864) + return result865 def parse_ffi_args(self) -> Sequence[logic_pb2.Abstraction]: + span_start874 = 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 + 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_start885 = 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) + _t1592 = self.parse_relation_id() + relation_id876 = _t1592 + self.pop_path() + self.push_path(2) + 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() + 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(")") + _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_start896 = 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) + _t1595 = self.parse_name() + name887 = _t1595 + self.pop_path() + self.push_path(2) + 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() + 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(")") + _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_start917 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("primitive", 1): - _t999 = 9 + _t1599 = 9 else: if self.match_lookahead_literal(">=", 1): - _t1000 = 4 + _t1600 = 4 else: if self.match_lookahead_literal(">", 1): - _t1001 = 3 + _t1601 = 3 else: if self.match_lookahead_literal("=", 1): - _t1002 = 0 + _t1602 = 0 else: if self.match_lookahead_literal("<=", 1): - _t1003 = 2 + _t1603 = 2 else: if self.match_lookahead_literal("<", 1): - _t1004 = 1 + _t1604 = 1 else: if self.match_lookahead_literal("/", 1): - _t1005 = 8 + _t1605 = 8 else: if self.match_lookahead_literal("-", 1): - _t1006 = 6 + _t1606 = 6 else: if self.match_lookahead_literal("+", 1): - _t1007 = 5 + _t1607 = 5 else: if self.match_lookahead_literal("*", 1): - _t1008 = 7 + _t1608 = 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: + _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") - _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) + _t1610 = self.parse_name() + name908 = _t1610 + self.pop_path() + self.push_path(2) + 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() + 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(")") - _t1012 = logic_pb2.Primitive(name=name516, terms=rel_terms520) - _t1009 = _t1012 + _t1612 = logic_pb2.Primitive(name=name908, terms=rel_terms912) + _t1609 = _t1612 else: - if prediction506 == 8: - _t1014 = self.parse_divide() - divide515 = _t1014 - _t1013 = divide515 + if prediction898 == 8: + _t1614 = self.parse_divide() + divide907 = _t1614 + _t1613 = divide907 else: - if prediction506 == 7: - _t1016 = self.parse_multiply() - multiply514 = _t1016 - _t1015 = multiply514 + if prediction898 == 7: + _t1616 = self.parse_multiply() + multiply906 = _t1616 + _t1615 = multiply906 else: - if prediction506 == 6: - _t1018 = self.parse_minus() - minus513 = _t1018 - _t1017 = minus513 + if prediction898 == 6: + _t1618 = self.parse_minus() + minus905 = _t1618 + _t1617 = minus905 else: - if prediction506 == 5: - _t1020 = self.parse_add() - add512 = _t1020 - _t1019 = add512 + if prediction898 == 5: + _t1620 = self.parse_add() + add904 = _t1620 + _t1619 = add904 else: - if prediction506 == 4: - _t1022 = self.parse_gt_eq() - gt_eq511 = _t1022 - _t1021 = gt_eq511 + if prediction898 == 4: + _t1622 = self.parse_gt_eq() + gt_eq903 = _t1622 + _t1621 = gt_eq903 else: - if prediction506 == 3: - _t1024 = self.parse_gt() - gt510 = _t1024 - _t1023 = gt510 + if prediction898 == 3: + _t1624 = self.parse_gt() + gt902 = _t1624 + _t1623 = gt902 else: - if prediction506 == 2: - _t1026 = self.parse_lt_eq() - lt_eq509 = _t1026 - _t1025 = lt_eq509 + if prediction898 == 2: + _t1626 = self.parse_lt_eq() + lt_eq901 = _t1626 + _t1625 = lt_eq901 else: - if prediction506 == 1: - _t1028 = self.parse_lt() - lt508 = _t1028 - _t1027 = lt508 + if prediction898 == 1: + _t1628 = self.parse_lt() + lt900 = _t1628 + _t1627 = lt900 else: - if prediction506 == 0: - _t1030 = self.parse_eq() - eq507 = _t1030 - _t1029 = eq507 + 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}`") - _t1027 = _t1029 - _t1025 = _t1027 - _t1023 = _t1025 - _t1021 = _t1023 - _t1019 = _t1021 - _t1017 = _t1019 - _t1015 = _t1017 - _t1013 = _t1015 - _t1009 = _t1013 - return _t1009 + _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_start921 = 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 + _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_start925 = 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 + _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_start929 = 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 + _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_start933 = 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 + _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_start937 = 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 + _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_start942 = 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 + _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_start947 = 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 + _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_start952 = 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 + _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_start957 = 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 + _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_start962 = self.span_start() if self.match_lookahead_literal("true", 0): - _t1084 = 1 + _t1684 = 1 else: if self.match_lookahead_literal("missing", 0): - _t1085 = 1 + _t1685 = 1 else: if self.match_lookahead_literal("false", 0): - _t1086 = 1 + _t1686 = 1 else: if self.match_lookahead_literal("(", 0): - _t1087 = 1 + _t1687 = 1 else: if self.match_lookahead_literal("#", 0): - _t1088 = 0 + _t1688 = 0 else: if self.match_lookahead_terminal("UINT128", 0): - _t1089 = 1 + _t1689 = 1 else: if self.match_lookahead_terminal("SYMBOL", 0): - _t1090 = 1 + _t1690 = 1 else: if self.match_lookahead_terminal("STRING", 0): - _t1091 = 1 + _t1691 = 1 else: if self.match_lookahead_terminal("INT128", 0): - _t1092 = 1 + _t1692 = 1 else: if self.match_lookahead_terminal("INT", 0): - _t1093 = 1 + _t1693 = 1 else: if self.match_lookahead_terminal("FLOAT", 0): - _t1094 = 1 + _t1694 = 1 else: if self.match_lookahead_terminal("DECIMAL", 0): - _t1095 = 1 + _t1695 = 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 + _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}`") - _t1096 = _t1099 - return _t1096 + _t1696 = _t1699 + result963 = _t1696 + self.record_span(span_start962) + return result963 def parse_specialized_value(self) -> logic_pb2.Value: + span_start965 = self.span_start() self.consume_literal("#") - _t1102 = self.parse_value() - value546 = _t1102 - return value546 + _t1702 = self.parse_value() + value964 = _t1702 + result966 = value964 + self.record_span(span_start965) + return result966 def parse_rel_atom(self) -> logic_pb2.RelAtom: + span_start976 = 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) + _t1703 = self.parse_name() + name967 = _t1703 + self.pop_path() + self.push_path(2) + 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() + 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(")") + _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_start980 = 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) + _t1706 = self.parse_term() + term978 = _t1706 + self.pop_path() + self.push_path(3) + _t1707 = self.parse_term() + term_3979 = _t1707 + self.pop_path() + self.consume_literal(")") + _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_start990 = 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 + 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_start1001 = 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) + _t1710 = self.parse_name() + name992 = _t1710 + self.pop_path() + self.push_path(2) + 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() + 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(")") + _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_start1012 = 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) + 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() + 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) + _t1714 = self.parse_script() + script1011 = _t1714 + self.pop_path() + self.consume_literal(")") + _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_start1022 = 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) + xs1018 = [] + cond1019 = self.match_lookahead_literal("(", 0) + idx1020 = 0 + while cond1019: + self.push_path(idx1020) + _t1716 = self.parse_construct() + item1021 = _t1716 + self.pop_path() + xs1018.append(item1021) + idx1020 = (idx1020 + 1) + cond1019 = self.match_lookahead_literal("(", 0) + constructs1017 = xs1018 + self.pop_path() + self.consume_literal(")") + _t1717 = logic_pb2.Script(constructs=constructs1017) + result1023 = _t1717 + self.record_span(span_start1022) + return result1023 def parse_construct(self) -> logic_pb2.Construct: + span_start1027 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1119 = 1 + _t1719 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1120 = 1 + _t1720 = 1 else: if self.match_lookahead_literal("monoid", 1): - _t1121 = 1 + _t1721 = 1 else: if self.match_lookahead_literal("loop", 1): - _t1122 = 0 + _t1722 = 0 else: if self.match_lookahead_literal("break", 1): - _t1123 = 1 + _t1723 = 1 else: if self.match_lookahead_literal("assign", 1): - _t1124 = 1 + _t1724 = 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 + _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}`") - _t1125 = _t1128 - return _t1125 + _t1725 = _t1728 + result1028 = _t1725 + self.record_span(span_start1027) + return result1028 def parse_loop(self) -> logic_pb2.Loop: + span_start1031 = 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) + _t1731 = self.parse_init() + init1029 = _t1731 + self.pop_path() + self.push_path(2) + _t1732 = self.parse_script() + script1030 = _t1732 + self.pop_path() + self.consume_literal(")") + _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_start1041 = 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 + 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_start1049 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("upsert", 1): - _t1136 = 1 + _t1736 = 1 else: if self.match_lookahead_literal("monus", 1): - _t1137 = 4 + _t1737 = 4 else: if self.match_lookahead_literal("monoid", 1): - _t1138 = 3 + _t1738 = 3 else: if self.match_lookahead_literal("break", 1): - _t1139 = 2 + _t1739 = 2 else: if self.match_lookahead_literal("assign", 1): - _t1140 = 0 + _t1740 = 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 + _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 prediction581 == 2: - _t1148 = self.parse_break() - break584 = _t1148 - _t1149 = logic_pb2.Instruction() - getattr(_t1149, 'break').CopyFrom(break584) - _t1147 = _t1149 + 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 prediction581 == 1: - _t1151 = self.parse_upsert() - upsert583 = _t1151 - _t1152 = logic_pb2.Instruction(upsert=upsert583) - _t1150 = _t1152 + 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 prediction581 == 0: - _t1154 = self.parse_assign() - assign582 = _t1154 - _t1155 = logic_pb2.Instruction(assign=assign582) - _t1153 = _t1155 + 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}`") - _t1150 = _t1153 - _t1147 = _t1150 - _t1144 = _t1147 - _t1141 = _t1144 - return _t1141 + _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_start1054 = 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) + _t1756 = self.parse_relation_id() + relation_id1051 = _t1756 + self.pop_path() + self.push_path(2) + _t1757 = self.parse_abstraction() + abstraction1052 = _t1757 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1159 = self.parse_attrs() - _t1158 = _t1159 + _t1759 = self.parse_attrs() + _t1758 = _t1759 else: - _t1158 = None - attrs589 = _t1158 + _t1758 = None + attrs1053 = _t1758 + 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 + _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_start1059 = 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) + _t1761 = self.parse_relation_id() + relation_id1056 = _t1761 + self.pop_path() + _t1762 = self.parse_abstraction_with_arity() + abstraction_with_arity1057 = _t1762 + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1164 = self.parse_attrs() - _t1163 = _t1164 + _t1764 = self.parse_attrs() + _t1763 = _t1764 else: - _t1163 = None - attrs592 = _t1163 + _t1763 = None + attrs1058 = _t1763 + 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 + _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_start1063 = self.span_start() self.consume_literal("(") - _t1166 = self.parse_bindings() - bindings593 = _t1166 - _t1167 = self.parse_formula() - formula594 = _t1167 + _t1766 = self.parse_bindings() + bindings1061 = _t1766 + _t1767 = self.parse_formula() + formula1062 = _t1767 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]),) + _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_start1068 = 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) + _t1769 = self.parse_relation_id() + relation_id1065 = _t1769 + self.pop_path() + self.push_path(2) + _t1770 = self.parse_abstraction() + abstraction1066 = _t1770 + self.pop_path() + self.push_path(3) if self.match_lookahead_literal("(", 0): - _t1172 = self.parse_attrs() - _t1171 = _t1172 + _t1772 = self.parse_attrs() + _t1771 = _t1772 else: - _t1171 = None - attrs597 = _t1171 + _t1771 = None + attrs1067 = _t1771 + 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 + _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_start1074 = 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) + _t1774 = self.parse_monoid() + monoid1070 = _t1774 + self.pop_path() + self.push_path(2) + _t1775 = self.parse_relation_id() + relation_id1071 = _t1775 + self.pop_path() + _t1776 = self.parse_abstraction_with_arity() + abstraction_with_arity1072 = _t1776 + self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1178 = self.parse_attrs() - _t1177 = _t1178 + _t1778 = self.parse_attrs() + _t1777 = _t1778 else: - _t1177 = None - attrs601 = _t1177 + _t1777 = None + attrs1073 = _t1777 + 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 + _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_start1081 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("sum", 1): - _t1181 = 3 + _t1781 = 3 else: if self.match_lookahead_literal("or", 1): - _t1182 = 0 + _t1782 = 0 else: if self.match_lookahead_literal("min", 1): - _t1183 = 1 + _t1783 = 1 else: if self.match_lookahead_literal("max", 1): - _t1184 = 2 + _t1784 = 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 + _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 prediction602 == 1: - _t1192 = self.parse_min_monoid() - min_monoid604 = _t1192 - _t1193 = logic_pb2.Monoid(min_monoid=min_monoid604) - _t1191 = _t1193 + 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 prediction602 == 0: - _t1195 = self.parse_or_monoid() - or_monoid603 = _t1195 - _t1196 = logic_pb2.Monoid(or_monoid=or_monoid603) - _t1194 = _t1196 + 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}`") - _t1191 = _t1194 - _t1188 = _t1191 - _t1185 = _t1188 - return _t1185 + _t1791 = _t1794 + _t1788 = _t1791 + _t1785 = _t1788 + result1082 = _t1785 + self.record_span(span_start1081) + return result1082 def parse_or_monoid(self) -> logic_pb2.OrMonoid: + span_start1083 = self.span_start() self.consume_literal("(") self.consume_literal("or") self.consume_literal(")") - _t1197 = logic_pb2.OrMonoid() - return _t1197 + _t1797 = logic_pb2.OrMonoid() + result1084 = _t1797 + self.record_span(span_start1083) + return result1084 def parse_min_monoid(self) -> logic_pb2.MinMonoid: + span_start1086 = self.span_start() self.consume_literal("(") self.consume_literal("min") - _t1198 = self.parse_type() - type607 = _t1198 + self.push_path(1) + _t1798 = self.parse_type() + type1085 = _t1798 + self.pop_path() self.consume_literal(")") - _t1199 = logic_pb2.MinMonoid(type=type607) - return _t1199 + _t1799 = logic_pb2.MinMonoid(type=type1085) + result1087 = _t1799 + self.record_span(span_start1086) + return result1087 def parse_max_monoid(self) -> logic_pb2.MaxMonoid: + span_start1089 = self.span_start() self.consume_literal("(") self.consume_literal("max") - _t1200 = self.parse_type() - type608 = _t1200 + self.push_path(1) + _t1800 = self.parse_type() + type1088 = _t1800 + self.pop_path() self.consume_literal(")") - _t1201 = logic_pb2.MaxMonoid(type=type608) - return _t1201 + _t1801 = logic_pb2.MaxMonoid(type=type1088) + result1090 = _t1801 + self.record_span(span_start1089) + return result1090 def parse_sum_monoid(self) -> logic_pb2.SumMonoid: + span_start1092 = self.span_start() self.consume_literal("(") self.consume_literal("sum") - _t1202 = self.parse_type() - type609 = _t1202 + self.push_path(1) + _t1802 = self.parse_type() + type1091 = _t1802 + self.pop_path() self.consume_literal(")") - _t1203 = logic_pb2.SumMonoid(type=type609) - return _t1203 + _t1803 = logic_pb2.SumMonoid(type=type1091) + result1093 = _t1803 + self.record_span(span_start1092) + return result1093 def parse_monus_def(self) -> logic_pb2.MonusDef: + span_start1098 = 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) + _t1804 = self.parse_monoid() + monoid1094 = _t1804 + self.pop_path() + self.push_path(2) + _t1805 = self.parse_relation_id() + relation_id1095 = _t1805 + self.pop_path() + _t1806 = self.parse_abstraction_with_arity() + abstraction_with_arity1096 = _t1806 + self.push_path(4) if self.match_lookahead_literal("(", 0): - _t1208 = self.parse_attrs() - _t1207 = _t1208 + _t1808 = self.parse_attrs() + _t1807 = _t1808 else: - _t1207 = None - attrs613 = _t1207 + _t1807 = None + attrs1097 = _t1807 + 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 + _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_start1104 = 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) + _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_start1114 = 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 + 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_start1124 = 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 + 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_start1130 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("rel_edb", 1): - _t1219 = 0 + _t1819 = 0 else: if self.match_lookahead_literal("csv_data", 1): - _t1220 = 2 + _t1820 = 2 else: if self.match_lookahead_literal("betree_relation", 1): - _t1221 = 1 + _t1821 = 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 + _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 prediction626 == 0: - _t1229 = self.parse_rel_edb() - rel_edb627 = _t1229 - _t1230 = logic_pb2.Data(rel_edb=rel_edb627) - _t1228 = _t1230 + 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}`") - _t1225 = _t1228 - _t1222 = _t1225 - return _t1222 + _t1825 = _t1828 + _t1822 = _t1825 + result1131 = _t1822 + self.record_span(span_start1130) + return result1131 def parse_rel_edb(self) -> logic_pb2.RelEDB: + span_start1135 = 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) + _t1831 = self.parse_relation_id() + relation_id1132 = _t1831 + self.pop_path() + self.push_path(2) + _t1832 = self.parse_rel_edb_path() + rel_edb_path1133 = _t1832 + self.pop_path() + self.push_path(3) + _t1833 = self.parse_rel_edb_types() + rel_edb_types1134 = _t1833 + self.pop_path() + self.consume_literal(")") + _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_start1145 = 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 + 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("]") - return strings636 + result1146 = strings1140 + self.record_span(span_start1145) + return result1146 def parse_rel_edb_types(self) -> Sequence[logic_pb2.Type]: + span_start1155 = 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 + 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("]") - return types640 + result1156 = types1150 + self.record_span(span_start1155) + return result1156 def parse_betree_relation(self) -> logic_pb2.BeTreeRelation: + span_start1159 = 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) + _t1836 = self.parse_relation_id() + relation_id1157 = _t1836 + self.pop_path() + self.push_path(2) + _t1837 = self.parse_betree_info() + betree_info1158 = _t1837 + self.pop_path() + self.consume_literal(")") + _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_start1164 = 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 + _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_start1174 = 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 + 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_start1184 = 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 + 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(")") + result1185 = types1179 + self.record_span(span_start1184) + return result1185 def parse_csv_data(self) -> logic_pb2.CSVData: + span_start1190 = 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) + _t1845 = self.parse_csvlocator() + csvlocator1186 = _t1845 + self.pop_path() + self.push_path(2) + _t1846 = self.parse_csv_config() + csv_config1187 = _t1846 + self.pop_path() + self.push_path(3) + _t1847 = self.parse_csv_columns() + csv_columns1188 = _t1847 + self.pop_path() + self.push_path(4) + _t1848 = self.parse_csv_asof() + csv_asof1189 = _t1848 + self.pop_path() + self.consume_literal(")") + _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_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)): - _t1251 = self.parse_csv_locator_paths() - _t1250 = _t1251 + _t1851 = self.parse_csv_locator_paths() + _t1850 = _t1851 else: - _t1250 = None - csv_locator_paths658 = _t1250 + _t1850 = None + csv_locator_paths1192 = _t1850 + self.pop_path() + self.push_path(2) if self.match_lookahead_literal("(", 0): - _t1253 = self.parse_csv_locator_inline_data() - _t1252 = _t1253 + _t1853 = self.parse_csv_locator_inline_data() + _t1852 = _t1853 else: - _t1252 = None - csv_locator_inline_data659 = _t1252 + _t1852 = None + csv_locator_inline_data1193 = _t1852 + 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 + _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_start1204 = 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 + 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_start1207 = self.span_start() self.consume_literal("(") self.consume_literal("inline_data") - string664 = self.consume_terminal("STRING") + string1206 = self.consume_terminal("STRING") self.consume_literal(")") - return string664 + result1208 = string1206 + self.record_span(span_start1207) + return result1208 def parse_csv_config(self) -> logic_pb2.CSVConfig: + span_start1210 = self.span_start() self.consume_literal("(") self.consume_literal("csv_config") - _t1255 = self.parse_config_dict() - config_dict665 = _t1255 + _t1855 = self.parse_config_dict() + config_dict1209 = _t1855 self.consume_literal(")") - _t1256 = self.construct_csv_config(config_dict665) - return _t1256 + _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_start1220 = 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 + 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_start1232 = 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) + string1222 = self.consume_terminal("STRING") + self.pop_path() + self.push_path(2) + _t1858 = self.parse_relation_id() + relation_id1223 = _t1858 + 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) + 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() + 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(")") - _t1260 = logic_pb2.CSVColumn(column_name=string670, target_id=relation_id671, types=types675) - return _t1260 + _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_start1235 = self.span_start() self.consume_literal("(") self.consume_literal("asof") - string676 = self.consume_terminal("STRING") + string1234 = self.consume_terminal("STRING") self.consume_literal(")") - return string676 + result1236 = string1234 + self.record_span(span_start1235) + return result1236 def parse_undefine(self) -> transactions_pb2.Undefine: + span_start1238 = self.span_start() self.consume_literal("(") self.consume_literal("undefine") - _t1261 = self.parse_fragment_id() - fragment_id677 = _t1261 + self.push_path(1) + _t1861 = self.parse_fragment_id() + fragment_id1237 = _t1861 + self.pop_path() self.consume_literal(")") - _t1262 = transactions_pb2.Undefine(fragment_id=fragment_id677) - return _t1262 + _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_start1248 = 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) + 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() + 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(")") + _t1864 = transactions_pb2.Context(relations=relation_ids1243) + result1249 = _t1864 + self.record_span(span_start1248) + return result1249 def parse_snapshot(self) -> transactions_pb2.Snapshot: + span_start1252 = 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) + _t1865 = self.parse_rel_edb_path() + rel_edb_path1250 = _t1865 + self.pop_path() + self.push_path(2) + _t1866 = self.parse_relation_id() + relation_id1251 = _t1866 + self.pop_path() + self.consume_literal(")") + _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_start1262 = 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 + 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_start1270 = self.span_start() if self.match_lookahead_literal("(", 0): if self.match_lookahead_literal("what_if", 1): - _t1270 = 2 + _t1870 = 2 else: if self.match_lookahead_literal("output", 1): - _t1271 = 1 + _t1871 = 1 else: if self.match_lookahead_literal("export", 1): - _t1272 = 4 + _t1872 = 4 else: if self.match_lookahead_literal("demand", 1): - _t1273 = 0 + _t1873 = 0 else: if self.match_lookahead_literal("abort", 1): - _t1274 = 3 + _t1874 = 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 + _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 prediction688 == 2: - _t1282 = self.parse_what_if() - what_if691 = _t1282 - _t1283 = transactions_pb2.Read(what_if=what_if691) - _t1281 = _t1283 + 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 prediction688 == 1: - _t1285 = self.parse_output() - output690 = _t1285 - _t1286 = transactions_pb2.Read(output=output690) - _t1284 = _t1286 + 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 prediction688 == 0: - _t1288 = self.parse_demand() - demand689 = _t1288 - _t1289 = transactions_pb2.Read(demand=demand689) - _t1287 = _t1289 + 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}`") - _t1284 = _t1287 - _t1281 = _t1284 - _t1278 = _t1281 - _t1275 = _t1278 - return _t1275 + _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_start1273 = self.span_start() self.consume_literal("(") self.consume_literal("demand") - _t1290 = self.parse_relation_id() - relation_id694 = _t1290 + self.push_path(1) + _t1890 = self.parse_relation_id() + relation_id1272 = _t1890 + self.pop_path() self.consume_literal(")") - _t1291 = transactions_pb2.Demand(relation_id=relation_id694) - return _t1291 + _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_start1277 = 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) + _t1892 = self.parse_name() + name1275 = _t1892 + self.pop_path() + self.push_path(2) + _t1893 = self.parse_relation_id() + relation_id1276 = _t1893 + self.pop_path() + self.consume_literal(")") + _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_start1281 = 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) + _t1895 = self.parse_name() + name1279 = _t1895 + self.pop_path() + self.push_path(2) + _t1896 = self.parse_epoch() + epoch1280 = _t1896 + self.pop_path() + self.consume_literal(")") + _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_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)): - _t1299 = self.parse_name() - _t1298 = _t1299 + _t1899 = self.parse_name() + _t1898 = _t1899 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 + _t1898 = None + name1283 = _t1898 + self.pop_path() + self.push_path(2) + _t1900 = self.parse_relation_id() + relation_id1284 = _t1900 + self.pop_path() + self.consume_literal(")") + _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_start1288 = self.span_start() self.consume_literal("(") self.consume_literal("export") - _t1302 = self.parse_export_csv_config() - export_csv_config701 = _t1302 + self.push_path(1) + _t1902 = self.parse_export_csv_config() + export_csv_config1287 = _t1902 + self.pop_path() self.consume_literal(")") - _t1303 = transactions_pb2.Export(csv_config=export_csv_config701) - return _t1303 + _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_start1293 = 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 + _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_start1296 = self.span_start() self.consume_literal("(") self.consume_literal("path") - string705 = self.consume_terminal("STRING") + string1295 = self.consume_terminal("STRING") self.consume_literal(")") - return string705 + result1297 = string1295 + self.record_span(span_start1296) + return result1297 def parse_export_csv_columns(self) -> Sequence[transactions_pb2.ExportCSVColumn]: + span_start1306 = 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 + 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_start1310 = 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) + string1308 = self.consume_terminal("STRING") + self.pop_path() + self.push_path(2) + _t1909 = self.parse_relation_id() + relation_id1309 = _t1909 + self.pop_path() + self.consume_literal(")") + _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]]: + """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/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_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_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_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..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}'" + ) diff --git a/sdks/python/tests/test_provenance.py b/sdks/python/tests/test_provenance.py new file mode 100644 index 00000000..f91a94c6 --- /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.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(): + """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 stop Location.""" + _, provenance = parse(SIMPLE_INPUT) + root_span = provenance[()] + assert isinstance(root_span, Span) + assert isinstance(root_span.start, Location) + assert isinstance(root_span.stop, Location)