Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
90d3563
Replace Python ANTLR parser with C++ parser via pybind11
javihern98 Mar 11, 2026
1a78318
Fix import sorting and cibuildwheel config
javihern98 Mar 11, 2026
5ca9b9a
Fix CI workflows to build C++ parser extension
javihern98 Mar 11, 2026
95a2883
Fix CI: copy .so for mypy, use --no-deps for ubuntu 24.04
javihern98 Mar 11, 2026
7fa2d26
Fix python -c indentation error in testing workflow
javihern98 Mar 11, 2026
b473a85
Silence mypy errors in AST modules instead of copying .so
javihern98 Mar 11, 2026
806d434
Narrow mypy overrides to ASTConstructor and _cpp_parser only
javihern98 Mar 11, 2026
fac32f5
Simplify version check: extract versions from source files directly
javihern98 Mar 11, 2026
45e07cc
Move version check to bash script, remove Python dependency
javihern98 Mar 11, 2026
e3f174e
Cache C++ parser wheel in CI to skip rebuild on subsequent runs
javihern98 Mar 11, 2026
af3bc11
Broaden mypy override to all AST modules
javihern98 Mar 11, 2026
0f79663
Fix Windows MSVC build and broaden mypy AST override
javihern98 Mar 11, 2026
d4bf23c
Exclude ProfilingATNSimulator from ANTLR4 build
javihern98 Mar 11, 2026
d81bfa9
Fix MSVC build: force-include <chrono> instead of excluding file
javihern98 Mar 11, 2026
4ef481a
Add poetry dependency cache and merge install steps
javihern98 Mar 11, 2026
78d8883
Add C++ AST builder infrastructure and port Terminals + ExprComponents
javihern98 Mar 11, 2026
04369e0
Port Expr visitor methods (Phase 3) to C++ AST builder
javihern98 Mar 11, 2026
a96721f
Port ASTConstructor top-level (Phase 4) to C++ AST builder
javihern98 Mar 11, 2026
808c914
Wire build_ast() into create_ast and fix Windowing/integer bugs
javihern98 Mar 11, 2026
23b675a
Add cleanup for cached py::object refs and fix integer overflow
javihern98 Mar 11, 2026
4fad338
Fix segfault at interpreter shutdown by using release() for static py…
javihern98 Mar 11, 2026
e81cbe0
Remove dead Python AST visitor code replaced by C++ AST builder
javihern98 Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,43 @@ permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5

- name: Build wheels
uses: pypa/cibuildwheel@v2.22

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl

publish:
name: Publish to PyPI
needs: [build-wheels]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
python-version: "3.x"
- name: Build package
run: poetry build
path: dist
merge-multiple: true

