diff --git a/.github/workflows/build-binary-packages.yml b/.github/workflows/build-binary-packages.yml index 493d5e774..f4c1a5b5e 100644 --- a/.github/workflows/build-binary-packages.yml +++ b/.github/workflows/build-binary-packages.yml @@ -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 diff --git a/.github/workflows/build-majestic.yml b/.github/workflows/build-majestic.yml index 3a3b934ff..2dd842a96 100644 --- a/.github/workflows/build-majestic.yml +++ b/.github/workflows/build-majestic.yml @@ -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 diff --git a/.github/workflows/build-python-package.yml b/.github/workflows/build-python-package.yml index 67cbba6dd..b2565eb05 100644 --- a/.github/workflows/build-python-package.yml +++ b/.github/workflows/build-python-package.yml @@ -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/* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 678397df2..93d660fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/doc/MOLTO_D2.3.pdf b/doc/MOLTO_D2.3.pdf new file mode 100644 index 000000000..51cc1d8c2 Binary files /dev/null and b/doc/MOLTO_D2.3.pdf differ diff --git a/doc/gf-developers.t2t b/doc/gf-developers.t2t index c20afda52..aafe6d3f2 100644 --- a/doc/gf-developers.t2t +++ b/doc/gf-developers.t2t @@ -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: diff --git a/doc/tutorial/gf-tutorial.t2t b/doc/tutorial/gf-tutorial.t2t index 63407a38a..d58b93f16 100644 --- a/doc/tutorial/gf-tutorial.t2t +++ b/doc/tutorial/gf-tutorial.t2t @@ -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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..232e59372 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..ccacc15b0 --- /dev/null +++ b/flake.nix @@ -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 = [ ]; + }); + }); + }; +} diff --git a/index.html b/index.html index 4f963961e..aafa5adbd 100644 --- a/index.html +++ b/index.html @@ -55,15 +55,14 @@
  • The GF Book
  • Reference Manual
  • Shell Reference
  • -
  • Best Practices [PDF]
  • +
  • Best Practices [PDF]
  • Scaling Up (Computational Linguistics 2020)
  • -
  • GF WordNet
  • GF blog
  • - RGL Synopsis + RGL API @@ -73,8 +72,12 @@
  • Developers Guide
  • PGF library API:
    - Haskell / - C runtime +
  • GF compiler API