-module(sqlode@query_ir). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/sqlode/query_ir.gleam"). -export_type([tokenized_query/0, sql_statement/0, select_item/0, from_item/0, join_clause/0, structured_query/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Intermediate representation shared between the query parser and the\n" " query analyzer. `TokenizedQuery` carries the expanded token list\n" " alongside the `ParsedQuery` metadata so analyzer layers can walk\n" " tokens without re-tokenizing the SQL string on every pass.\n" "\n" " `StructuredQuery` adds a thin structural layer that identifies the\n" " statement kind and its major clauses (tables, SELECT items, WHERE\n" " predicates, etc.) so inference passes can consume pre-parsed\n" " structure instead of re-scanning the raw token list.\n" ). -type tokenized_query() :: {tokenized_query, sqlode@model:parsed_query(), list(sqlode@lexer:token())}. -type sql_statement() :: {select_statement, list(select_item()), list(from_item()), list(join_clause()), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token()))} | {insert_statement, binary(), list(binary()), list(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token()))} | {update_statement, binary(), list(sqlode@lexer:token()), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token()))} | {delete_statement, binary(), gleam@option:option(list(sqlode@lexer:token())), gleam@option:option(list(sqlode@lexer:token()))} | {unstructured_statement, list(sqlode@lexer:token())}. -type select_item() :: {star_item, gleam@option:option(binary())} | {expression_item, list(sqlode@lexer:token()), gleam@option:option(binary())}. -type from_item() :: {table_ref, binary(), gleam@option:option(binary())} | {subquery_ref, list(sqlode@lexer:token()), gleam@option:option(binary())}. -type join_clause() :: {join_clause, binary(), gleam@option:option(binary()), gleam@option:option(list(sqlode@lexer:token()))}. -type structured_query() :: {structured_query, sqlode@model:parsed_query(), list(sqlode@lexer:token()), sql_statement()}.