- name: Publish to PyPI
run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
22 changes: 19 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -29,8 +29,24 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: poetry install --all-extras
cache: poetry
- name: Cache C++ parser wheel
uses: actions/cache@v4
id: cpp-cache
with:
path: .cpp-wheel
key: cpp-parser-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('src/vtlengine/AST/Grammar/_cpp_parser/**', 'CMakeLists.txt', 'pyproject.toml', 'scripts/setup_antlr4_runtime.sh') }}
- name: Download ANTLR4 C++ runtime
if: steps.cpp-cache.outputs.cache-hit != 'true'
run: bash scripts/setup_antlr4_runtime.sh
- name: Build C++ parser wheel
if: steps.cpp-cache.outputs.cache-hit != 'true'
run: pip wheel . -w .cpp-wheel --no-deps -v
- name: Install package and dependencies
run: |
poetry install --no-root --all-extras
poetry run pip install .cpp-wheel/*.whl
shell: bash
- name: Check compliance with code formatting guidelines
run: poetry run ruff format --no-cache --check
- name: Run lint checks
Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/ubuntu_test_24_04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache C++ parser wheel
uses: actions/cache@v4
id: cpp-cache
with:
path: .cpp-wheel
key: cpp-parser-ubuntu2404-py3.12-${{ hashFiles('src/vtlengine/AST/Grammar/_cpp_parser/**', 'CMakeLists.txt', 'pyproject.toml', 'scripts/setup_antlr4_runtime.sh') }}

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
python3-antlr4 \
python3-pip \
python3-httpx \
python3-pandas \
Expand All @@ -31,7 +37,10 @@ jobs:
python3-jsonschema \
python3-networkx \
python3-sqlglot \
python3-pytest
python3-pytest \
cmake \
g++ \
pybind11-dev

- name: Install pip-only dependencies
run: |
Expand All @@ -43,18 +52,18 @@ jobs:
duckdb==1.1 \
pysdmx==1.9.0

- name: Install Poetry
run: |
pip install poetry
poetry config virtualenvs.create false
- name: Download ANTLR4 C++ runtime
if: steps.cpp-cache.outputs.cache-hit != 'true'
run: bash scripts/setup_antlr4_runtime.sh

- name: Build wheel
run: |
poetry build -f wheel -o .
- name: Build C++ parser wheel
if: steps.cpp-cache.outputs.cache-hit != 'true'
run: pip wheel . -w .cpp-wheel --no-deps -v
env:
PIP_BREAK_SYSTEM_PACKAGES: "1"

- name: Install built package
run: |
pip install "./vtlengine-$(poetry version -s)-py3-none-any.whl" --no-dependencies --break-system-packages
- name: Install C++ parser
run: pip install --break-system-packages --no-deps .cpp-wheel/*.whl

- name: Run tests
run: pytest --verbose --tb=short --strict-markers --strict-config --durations=10
30 changes: 1 addition & 29 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,5 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install poetry
run: pipx install poetry
- name: Install dependencies
run: poetry install

- name: Extract __version__ from module
id: module-version
run: |
echo "MODULE_VERSION=$(poetry run python -c 'import vtlengine; print(vtlengine.__version__)')" >> $GITHUB_OUTPUT

- name: Extract version from pyproject.toml
id: pyproject-version
run: |
echo "value=$(poetry version --short)" >> $GITHUB_OUTPUT

- name: Compare versions
run: |
if [ "${{ steps.pyproject-version.outputs.value }}" != "${{ steps.module-version.outputs.MODULE_VERSION }}" ]; then
echo "❌ Version mismatch detected!"
echo "pyproject.toml version: ${{ steps.pyproject-version.outputs.value }}"
echo "__version__ value: ${{ steps.module-version.outputs.MODULE_VERSION }}"
exit 1
else
echo "✅ Versions match (${{ steps.pyproject-version.outputs.value }})"
fi
run: bash scripts/check_version.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ docs/plans/
!/CONTRIBUTING.md
!/SECURITY.md

# C++ parser build artifacts
third_party/
build/

# Claude Code settings
.claude/*
!.claude/CLAUDE.md
70 changes: 70 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
cmake_minimum_required(VERSION 3.15...3.30)
project(vtlengine_cpp_parser LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Find pybind11
find_package(pybind11 CONFIG REQUIRED)

# -------------------------------------------------------------------
# ANTLR4 C++ runtime (vendored as static library)
# -------------------------------------------------------------------
set(ANTLR4_SRC_DIR "${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime/src")

# Collect all ANTLR4 runtime .cpp files
file(GLOB_RECURSE ANTLR4_RUNTIME_SOURCES "${ANTLR4_SRC_DIR}/*.cpp")

add_library(antlr4_runtime STATIC ${ANTLR4_RUNTIME_SOURCES})
target_include_directories(antlr4_runtime PUBLIC "${ANTLR4_SRC_DIR}")
target_compile_definitions(antlr4_runtime PUBLIC ANTLR4CPP_STATIC)

# Suppress warnings from third-party code
if(MSVC)
target_compile_options(antlr4_runtime PRIVATE /w)
# Fix missing chrono include in ProfilingATNSimulator on MSVC
target_compile_options(antlr4_runtime PRIVATE /FI"chrono")
else()
target_compile_options(antlr4_runtime PRIVATE -w)
endif()

# -------------------------------------------------------------------
# Generated VTL parser (C++ files from ANTLR)
# -------------------------------------------------------------------
set(VTL_PARSER_DIR "${CMAKE_SOURCE_DIR}/src/vtlengine/AST/Grammar/_cpp_parser")

set(VTL_PARSER_SOURCES
"${VTL_PARSER_DIR}/VtlLexer.cpp"
"${VTL_PARSER_DIR}/VtlParser.cpp"
"${VTL_PARSER_DIR}/VtlBaseListener.cpp"
"${VTL_PARSER_DIR}/VtlBaseVisitor.cpp"
"${VTL_PARSER_DIR}/VtlListener.cpp"
"${VTL_PARSER_DIR}/VtlVisitor.cpp"
)

# -------------------------------------------------------------------
# pybind11 module
# -------------------------------------------------------------------
pybind11_add_module(vtl_cpp_parser
"${VTL_PARSER_DIR}/bindings.cpp"
"${VTL_PARSER_DIR}/ast_builder.cpp"
${VTL_PARSER_SOURCES}
)

target_include_directories(vtl_cpp_parser PRIVATE
"${ANTLR4_SRC_DIR}"
"${VTL_PARSER_DIR}"
)

target_link_libraries(vtl_cpp_parser PRIVATE antlr4_runtime)

# Suppress warnings from generated parser code
if(MSVC)
target_compile_options(vtl_cpp_parser PRIVATE /w)
else()
target_compile_options(vtl_cpp_parser PRIVATE -w)
endif()

# Install the module into the vtlengine._cpp_parser package
install(TARGETS vtl_cpp_parser DESTINATION vtlengine/AST/Grammar/_cpp_parser)
Loading
Loading