Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic

This commit is contained in:
Krasimir Angelov
2026-09-09 15:10:11 +02:00
24 changed files with 455 additions and 221 deletions
+62 -52
View File
@@ -13,9 +13,9 @@ jobs:
name: Build Ubuntu package name: Build Ubuntu package
strategy: strategy:
matrix: matrix:
os: ghc: ["9.6"]
- ubuntu-18.04 cabal: ["3.10"]
- ubuntu-20.04 os: ["ubuntu-24.04"]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -25,12 +25,13 @@ jobs:
# Note: `haskell-platform` is listed as requirement in debian/control, # Note: `haskell-platform` is listed as requirement in debian/control,
# which is why it's installed using apt instead of the Setup Haskell action. # which is why it's installed using apt instead of the Setup Haskell action.
# - name: Setup Haskell - name: Setup Haskell
# uses: actions/setup-haskell@v1 uses: haskell-actions/setup@v2
# id: setup-haskell-cabal id: setup-haskell-cabal
# with: with:
# ghc-version: ${{ matrix.ghc }} ghc-version: ${{ matrix.ghc }}
# cabal-version: ${{ matrix.cabal }} cabal-version: ${{ matrix.cabal }}
if: matrix.os == 'ubuntu-24.04'
- name: Install build tools - name: Install build tools
run: | run: |
@@ -39,14 +40,15 @@ jobs:
make \ make \
dpkg-dev \ dpkg-dev \
debhelper \ debhelper \
haskell-platform \
libghc-json-dev \ libghc-json-dev \
python-dev \
default-jdk \ default-jdk \
python-dev-is-python3 \
libtool-bin libtool-bin
cabal install alex happy
- name: Build package - name: Build package
run: | run: |
export PYTHONPATH="/home/runner/work/gf-core/gf-core/debian/gf/usr/local/lib/python3.12/dist-packages/"
make deb make deb
- name: Copy package - name: Copy package
@@ -54,7 +56,7 @@ jobs:
cp ../gf_*.deb dist/ cp ../gf_*.deb dist/
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
path: dist/gf_*.deb path: dist/gf_*.deb
@@ -64,14 +66,14 @@ jobs:
run: | run: |
mv dist/gf_*.deb dist/gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb mv dist/gf_*.deb dist/gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
- uses: actions/upload-release-asset@v1.0.2 #- uses: actions/upload-release-asset@v1.0.2
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: # with:
upload_url: ${{ github.event.release.upload_url }} # upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb # asset_path: dist/gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
asset_name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb # asset_name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
asset_content_type: application/octet-stream # asset_content_type: application/octet-stream
# --- # ---
@@ -79,16 +81,16 @@ jobs:
name: Build macOS package name: Build macOS package
strategy: strategy:
matrix: matrix:
ghc: ["8.6.5"] ghc: ["9.6"]
cabal: ["2.4"] cabal: ["3.10"]
os: ["macos-10.15"] os: ["macos-latest", "macos-13"]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup Haskell - name: Setup Haskell
uses: actions/setup-haskell@v1 uses: haskell-actions/setup@v2
id: setup-haskell-cabal id: setup-haskell-cabal
with: with:
ghc-version: ${{ matrix.ghc }} ghc-version: ${{ matrix.ghc }}
@@ -97,8 +99,10 @@ jobs:
- name: Install build tools - name: Install build tools
run: | run: |
brew install \ brew install \
automake automake \
libtool
cabal v1-install alex happy cabal v1-install alex happy
pip install setuptools
- name: Build package - name: Build package
run: | run: |
@@ -107,9 +111,9 @@ jobs:
make pkg make pkg
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: gf-${{ github.event.release.tag_name }}-macos name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}
path: dist/gf-*.pkg path: dist/gf-*.pkg
if-no-files-found: error if-no-files-found: error
@@ -117,14 +121,14 @@ jobs:
run: | run: |
mv dist/gf-*.pkg dist/gf-${{ github.event.release.tag_name }}-macos.pkg mv dist/gf-*.pkg dist/gf-${{ github.event.release.tag_name }}-macos.pkg
- uses: actions/upload-release-asset@v1.0.2 #- uses: actions/upload-release-asset@v1.0.2
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: # with:
upload_url: ${{ github.event.release.upload_url }} # upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/gf-${{ github.event.release.tag_name }}-macos.pkg # asset_path: dist/gf-${{ github.event.release.tag_name }}-macos.pkg
asset_name: gf-${{ github.event.release.tag_name }}-macos.pkg # asset_name: gf-${{ github.event.release.tag_name }}-macos.pkg
asset_content_type: application/octet-stream # asset_content_type: application/octet-stream
# --- # ---
@@ -132,9 +136,9 @@ jobs:
name: Build Windows package name: Build Windows package
strategy: strategy:
matrix: matrix:
ghc: ["8.6.5"] ghc: ["9.6.7"]
cabal: ["2.4"] cabal: ["3.10"]
os: ["windows-2019"] os: ["windows-2022"]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
@@ -147,6 +151,7 @@ jobs:
base-devel base-devel
gcc gcc
python-devel python-devel
autotools
- name: Prepare dist folder - name: Prepare dist folder
shell: msys2 {0} shell: msys2 {0}
@@ -171,7 +176,8 @@ jobs:
- name: Build Java bindings - name: Build Java bindings
shell: msys2 {0} shell: msys2 {0}
run: | run: |
export JDKPATH=/c/hostedtoolcache/windows/Java_Adopt_jdk/8.0.292-10/x64 echo $JAVA_HOME_8_X64
export JDKPATH="$(cygpath -u "${JAVA_HOME_8_X64}")"
export PATH="${PATH}:${JDKPATH}/bin" export PATH="${PATH}:${JDKPATH}/bin"
cd src/runtime/java cd src/runtime/java
make \ make \
@@ -180,6 +186,9 @@ jobs:
make install make install
cp .libs/msys-jpgf-0.dll /c/tmp-dist/java/jpgf.dll cp .libs/msys-jpgf-0.dll /c/tmp-dist/java/jpgf.dll
cp jpgf.jar /c/tmp-dist/java cp jpgf.jar /c/tmp-dist/java
if: false
# - uses: actions/setup-python@v5
- name: Build Python bindings - name: Build Python bindings
shell: msys2 {0} shell: msys2 {0}
@@ -188,12 +197,13 @@ jobs:
EXTRA_LIB_DIRS: /mingw64/lib EXTRA_LIB_DIRS: /mingw64/lib
run: | run: |
cd src/runtime/python cd src/runtime/python
pacman --noconfirm -S python-setuptools
python setup.py build python setup.py build
python setup.py install python setup.py install
cp /usr/lib/python3.9/site-packages/pgf* /c/tmp-dist/python cp -r /usr/lib/python3.12/site-packages/pgf* /c/tmp-dist/python
- name: Setup Haskell - name: Setup Haskell
uses: actions/setup-haskell@v1 uses: haskell-actions/setup@v2
id: setup-haskell-cabal id: setup-haskell-cabal
with: with:
ghc-version: ${{ matrix.ghc }} ghc-version: ${{ matrix.ghc }}
@@ -205,13 +215,13 @@ jobs:
- name: Build GF - name: Build GF
run: | run: |
cabal install --only-dependencies -fserver cabal install -fserver --only-dependencies
cabal configure -fserver cabal configure -fserver
cabal build cabal build
copy dist\build\gf\gf.exe C:\tmp-dist copy dist-newstyle/build/x86_64-windows/ghc-${{matrix.ghc}}/*/x/gf/build/gf/gf.exe C:/tmp-dist
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: gf-${{ github.event.release.tag_name }}-windows name: gf-${{ github.event.release.tag_name }}-windows
path: C:\tmp-dist\* path: C:\tmp-dist\*
@@ -220,11 +230,11 @@ jobs:
- name: Create archive - name: Create archive
run: | run: |
Compress-Archive C:\tmp-dist C:\gf-${{ github.event.release.tag_name }}-windows.zip Compress-Archive C:\tmp-dist C:\gf-${{ github.event.release.tag_name }}-windows.zip
- uses: actions/upload-release-asset@v1.0.2 #- uses: actions/upload-release-asset@v1.0.2
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: # with:
upload_url: ${{ github.event.release.upload_url }} # upload_url: ${{ github.event.release.upload_url }}
asset_path: C:\gf-${{ github.event.release.tag_name }}-windows.zip # asset_path: C:\gf-${{ github.event.release.tag_name }}-windows.zip
asset_name: gf-${{ github.event.release.tag_name }}-windows.zip # asset_name: gf-${{ github.event.release.tag_name }}-windows.zip
asset_content_type: application/zip # asset_content_type: application/zip
+129 -50
View File
@@ -2,19 +2,18 @@ name: Build majestic runtime
on: push on: push
env:
LD_LIBRARY_PATH: /usr/local/lib
jobs: jobs:
linux-runtime: linux-runtime:
name: Runtime (Linux) name: Runtime (Linux)
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: quay.io/pypa/manylinux2014_x86_64:2024-01-08-eb135ed image: quay.io/pypa/manylinux_2_28_x86_64
env:
LD_LIBRARY_PATH: /usr/local/lib
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Build runtime - name: Build runtime
working-directory: ./src/runtime/c working-directory: ./src/runtime/c
@@ -25,7 +24,7 @@ jobs:
make install make install
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: libpgf-linux name: libpgf-linux
path: | path: |
@@ -36,11 +35,13 @@ jobs:
name: Haskell (Linux) name: Haskell (Linux)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: linux-runtime needs: linux-runtime
env:
LD_LIBRARY_PATH: /usr/local/lib
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v4
with: with:
name: libpgf-linux name: libpgf-linux
- run: | - run: |
@@ -48,7 +49,7 @@ jobs:
sudo mv include/* /usr/local/include/ sudo mv include/* /usr/local/include/
- name: Setup Haskell - name: Setup Haskell
uses: haskell/actions/setup@v2 uses: haskell-actions/setup@v2
with: with:
ghc-version: 8 ghc-version: 8
@@ -68,7 +69,7 @@ jobs:
cabal v1-install cabal v1-install
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@v4
with: with:
name: compiler-linux name: compiler-linux
path: | path: |
@@ -78,11 +79,13 @@ jobs:
name: Python (Linux) name: Python (Linux)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: linux-runtime needs: linux-runtime
env:
LD_LIBRARY_PATH: /usr/local/lib
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v4
with: with:
name: libpgf-linux name: libpgf-linux
@@ -99,7 +102,7 @@ jobs:
run: | run: |
python3 -m cibuildwheel src/runtime/python --output-dir wheelhouse python3 -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@master - uses: actions/upload-artifact@v4
with: with:
name: python-linux name: python-linux
path: ./wheelhouse path: ./wheelhouse
@@ -110,7 +113,7 @@ jobs:
# needs: linux-runtime # needs: linux-runtime
# #
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v7
# - name: Download artifact # - name: Download artifact
# uses: actions/download-artifact@master # uses: actions/download-artifact@master
# with: # with:
@@ -138,10 +141,12 @@ jobs:
macos-runtime: macos-runtime:
name: Runtime (macOS) name: Runtime (macOS)
runs-on: macOS-11 runs-on: macOS-latest
env:
LD_LIBRARY_PATH: /opt/homebrew/lib
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Install build tools - name: Install build tools
run: | run: |
@@ -155,65 +160,91 @@ jobs:
run: | run: |
glibtoolize glibtoolize
autoreconf -i autoreconf -i
./configure ./configure --prefix=/opt/homebrew
make make
sudo make install sudo make install
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@v4
with: with:
name: libpgf-macos name: libpgf-macos
path: | path: |
/usr/local/lib/libpgf* /opt/homebrew/lib/libpgf*
/usr/local/include/pgf /opt/homebrew/include/pgf
macos-haskell: macos-haskell:
name: Haskell (macOS) name: Haskell (macOS)
runs-on: macOS-11 runs-on: macOS-latest
needs: macos-runtime needs: macos-runtime
env:
LD_LIBRARY_PATH: /opt/homebrew/lib
CPATH: /opt/homebrew/include:$CPATH
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@master uses: actions/download-artifact@v4
with: with:
name: libpgf-macos name: libpgf-macos
- run: | - run: |
sudo mv lib/* /usr/local/lib/ sudo mv lib/* /opt/homebrew/lib/
sudo mv include/* /usr/local/include/ sudo mv include/* /opt/homebrew/include/
- name: Setup Haskell - name: Setup Haskell
uses: haskell/actions/setup@v2 uses: haskell-actions/setup@v2
with: with:
ghc-version: 8 ghc-version: 9
- name: Build & run testsuite - name: Install Haskell build tools
run: |
cabal v1-install alex happy
- name: build and test the runtime
working-directory: ./src/runtime/haskell working-directory: ./src/runtime/haskell
run: | run: |
cabal test --extra-lib-dirs=/usr/local/lib cabal v1-install --extra-lib-dirs=/opt/homebrew/lib --extra-include-dirs=/opt/homebrew/include
cabal test --extra-lib-dirs=/opt/homebrew/lib
- name: build the compiler
working-directory: ./src/compiler
run: |
cabal v1-install
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: compiler-macos
path: |
~/.cabal/bin/gf
macos-python: macos-python:
name: Python (macOS) name: Python (macOS)
runs-on: macOS-11 runs-on: macOS-latest
needs: macos-runtime needs: macos-runtime
env: env:
EXTRA_INCLUDE_DIRS: /usr/local/include LD_LIBRARY_PATH: /opt/homebrew/lib
EXTRA_LIB_DIRS: /usr/local/lib EXTRA_INCLUDE_DIRS: /opt/homebrew/include
MACOSX_DEPLOYMENT_TARGET: 11.0 EXTRA_LIB_DIRS: /opt/homebrew/lib
MACOSX_DEPLOYMENT_TARGET: 26.0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@master uses: actions/download-artifact@v4
with: with:
name: libpgf-macos name: libpgf-macos
- run: | - run: |
sudo mv lib/* /usr/local/lib/ sudo mv lib/* /opt/homebrew/lib/
sudo mv include/* /usr/local/include/ sudo mv include/* /opt/homebrew/include/
- name: Create Python virtual environment
run: |
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
- name: Install cibuildwheel - name: Install cibuildwheel
run: | run: |
python3 -m pip install git+https://github.com/joerick/cibuildwheel.git@main .venv/bin/python -m pip install git+https://github.com/joerick/cibuildwheel.git@main
- name: Install and test bindings - name: Install and test bindings
env: env:
@@ -221,9 +252,9 @@ jobs:
CIBW_TEST_COMMAND: "pytest {project}/src/runtime/python" CIBW_TEST_COMMAND: "pytest {project}/src/runtime/python"
CIBW_SKIP: "pp* cp36* cp37* cp38* cp39*" CIBW_SKIP: "pp* cp36* cp37* cp38* cp39*"
run: | run: |
python3 -m cibuildwheel src/runtime/python --output-dir wheelhouse .venv/bin/python -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@master - uses: actions/upload-artifact@v4
with: with:
name: python-macos name: python-macos
path: ./wheelhouse path: ./wheelhouse
@@ -234,7 +265,7 @@ jobs:
# needs: macos-runtime # needs: macos-runtime
# #
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v7
# - name: Download artifact # - name: Download artifact
# uses: actions/download-artifact@master # uses: actions/download-artifact@master
# with: # with:
@@ -265,7 +296,7 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Setup MSYS2 - name: Setup MSYS2
uses: msys2/setup-msys2@v2 uses: msys2/setup-msys2@v2
@@ -289,7 +320,7 @@ jobs:
make install make install
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@v4
with: with:
name: libpgf-windows name: libpgf-windows
path: | path: |
@@ -300,17 +331,65 @@ jobs:
${{runner.temp}}/msys64/mingw64/lib/libpgf* ${{runner.temp}}/msys64/mingw64/lib/libpgf*
${{runner.temp}}/msys64/mingw64/include/pgf ${{runner.temp}}/msys64/mingw64/include/pgf
windows-haskell:
name: Haskell (Windows)
runs-on: windows-latest
needs: mingw64-runtime
steps:
- uses: actions/checkout@v7
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: libpgf-windows
- name: Setup Haskell
uses: haskell-actions/setup@v2
with:
ghc-version: 8
- name: Install libpgf for GHC
shell: pwsh
run: |
$ghcLibDir = ghc --print-libdir
Copy-Item "${{ github.workspace }}\lib\*" "$ghcLibDir\..\mingw\lib\" -Force
Copy-Item "${{ github.workspace }}\include\pgf" "$ghcLibDir\..\mingw\include\" -Recurse -Force
Copy-Item "${{ github.workspace }}\bin\*" "$ghcLibDir\..\bin\" -Force
- name: Install Haskell build tools
run: |
cabal v1-install alex happy
- name: build and test the runtime
working-directory: ./src/runtime/haskell
run: |
cabal v1-install
cabal test
- name: build the compiler
working-directory: ./src/compiler
run: |
cabal v1-install
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: compiler-windows
path: |
~/.cabal/bin/gf
windows-python: windows-python:
name: Python (Windows) name: Python (Windows)
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: '3.10' python-version: '3.11'
- name: Install cibuildwheel - name: Install cibuildwheel
run: | run: |
@@ -324,7 +403,7 @@ jobs:
run: | run: |
python3 -m cibuildwheel src\runtime\python --output-dir wheelhouse python3 -m cibuildwheel src\runtime\python --output-dir wheelhouse
- uses: actions/upload-artifact@master - uses: actions/upload-artifact@v4
with: with:
name: python-windows name: python-windows
path: ./wheelhouse path: ./wheelhouse
@@ -336,7 +415,7 @@ jobs:
if: github.ref == 'refs/heads/majestic' && github.event_name == 'push' if: github.ref == 'refs/heads/majestic' && github.event_name == 'push'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v7
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v3 uses: actions/setup-python@v3
@@ -346,17 +425,17 @@ jobs:
- name: Install twine - name: Install twine
run: pip install twine run: pip install twine
- uses: actions/download-artifact@master - uses: actions/download-artifact@v4
with: with:
name: python-linux name: python-linux
path: ./dist path: ./dist
- uses: actions/download-artifact@master - uses: actions/download-artifact@v4
with: with:
name: python-macos name: python-macos
path: ./dist path: ./dist
- uses: actions/download-artifact@master - uses: actions/download-artifact@v4
with: with:
name: python-windows name: python-windows
path: ./dist path: ./dist
+21 -17
View File
@@ -13,24 +13,25 @@ jobs:
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-18.04, macos-10.15] os: [ubuntu-latest, macos-latest, macos-13]
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v4
- uses: actions/setup-python@v1 - uses: actions/setup-python@v5
name: Install Python name: Install Python
with: with:
python-version: '3.7' python-version: '3.x'
- name: Install cibuildwheel - name: Install cibuildwheel
run: | run: |
python -m pip install git+https://github.com/joerick/cibuildwheel.git@main python -m pip install cibuildwheel
- name: Install build tools for OSX - name: Install build tools for OSX
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
run: | run: |
brew install automake brew install automake
brew install libtool
- name: Build wheels on Linux - name: Build wheels on Linux
if: startsWith(matrix.os, 'macos') != true if: startsWith(matrix.os, 'macos') != true
@@ -42,30 +43,32 @@ jobs:
- name: Build wheels on OSX - name: Build wheels on OSX
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
env: env:
CIBW_BEFORE_BUILD: cd src/runtime/c && glibtoolize && autoreconf -i && ./configure && make && make install CIBW_BEFORE_BUILD: cd src/runtime/c && glibtoolize && autoreconf -i && ./configure && make && sudo make install
run: | run: |
python -m cibuildwheel src/runtime/python --output-dir wheelhouse python -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: wheel-${{ matrix.os }}
path: ./wheelhouse path: ./wheelhouse
build_sdist: build_sdist:
name: Build source distribution name: Build source distribution
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- uses: actions/setup-python@v2 - uses: actions/setup-python@v5
name: Install Python name: Install Python
with: with:
python-version: '3.7' python-version: '3.10'
- name: Build sdist - name: Build sdist
run: cd src/runtime/python && python setup.py sdist run: cd src/runtime/python && python setup.py sdist
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: wheel-source
path: ./src/runtime/python/dist/*.tar.gz path: ./src/runtime/python/dist/*.tar.gz
upload_pypi: upload_pypi:
@@ -75,24 +78,25 @@ jobs:
if: github.ref == 'refs/heads/master' && github.event_name == 'push' if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.x'
- name: Install twine - name: Install twine
run: pip install twine run: pip install twine
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v4.1.7
with: with:
name: artifact pattern: wheel-*
merge-multiple: true
path: ./dist path: ./dist
- name: Publish - name: Publish
env: env:
TWINE_USERNAME: __token__ TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: | run: |
(cd ./src/runtime/python && curl -I --fail https://pypi.org/project/$(python setup.py --name)/$(python setup.py --version)/) || twine upload dist/* twine upload --verbose --non-interactive --skip-existing dist/*
+6 -9
View File
@@ -5,7 +5,6 @@
*.jar *.jar
*.gfo *.gfo
*.pgf *.pgf
*.ngf
debian/.debhelper debian/.debhelper
debian/debhelper-build-stamp debian/debhelper-build-stamp
debian/gf debian/gf
@@ -47,8 +46,6 @@ src/runtime/c/sg/.dirstamp
src/runtime/c/stamp-h1 src/runtime/c/stamp-h1
src/runtime/java/.libs/ src/runtime/java/.libs/
src/runtime/python/build/ src/runtime/python/build/
src/runtime/python/**/__pycache__/
src/runtime/python/**/.pytest_cache/
.cabal-sandbox .cabal-sandbox
cabal.sandbox.config cabal.sandbox.config
.stack-work .stack-work
@@ -56,12 +53,6 @@ DATA_DIR
stack*.yaml.lock stack*.yaml.lock
# Generated source files
src/compiler/api/GF/Grammar/Lexer.hs
src/compiler/api/GF/Grammar/Parser.hs
src/compiler/api/PackageInfo_gf.hs
src/compiler/api/Paths_gf.hs
# Output files for test suite # Output files for test suite
*.out *.out
gf-tests.html gf-tests.html
@@ -82,3 +73,9 @@ doc/icfp-2012.html
download/*.html download/*.html
gf-book/index.html gf-book/index.html
src/www/gf-web-api.html src/www/gf-web-api.html
.devenv
.direnv
result
.vscode
.envrc
.pre-commit-config.yaml
Binary file not shown.
+39 -22
View File
@@ -150,11 +150,9 @@ Open a terminal, go to the top directory (``gf-core``), and type the following c
$ stack install $ stack install
``` ```
It will install GF and all necessary tools and libraries to do that.
=== Alternative: use Cabal === === Alternative: use Cabal ===
You can also install GF using Cabal, if you prefer Cabal to Stack. In that case, you may need to install some prerequisites yourself.
If you prefer Cabal, then you just need to manually choose a suitable GHC to build GF. We recommend GHC 9.6.7, see other supported options in [gf.cabal https://github.com/GrammaticalFramework/gf-core/blob/master/gf.cabal#L14].
The actual installation process is similar to Stack: open a terminal, go to the top directory (``gf-core``), and type the following command. The actual installation process is similar to Stack: open a terminal, go to the top directory (``gf-core``), and type the following command.
@@ -162,7 +160,13 @@ The actual installation process is similar to Stack: open a terminal, go to the
$ cabal install $ cabal install
``` ```
//The old (potentially outdated) instructions for Cabal are moved to a [separate page ../doc/gf-developers-old-cabal.html]. If you run into trouble with ``cabal install``, you may want to take a look.// === Nix ===
As of 3.12, GF can also be installed via Nix. You can install GF from github with the following command:
```
nix profile install github:GrammaticalFramework/gf-core#gf
```
== Compiling GF with C runtime system support == == Compiling GF with C runtime system support ==
@@ -197,7 +201,7 @@ Depending on what you want to do with the C runtime, you can follow one or more
=== Use the C runtime from another programming language ===[bindings] === Use the C runtime from another programming language ===[bindings]
% **If you just want to use the C runtime from Python, Java, or Haskell, you don't need to change your GF installation.** % **If you just want to use the C runtime from Python or Haskell, you don't need to change your GF installation.**
- **What —** - **What —**
This is the most common use case for the C runtime: compile This is the most common use case for the C runtime: compile
@@ -230,20 +234,13 @@ modes (use the ``help`` command in the shell for details).
(Re)compiling your GF with these flags will also give you (Re)compiling your GF with these flags will also give you
Haskell bindings to the C runtime, as a library called ``PGF2``, Haskell bindings to the C runtime, as a library called ``PGF2``,
but if you want Python or Java bindings, you need to do [the previous step #bindings]. but if you want Python bindings, you need to do [the previous step #bindings].
% ``PGF2``: a module to import in Haskell programs, providing a binding to the C run-time system. % ``PGF2``: a module to import in Haskell programs, providing a binding to the C run-time system.
- **How —** - **How —**
If you use cabal, run the following command:
``` Add (or uncomment) the following lines in the ``stack.yaml`` file:
cabal install -fc-runtime
```
from the top directory (``gf-core``).
If you use stack, uncomment the following lines in the ``stack.yaml`` file:
``` ```
flags: flags:
@@ -254,6 +251,32 @@ extra-lib-dirs:
``` ```
and then run ``stack install`` from the top directory (``gf-core``). and then run ``stack install`` from the top directory (``gf-core``).
Run the newly built executable with the flag ``-cshell``, and you should see the following welcome message:
```
$ gf -cshell
* * *
* *
* *
*
*
* * * * * * *
* * *
* * * * * *
* * *
* * *
This is GF version 3.12.0.
Built on ...
Git info: ...
Flags: interrupt server c-runtime
License: see help -license.
This shell uses the C run-time system. See help for available commands.
>
```
//If you get an "``error while loading shared libraries``" when trying to run GF with C runtime, remember to declare your ``LD_LIBRARY_PATH``.// //If you get an "``error while loading shared libraries``" when trying to run GF with C runtime, remember to declare your ``LD_LIBRARY_PATH``.//
//Add ``export LD_LIBRARY_PATH="/usr/local/lib"`` to either your ``.bashrc`` or ``.profile``. You should now be able to start GF with C runtime.// //Add ``export LD_LIBRARY_PATH="/usr/local/lib"`` to either your ``.bashrc`` or ``.profile``. You should now be able to start GF with C runtime.//
@@ -266,14 +289,8 @@ With this feature, ``gf -server`` mode is extended with new requests to call the
system, e.g. ``c-parse``, ``c-linearize`` and ``c-translate``. system, e.g. ``c-parse``, ``c-linearize`` and ``c-translate``.
- **How —** - **How —**
If you use cabal, run the following command:
``` Add the following lines in the ``stack.yaml`` file:
cabal install -fc-runtime -fserver
```
from the top directory.
If you use stack, add the following lines in the ``stack.yaml`` file:
``` ```
flags: flags:
+18 -5
View File
@@ -1188,7 +1188,7 @@ use ``generate_trees = gt``.
this wine is fresh this wine is fresh
this wine is warm this wine is warm
``` ```
The default **depth** is 3; the depth can be The default **depth** is 5; the depth can be
set by using the ``depth`` flag: set by using the ``depth`` flag:
``` ```
> generate_trees -depth=2 | l > generate_trees -depth=2 | l
@@ -1265,10 +1265,16 @@ Human eye may prefer to see a visualization: ``visualize_tree = vt``:
> parse "this delicious cheese is very Italian" | visualize_tree > parse "this delicious cheese is very Italian" | visualize_tree
``` ```
The tree is generated in postscript (``.ps``) file. The ``-view`` option is used for The tree is generated in postscript (``.ps``) file. The ``-view`` option is used for
telling what command to use to view the file. Its default is ``"open"``, which works telling what command to use to view the file.
on Mac OS X. On Ubuntu Linux, one can write
This works on Mac OS X:
``` ```
> parse "this delicious cheese is very Italian" | visualize_tree -view="eog" > parse "this delicious cheese is very Italian" | visualize_tree -view=open
```
On Linux, one can use one of the following commands.
```
> parse "this delicious cheese is very Italian" | visualize_tree -view=eog
> parse "this delicious cheese is very Italian" | visualize_tree -view=xdg-open
``` ```
@@ -1733,6 +1739,13 @@ A new module can **extend** an old one:
Pizza : Kind ; Pizza : Kind ;
} }
``` ```
Note that the extended grammar doesn't inherit the start
category from the grammar it extends, so if you want to
generate sentences with this grammar, you'll have to either
add a startcat (e.g. ``flags startcat = Question ;``),
or in the GF shell, specify the category to ``generate_random`` or ``geneate_trees``
(e.g. ``gr -cat=Comment`` or ``gt -cat=Question``).
Parallel to the abstract syntax, extensions can Parallel to the abstract syntax, extensions can
be built for concrete syntaxes: be built for concrete syntaxes:
``` ```
@@ -4578,7 +4591,7 @@ in any multilingual grammar between any languages in the grammar.
module Main where module Main where
import PGF import PGF
import System (getArgs) import System.Environment (getArgs)
main :: IO () main :: IO ()
main = do main = do
Generated
+43
View File
@@ -0,0 +1,43 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1704290814,
"narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+50
View File
@@ -0,0 +1,50 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
systems.url = "github:nix-systems/default";
};
nixConfig = {
# extra-trusted-public-keys =
# "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
# extra-substituters = "https://devenv.cachix.org";
};
outputs = { self, nixpkgs, systems, ... }@inputs:
let forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = forEachSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
haskellPackages = pkgs.haskell.packages.ghc925.override {
overrides = self: _super: {
cgi = pkgs.haskell.lib.unmarkBroken (pkgs.haskell.lib.dontCheck
(self.callHackage "cgi" "3001.5.0.1" { }));
};
};
in {
gf = pkgs.haskell.lib.overrideCabal
(haskellPackages.callCabal2nixWithOptions "gf" self "--flag=-server"
{ }) (_old: {
# Fix utf8 encoding problems
patches = [
# Already applied in master
# (
# pkgs.fetchpatch {
# url = "https://github.com/anka-213/gf-core/commit/6f1ca05fddbcbc860898ddf10a557b513dfafc18.patch";
# sha256 = "17vn3hncxm1dwbgpfmrl6gk6wljz3r28j191lpv5zx741pmzgbnm";
# }
# )
./nix/expose-all.patch
./nix/revert-new-cabal-madness.patch
];
jailbreak = true;
# executableSystemDepends = [
# (pkgs.ncurses.override { enableStatic = true; })
# ];
# executableHaskellDepends = [ ];
});
});
};
}
+24 -21
View File
@@ -55,15 +55,14 @@
<li><a href="gf-book">The GF Book</a></li> <li><a href="gf-book">The GF Book</a></li>
<li><a href="doc/gf-refman.html">Reference Manual</a></li> <li><a href="doc/gf-refman.html">Reference Manual</a></li>
<li><a href="doc/gf-shell-reference.html">Shell Reference</a></li> <li><a href="doc/gf-shell-reference.html">Shell Reference</a></li>
<li><a href="http://www.molto-project.eu/sites/default/files/MOLTO_D2.3.pdf">Best Practices</a> <small>[PDF]</small></li> <li><a href="https://www.grammaticalframework.org/doc/MOLTO_D2.3.pdf">Best Practices</a> <small>[PDF]</small></li>
<li><a href="https://www.mitpressjournals.org/doi/pdf/10.1162/COLI_a_00378">Scaling Up (Computational Linguistics 2020)</a></li> <li><a href="https://www.mitpressjournals.org/doi/pdf/10.1162/COLI_a_00378">Scaling Up (Computational Linguistics 2020)</a></li>
<li><a href="https://github.com/GrammaticalFramework/gf-wordnet/blob/master/README.md">GF WordNet</a></li>
<li><a href="https://inariksit.github.io/blog/">GF blog</a></li> <li><a href="https://inariksit.github.io/blog/">GF blog</a></li>
</ul> </ul>
<a href="lib/doc/synopsis/index.html" class="btn btn-primary ml-3"> <a href="lib/doc/synopsis/index.html" class="btn btn-primary ml-3">
<i class="fab fa-readme mr-1"></i> <i class="fab fa-readme mr-1"></i>
RGL Synopsis RGL API
</a> </a>
</div> </div>
@@ -73,8 +72,12 @@
<li><a href="doc/gf-developers.html">Developers Guide</a></li> <li><a href="doc/gf-developers.html">Developers Guide</a></li>
<!-- <li><a href="/~hallgren/gf-experiment/browse/">Browse Source Code</a></li> --> <!-- <li><a href="/~hallgren/gf-experiment/browse/">Browse Source Code</a></li> -->
<li>PGF library API:<br> <li>PGF library API:<br>
<a href="http://hackage.haskell.org/package/gf/docs/PGF.html">Haskell</a> / <ul>
<a href="doc/runtime-api.html">C&nbsp;runtime</a> <li><a href="http://hackage.haskell.org/package/gf/docs/PGF.html">Haskell</a>
</li><li><a href="doc/runtime-api.html#python">Python</a>
</li><li><a href="doc/runtime-api.html">C&nbsp;runtime</a>
</li>
</ul>
</li> </li>
<li><a href="http://hackage.haskell.org/package/gf/docs/GF.html">GF compiler API</a></li> <li><a href="http://hackage.haskell.org/package/gf/docs/GF.html">GF compiler API</a></li>
<!-- <li><a href="src/ui/android/README">GF on Android (new)</a></li> <!-- <li><a href="src/ui/android/README">GF on Android (new)</a></li>
@@ -88,11 +91,6 @@
<h3>Contribute</h3> <h3>Contribute</h3>
<ul class="mb-2"> <ul class="mb-2">
<li> <li>
<a href="https://web.libera.chat/?channels=#gf">
<i class="fas fa-hashtag"></i>
IRC
</a>
/
<a href="https://discord.gg/EvfUsjzmaz"> <a href="https://discord.gg/EvfUsjzmaz">
<i class="fab fa-discord"></i> <i class="fab fa-discord"></i>
Discord Discord
@@ -106,7 +104,7 @@
</li> </li>
<li><a href="https://groups.google.com/group/gf-dev">Mailing List</a></li> <li><a href="https://groups.google.com/group/gf-dev">Mailing List</a></li>
<li><a href="https://github.com/GrammaticalFramework/gf-core/issues">Issue Tracker</a></li> <li><a href="https://github.com/GrammaticalFramework/gf-core/issues">Issue Tracker</a></li>
<li><a href="//school.grammaticalframework.org/2020/">Summer School</a></li> <li><a href="//school.grammaticalframework.org/">Summer School</a></li>
<li><a href="doc/gf-people.html">Authors</a></li> <li><a href="doc/gf-people.html">Authors</a></li>
</ul> </ul>
<a href="https://github.com/GrammaticalFramework/" class="btn btn-primary ml-3"> <a href="https://github.com/GrammaticalFramework/" class="btn btn-primary ml-3">
@@ -233,14 +231,10 @@ least one, it may help you to get a first idea of what GF is.
</p> </p>
<p> <p>
We run the IRC channel <strong><code>#gf</code></strong> on the Libera network, where you are welcome to look for help with small questions or just start a general discussion. We run the <a href="https://discord.gg/EvfUsjzmaz">GF server on Discord</a>, where you are welcome to look for help with small questions or just start a general discussion.
You can <a href="https://web.libera.chat/?channels=#gf">open a web chat</a>
or <a href="https://www.grammaticalframework.org/irc/?C=M;O=D">browse the channel logs</a>.
</p>
<p>
There is also a <a href="https://discord.gg/EvfUsjzmaz">GF server on Discord</a>.
</p> </p>
<p> <p>
For bug reports and feature requests, please create an issue in the For bug reports and feature requests, please create an issue in the
<a href="https://github.com/GrammaticalFramework/gf-core/issues">GF Core</a> or <a href="https://github.com/GrammaticalFramework/gf-core/issues">GF Core</a> or
@@ -255,6 +249,19 @@ least one, it may help you to get a first idea of what GF is.
<div class="col-md-6"> <div class="col-md-6">
<h2>News</h2> <h2>News</h2>
<dl class="row"> <dl class="row">
<dt class="col-sm-3 text-center text-nowrap">2025-08-08</dt>
<dd class="col-sm-9">
<strong>GF 3.12 released.</strong>
<a href="download/release-3.12.html">Release notes</a>
</dd>
<dt class="col-sm-3 text-center text-nowrap">2025-01-18</dt>
<dd class="col-sm-9">
<a href="//school.grammaticalframework.org/2025/">9th GF Summer School</a>, in Gothenburg, Sweden, 18 &ndash; 29 August 2025.
</dd>
<dt class="col-sm-3 text-center text-nowrap">2023-01-24</dt>
<dd class="col-sm-9">
<a href="//school.grammaticalframework.org/2023/">8th GF Summer School</a>, in Tampere, Finland, 14 &ndash; 25 August 2023.
</dd>
<dt class="col-sm-3 text-center text-nowrap">2021-07-25</dt> <dt class="col-sm-3 text-center text-nowrap">2021-07-25</dt>
<dd class="col-sm-9"> <dd class="col-sm-9">
<strong>GF 3.11 released.</strong> <strong>GF 3.11 released.</strong>
@@ -264,10 +271,6 @@ least one, it may help you to get a first idea of what GF is.
<dd class="col-sm-9"> <dd class="col-sm-9">
<a href="https://cloud.grammaticalframework.org/wordnet/">GF WordNet</a> now supports languages for which there are no other WordNets. New additions: Afrikaans, German, Korean, Maltese, Polish, Somali, Swahili. <a href="https://cloud.grammaticalframework.org/wordnet/">GF WordNet</a> now supports languages for which there are no other WordNets. New additions: Afrikaans, German, Korean, Maltese, Polish, Somali, Swahili.
</dd> </dd>
<dt class="col-sm-3 text-center text-nowrap">2021-03-01</dt>
<dd class="col-sm-9">
<a href="//school.grammaticalframework.org/2020/">Seventh GF Summer School</a>, in Singapore and online, 26 July &ndash; 6 August 2021.
</dd>
<dt class="col-sm-3 text-center text-nowrap">2020-09-29</dt> <dt class="col-sm-3 text-center text-nowrap">2020-09-29</dt>
<dd class="col-sm-9"> <dd class="col-sm-9">
<a href="https://www.mitpressjournals.org/doi/pdf/10.1162/COLI_a_00378">Abstract Syntax as Interlingua</a>: Scaling Up the Grammatical Framework from Controlled Languages to Robust Pipelines. A paper in Computational Linguistics (2020) summarizing much of the development in GF in the past ten years. <a href="https://www.mitpressjournals.org/doi/pdf/10.1162/COLI_a_00378">Abstract Syntax as Interlingua</a>: Scaling Up the Grammatical Framework from Controlled Languages to Robust Pipelines. A paper in Computational Linguistics (2020) summarizing much of the development in GF in the past ten years.
+12
View File
@@ -0,0 +1,12 @@
diff --git a/gf.cabal b/gf.cabal
index 0076e7638..8d3fe4b49 100644
--- a/gf.cabal
+++ b/gf.cabal
@@ -168,7 +168,6 @@ Library
GF.Text.Lexing
GF.Grammar.Canonical
- other-modules:
GF.Main
GF.Compiler
GF.Interactive
+5
View File
@@ -78,6 +78,7 @@ data Value
| VMarkup Ident [(Ident,Value)] [L Value] | VMarkup Ident [(Ident,Value)] [L Value]
| VReset Ident (Maybe Value) Value (Maybe QIdent) | VReset Ident (Maybe Value) Value (Maybe QIdent)
| VSymCat Int LIndex [(LIndex, (Value, Type))] | VSymCat Int LIndex [(LIndex, (Value, Type))]
| VSymVar Int Int
| VError Doc | VError Doc
| VInts Integer Bool | VInts Integer Bool
@@ -311,6 +312,7 @@ eval g env c (Markup tag as ts) [] =
in (VMarkup tag vas vs) in (VMarkup tag vas vs)
eval g env c (Reset ctl mb_ct t qid) [] = VReset ctl (fmap (\t -> eval g env c t []) mb_ct) (eval g env c t []) qid eval g env c (Reset ctl mb_ct t qid) [] = VReset ctl (fmap (\t -> eval g env c t []) mb_ct) (eval g env c t []) qid
eval g env c (TSymCat d r rs) []= VSymCat d r [(i,(fromJust (lookup pv env),ty)) | (i,(pv,ty)) <- rs] eval g env c (TSymCat d r rs) []= VSymCat d r [(i,(fromJust (lookup pv env),ty)) | (i,(pv,ty)) <- rs]
eval g env c (TSymVar d j) []= VSymVar d j
eval g env c t@(Opts n cs) vs = if null cs eval g env c t@(Opts n cs) vs = if null cs
then VError ("No options in expression:" $$ ppTerm Unqualified 0 t) then VError ("No options in expression:" $$ ppTerm Unqualified 0 t)
else let (c1,c2,c3) = split3 c else let (c1,c2,c3) = split3 c
@@ -439,6 +441,7 @@ bubble v = snd (bubble v)
bubble (VSymCat d i0 vs) = bubble (VSymCat d i0 vs) =
let (union,vs') = mapAccumL descendC Map.empty vs let (union,vs') = mapAccumL descendC Map.empty vs
in (union, addVariants (VSymCat d i0 vs') union) in (union, addVariants (VSymCat d i0 vs') union)
bubble v@(VSymVar _ _) = lift0 v
bubble v@(VError _) = lift0 v bubble v@(VError _) = lift0 v
bubble v@(VInts _ _) = lift0 v bubble v@(VInts _ _) = lift0 v
@@ -577,6 +580,7 @@ patternMatch g s v0 ((env0,ps,args0,t):eqs) = match env0 ps eqs args0
(p, VP _ _ _) -> v0 (p, VP _ _ _) -> v0
(p, VS _ _ _) -> v0 (p, VS _ _ _) -> v0
(p, VSymCat _ _ _) -> v0 (p, VSymCat _ _ _) -> v0
(p, VSymVar _ _) -> v0
(PP q qs, VApp r vs) (PP q qs, VApp r vs)
| q == r -> match env (qs++ps) eqs (vs++args) | q == r -> match env (qs++ps) eqs (vs++args)
(PR pas, VR as) -> matchRec env (reverse pas) as ps eqs args (PR pas, VR as) -> matchRec env (reverse pas) as ps eqs args
@@ -1158,6 +1162,7 @@ ppValue q d (VReset ctl ct t _) = pp "[" <> pp ctl <>
pp "|" <> ppValue q 0 t <> pp "|" <> ppValue q 0 t <>
pp "]" pp "]"
ppValue q d (VSymCat i r rs) = pp '<' <> pp i <> pp ',' <> pp r <> pp '>' ppValue q d (VSymCat i r rs) = pp '<' <> pp i <> pp ',' <> pp r <> pp '>'
ppValue q d (VSymVar i j) = pp '<' <> pp i <> pp ',' <> pp '$' <> pp j <> pp '>'
ppValue q d (VError msg) = prec d 4 (pp "error" <+> ppTerm q 5 (K (show msg))) ppValue q d (VError msg) = prec d 4 (pp "error" <+> ppTerm q 5 (K (show msg)))
ppValue q d (VInts n ext) ppValue q d (VInts n ext)
| ext = prec d 4 (pp "Ints" <+> brackets (pp n <> "..")) | ext = prec d 4 (pp "Ints" <+> brackets (pp n <> ".."))
@@ -258,6 +258,7 @@ force (VSymCat d r rs) = do
force_ (factor, (v, ty)) = do force_ (factor, (v, ty)) = do
v <- force v v <- force v
return (factor, (v, ty)) return (factor, (v, ty))
force (VSymVar d j) = return (VSymVar d j)
force (VApp q vs) = do force (VApp q vs) = do
vs <- mapM force vs vs <- mapM force vs
return (VApp q vs) return (VApp q vs)
@@ -306,6 +307,8 @@ flatten subst (VStr s) = return (subst,[SymKS s])
flatten subst (VSymCat d r rs) = do flatten subst (VSymCat d r rs) = do
(subst,lin_index) <- params2int' subst r rs (subst,lin_index) <- params2int' subst r rs
return (subst,[SymCat d lin_index]) return (subst,[SymCat d lin_index])
flatten subst (VSymVar d j) = do
return (subst,[SymVar d j])
flatten subst (VApp (m,id) []) flatten subst (VApp (m,id) [])
| m == cPredef && id == cBIND = return (subst,[SymBIND]) | m == cPredef && id == cBIND = return (subst,[SymBIND])
| m == cPredef && id == cSOFT_BIND = return (subst,[SymSOFT_BIND]) | m == cPredef && id == cSOFT_BIND = return (subst,[SymSOFT_BIND])
+1 -1
View File
@@ -50,7 +50,7 @@ grammar2haskell opts name gr = foldr (++++) [] $
derivingClause derivingClause
| dataExt = "deriving (Show,Data)" | dataExt = "deriving (Show,Data)"
| otherwise = "deriving Show" | otherwise = "deriving Show"
extraImports | gadt = ["import Control.Monad.Identity", "import Data.Monoid"] extraImports | gadt = ["import Control.Monad.Identity", "import Control.Monad", "import Data.Monoid"]
| dataExt = ["import Data.Data"] | dataExt = ["import Data.Data"]
| otherwise = [] | otherwise = []
pgfImports = ["import PGF2", ""] pgfImports = ["import PGF2", ""]
+2 -2
View File
@@ -77,8 +77,8 @@ class PGF_INTERNAL_DECL interval_map {
Node *upd_node(Node *node, Node *left, Node *right) Node *upd_node(Node *node, Node *left, Node *right)
{ {
node->sz = 1+size(left)+size(right); node->sz = 1+size(left)+size(right);
node->max = std::max((left == NULL) ? node->end : left->max, node->max = std::max<size_t>((left == NULL) ? node->end : left->max,
(right == NULL) ? node->end : right->max); (right == NULL) ? node->end : right->max);
node->left = left; node->left = left;
node->right = right; node->right = right;
return node; return node;
+5 -1
View File
@@ -14,6 +14,8 @@ PgfAbstractParser::PgfAbstractParser(ref<PgfConcr> concr)
this->last_fid = concr->last_fid; this->last_fid = concr->last_fid;
} }
PgfAbstractParser::ItemProbComparator PgfAbstractParser::item_prob_comp;
void PgfAbstractParser::get_info(CCat *ccat, ref<PgfConcrRule> *prule, size_t **pvalues) void PgfAbstractParser::get_info(CCat *ccat, ref<PgfConcrRule> *prule, size_t **pvalues)
{ {
if (ccat->fid <= concr->last_fid) { if (ccat->fid <= concr->last_fid) {
@@ -514,7 +516,7 @@ void PgfAbstractParser::combine(State *state, Item *item, CCat *ccat)
state->push_item(item); state->push_item(item);
} }
bool PgfAbstractParser::ItemComparator::operator()(Item *item1, Item *item2) bool PgfAbstractParser::ItemComparator::operator()(Item *item1, Item *item2) const
{ {
if (item1->rule.as_object() < item2->rule.as_object()) if (item1->rule.as_object() < item2->rule.as_object())
return true; return true;
@@ -860,6 +862,8 @@ PgfParser::PgfParser(ref<PgfConcr> concr, PgfText *sentence, bool case_sensitive
this->allocated_size = sizeof(PgfText)+sentence->size+1; this->allocated_size = sizeof(PgfText)+sentence->size+1;
} }
PgfParser::ExprStateComparator PgfParser::estate_comp;
PgfParser::~PgfParser() PgfParser::~PgfParser()
{ {
free(sentence); free(sentence);
+1 -1
View File
@@ -132,7 +132,7 @@ protected:
} item_prob_comp; } item_prob_comp;
struct ItemComparator : std::less<Item*> { struct ItemComparator : std::less<Item*> {
bool operator()(Item *item1, Item *item2); bool operator()(Item *item1, Item *item2) const;
}; };
struct Cont { struct Cont {
+1 -1
View File
@@ -1870,7 +1870,7 @@ public:
this->sym_index = (size_t) -1; this->sym_index = (size_t) -1;
this->alt_index = (size_t) -1; this->alt_index = (size_t) -1;
this->n_lindefs = n_rules; this->n_lindefs = n_rules;
this->n_linrefs = n_linrefs; this->n_linrefs = 0;
this->n_args = 1; this->n_args = 1;
this->rule_index = 0; this->rule_index = 0;
this->syms = 0; this->syms = 0;
+3 -1
View File
@@ -154,7 +154,9 @@ PgfProbspace probspace_delete_by_cat(PgfProbspace space, PgfText *cat,
return Node<PgfProbspaceEntry>::link(space,space->left,right); return Node<PgfProbspaceEntry>::link(space,space->left,right);
} else { } else {
itor->fn(itor, &space->value.fun->name, space->value.fun.as_object(), err); PgfText *name = textdup(&space->value.fun->name);
itor->fn(itor, name, space->value.fun.as_object(), err);
free(name);
if (err->type != PGF_EXN_NONE) if (err->type != PGF_EXN_NONE)
return 0; return 0;
+1 -1
View File
@@ -82,7 +82,7 @@ PgfType PgfTypechecker::marshall_type(Type *ty, PgfUnmarshaller *u)
for (;;) { for (;;) {
Pi *pi = ty->is_pi(); Pi *pi = ty->is_pi();
if (pi) { if (pi) {
hypos = (PgfTypeHypo *) realloc(hypos, n_hypos*sizeof(PgfTypeHypo)); hypos = (PgfTypeHypo *) realloc(hypos, (n_hypos+1)*sizeof(PgfTypeHypo));
PgfTypeHypo *hypo = &hypos[n_hypos++]; PgfTypeHypo *hypo = &hypos[n_hypos++];
hypo->bind_type = pi->bind_type; hypo->bind_type = pi->bind_type;
hypo->cid = &pi->var; hypo->cid = &pi->var;
Binary file not shown.
+21 -29
View File
@@ -19,48 +19,40 @@ concrete basic_cnc {
lincat Float = [ lincat Float = [
"s" "s"
] ]
lindef Float(0) -> Float[String(0)] = [S0] lindef Float(0) -> Float[String(0)]; 0 : <0,0>
linref String(0) -> Float[Float(0)] = [S0] linref String(0) -> Float[Float(0)]; 0 : <0,0>
lincat Int = [ lincat Int = [
"s" "s"
] ]
lindef Int(0) -> Int[String(0)] = [S0] lindef Int(0) -> Int[String(0)]; 0 : <0,0>
linref String(0) -> Int[Int(0)] = [S0] linref String(0) -> Int[Int(0)]; 0 : <0,0>
lincat N = [ lincat N = [
"s" "s"
] ]
lindef N(0) -> N[String(0)] = [S0] lindef N(0) -> N[String(0)]; 0 : <0,0>
linref {i<2} . String(0) -> N[N(i)] = [S0] linref {i<2} String(0) -> N[N(i)]; 0 : <0,0>
lincat P = [ lincat P = [
"s" "s"
] ]
lindef P(0) -> P[String(0)] = [S0] lindef P(0) -> P[String(0)]; 0 : <0,0>
linref String(0) -> P[P(0)] = [S0] linref String(0) -> P[P(0)]; 0 : <0,0>
lincat S = [ lincat S = [
"" ""
] ]
lindef S(0) -> S[String(0)] = [S0] lindef S(0) -> S[String(0)]; 0 : <0,0>
linref String(0) -> S[S(0)] = [S0] linref String(0) -> S[S(0)]; 0 : <0,0>
lincat String = [ lincat String = [
"s" "s"
] ]
lindef String(0) -> String[String(0)] = [S0] lindef String(0) -> String[String(0)]; 0 : <0,0>
linref String(0) -> String[String(0)] = [S0] linref String(0) -> String[String(0)]; 0 : <0,0>
lin {i<2} . S(0) -> c[N(i)] = [S0] lin {i<2} S(0) -> c[N(i)]; 0 : <0,0>
lin S(0) -> floatLit[Float(0)] = [S0] lin S(0) -> floatLit[Float(0)]; 0 : <0,0>
lin {i<2} . P(0) -> ind[P(0),P(0),N(i)] = [S1] lin {i<2} P(0) -> ind[P(0),P(0),N(i)]; 0 : <0,0> "&" "λ" SOFT_BIND <1,$0> SOFT_BIND "," SOFT_BIND <1,$1> "." <1,0>
lin S(0) -> intLit[Int(0)] = [S0] lin S(0) -> intLit[Int(0)]; 0 : <0,0>
lin {i<2} . P(0) -> nat[N(i)] = [S5] lin {i<2} P(0) -> nat[N(i)]; 0 : "nat" SOFT_BIND "(" SOFT_BIND <0,0> SOFT_BIND ")"
lin N(0) -> s[N(0)] = [S2] lin N(0) -> s[N(1)]; 0 : "1"
lin N(0) -> s[N(1)] = [S4] lin N(0) -> s[N(0)]; 0 : <0,0> "+" "1"
lin S(0) -> stringLit[String(0)] = [S0] lin S(0) -> stringLit[String(0)]; 0 : <0,0>
lin N(1) -> z[] = [S3] lin N(1) -> z[]; 0 : "0"
sequences {
S0 = <0,0>
S1 = <0,0> "&" "λ" SOFT_BIND <1,$0> SOFT_BIND "," SOFT_BIND <1,$1> "." <1,0>
S2 = <0,0> "+" "1"
S3 = "0"
S4 = "1"
S5 = "nat" SOFT_BIND "(" SOFT_BIND <0,0> SOFT_BIND ")"
}
} }
+1 -1
View File
@@ -24,7 +24,7 @@ main = do
,TestCase (assertInference "infer literal 3" gr (Right "String") "\"abc\"") ,TestCase (assertInference "infer literal 3" gr (Right "String") "\"abc\"")
,TestCase (assertInference "infer meta 1" gr (Left "Cannot infer the type of a meta variable") "?") ,TestCase (assertInference "infer meta 1" gr (Left "Cannot infer the type of a meta variable") "?")
,TestCase (assertInference "infer meta 2" gr (Right "N->N") "<? : N->N>") ,TestCase (assertInference "infer meta 2" gr (Right "N->N") "<? : N->N>")
,TestCase (assertInference "infer lambda" gr (Left "Cannot infer the type of a lambda abstraction") "\\x->x") ,TestCase (assertInference "infer lambda" gr (Left "Cannot infer the type of a lambda variable") "\\x->x")
,TestCase (assertChecking "check fun 1" gr (Right "s") "s" "N->N") ,TestCase (assertChecking "check fun 1" gr (Right "s") "s" "N->N")
,TestCase (assertChecking "check fun 2" gr (Right "s z") "s z" "N") ,TestCase (assertChecking "check fun 2" gr (Right "s z") "s z" "N")
,TestCase (assertChecking "check fun 3" gr (Left "Types doesn't match") "s z" "N->N") ,TestCase (assertChecking "check fun 3" gr (Left "Types doesn't match") "s z" "N->N")
+1 -1
View File
@@ -15,7 +15,7 @@ if on_windows:
cpath = '../c/pgf/' cpath = '../c/pgf/'
extra_sources = [cpath+f for f in os.listdir(cpath) if f.endswith('.cxx')] extra_sources = [cpath+f for f in os.listdir(cpath) if f.endswith('.cxx')]
includes+=["../c"] includes+=["../c"]
flags = ['/DCOMPILING_STATIC_PGF=1'] flags = ['/DCOMPILING_STATIC_PGF=1', "/std:c++20"]
else: else:
extra_sources = [] extra_sources = []
flags = ['-std=c99', '-Werror', '-Wno-error=unused-variable', '-Wno-comment'] flags = ['-std=c99', '-Werror', '-Wno-error=unused-variable', '-Wno-comment']