Skip to content

Compiler#2

Merged
korenmiklos merged 5 commits into
mainfrom
compiler
May 27, 2026
Merged

Compiler#2
korenmiklos merged 5 commits into
mainfrom
compiler

Conversation

@korenmiklos
Copy link
Copy Markdown
Member

No description provided.

korenmiklos and others added 3 commits May 27, 2026 18:35
Extract the .do-to-SQL translation logic (tokenizer, expression
translator, command processor) into src/core/ with no DuckDB
dependency. The DuckDB extension becomes a thin wrapper in
src/extension/. A new dodoc CLI (src/cli/) compiles .do files
to SQL, reading from stdin/file and writing to stdout/file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- `make dodoc` builds the CLI with a single c++ invocation (no DuckDB)
- `make dodoc-install` installs to /usr/local/bin
- GitHub Actions workflow builds for macOS arm64/x86_64 and Linux
  x86_64/arm64, uploads binaries to GitHub Releases on dodoc-v* tags
- README documents install and usage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MSVC build with static CRT (/MT), packaged as .zip.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR splits the DuckDB extension “glue” from the core .do-to-SQL translation logic, and introduces dodoc, a standalone compiler binary that can compile .do files to SQL without linking DuckDB.

Changes:

  • Moved the extension interface into src/extension/* and extracted a DuckDB-independent core into src/core/*.
  • Added dodoc CLI (Makefile + CMake target) plus a GitHub Actions workflow to build and publish release artifacts.
  • Added src/include/* proxy headers to preserve include paths expected by DuckDB’s generated loader.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/include/string_utils.hpp Proxy header forwarding to the new core location.
src/include/dodo_extension.hpp Proxy header forwarding to the new extension header.
src/include/dodo_core.hpp Proxy header forwarding to the new core header.
src/extension/dodo_extension.hpp New extension-facing header that wraps dodo::DodoState for DuckDB.
src/extension/dodo_extension.cpp New DuckDB extension entrypoint and parser/operator extension wiring.
src/core/string_utils.hpp New DuckDB-independent string utilities + DodoException.
src/core/dodo_core.hpp New core public API for parsing/compiling .do commands.
src/core/dodo_core.cpp Refactored core implementation, plus extracted .do file processing helper.
src/cli/dodoc.cpp New standalone CLI for compiling .do input to SQL.
README.md Documentation for installing/using dodoc.
Makefile Added dodoc build/install/clean targets.
CMakeLists.txt Updated extension sources and added dodoc executable target.
.github/workflows/dodoc-release.yml New release workflow for building and packaging dodoc binaries.
Comments suppressed due to low confidence (3)

src/core/dodo_core.cpp:200

  • FileReadFunction interpolates filename directly into single-quoted SQL string literals (e.g., read_csv('...')) without escaping embedded '. Filenames containing a single quote will generate invalid SQL and can be used to inject SQL when compiling untrusted input. Escape single quotes in filename (replace ' with '') before building the SQL literal.
    src/core/dodo_core.cpp:2136
  • In the do-file lazy rewrite branch, you clear state.cte_steps and reset step_counter but you do not clear state.cte_commands (and related undo/redo metadata). This can leave cte_steps/cte_commands out of sync and break later history/live-view logic. Clear cte_commands (and consider clearing redo_stack/preserve fields) when resetting the chain here, matching the CLI’s reset logic.
    src/core/dodo_core.cpp:206
  • ParseByOption (and several nearby helper functions) no longer have internal linkage (static) and are not declared in the public header. This unnecessarily exports symbols and increases the chance of name collisions at link time. Mark these helpers static again (or declare them in the header if they’re meant to be public API).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
// Proxy header — DuckDB's generated extension loader includes "dodo_extension.hpp"
// from src/include. Forward to the actual location.
#include "../extension/dodo_extension.hpp"
Comment thread src/include/dodo_core.hpp
Comment on lines +1 to +2
// Proxy header — forward to actual location
#include "../core/dodo_core.hpp"
Comment on lines +1 to +2
// Proxy header — forward to actual location
#include "../core/string_utils.hpp"
Comment thread src/core/string_utils.hpp
Comment on lines +124 to +128
inline std::string QuoteIdent(const std::string &s) {
if (NeedsQuoting(s)) {
return "\"" + s + "\"";
}
return s;
Comment thread src/cli/dodoc.cpp
Comment on lines +35 to +38
if (arg == "-h" || arg == "--help") {
print_usage(argv[0]);
std::exit(0);
} else if (arg == "-o" || arg == "--output") {
@korenmiklos korenmiklos merged commit 992dbaf into main May 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants