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
+66 -56
View File
@@ -2,7 +2,7 @@ name: Build Binary Packages
on:
workflow_dispatch:
release:
release:
types: ["created"]
jobs:
@@ -13,9 +13,9 @@ jobs:
name: Build Ubuntu package
strategy:
matrix:
os:
- ubuntu-18.04
- ubuntu-20.04
ghc: ["9.6"]
cabal: ["3.10"]
os: ["ubuntu-24.04"]
runs-on: ${{ matrix.os }}
@@ -25,12 +25,13 @@ jobs:
# Note: `haskell-platform` is listed as requirement in debian/control,
# which is why it's installed using apt instead of the Setup Haskell action.
# - name: Setup Haskell
# uses: actions/setup-haskell@v1
# id: setup-haskell-cabal
# with:
# ghc-version: ${{ matrix.ghc }}
# cabal-version: ${{ matrix.cabal }}
- name: Setup Haskell
uses: haskell-actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
if: matrix.os == 'ubuntu-24.04'
- name: Install build tools
run: |
@@ -39,14 +40,15 @@ jobs:
make \
dpkg-dev \
debhelper \
haskell-platform \
libghc-json-dev \
python-dev \
default-jdk \
libtool-bin
python-dev-is-python3 \
libtool-bin
cabal install alex happy
- name: Build package
run: |
export PYTHONPATH="/home/runner/work/gf-core/gf-core/debian/gf/usr/local/lib/python3.12/dist-packages/"
make deb
- name: Copy package
@@ -54,7 +56,7 @@ jobs:
cp ../gf_*.deb dist/
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
path: dist/gf_*.deb
@@ -64,14 +66,14 @@ jobs:
run: |
mv dist/gf_*.deb dist/gf-${{ github.event.release.tag_name }}-${{ matrix.os }}.deb
- uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/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
#- uses: actions/upload-release-asset@v1.0.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ github.event.release.upload_url }}
# asset_path: dist/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
# ---
@@ -79,16 +81,16 @@ jobs:
name: Build macOS package
strategy:
matrix:
ghc: ["8.6.5"]
cabal: ["2.4"]
os: ["macos-10.15"]
ghc: ["9.6"]
cabal: ["3.10"]
os: ["macos-latest", "macos-13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Haskell
uses: actions/setup-haskell@v1
uses: haskell-actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
@@ -97,8 +99,10 @@ jobs:
- name: Install build tools
run: |
brew install \
automake
automake \
libtool
cabal v1-install alex happy
pip install setuptools
- name: Build package
run: |
@@ -107,24 +111,24 @@ jobs:
make pkg
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: gf-${{ github.event.release.tag_name }}-macos
name: gf-${{ github.event.release.tag_name }}-${{ matrix.os }}
path: dist/gf-*.pkg
if-no-files-found: error
- name: Rename package
run: |
mv dist/gf-*.pkg dist/gf-${{ github.event.release.tag_name }}-macos.pkg
- uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/gf-${{ github.event.release.tag_name }}-macos.pkg
asset_name: gf-${{ github.event.release.tag_name }}-macos.pkg
asset_content_type: application/octet-stream
#- uses: actions/upload-release-asset@v1.0.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ github.event.release.upload_url }}
# asset_path: dist/gf-${{ github.event.release.tag_name }}-macos.pkg
# asset_name: gf-${{ github.event.release.tag_name }}-macos.pkg
# asset_content_type: application/octet-stream
# ---
@@ -132,9 +136,9 @@ jobs:
name: Build Windows package
strategy:
matrix:
ghc: ["8.6.5"]
cabal: ["2.4"]
os: ["windows-2019"]
ghc: ["9.6.7"]
cabal: ["3.10"]
os: ["windows-2022"]
runs-on: ${{ matrix.os }}
steps:
@@ -147,6 +151,7 @@ jobs:
base-devel
gcc
python-devel
autotools
- name: Prepare dist folder
shell: msys2 {0}
@@ -171,7 +176,8 @@ jobs:
- name: Build Java bindings
shell: msys2 {0}
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"
cd src/runtime/java
make \
@@ -180,6 +186,9 @@ jobs:
make install
cp .libs/msys-jpgf-0.dll /c/tmp-dist/java/jpgf.dll
cp jpgf.jar /c/tmp-dist/java
if: false
# - uses: actions/setup-python@v5
- name: Build Python bindings
shell: msys2 {0}
@@ -188,12 +197,13 @@ jobs:
EXTRA_LIB_DIRS: /mingw64/lib
run: |
cd src/runtime/python
pacman --noconfirm -S python-setuptools
python setup.py build
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
uses: actions/setup-haskell@v1
uses: haskell-actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
@@ -205,13 +215,13 @@ jobs:
- name: Build GF
run: |
cabal install --only-dependencies -fserver
cabal install -fserver --only-dependencies
cabal configure -fserver
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
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: gf-${{ github.event.release.tag_name }}-windows
path: C:\tmp-dist\*
@@ -220,11 +230,11 @@ jobs:
- name: Create archive
run: |
Compress-Archive C:\tmp-dist C:\gf-${{ github.event.release.tag_name }}-windows.zip
- uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: C:\gf-${{ github.event.release.tag_name }}-windows.zip
asset_name: gf-${{ github.event.release.tag_name }}-windows.zip
asset_content_type: application/zip
#- uses: actions/upload-release-asset@v1.0.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ github.event.release.upload_url }}
# asset_path: C:\gf-${{ github.event.release.tag_name }}-windows.zip
# asset_name: gf-${{ github.event.release.tag_name }}-windows.zip
# asset_content_type: application/zip
+129 -50
View File
@@ -2,19 +2,18 @@ name: Build majestic runtime
on: push
env:
LD_LIBRARY_PATH: /usr/local/lib
jobs:
linux-runtime:
name: Runtime (Linux)
runs-on: ubuntu-latest
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:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Build runtime
working-directory: ./src/runtime/c
@@ -25,7 +24,7 @@ jobs:
make install
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libpgf-linux
path: |
@@ -36,11 +35,13 @@ jobs:
name: Haskell (Linux)
runs-on: ubuntu-latest
needs: linux-runtime
env:
LD_LIBRARY_PATH: /usr/local/lib
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: libpgf-linux
- run: |
@@ -48,7 +49,7 @@ jobs:
sudo mv include/* /usr/local/include/
- name: Setup Haskell
uses: haskell/actions/setup@v2
uses: haskell-actions/setup@v2
with:
ghc-version: 8
@@ -68,7 +69,7 @@ jobs:
cabal v1-install
- name: Upload artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: compiler-linux
path: |
@@ -78,11 +79,13 @@ jobs:
name: Python (Linux)
runs-on: ubuntu-latest
needs: linux-runtime
env:
LD_LIBRARY_PATH: /usr/local/lib
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: libpgf-linux
@@ -99,7 +102,7 @@ jobs:
run: |
python3 -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: python-linux
path: ./wheelhouse
@@ -110,7 +113,7 @@ jobs:
# needs: linux-runtime
#
# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v7
# - name: Download artifact
# uses: actions/download-artifact@master
# with:
@@ -138,10 +141,12 @@ jobs:
macos-runtime:
name: Runtime (macOS)
runs-on: macOS-11
runs-on: macOS-latest
env:
LD_LIBRARY_PATH: /opt/homebrew/lib
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Install build tools
run: |
@@ -155,65 +160,91 @@ jobs:
run: |
glibtoolize
autoreconf -i
./configure
./configure --prefix=/opt/homebrew
make
sudo make install
- name: Upload artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: libpgf-macos
path: |
/usr/local/lib/libpgf*
/usr/local/include/pgf
/opt/homebrew/lib/libpgf*
/opt/homebrew/include/pgf
macos-haskell:
name: Haskell (macOS)
runs-on: macOS-11
runs-on: macOS-latest
needs: macos-runtime
env:
LD_LIBRARY_PATH: /opt/homebrew/lib
CPATH: /opt/homebrew/include:$CPATH
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Download artifact
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: libpgf-macos
- run: |
sudo mv lib/* /usr/local/lib/
sudo mv include/* /usr/local/include/
sudo mv lib/* /opt/homebrew/lib/
sudo mv include/* /opt/homebrew/include/
- name: Setup Haskell
uses: haskell/actions/setup@v2
uses: haskell-actions/setup@v2
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
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:
name: Python (macOS)
runs-on: macOS-11
runs-on: macOS-latest
needs: macos-runtime
env:
EXTRA_INCLUDE_DIRS: /usr/local/include
EXTRA_LIB_DIRS: /usr/local/lib
MACOSX_DEPLOYMENT_TARGET: 11.0
LD_LIBRARY_PATH: /opt/homebrew/lib
EXTRA_INCLUDE_DIRS: /opt/homebrew/include
EXTRA_LIB_DIRS: /opt/homebrew/lib
MACOSX_DEPLOYMENT_TARGET: 26.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Download artifact
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: libpgf-macos
- run: |
sudo mv lib/* /usr/local/lib/
sudo mv include/* /usr/local/include/
sudo mv lib/* /opt/homebrew/lib/
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
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
env:
@@ -221,9 +252,9 @@ jobs:
CIBW_TEST_COMMAND: "pytest {project}/src/runtime/python"
CIBW_SKIP: "pp* cp36* cp37* cp38* cp39*"
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:
name: python-macos
path: ./wheelhouse
@@ -234,7 +265,7 @@ jobs:
# needs: macos-runtime
#
# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v7
# - name: Download artifact
# uses: actions/download-artifact@master
# with:
@@ -265,7 +296,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
@@ -289,7 +320,7 @@ jobs:
make install
- name: Upload artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: libpgf-windows
path: |
@@ -300,17 +331,65 @@ jobs:
${{runner.temp}}/msys64/mingw64/lib/libpgf*
${{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:
name: Python (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install cibuildwheel
run: |
@@ -324,7 +403,7 @@ jobs:
run: |
python3 -m cibuildwheel src\runtime\python --output-dir wheelhouse
- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: python-windows
path: ./wheelhouse
@@ -336,7 +415,7 @@ jobs:
if: github.ref == 'refs/heads/majestic' && github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v3
@@ -346,17 +425,17 @@ jobs:
- name: Install twine
run: pip install twine
- uses: actions/download-artifact@master
- uses: actions/download-artifact@v4
with:
name: python-linux
path: ./dist
- uses: actions/download-artifact@master
- uses: actions/download-artifact@v4
with:
name: python-macos
path: ./dist
- uses: actions/download-artifact@master
- uses: actions/download-artifact@v4
with:
name: python-windows
path: ./dist
+21 -17
View File
@@ -13,24 +13,25 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-18.04, macos-10.15]
os: [ubuntu-latest, macos-latest, macos-13]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v1
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.7'
python-version: '3.x'
- name: Install cibuildwheel
run: |
python -m pip install git+https://github.com/joerick/cibuildwheel.git@main
python -m pip install cibuildwheel
- name: Install build tools for OSX
if: startsWith(matrix.os, 'macos')
run: |
brew install automake
brew install libtool
- name: Build wheels on Linux
if: startsWith(matrix.os, 'macos') != true
@@ -42,30 +43,32 @@ jobs:
- name: Build wheels on OSX
if: startsWith(matrix.os, 'macos')
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: |
python -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}
path: ./wheelhouse
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.7'
python-version: '3.10'
- name: Build sdist
run: cd src/runtime/python && python setup.py sdist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: wheel-source
path: ./src/runtime/python/dist/*.tar.gz
upload_pypi:
@@ -75,24 +78,25 @@ jobs:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install twine
run: pip install twine
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.7
with:
name: artifact
pattern: wheel-*
merge-multiple: true
path: ./dist
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
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
*.gfo
*.pgf
*.ngf
debian/.debhelper
debian/debhelper-build-stamp
debian/gf
@@ -47,8 +46,6 @@ src/runtime/c/sg/.dirstamp
src/runtime/c/stamp-h1
src/runtime/java/.libs/
src/runtime/python/build/
src/runtime/python/**/__pycache__/
src/runtime/python/**/.pytest_cache/
.cabal-sandbox
cabal.sandbox.config
.stack-work
@@ -56,12 +53,6 @@ DATA_DIR
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
*.out
gf-tests.html
@@ -82,3 +73,9 @@ doc/icfp-2012.html
download/*.html
gf-book/index.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
```
It will install GF and all necessary tools and libraries to do that.
=== 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.
@@ -162,7 +160,13 @@ The actual installation process is similar to Stack: open a terminal, go to the
$ 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 ==
@@ -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]
% **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 —**
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
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.
- **How —**
If you use cabal, run the following command:
```
cabal install -fc-runtime
```
from the top directory (``gf-core``).
If you use stack, uncomment the following lines in the ``stack.yaml`` file:
Add (or uncomment) the following lines in the ``stack.yaml`` file:
```
flags:
@@ -254,6 +251,32 @@ extra-lib-dirs:
```
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``.//
//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``.
- **How —**
If you use cabal, run the following command:
```
cabal install -fc-runtime -fserver
```
from the top directory.
If you use stack, add the following lines in the ``stack.yaml`` file:
Add the following lines in the ``stack.yaml`` file:
```
flags:
+20 -7
View File
@@ -1188,7 +1188,7 @@ use ``generate_trees = gt``.
this wine is fresh
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:
```
> 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
```
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
on Mac OS X. On Ubuntu Linux, one can write
telling what command to use to view the file.
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 ;
}
```
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
be built for concrete syntaxes:
```
@@ -3733,7 +3746,7 @@ However, type-incorrect commands are rejected by the typecheck:
The parsing is successful but the type checking failed with error(s):
Couldn't match expected type Device light
against the interred type Device fan
In the expression: DKindOne fan
In the expression: DKindOne fan
```
#NEW
@@ -4171,7 +4184,7 @@ division of integers.
```
abstract Calculator = {
flags startcat = Exp ;
cat Exp ;
fun
@@ -4578,7 +4591,7 @@ in any multilingual grammar between any languages in the grammar.
module Main where
import PGF
import System (getArgs)
import System.Environment (getArgs)
main :: IO ()
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="doc/gf-refman.html">Reference Manual</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://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>
</ul>
<a href="lib/doc/synopsis/index.html" class="btn btn-primary ml-3">
<i class="fab fa-readme mr-1"></i>
RGL Synopsis
RGL API
</a>
</div>
@@ -73,8 +72,12 @@
<li><a href="doc/gf-developers.html">Developers Guide</a></li>
<!-- <li><a href="/~hallgren/gf-experiment/browse/">Browse Source Code</a></li> -->
<li>PGF library API:<br>
<a href="http://hackage.haskell.org/package/gf/docs/PGF.html">Haskell</a> /
<a href="doc/runtime-api.html">C&nbsp;runtime</a>
<ul>
<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><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>
@@ -88,11 +91,6 @@
<h3>Contribute</h3>
<ul class="mb-2">
<li>
<a href="https://web.libera.chat/?channels=#gf">
<i class="fas fa-hashtag"></i>
IRC
</a>
/
<a href="https://discord.gg/EvfUsjzmaz">
<i class="fab fa-discord"></i>
Discord
@@ -106,7 +104,7 @@
</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="//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>
</ul>
<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>
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.
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>.
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.
</p>
<p>
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
@@ -255,6 +249,19 @@ least one, it may help you to get a first idea of what GF is.
<div class="col-md-6">
<h2>News</h2>
<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>
<dd class="col-sm-9">
<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">
<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>
<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>
<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.
+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]
| VReset Ident (Maybe Value) Value (Maybe QIdent)
| VSymCat Int LIndex [(LIndex, (Value, Type))]
| VSymVar Int Int
| VError Doc
| VInts Integer Bool
@@ -311,6 +312,7 @@ eval g env c (Markup tag as ts) [] =
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 (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
then VError ("No options in expression:" $$ ppTerm Unqualified 0 t)
else let (c1,c2,c3) = split3 c
@@ -439,6 +441,7 @@ bubble v = snd (bubble v)
bubble (VSymCat d i0 vs) =
let (union,vs') = mapAccumL descendC Map.empty vs
in (union, addVariants (VSymCat d i0 vs') union)
bubble v@(VSymVar _ _) = lift0 v
bubble v@(VError _) = 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, VS _ _ _) -> v0
(p, VSymCat _ _ _) -> v0
(p, VSymVar _ _) -> v0
(PP q qs, VApp r vs)
| q == r -> match env (qs++ps) eqs (vs++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 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 (VInts n ext)
| ext = prec d 4 (pp "Ints" <+> brackets (pp n <> ".."))
@@ -258,6 +258,7 @@ force (VSymCat d r rs) = do
force_ (factor, (v, ty)) = do
v <- force v
return (factor, (v, ty))
force (VSymVar d j) = return (VSymVar d j)
force (VApp q vs) = do
vs <- mapM force vs
return (VApp q vs)
@@ -306,6 +307,8 @@ flatten subst (VStr s) = return (subst,[SymKS s])
flatten subst (VSymCat d r rs) = do
(subst,lin_index) <- params2int' subst r rs
return (subst,[SymCat d lin_index])
flatten subst (VSymVar d j) = do
return (subst,[SymVar d j])
flatten subst (VApp (m,id) [])
| m == cPredef && id == cBIND = return (subst,[SymBIND])
| m == cPredef && id == cSOFT_BIND = return (subst,[SymSOFT_BIND])
+1 -1
View File
@@ -50,7 +50,7 @@ grammar2haskell opts name gr = foldr (++++) [] $
derivingClause
| dataExt = "deriving (Show,Data)"
| 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"]
| otherwise = []
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->sz = 1+size(left)+size(right);
node->max = std::max((left == NULL) ? node->end : left->max,
(right == NULL) ? node->end : right->max);
node->max = std::max<size_t>((left == NULL) ? node->end : left->max,
(right == NULL) ? node->end : right->max);
node->left = left;
node->right = right;
return node;
+5 -1
View File
@@ -14,6 +14,8 @@ PgfAbstractParser::PgfAbstractParser(ref<PgfConcr> concr)
this->last_fid = concr->last_fid;
}
PgfAbstractParser::ItemProbComparator PgfAbstractParser::item_prob_comp;
void PgfAbstractParser::get_info(CCat *ccat, ref<PgfConcrRule> *prule, size_t **pvalues)
{
if (ccat->fid <= concr->last_fid) {
@@ -514,7 +516,7 @@ void PgfAbstractParser::combine(State *state, Item *item, CCat *ccat)
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())
return true;
@@ -860,6 +862,8 @@ PgfParser::PgfParser(ref<PgfConcr> concr, PgfText *sentence, bool case_sensitive
this->allocated_size = sizeof(PgfText)+sentence->size+1;
}
PgfParser::ExprStateComparator PgfParser::estate_comp;
PgfParser::~PgfParser()
{
free(sentence);
+1 -1
View File
@@ -132,7 +132,7 @@ protected:
} item_prob_comp;
struct ItemComparator : std::less<Item*> {
bool operator()(Item *item1, Item *item2);
bool operator()(Item *item1, Item *item2) const;
};
struct Cont {
+1 -1
View File
@@ -1870,7 +1870,7 @@ public:
this->sym_index = (size_t) -1;
this->alt_index = (size_t) -1;
this->n_lindefs = n_rules;
this->n_linrefs = n_linrefs;
this->n_linrefs = 0;
this->n_args = 1;
this->rule_index = 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);
} 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)
return 0;
+1 -1
View File
@@ -82,7 +82,7 @@ PgfType PgfTypechecker::marshall_type(Type *ty, PgfUnmarshaller *u)
for (;;) {
Pi *pi = ty->is_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++];
hypo->bind_type = pi->bind_type;
hypo->cid = &pi->var;
Binary file not shown.
+21 -29
View File
@@ -19,48 +19,40 @@ concrete basic_cnc {
lincat Float = [
"s"
]
lindef Float(0) -> Float[String(0)] = [S0]
linref String(0) -> Float[Float(0)] = [S0]
lindef Float(0) -> Float[String(0)]; 0 : <0,0>
linref String(0) -> Float[Float(0)]; 0 : <0,0>
lincat Int = [
"s"
]
lindef Int(0) -> Int[String(0)] = [S0]
linref String(0) -> Int[Int(0)] = [S0]
lindef Int(0) -> Int[String(0)]; 0 : <0,0>
linref String(0) -> Int[Int(0)]; 0 : <0,0>
lincat N = [
"s"
]
lindef N(0) -> N[String(0)] = [S0]
linref {i<2} . String(0) -> N[N(i)] = [S0]
lindef N(0) -> N[String(0)]; 0 : <0,0>
linref {i<2} String(0) -> N[N(i)]; 0 : <0,0>
lincat P = [
"s"
]
lindef P(0) -> P[String(0)] = [S0]
linref String(0) -> P[P(0)] = [S0]
lindef P(0) -> P[String(0)]; 0 : <0,0>
linref String(0) -> P[P(0)]; 0 : <0,0>
lincat S = [
""
]
lindef S(0) -> S[String(0)] = [S0]
linref String(0) -> S[S(0)] = [S0]
lindef S(0) -> S[String(0)]; 0 : <0,0>
linref String(0) -> S[S(0)]; 0 : <0,0>
lincat String = [
"s"
]
lindef String(0) -> String[String(0)] = [S0]
linref String(0) -> String[String(0)] = [S0]
lin {i<2} . S(0) -> c[N(i)] = [S0]
lin S(0) -> floatLit[Float(0)] = [S0]
lin {i<2} . P(0) -> ind[P(0),P(0),N(i)] = [S1]
lin S(0) -> intLit[Int(0)] = [S0]
lin {i<2} . P(0) -> nat[N(i)] = [S5]
lin N(0) -> s[N(0)] = [S2]
lin N(0) -> s[N(1)] = [S4]
lin S(0) -> stringLit[String(0)] = [S0]
lin N(1) -> z[] = [S3]
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 ")"
}
lindef String(0) -> String[String(0)]; 0 : <0,0>
linref String(0) -> String[String(0)]; 0 : <0,0>
lin {i<2} S(0) -> c[N(i)]; 0 : <0,0>
lin S(0) -> floatLit[Float(0)]; 0 : <0,0>
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)]; 0 : <0,0>
lin {i<2} P(0) -> nat[N(i)]; 0 : "nat" SOFT_BIND "(" SOFT_BIND <0,0> SOFT_BIND ")"
lin N(0) -> s[N(1)]; 0 : "1"
lin N(0) -> s[N(0)]; 0 : <0,0> "+" "1"
lin S(0) -> stringLit[String(0)]; 0 : <0,0>
lin N(1) -> z[]; 0 : "0"
}
+1 -1
View File
@@ -24,7 +24,7 @@ main = do
,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 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 2" gr (Right "s z") "s z" "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/'
extra_sources = [cpath+f for f in os.listdir(cpath) if f.endswith('.cxx')]
includes+=["../c"]
flags = ['/DCOMPILING_STATIC_PGF=1']
flags = ['/DCOMPILING_STATIC_PGF=1', "/std:c++20"]
else:
extra_sources = []
flags = ['-std=c99', '-Werror', '-Wno-error=unused-variable', '-Wno-comment']