mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 13:09:33 -06:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1957eb1fc5 | ||
|
|
bd3ccb4a0d | ||
|
|
c71ed9f513 | ||
|
|
f9ca462a06 | ||
|
|
7492cd52d1 | ||
|
|
6f6f742d01 | ||
|
|
d477250c48 | ||
|
|
3a17a68da6 | ||
|
|
6ea53e44a4 | ||
|
|
4ecd216796 | ||
|
|
0b01f56fd7 | ||
|
|
0bac8f0dae | ||
|
|
8df9767493 | ||
|
|
3d272ac053 | ||
|
|
63828de0c2 | ||
|
|
72bec84f58 | ||
|
|
539b946c96 | ||
|
|
a42cec2107 | ||
|
|
4d446fcd3f | ||
|
|
ae460e76b6 | ||
|
|
65308861bc | ||
|
|
b7672b67a3 | ||
|
|
e33de168fd | ||
|
|
fc5b3e9037 | ||
|
|
9b9905c0b2 | ||
|
|
ec70e4a83e | ||
|
|
e6ade90679 | ||
|
|
6414bc8923 | ||
|
|
b0b2a06f3b | ||
|
|
221597bd79 | ||
|
|
862aeb5d9b | ||
|
|
25dd1354c7 | ||
|
|
b762e24a82 | ||
|
|
20453193fe | ||
|
|
b53a102c98 | ||
|
|
bc14a56f83 | ||
|
|
3a1213ab37 | ||
|
|
1b41e94f83 | ||
|
|
308f4773dc | ||
|
|
05fc093b5e | ||
|
|
4caf6d684e | ||
|
|
bfd8f9c16d | ||
|
|
aefac84670 | ||
|
|
9f2a3de7a3 | ||
|
|
e4b2f281d9 | ||
|
|
063c517f3c | ||
|
|
bedb46527d | ||
|
|
0258a87257 | ||
|
|
ef0e831c9e | ||
|
|
8ec13b1030 | ||
|
|
058526ec5d | ||
|
|
974e8b0835 | ||
|
|
bbe4682c3d | ||
|
|
e477ce4b1f | ||
|
|
7a63ba34b4 | ||
|
|
723bec1ba0 |
17
.github/workflows/build-all-versions.yml
vendored
17
.github/workflows/build-all-versions.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
|||||||
ghc:
|
ghc:
|
||||||
- "8.6.5"
|
- "8.6.5"
|
||||||
- "8.8.3"
|
- "8.8.3"
|
||||||
- "8.10.1"
|
- "8.10.7"
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
ghc: 8.8.3
|
ghc: 8.8.3
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
||||||
|
|
||||||
- uses: haskell/actions/setup@v1
|
- uses: haskell/actions/setup@v1.2.9
|
||||||
id: setup-haskell-cabal
|
id: setup-haskell-cabal
|
||||||
name: Setup Haskell
|
name: Setup Haskell
|
||||||
with:
|
with:
|
||||||
@@ -66,25 +66,32 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
stack: ["latest"]
|
stack: ["latest"]
|
||||||
ghc: ["7.10.3","8.0.2", "8.2.2", "8.4.4", "8.6.5", "8.8.4"]
|
ghc: ["7.10.3","8.0.2", "8.2.2", "8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2"]
|
||||||
# ghc: ["8.8.3"]
|
# ghc: ["8.8.3"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
|
||||||
|
|
||||||
- uses: haskell/actions/setup@v1
|
- uses: haskell/actions/setup@v1.2.9
|
||||||
name: Setup Haskell Stack
|
name: Setup Haskell Stack
|
||||||
with:
|
with:
|
||||||
ghc-version: ${{ matrix.ghc }}
|
ghc-version: ${{ matrix.ghc }}
|
||||||
stack-version: 'latest'
|
stack-version: 'latest'
|
||||||
enable-stack: true
|
enable-stack: true
|
||||||
|
|
||||||
|
|
||||||
|
# Fix linker errrors on ghc-7.10.3 for ubuntu (see https://github.com/commercialhaskell/stack/blob/255cd830627870cdef34b5e54d670ef07882523e/doc/faq.md#i-get-strange-ld-errors-about-recompiling-with--fpic)
|
||||||
|
- run: sed -i.bak 's/"C compiler link flags", "/&-no-pie /' /home/runner/.ghcup/ghc/7.10.3/lib/ghc-7.10.3/settings
|
||||||
|
if: matrix.ghc == '7.10.3'
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
name: Cache ~/.stack
|
name: Cache ~/.stack
|
||||||
with:
|
with:
|
||||||
path: ~/.stack
|
path: ~/.stack
|
||||||
key: ${{ runner.os }}-${{ matrix.ghc }}-stack
|
key: ${{ runner.os }}-${{ matrix.ghc }}-stack--${{ hashFiles(format('stack-ghc{0}', matrix.ghc)) }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-${{ matrix.ghc }}-stack
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
14
.travis.yml
14
.travis.yml
@@ -1,14 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
|
|
||||||
language: c
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- docker pull odanoburu/gf-src:3.9
|
|
||||||
|
|
||||||
script:
|
|
||||||
- |
|
|
||||||
docker run --mount src="$(pwd)",target=/home/gfer,type=bind odanoburu/gf-src:3.9 /bin/bash -c "cd /home/gfer/src/runtime/c &&
|
|
||||||
autoreconf -i && ./configure && make && make install ; cd /home/gfer ; cabal install -fserver -fc-runtime --extra-lib-dirs='/usr/local/lib'"
|
|
||||||
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
### New since 3.11 (WIP)
|
||||||
|
|
||||||
|
- Added a changelog!
|
||||||
|
|
||||||
|
### 3.11
|
||||||
|
|
||||||
|
See <https://www.grammaticalframework.org/download/release-3.11.html>
|
||||||
|
|
||||||
|
### 3.10
|
||||||
|
|
||||||
|
See <https://www.grammaticalframework.org/download/release-3.10.html>
|
||||||
6
Makefile
6
Makefile
@@ -65,6 +65,6 @@ bintar:
|
|||||||
|
|
||||||
# Make a source tar.gz distribution using git to make sure that everything is included.
|
# Make a source tar.gz distribution using git to make sure that everything is included.
|
||||||
# We put the distribution in dist/ so it is removed on `make clean`
|
# We put the distribution in dist/ so it is removed on `make clean`
|
||||||
sdist:
|
# sdist:
|
||||||
test -d dist || mkdir dist
|
# test -d dist || mkdir dist
|
||||||
git archive --format=tar.gz --output=dist/gf-${VERSION}.tar.gz HEAD
|
# git archive --format=tar.gz --output=dist/gf-${VERSION}.tar.gz HEAD
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||

|

|
||||||
|
|
||||||
# Grammatical Framework (GF)
|
# Grammatical Framework (GF)
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ or:
|
|||||||
stack install
|
stack install
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information, including links to precompiled binaries, see the [download page](http://www.grammaticalframework.org/download/index.html).
|
For more information, including links to precompiled binaries, see the [download page](https://www.grammaticalframework.org/download/index.html).
|
||||||
|
|
||||||
## About this repository
|
## About this repository
|
||||||
|
|
||||||
|
|||||||
11
RELEASE.md
11
RELEASE.md
@@ -47,11 +47,14 @@ but the generated _artifacts_ must be manually attached to the release as _asset
|
|||||||
|
|
||||||
In order to do this you will need to be added the [GF maintainers](https://hackage.haskell.org/package/gf/maintainers/) on Hackage.
|
In order to do this you will need to be added the [GF maintainers](https://hackage.haskell.org/package/gf/maintainers/) on Hackage.
|
||||||
|
|
||||||
1. Run `make sdist`
|
1. Run `stack sdist --test-tarball` and address any issues.
|
||||||
2. Upload the package, either:
|
2. Upload the package, either:
|
||||||
1. **Manually**: visit <https://hackage.haskell.org/upload> and upload the file `dist/gf-X.Y.tar.gz`
|
1. **Manually**: visit <https://hackage.haskell.org/upload> and upload the file generated by the previous command.
|
||||||
2. **via Cabal (≥2.4)**: `cabal upload dist/gf-X.Y.tar.gz`
|
2. **via Stack**: `stack upload . --candidate`
|
||||||
3. If the documentation-building fails on the Hackage server, do:
|
3. After testing the candidate, publish it:
|
||||||
|
1. **Manually**: visit <https://hackage.haskell.org/package/gf-X.Y.Z/candidate/publish>
|
||||||
|
1. **via Stack**: `stack upload .`
|
||||||
|
4. If the documentation-building fails on the Hackage server, do:
|
||||||
```
|
```
|
||||||
cabal v2-haddock --builddir=dist/docs --haddock-for-hackage --enable-doc
|
cabal v2-haddock --builddir=dist/docs --haddock-for-hackage --enable-doc
|
||||||
cabal upload --documentation dist/docs/*-docs.tar.gz
|
cabal upload --documentation dist/docs/*-docs.tar.gz
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ instructions inside.
|
|||||||
|
|
||||||
==Visual Studio Code==
|
==Visual Studio Code==
|
||||||
|
|
||||||
[Grammatical Framework Language Server https://marketplace.visualstudio.com/items?itemName=anka-213.gf-vscode] by Andreas Källberg.
|
- [Grammatical Framework Language Server https://marketplace.visualstudio.com/items?itemName=anka-213.gf-vscode] by Andreas Källberg.
|
||||||
|
This provides syntax highlighting and a client for the Grammatical Framework language server. Follow the installation instructions in the link.
|
||||||
This provides syntax highlighting and a client for the Grammatical Framework language server. Follow the installation instructions in the link.
|
- [Grammatical Framework https://marketplace.visualstudio.com/items?itemName=GrammaticalFramework.gf-vscode] is a simpler extension
|
||||||
|
without any external dependencies which provides only syntax highlighting.
|
||||||
|
|
||||||
==Eclipse==
|
==Eclipse==
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ title: "Grammatical Framework: Authors and Acknowledgements"
|
|||||||
The current maintainers of GF are
|
The current maintainers of GF are
|
||||||
|
|
||||||
[Krasimir Angelov](http://www.chalmers.se/cse/EN/organization/divisions/computing-science/people/angelov-krasimir),
|
[Krasimir Angelov](http://www.chalmers.se/cse/EN/organization/divisions/computing-science/people/angelov-krasimir),
|
||||||
[Thomas Hallgren](http://www.cse.chalmers.se/~hallgren/),
|
|
||||||
[Aarne Ranta](http://www.cse.chalmers.se/~aarne/),
|
[Aarne Ranta](http://www.cse.chalmers.se/~aarne/),
|
||||||
[John J. Camilleri](http://johnjcamilleri.com), and
|
[John J. Camilleri](http://johnjcamilleri.com), and
|
||||||
[Inari Listenmaa](https://inariksit.github.io/).
|
[Inari Listenmaa](https://inariksit.github.io/).
|
||||||
@@ -22,6 +21,7 @@ and
|
|||||||
|
|
||||||
The following people have contributed code to some of the versions:
|
The following people have contributed code to some of the versions:
|
||||||
|
|
||||||
|
- [Thomas Hallgren](http://www.cse.chalmers.se/~hallgren/) (University of Gothenburg)
|
||||||
- Grégoire Détrez (University of Gothenburg)
|
- Grégoire Détrez (University of Gothenburg)
|
||||||
- Ramona Enache (University of Gothenburg)
|
- Ramona Enache (University of Gothenburg)
|
||||||
- [Björn Bringert](http://www.cse.chalmers.se/alumni/bringert) (University of Gothenburg)
|
- [Björn Bringert](http://www.cse.chalmers.se/alumni/bringert) (University of Gothenburg)
|
||||||
|
|||||||
@@ -53,26 +53,39 @@ You will probably need to update the `PATH` environment variable to include your
|
|||||||
|
|
||||||
For more information, see [Using GF on Windows](https://www.grammaticalframework.org/~inari/gf-windows.html) (latest updated for Windows 10).
|
For more information, see [Using GF on Windows](https://www.grammaticalframework.org/~inari/gf-windows.html) (latest updated for Windows 10).
|
||||||
|
|
||||||
<!--## Installing the latest Hackage release (macOS, Linux, and WSL2 on Windows)
|
## Installing from Hackage
|
||||||
|
|
||||||
|
_Instructions applicable for macOS, Linux, and WSL2 on Windows._
|
||||||
|
|
||||||
[GF is on Hackage](http://hackage.haskell.org/package/gf), so under
|
[GF is on Hackage](http://hackage.haskell.org/package/gf), so under
|
||||||
normal circumstances the procedure is fairly simple:
|
normal circumstances the procedure is fairly simple:
|
||||||
|
|
||||||
1. Install ghcup https://www.haskell.org/ghcup/
|
```
|
||||||
2. `ghcup install ghc 8.10.4`
|
cabal update
|
||||||
3. `ghcup set ghc 8.10.4`
|
cabal install gf-3.11
|
||||||
4. `cabal update`
|
```
|
||||||
5. On Linux: install some C libraries from your Linux distribution (see note below)
|
|
||||||
6. `cabal install gf-3.11`
|
|
||||||
|
|
||||||
You can also download the source code release from [GitHub](https://github.com/GrammaticalFramework/gf-core/releases),
|
|
||||||
and follow the instructions below under **Installing from the latest developer source code**.
|
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
|
|
||||||
|
**GHC version**
|
||||||
|
|
||||||
|
The GF source code is known to be compilable with GHC versions 7.10 through to 8.10.
|
||||||
|
|
||||||
|
**Obtaining Haskell**
|
||||||
|
|
||||||
|
There are various ways of obtaining Haskell, including:
|
||||||
|
|
||||||
|
- ghcup
|
||||||
|
1. Install from https://www.haskell.org/ghcup/
|
||||||
|
2. `ghcup install ghc 8.10.4`
|
||||||
|
3. `ghcup set ghc 8.10.4`
|
||||||
|
- Haskell Platform https://www.haskell.org/platform/
|
||||||
|
- Stack https://haskellstack.org/
|
||||||
|
|
||||||
|
|
||||||
**Installation location**
|
**Installation location**
|
||||||
|
|
||||||
The above steps installs GF for a single user.
|
The above steps install GF for a single user.
|
||||||
The executables are put in `$HOME/.cabal/bin` (or on macOS in `$HOME/Library/Haskell/bin`),
|
The executables are put in `$HOME/.cabal/bin` (or on macOS in `$HOME/Library/Haskell/bin`),
|
||||||
so you might want to add this directory to your path (in `.bash_profile` or similar):
|
so you might want to add this directory to your path (in `.bash_profile` or similar):
|
||||||
|
|
||||||
@@ -84,32 +97,34 @@ PATH=$HOME/.cabal/bin:$PATH
|
|||||||
|
|
||||||
GF uses [`haskeline`](http://hackage.haskell.org/package/haskeline), which
|
GF uses [`haskeline`](http://hackage.haskell.org/package/haskeline), which
|
||||||
on Linux depends on some non-Haskell libraries that won't be installed
|
on Linux depends on some non-Haskell libraries that won't be installed
|
||||||
automatically by cabal, and therefore need to be installed manually.
|
automatically by Cabal, and therefore need to be installed manually.
|
||||||
Here is one way to do this:
|
Here is one way to do this:
|
||||||
|
|
||||||
- On Ubuntu: `sudo apt-get install libghc-haskeline-dev`
|
- On Ubuntu: `sudo apt-get install libghc-haskeline-dev`
|
||||||
- On Fedora: `sudo dnf install ghc-haskeline-devel`
|
- On Fedora: `sudo dnf install ghc-haskeline-devel`
|
||||||
|
|
||||||
**GHC version**
|
## Installing from source code
|
||||||
|
|
||||||
The GF source code has been updated to compile with GHC versions 7.10 through to 8.8.
|
**Obtaining**
|
||||||
-->
|
|
||||||
## Installing from the latest developer source code
|
|
||||||
|
|
||||||
If you haven't already, clone the repository with:
|
To obtain the source code for the **release**,
|
||||||
|
download it from [GitHub](https://github.com/GrammaticalFramework/gf-core/releases).
|
||||||
|
|
||||||
|
Alternatively, to obtain the **latest version** of the source code:
|
||||||
|
|
||||||
|
1. If you haven't already, clone the repository with:
|
||||||
```
|
```
|
||||||
git clone https://github.com/GrammaticalFramework/gf-core.git
|
git clone https://github.com/GrammaticalFramework/gf-core.git
|
||||||
```
|
```
|
||||||
|
2. If you've already cloned the repository previously, update with:
|
||||||
If you've already cloned the repository previously, update with:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
git pull
|
git pull
|
||||||
```
|
```
|
||||||
|
|
||||||
Then install with:
|
|
||||||
|
|
||||||
|
**Installing**
|
||||||
|
|
||||||
|
You can then install with:
|
||||||
```
|
```
|
||||||
cabal install
|
cabal install
|
||||||
```
|
```
|
||||||
|
|||||||
27
gf.cabal
27
gf.cabal
@@ -8,12 +8,17 @@ license-file: LICENSE
|
|||||||
category: Natural Language Processing, Compiler
|
category: Natural Language Processing, Compiler
|
||||||
synopsis: Grammatical Framework
|
synopsis: Grammatical Framework
|
||||||
description: GF, Grammatical Framework, is a programming language for multilingual grammar applications
|
description: GF, Grammatical Framework, is a programming language for multilingual grammar applications
|
||||||
|
maintainer: John J. Camilleri <john@digitalgrammars.com>
|
||||||
homepage: https://www.grammaticalframework.org/
|
homepage: https://www.grammaticalframework.org/
|
||||||
bug-reports: https://github.com/GrammaticalFramework/gf-core/issues
|
bug-reports: https://github.com/GrammaticalFramework/gf-core/issues
|
||||||
tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.10.4
|
tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.10.4, GHC==9.0.2
|
||||||
|
|
||||||
data-dir: src
|
data-dir: src
|
||||||
extra-source-files: WebSetup.hs
|
extra-source-files:
|
||||||
|
README.md
|
||||||
|
CHANGELOG.md
|
||||||
|
WebSetup.hs
|
||||||
|
doc/Logos/gf0.png
|
||||||
data-files:
|
data-files:
|
||||||
www/*.html
|
www/*.html
|
||||||
www/*.css
|
www/*.css
|
||||||
@@ -41,7 +46,7 @@ data-files:
|
|||||||
|
|
||||||
custom-setup
|
custom-setup
|
||||||
setup-depends:
|
setup-depends:
|
||||||
base >= 4.9.1 && < 4.15,
|
base >= 4.9.1 && < 4.16,
|
||||||
Cabal >= 1.22.0.0,
|
Cabal >= 1.22.0.0,
|
||||||
directory >= 1.3.0 && < 1.4,
|
directory >= 1.3.0 && < 1.4,
|
||||||
filepath >= 1.4.1 && < 1.5,
|
filepath >= 1.4.1 && < 1.5,
|
||||||
@@ -76,11 +81,11 @@ library
|
|||||||
build-depends:
|
build-depends:
|
||||||
-- GHC 8.0.2 to GHC 8.10.4
|
-- GHC 8.0.2 to GHC 8.10.4
|
||||||
array >= 0.5.1 && < 0.6,
|
array >= 0.5.1 && < 0.6,
|
||||||
base >= 4.9.1 && < 4.15,
|
base >= 4.9.1 && < 4.16,
|
||||||
bytestring >= 0.10.8 && < 0.11,
|
bytestring >= 0.10.8 && < 0.11,
|
||||||
containers >= 0.5.7 && < 0.7,
|
containers >= 0.5.7 && < 0.7,
|
||||||
exceptions >= 0.8.3 && < 0.11,
|
exceptions >= 0.8.3 && < 0.11,
|
||||||
ghc-prim >= 0.5.0 && < 0.7,
|
ghc-prim >= 0.5.0 && < 0.7.1,
|
||||||
mtl >= 2.2.1 && < 2.3,
|
mtl >= 2.2.1 && < 2.3,
|
||||||
pretty >= 1.1.3 && < 1.2,
|
pretty >= 1.1.3 && < 1.2,
|
||||||
random >= 1.1 && < 1.3,
|
random >= 1.1 && < 1.3,
|
||||||
@@ -106,7 +111,7 @@ library
|
|||||||
--ghc-options: -fwarn-unused-imports
|
--ghc-options: -fwarn-unused-imports
|
||||||
--if impl(ghc>=7.8)
|
--if impl(ghc>=7.8)
|
||||||
-- ghc-options: +RTS -A20M -RTS
|
-- ghc-options: +RTS -A20M -RTS
|
||||||
ghc-prof-options: -fprof-auto
|
-- ghc-prof-options: -fprof-auto
|
||||||
|
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
PGF
|
PGF
|
||||||
@@ -297,14 +302,14 @@ library
|
|||||||
build-depends:
|
build-depends:
|
||||||
cgi >= 3001.3.0.2 && < 3001.6,
|
cgi >= 3001.3.0.2 && < 3001.6,
|
||||||
httpd-shed >= 0.4.0 && < 0.5,
|
httpd-shed >= 0.4.0 && < 0.5,
|
||||||
network>=2.3 && <2.7
|
network>=2.3 && <3.2
|
||||||
if flag(network-uri)
|
if flag(network-uri)
|
||||||
build-depends:
|
build-depends:
|
||||||
network-uri >= 2.6.1.0 && < 2.7,
|
network-uri >= 2.6.1.0 && < 2.7,
|
||||||
network>=2.6 && <2.7
|
network>=2.6 && <3.2
|
||||||
else
|
else
|
||||||
build-depends:
|
build-depends:
|
||||||
network >= 2.5 && <2.6
|
network >= 2.5 && <3.2
|
||||||
|
|
||||||
cpp-options: -DSERVER_MODE
|
cpp-options: -DSERVER_MODE
|
||||||
other-modules:
|
other-modules:
|
||||||
@@ -370,7 +375,7 @@ executable gf
|
|||||||
if impl(ghc<7.8)
|
if impl(ghc<7.8)
|
||||||
ghc-options: -with-rtsopts=-K64M
|
ghc-options: -with-rtsopts=-K64M
|
||||||
|
|
||||||
ghc-prof-options: -auto-all
|
-- ghc-prof-options: -auto-all
|
||||||
|
|
||||||
if impl(ghc>=8.2)
|
if impl(ghc>=8.2)
|
||||||
ghc-options: -fhide-source-paths
|
ghc-options: -fhide-source-paths
|
||||||
@@ -395,7 +400,7 @@ test-suite gf-tests
|
|||||||
main-is: run.hs
|
main-is: run.hs
|
||||||
hs-source-dirs: testsuite
|
hs-source-dirs: testsuite
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.9.1 && < 4.15,
|
base >= 4.9.1 && < 4.16,
|
||||||
Cabal >= 1.8,
|
Cabal >= 1.8,
|
||||||
directory >= 1.3.0 && < 1.4,
|
directory >= 1.3.0 && < 1.4,
|
||||||
filepath >= 1.4.1 && < 1.5,
|
filepath >= 1.4.1 && < 1.5,
|
||||||
|
|||||||
76
index.html
76
index.html
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous">
|
||||||
|
|
||||||
<link rel="alternate" href="https://github.com/GrammaticalFramework/gf-core/" title="GF GitHub repository">
|
<link rel="alternate" href="https://github.com/GrammaticalFramework/gf-core/" title="GF GitHub repository">
|
||||||
</head>
|
</head>
|
||||||
@@ -85,10 +85,27 @@
|
|||||||
<div class="col-sm-6 col-md-3 mb-4">
|
<div class="col-sm-6 col-md-3 mb-4">
|
||||||
<h3>Contribute</h3>
|
<h3>Contribute</h3>
|
||||||
<ul class="mb-2">
|
<ul class="mb-2">
|
||||||
<li><a href="http://groups.google.com/group/gf-dev">Mailing List</a></li>
|
<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
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://stackoverflow.com/questions/tagged/gf">
|
||||||
|
<i class="fab fa-stack-overflow"></i>
|
||||||
|
Stack Overflow
|
||||||
|
</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="doc/gf-people.html">Authors</a></li>
|
|
||||||
<li><a href="//school.grammaticalframework.org/2020/">Summer School</a></li>
|
<li><a href="//school.grammaticalframework.org/2020/">Summer School</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">
|
||||||
<i class="fab fa-github mr-1"></i>
|
<i class="fab fa-github mr-1"></i>
|
||||||
@@ -154,7 +171,7 @@ least one, it may help you to get a first idea of what GF is.
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2>Applications & Availability</h2>
|
<h2>Applications & availability</h2>
|
||||||
<p>
|
<p>
|
||||||
GF can be used for building
|
GF can be used for building
|
||||||
<a href="//cloud.grammaticalframework.org/translator/">translation systems</a>,
|
<a href="//cloud.grammaticalframework.org/translator/">translation systems</a>,
|
||||||
@@ -219,19 +236,28 @@ least one, it may help you to get a first idea of what GF is.
|
|||||||
or <a href="https://www.grammaticalframework.org/irc/?C=M;O=D">browse the channel logs</a>.
|
or <a href="https://www.grammaticalframework.org/irc/?C=M;O=D">browse the channel logs</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you have a larger question which the community may benefit from, we recommend you ask it on the <a href="http://groups.google.com/group/gf-dev">mailing list</a>.
|
There is also a <a href="https://discord.gg/EvfUsjzmaz">GF server on Discord</a>.
|
||||||
|
</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
|
||||||
|
<a href="https://github.com/GrammaticalFramework/gf-rgl/issues">RGL</a> repository.
|
||||||
|
|
||||||
|
For programming questions, consider asking them on <a href="https://stackoverflow.com/questions/tagged/gf">Stack Overflow with the <code>gf</code> tag</a>.
|
||||||
|
If you have a more general question to the community, we recommend you ask it on the <a href="http://groups.google.com/group/gf-dev">mailing list</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2>News</h2>
|
<h2>News</h2>
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2021-07-25</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
<strong>GF 3.11 released.</strong>
|
|
||||||
<a href="download/release-3.11.html">Release notes</a>
|
|
||||||
</dd>
|
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
|
<dt class="col-sm-3 text-center text-nowrap">2021-07-25</dt>
|
||||||
|
<dd class="col-sm-9">
|
||||||
|
<strong>GF 3.11 released.</strong>
|
||||||
|
<a href="download/release-3.11.html">Release notes</a>
|
||||||
|
</dd>
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2021-05-05</dt>
|
<dt class="col-sm-3 text-center text-nowrap">2021-05-05</dt>
|
||||||
<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.
|
||||||
@@ -244,34 +270,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://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.
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2018-12-03</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
<a href="//school.grammaticalframework.org/2018/">Sixth GF Summer School</a> in Stellenbosch (South Africa), 3–14 December 2018
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2018-12-02</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
<strong>GF 3.10 released.</strong>
|
|
||||||
<a href="download/release-3.10.html">Release notes</a>
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2018-07-25</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
The GF repository has been split in two:
|
|
||||||
<a href="https://github.com/GrammaticalFramework/gf-core">gf-core</a> and
|
|
||||||
<a href="https://github.com/GrammaticalFramework/gf-rgl">gf-rgl</a>.
|
|
||||||
The original <a href="https://github.com/GrammaticalFramework/GF">GF</a> repository is now archived.
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2017-08-11</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
<strong>GF 3.9 released.</strong>
|
|
||||||
<a href="download/release-3.9.html">Release notes</a>
|
|
||||||
</dd>
|
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2017-06-29</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
GF is moving to <a href="https://github.com/GrammaticalFramework/GF/">GitHub</a>.</dd>
|
|
||||||
<dt class="col-sm-3 text-center text-nowrap">2017-03-13</dt>
|
|
||||||
<dd class="col-sm-9">
|
|
||||||
<a href="//school.grammaticalframework.org/2017/">GF Summer School</a> in Riga (Latvia), 14-25 August 2017
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h2>Projects</h2>
|
<h2>Projects</h2>
|
||||||
@@ -341,7 +339,7 @@ least one, it may help you to get a first idea of what GF is.
|
|||||||
Libraries are at the heart of modern software engineering. In natural language
|
Libraries are at the heart of modern software engineering. In natural language
|
||||||
applications, libraries are a way to cope with thousands of details involved in
|
applications, libraries are a way to cope with thousands of details involved in
|
||||||
syntax, lexicon, and inflection. The
|
syntax, lexicon, and inflection. The
|
||||||
<a href="lib/doc/synopsis/index.html">GF resource grammar library</a> has
|
<a href="lib/doc/synopsis/index.html">GF resource grammar library</a> (RGL) has
|
||||||
support for an increasing number of languages, currently including
|
support for an increasing number of languages, currently including
|
||||||
Afrikaans,
|
Afrikaans,
|
||||||
Amharic (partial),
|
Amharic (partial),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module GF.Command.Commands (
|
|||||||
options,flags,
|
options,flags,
|
||||||
) where
|
) where
|
||||||
import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint
|
import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint
|
||||||
|
import System.Info(os)
|
||||||
|
|
||||||
import PGF
|
import PGF
|
||||||
|
|
||||||
@@ -882,11 +883,15 @@ pgfCommands = Map.fromList [
|
|||||||
Right ty -> ty
|
Right ty -> ty
|
||||||
Nothing -> error ("Can't parse '"++str++"' as a type")
|
Nothing -> error ("Can't parse '"++str++"' as a type")
|
||||||
optViewFormat opts = valStrOpts "format" "png" opts
|
optViewFormat opts = valStrOpts "format" "png" opts
|
||||||
optViewGraph opts = valStrOpts "view" "open" opts
|
optViewGraph opts = valStrOpts "view" open_cmd opts
|
||||||
optNum opts = valIntOpts "number" 1 opts
|
optNum opts = valIntOpts "number" 1 opts
|
||||||
optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9
|
optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9
|
||||||
takeOptNum opts = take (optNumInf opts)
|
takeOptNum opts = take (optNumInf opts)
|
||||||
|
|
||||||
|
open_cmd | os == "linux" = "xdg-open"
|
||||||
|
| os == "mingw32" = "start"
|
||||||
|
| otherwise = "open"
|
||||||
|
|
||||||
returnFromExprs es = return $ case es of
|
returnFromExprs es = return $ case es of
|
||||||
[] -> pipeMessage "no trees found"
|
[] -> pipeMessage "no trees found"
|
||||||
_ -> fromExprs es
|
_ -> fromExprs es
|
||||||
@@ -1022,4 +1027,4 @@ stanzas = map unlines . chop . lines where
|
|||||||
|
|
||||||
#if !(MIN_VERSION_base(4,9,0))
|
#if !(MIN_VERSION_base(4,9,0))
|
||||||
errorWithoutStackTrace = error
|
errorWithoutStackTrace = error
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import Data.Version
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
import GHC.IO.Encoding
|
||||||
-- import GF.System.Console (setConsoleEncoding)
|
-- import GF.System.Console (setConsoleEncoding)
|
||||||
|
|
||||||
-- | Run the GF main program, taking arguments from the command line.
|
-- | Run the GF main program, taking arguments from the command line.
|
||||||
@@ -23,6 +24,7 @@ import System.Exit
|
|||||||
-- Run @gf --help@ for usage info.
|
-- Run @gf --help@ for usage info.
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
setLocaleEncoding utf8
|
||||||
-- setConsoleEncoding
|
-- setConsoleEncoding
|
||||||
uncurry mainOpts =<< getOptions
|
uncurry mainOpts =<< getOptions
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ decodeUnicode :: TextEncoding -> ByteString -> String
|
|||||||
decodeUnicode enc bs = unsafePerformIO $ decodeUnicodeIO enc bs
|
decodeUnicode enc bs = unsafePerformIO $ decodeUnicodeIO enc bs
|
||||||
|
|
||||||
decodeUnicodeIO enc (PS fptr l len) = do
|
decodeUnicodeIO enc (PS fptr l len) = do
|
||||||
let bbuf = Buffer{bufRaw=fptr, bufState=ReadBuffer, bufSize=len, bufL=l, bufR=l+len}
|
let bbuf = (emptyBuffer fptr len ReadBuffer) { bufL=l, bufR=l+len }
|
||||||
cbuf <- newCharBuffer 128 WriteBuffer
|
cbuf <- newCharBuffer 128 WriteBuffer
|
||||||
case enc of
|
case enc of
|
||||||
TextEncoding {mkTextDecoder=mk} -> do decoder <- mk
|
TextEncoding {mkTextDecoder=mk} -> do decoder <- mk
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
import qualified GF
|
import qualified GF
|
||||||
|
|
||||||
main = GF.main
|
main = GF.main
|
||||||
|
|||||||
@@ -18,12 +18,24 @@ gu_exn_is_raised(GuExn* err) {
|
|||||||
return err && (err->state == GU_EXN_RAISED);
|
return err && (err->state == GU_EXN_RAISED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GU_API_DECL void
|
||||||
|
gu_exn_clear(GuExn* err) {
|
||||||
|
err->caught = NULL;
|
||||||
|
err->state = GU_EXN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
GU_API bool
|
GU_API bool
|
||||||
gu_exn_caught_(GuExn* err, const char* type)
|
gu_exn_caught_(GuExn* err, const char* type)
|
||||||
{
|
{
|
||||||
return (err->caught && strcmp(err->caught, type) == 0);
|
return (err->caught && strcmp(err->caught, type) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GU_API_DECL void*
|
||||||
|
gu_exn_caught_data(GuExn* err)
|
||||||
|
{
|
||||||
|
return err->data.data;
|
||||||
|
}
|
||||||
|
|
||||||
GU_API void
|
GU_API void
|
||||||
gu_exn_block(GuExn* err)
|
gu_exn_block(GuExn* err)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,11 +71,13 @@ gu_new_exn(GuPool* pool);
|
|||||||
GU_API_DECL bool
|
GU_API_DECL bool
|
||||||
gu_exn_is_raised(GuExn* err);
|
gu_exn_is_raised(GuExn* err);
|
||||||
|
|
||||||
static inline void
|
// static inline void
|
||||||
gu_exn_clear(GuExn* err) {
|
// gu_exn_clear(GuExn* err) {
|
||||||
err->caught = NULL;
|
// err->caught = NULL;
|
||||||
err->state = GU_EXN_OK;
|
// err->state = GU_EXN_OK;
|
||||||
}
|
// }
|
||||||
|
GU_API_DECL void
|
||||||
|
gu_exn_clear(GuExn* err);
|
||||||
|
|
||||||
#define gu_exn_caught(err, type) \
|
#define gu_exn_caught(err, type) \
|
||||||
(err->caught && strcmp(err->caught, #type) == 0)
|
(err->caught && strcmp(err->caught, #type) == 0)
|
||||||
@@ -83,11 +85,13 @@ gu_exn_clear(GuExn* err) {
|
|||||||
GU_API_DECL bool
|
GU_API_DECL bool
|
||||||
gu_exn_caught_(GuExn* err, const char* type);
|
gu_exn_caught_(GuExn* err, const char* type);
|
||||||
|
|
||||||
static inline const void*
|
// static inline const void*
|
||||||
gu_exn_caught_data(GuExn* err)
|
// gu_exn_caught_data(GuExn* err)
|
||||||
{
|
// {
|
||||||
return err->data.data;
|
// return err->data.data;
|
||||||
}
|
// }
|
||||||
|
GU_API_DECL void*
|
||||||
|
gu_exn_caught_data(GuExn* err);
|
||||||
|
|
||||||
/// Temporarily block a raised exception.
|
/// Temporarily block a raised exception.
|
||||||
GU_API_DECL void
|
GU_API_DECL void
|
||||||
|
|||||||
@@ -8,6 +8,42 @@
|
|||||||
|
|
||||||
//#define PGF_JIT_DEBUG
|
//#define PGF_JIT_DEBUG
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
|
||||||
|
PGF_INTERNAL PgfJitState*
|
||||||
|
pgf_new_jit(PgfReader* rdr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PGF_INTERNAL PgfEvalGates*
|
||||||
|
pgf_jit_gates(PgfReader* rdr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PGF_INTERNAL void
|
||||||
|
pgf_jit_predicate(PgfReader* rdr, PgfAbstr* abstr,
|
||||||
|
PgfAbsCat* abscat)
|
||||||
|
{
|
||||||
|
size_t n_funs = pgf_read_len(rdr);
|
||||||
|
gu_return_on_exn(rdr->err, );
|
||||||
|
|
||||||
|
for (size_t i = 0; i < n_funs; i++) {
|
||||||
|
gu_in_f64be(rdr->in, rdr->err); // ignore
|
||||||
|
gu_return_on_exn(rdr->err, );
|
||||||
|
|
||||||
|
PgfCId name = pgf_read_cid(rdr, rdr->tmp_pool);
|
||||||
|
gu_return_on_exn(rdr->err, );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PGF_INTERNAL void
|
||||||
|
pgf_jit_done(PgfReader* rdr, PgfAbstr* abstr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
struct PgfJitState {
|
struct PgfJitState {
|
||||||
jit_state jit;
|
jit_state jit;
|
||||||
@@ -1329,3 +1365,5 @@ pgf_jit_done(PgfReader* rdr, PgfAbstr* abstr)
|
|||||||
|
|
||||||
jit_flush_code(rdr->jit_state->buf, jit_get_ip().ptr);
|
jit_flush_code(rdr->jit_state->buf, jit_get_ip().ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ typedef struct {
|
|||||||
PgfParseState *before;
|
PgfParseState *before;
|
||||||
PgfParseState *after;
|
PgfParseState *after;
|
||||||
PgfToken prefix;
|
PgfToken prefix;
|
||||||
|
bool prefix_bind;
|
||||||
PgfTokenProb* tp;
|
PgfTokenProb* tp;
|
||||||
PgfExprEnum en; // enumeration for the generated trees/tokens
|
PgfExprEnum en; // enumeration for the generated trees/tokens
|
||||||
#ifdef PGF_COUNTS_DEBUG
|
#ifdef PGF_COUNTS_DEBUG
|
||||||
@@ -1009,6 +1010,7 @@ pgf_new_parse_state(PgfParsing* ps, size_t start_offset,
|
|||||||
(start_offset == end_offset);
|
(start_offset == end_offset);
|
||||||
state->start_offset = start_offset;
|
state->start_offset = start_offset;
|
||||||
state->end_offset = end_offset;
|
state->end_offset = end_offset;
|
||||||
|
|
||||||
state->viterbi_prob = viterbi_prob;
|
state->viterbi_prob = viterbi_prob;
|
||||||
state->lexicon_idx =
|
state->lexicon_idx =
|
||||||
gu_new_buf(PgfLexiconIdxEntry, ps->pool);
|
gu_new_buf(PgfLexiconIdxEntry, ps->pool);
|
||||||
@@ -1381,20 +1383,30 @@ pgf_parsing_symbol(PgfParsing* ps, PgfItem* item, PgfSymbol sym)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PGF_SYMBOL_BIND: {
|
case PGF_SYMBOL_BIND: {
|
||||||
if (ps->before->start_offset == ps->before->end_offset &&
|
if (!ps->prefix_bind && ps->prefix != NULL && *(ps->sentence + ps->before->end_offset) == 0) {
|
||||||
ps->before->needs_bind) {
|
PgfProductionApply* papp = gu_variant_data(item->prod);
|
||||||
PgfParseState* state =
|
|
||||||
pgf_new_parse_state(ps, ps->before->end_offset, BIND_HARD,
|
ps->tp = gu_new(PgfTokenProb, ps->out_pool);
|
||||||
item->inside_prob+item->conts->outside_prob);
|
ps->tp->tok = NULL;
|
||||||
if (state != NULL) {
|
ps->tp->cat = item->conts->ccat->cnccat->abscat->name;
|
||||||
pgf_item_advance(item, ps->pool);
|
ps->tp->fun = papp->fun->absfun->name;
|
||||||
gu_buf_heap_push(state->agenda, pgf_item_prob_order, &item);
|
ps->tp->prob = item->inside_prob + item->conts->outside_prob;
|
||||||
} else {
|
} else {
|
||||||
pgf_item_free(ps, item);
|
if (ps->before->start_offset == ps->before->end_offset &&
|
||||||
}
|
ps->before->needs_bind) {
|
||||||
} else {
|
PgfParseState* state =
|
||||||
pgf_item_free(ps, item);
|
pgf_new_parse_state(ps, ps->before->end_offset, BIND_HARD,
|
||||||
}
|
item->inside_prob+item->conts->outside_prob);
|
||||||
|
if (state != NULL) {
|
||||||
|
pgf_item_advance(item, ps->pool);
|
||||||
|
gu_buf_heap_push(state->agenda, pgf_item_prob_order, &item);
|
||||||
|
} else {
|
||||||
|
pgf_item_free(ps, item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pgf_item_free(ps, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PGF_SYMBOL_SOFT_BIND:
|
case PGF_SYMBOL_SOFT_BIND:
|
||||||
@@ -2337,7 +2349,8 @@ pgf_parser_completions_next(GuEnum* self, void* to, GuPool* pool)
|
|||||||
|
|
||||||
PGF_API GuEnum*
|
PGF_API GuEnum*
|
||||||
pgf_complete(PgfConcr* concr, PgfType* type, GuString sentence,
|
pgf_complete(PgfConcr* concr, PgfType* type, GuString sentence,
|
||||||
GuString prefix, GuExn *err, GuPool* pool)
|
GuString prefix, bool prefix_bind,
|
||||||
|
GuExn *err, GuPool* pool)
|
||||||
{
|
{
|
||||||
if (concr->sequences == NULL ||
|
if (concr->sequences == NULL ||
|
||||||
concr->cnccats == NULL) {
|
concr->cnccats == NULL) {
|
||||||
@@ -2377,6 +2390,7 @@ pgf_complete(PgfConcr* concr, PgfType* type, GuString sentence,
|
|||||||
// Now begin enumerating the completions
|
// Now begin enumerating the completions
|
||||||
ps->en.next = pgf_parser_completions_next;
|
ps->en.next = pgf_parser_completions_next;
|
||||||
ps->prefix = prefix;
|
ps->prefix = prefix;
|
||||||
|
ps->prefix_bind = prefix_bind;
|
||||||
ps->tp = NULL;
|
ps->tp = NULL;
|
||||||
return &ps->en;
|
return &ps->en;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,8 @@ typedef struct {
|
|||||||
|
|
||||||
PGF_API_DECL GuEnum*
|
PGF_API_DECL GuEnum*
|
||||||
pgf_complete(PgfConcr* concr, PgfType* type, GuString string,
|
pgf_complete(PgfConcr* concr, PgfType* type, GuString string,
|
||||||
GuString prefix, GuExn* err, GuPool* pool);
|
GuString prefix, bool prefix_bind,
|
||||||
|
GuExn* err, GuPool* pool);
|
||||||
|
|
||||||
typedef struct PgfLiteralCallback PgfLiteralCallback;
|
typedef struct PgfLiteralCallback PgfLiteralCallback;
|
||||||
|
|
||||||
|
|||||||
@@ -1326,7 +1326,7 @@ pgf_read_concretes(PgfReader* rdr, PgfAbstr* abstr, bool with_content)
|
|||||||
PGF_INTERNAL PgfPGF*
|
PGF_INTERNAL PgfPGF*
|
||||||
pgf_read_pgf(PgfReader* rdr) {
|
pgf_read_pgf(PgfReader* rdr) {
|
||||||
PgfPGF* pgf = gu_new(PgfPGF, rdr->opool);
|
PgfPGF* pgf = gu_new(PgfPGF, rdr->opool);
|
||||||
|
|
||||||
pgf->major_version = gu_in_u16be(rdr->in, rdr->err);
|
pgf->major_version = gu_in_u16be(rdr->in, rdr->err);
|
||||||
gu_return_on_exn(rdr->err, NULL);
|
gu_return_on_exn(rdr->err, NULL);
|
||||||
|
|
||||||
@@ -1335,7 +1335,7 @@ pgf_read_pgf(PgfReader* rdr) {
|
|||||||
|
|
||||||
pgf->gflags = pgf_read_flags(rdr);
|
pgf->gflags = pgf_read_flags(rdr);
|
||||||
gu_return_on_exn(rdr->err, NULL);
|
gu_return_on_exn(rdr->err, NULL);
|
||||||
|
|
||||||
pgf_read_abstract(rdr, &pgf->abstract);
|
pgf_read_abstract(rdr, &pgf->abstract);
|
||||||
gu_return_on_exn(rdr->err, NULL);
|
gu_return_on_exn(rdr->err, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -1026,7 +1026,10 @@ complete lang (Type ctype _) sent pfx =
|
|||||||
touchConcr lang
|
touchConcr lang
|
||||||
return []
|
return []
|
||||||
else do
|
else do
|
||||||
tok <- peekUtf8CString =<< (#peek PgfTokenProb, tok) cmpEntry
|
p_tok <- (#peek PgfTokenProb, tok) cmpEntry
|
||||||
|
tok <- if p_tok == nullPtr
|
||||||
|
then return "&+"
|
||||||
|
else peekUtf8CString p_tok
|
||||||
cat <- peekUtf8CString =<< (#peek PgfTokenProb, cat) cmpEntry
|
cat <- peekUtf8CString =<< (#peek PgfTokenProb, cat) cmpEntry
|
||||||
fun <- peekUtf8CString =<< (#peek PgfTokenProb, fun) cmpEntry
|
fun <- peekUtf8CString =<< (#peek PgfTokenProb, fun) cmpEntry
|
||||||
prob <- (#peek PgfTokenProb, prob) cmpEntry
|
prob <- (#peek PgfTokenProb, prob) cmpEntry
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ library
|
|||||||
PGF2.Expr,
|
PGF2.Expr,
|
||||||
PGF2.Type
|
PGF2.Type
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.9.1 && < 4.15,
|
base >= 4.9.1 && < 4.16,
|
||||||
containers >= 0.5.7 && < 0.7,
|
containers >= 0.5.7 && < 0.7,
|
||||||
pretty >= 1.1.3 && < 1.2
|
pretty >= 1.1.3 && < 1.2
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
{-# LANGUAGE CPP, MagicHash #-}
|
{-# LANGUAGE CPP, MagicHash #-}
|
||||||
|
-- This module makes profiling a lot slower, so don't add automatic cost centres
|
||||||
|
{-# OPTIONS_GHC -fno-prof-auto #-}
|
||||||
-- for unboxed shifts
|
-- for unboxed shifts
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ library
|
|||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
build-depends:
|
build-depends:
|
||||||
array >= 0.5.1 && < 0.6,
|
array >= 0.5.1 && < 0.6,
|
||||||
base >= 4.9.1 && < 4.15,
|
base >= 4.9.1 && < 4.16,
|
||||||
bytestring >= 0.10.8 && < 0.11,
|
bytestring >= 0.10.8 && < 0.11,
|
||||||
containers >= 0.5.7 && < 0.7,
|
containers >= 0.5.7 && < 0.7,
|
||||||
ghc-prim >= 0.5.0 && < 0.7,
|
ghc-prim >= 0.5.0 && < 0.7,
|
||||||
|
|||||||
1
src/runtime/javascript/.gitignore
vendored
Normal file
1
src/runtime/javascript/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.libs/
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# Deprecation notice
|
|
||||||
|
|
||||||
As of June 2019, this JavaScript version of the GF runtime is considered deprecated,
|
|
||||||
in favour of the TypeScript version in <https://github.com/GrammaticalFramework/gf-typescript>.
|
|
||||||
48
src/runtime/javascript/Dockerfile
Normal file
48
src/runtime/javascript/Dockerfile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
FROM emscripten/emsdk:latest
|
||||||
|
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install -y autoconf automake libtool make
|
||||||
|
|
||||||
|
WORKDIR /tmp/c
|
||||||
|
COPY gu/*.c gu/*.h /tmp/c/gu/
|
||||||
|
COPY pgf/*.c pgf/*.h /tmp/c/pgf/
|
||||||
|
COPY pgf/lightning/i386/*.h /tmp/c/pgf/lightning/i386/
|
||||||
|
COPY pgf/lightning/*.h /tmp/c/pgf/lightning/
|
||||||
|
COPY \
|
||||||
|
Makefile.am \
|
||||||
|
configure.ac \
|
||||||
|
lib*.pc.in \
|
||||||
|
/tmp/c/
|
||||||
|
RUN autoreconf -i
|
||||||
|
RUN emconfigure ./configure
|
||||||
|
RUN emmake make
|
||||||
|
RUN emcc .libs/libgu.a .libs/libpgf.a -o pgf.js \
|
||||||
|
-sALLOW_MEMORY_GROWTH \
|
||||||
|
-sEXPORTED_FUNCTIONS="\
|
||||||
|
_pgf_read,\
|
||||||
|
_pgf_abstract_name,\
|
||||||
|
_pgf_read_expr,\
|
||||||
|
_pgf_print_expr,\
|
||||||
|
_pgf_expr_arity,\
|
||||||
|
_gu_new_pool,\
|
||||||
|
_gu_new_exn,\
|
||||||
|
_gu_data_in,\
|
||||||
|
_gu_exn_is_raised,\
|
||||||
|
_gu_exn_caught_,\
|
||||||
|
_gu_exn_caught_data,\
|
||||||
|
_gu_exn_clear,\
|
||||||
|
_gu_new_string_buf,\
|
||||||
|
_gu_string_buf_out,\
|
||||||
|
_gu_string_buf_data,\
|
||||||
|
_malloc,\
|
||||||
|
_free\
|
||||||
|
"\
|
||||||
|
-sEXPORTED_RUNTIME_METHODS="\
|
||||||
|
ccall,\
|
||||||
|
FS,\
|
||||||
|
getValue,\
|
||||||
|
AsciiToString,\
|
||||||
|
stringToUTF8,\
|
||||||
|
UTF8ToString,\
|
||||||
|
allocateUTF8\
|
||||||
|
"
|
||||||
11
src/runtime/javascript/README.md
Normal file
11
src/runtime/javascript/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# JavaScript runtime using Web Assembly
|
||||||
|
|
||||||
|
This folder contains very early work experimenting with a pure JavaScript runtime,
|
||||||
|
compiled to Web Assembly (WASM) using [Emscripten](https://emscripten.org/).
|
||||||
|
|
||||||
|
1. Compile the WASM files (inside Docker) using `build-wasm.sh`, placing them in `.libs/`
|
||||||
|
2. Test in Node.js by running `node test-node.js [path to PGF]`
|
||||||
|
3. Test in a web browser
|
||||||
|
1. Start a server with `npx serve -l 41296`
|
||||||
|
2. Browse to `http://localhost:41296/test-web.html`
|
||||||
|
3. Check JavaScript console
|
||||||
10
src/runtime/javascript/build-wasm.sh
Executable file
10
src/runtime/javascript/build-wasm.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Build inside Docker image
|
||||||
|
IMAGE="gf/build-c-runtime-wasm"
|
||||||
|
docker build ../c --file Dockerfile --tag $IMAGE
|
||||||
|
|
||||||
|
# Copy bulit files from container to host
|
||||||
|
mkdir -p .libs
|
||||||
|
docker run --rm --volume "$PWD":/tmp/host $IMAGE bash -c "cp pgf.js pgf.wasm /tmp/host/.libs/"
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
abstract Editor = {
|
|
||||||
|
|
||||||
cat Adjective ;
|
|
||||||
Noun ;
|
|
||||||
Verb ;
|
|
||||||
Determiner ;
|
|
||||||
Sentence ;
|
|
||||||
|
|
||||||
fun Available : Adjective ;
|
|
||||||
Next : Adjective ;
|
|
||||||
Previous : Adjective ;
|
|
||||||
|
|
||||||
fun Bulgarian : Noun ;
|
|
||||||
Danish : Noun ;
|
|
||||||
English : Noun ;
|
|
||||||
Finnish : Noun ;
|
|
||||||
French : Noun ;
|
|
||||||
German : Noun ;
|
|
||||||
Italian : Noun ;
|
|
||||||
Norwegian : Noun ;
|
|
||||||
Russian : Noun ;
|
|
||||||
Spanish : Noun ;
|
|
||||||
Swedish : Noun ;
|
|
||||||
|
|
||||||
fun Float_N : Noun ;
|
|
||||||
Integer_N : Noun ;
|
|
||||||
String_N : Noun ;
|
|
||||||
|
|
||||||
Language : Noun ;
|
|
||||||
Node : Noun ;
|
|
||||||
Page : Noun ;
|
|
||||||
Refinement : Noun ;
|
|
||||||
Tree : Noun ;
|
|
||||||
Wrapper : Noun ;
|
|
||||||
|
|
||||||
fun Copy : Verb ;
|
|
||||||
Cut : Verb ;
|
|
||||||
Delete : Verb ;
|
|
||||||
Enter : Verb ;
|
|
||||||
Parse : Verb ;
|
|
||||||
Paste : Verb ;
|
|
||||||
Redo : Verb ;
|
|
||||||
Refine : Verb ;
|
|
||||||
Replace : Verb ;
|
|
||||||
Select : Verb ;
|
|
||||||
Show : Verb ;
|
|
||||||
Undo : Verb ;
|
|
||||||
Wrap : Verb ;
|
|
||||||
|
|
||||||
fun DefPlDet : Determiner ;
|
|
||||||
DefSgDet : Determiner ;
|
|
||||||
IndefPlDet : Determiner ;
|
|
||||||
IndefSgDet : Determiner ;
|
|
||||||
|
|
||||||
fun Command : Verb -> Determiner -> Noun -> Sentence ;
|
|
||||||
CommandAdj : Verb -> Determiner -> Adjective -> Noun -> Sentence ;
|
|
||||||
ErrorMessage : Adjective -> Noun -> Sentence ;
|
|
||||||
Label : Noun -> Sentence ;
|
|
||||||
RandomlyCommand : Verb -> Determiner -> Noun -> Sentence ;
|
|
||||||
SingleWordCommand : Verb -> Sentence ;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
--# -path=alltenses
|
|
||||||
concrete EditorEng of Editor = open GrammarEng, ParadigmsEng in {
|
|
||||||
|
|
||||||
lincat Adjective = A ;
|
|
||||||
Noun = N ;
|
|
||||||
Verb = V ;
|
|
||||||
Determiner = Det ;
|
|
||||||
Sentence = Utt ;
|
|
||||||
|
|
||||||
lin Available = mkA "available" ;
|
|
||||||
Next = mkA "next" ;
|
|
||||||
Previous = mkA "previous" ;
|
|
||||||
|
|
||||||
lin Bulgarian = mkN "Bulgarian" ;
|
|
||||||
Danish = mkN "Danish" ;
|
|
||||||
English = mkN "English" ;
|
|
||||||
Finnish = mkN "Finnish" ;
|
|
||||||
French = mkN "French" ;
|
|
||||||
German = mkN "German" ;
|
|
||||||
Italian = mkN "Italian" ;
|
|
||||||
Norwegian = mkN "Norwegian" ;
|
|
||||||
Russian = mkN "Russian" ;
|
|
||||||
Spanish = mkN "Spanish" ;
|
|
||||||
Swedish = mkN "Swedish" ;
|
|
||||||
|
|
||||||
lin Float_N = mkN "float" ;
|
|
||||||
Integer_N = mkN "integer" ;
|
|
||||||
String_N = mkN "string" ;
|
|
||||||
|
|
||||||
Language = mkN "language" ;
|
|
||||||
Node = mkN "node" ;
|
|
||||||
Page = mkN "page" ;
|
|
||||||
Refinement = mkN "refinement" ;
|
|
||||||
Tree = mkN "tree" ;
|
|
||||||
Wrapper = mkN "wrapper" ;
|
|
||||||
|
|
||||||
lin Copy = mkV "copy" ;
|
|
||||||
Cut = mkV "cut" ;
|
|
||||||
Delete = mkV "delete" ;
|
|
||||||
Enter = mkV "enter" ;
|
|
||||||
Parse = mkV "parse" ;
|
|
||||||
Paste = mkV "paste" ;
|
|
||||||
Redo = mkV "redo" ;
|
|
||||||
Refine = mkV "refine" ;
|
|
||||||
Replace = mkV "replace" ;
|
|
||||||
Select = mkV "select" ;
|
|
||||||
Show = mkV "show" ;
|
|
||||||
Undo = mkV "undo" ;
|
|
||||||
Wrap = mkV "wrap" ;
|
|
||||||
|
|
||||||
lin DefPlDet = DetQuant DefArt NumPl ;
|
|
||||||
DefSgDet = DetQuant DefArt NumSg ;
|
|
||||||
IndefPlDet = DetQuant IndefArt NumPl ;
|
|
||||||
IndefSgDet = DetQuant IndefArt NumSg ;
|
|
||||||
|
|
||||||
lin Command v d n = UttImpSg PPos (ImpVP (ComplSlash (SlashV2a (mkV2 v)) (DetCN d (UseN n)))) ;
|
|
||||||
CommandAdj v d a n = UttImpSg PPos (ImpVP (ComplSlash (SlashV2a (mkV2 v)) (DetCN d (AdjCN (PositA a) (UseN n))))) ;
|
|
||||||
ErrorMessage a n = UttNP (DetCN (DetQuant no_Quant NumPl) (AdjCN (PositA a) (UseN n))) ;
|
|
||||||
Label n = UttNP (MassNP (UseN n)) ;
|
|
||||||
RandomlyCommand v d n = UttImpSg PPos (ImpVP (AdvVP (ComplSlash (SlashV2a (mkV2 v)) (DetCN d (UseN n))) (PrepNP (mkPrep "at") (MassNP (UseN (mkN "random")))))) ;
|
|
||||||
SingleWordCommand v = UttImpSg PPos (ImpVP (UseV v)) ;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
|
||||||
<script type="text/javascript" src="gflib.js"></script>
|
|
||||||
<script type="text/javascript" src="editorGrammar.js"></script>
|
|
||||||
<script type="text/javascript" src="grammar.js"></script>
|
|
||||||
<script type="text/javascript" src="gfjseditor.js"></script>
|
|
||||||
<title>Web-based Syntax Editor</title>
|
|
||||||
</head>
|
|
||||||
<body onload="mkEditor('editor', Foods)" onkeydown="return hotKeys(event)">
|
|
||||||
<div id="editor">
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 161 B |
File diff suppressed because it is too large
Load Diff
@@ -1,54 +0,0 @@
|
|||||||
/* Output */
|
|
||||||
|
|
||||||
function sayText(text) {
|
|
||||||
document.voice_output_text = text;
|
|
||||||
activateForm("voice_output");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XHTML+Voice Utilities */
|
|
||||||
|
|
||||||
function activateForm(formid) {
|
|
||||||
var form = document.getElementById(formid);
|
|
||||||
var e = document.createEvent("UIEvents");
|
|
||||||
e.initEvent("DOMActivate","true","true");
|
|
||||||
form.dispatchEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* DOM utilities */
|
|
||||||
|
|
||||||
/* Gets the head element of the document. */
|
|
||||||
function getHeadElement() {
|
|
||||||
var hs = document.getElementsByTagName("head");
|
|
||||||
if (hs.length == 0) {
|
|
||||||
var head = document.createElement("head");
|
|
||||||
document.documentElement.insertBefore(head, document.documentElement.firstChild);
|
|
||||||
return head;
|
|
||||||
} else {
|
|
||||||
return hs[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gets the body element of the document. */
|
|
||||||
function getBodyElement() {
|
|
||||||
var bs = document.getElementsByTagName("body");
|
|
||||||
if (bs.length == 0) {
|
|
||||||
var body = document.createElement("body");
|
|
||||||
document.documentElement.appendChild(body);
|
|
||||||
return body;
|
|
||||||
} else {
|
|
||||||
return bs[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Removes all the children of a node */
|
|
||||||
function removeChildren(node) {
|
|
||||||
while (node.hasChildNodes()) {
|
|
||||||
node.removeChild(node.firstChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setText(node, text) {
|
|
||||||
removeChildren(node);
|
|
||||||
node.appendChild(document.createTextNode(text));
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
543
src/runtime/javascript/jspgf.js
Normal file
543
src/runtime/javascript/jspgf.js
Normal file
@@ -0,0 +1,543 @@
|
|||||||
|
/**
|
||||||
|
* This module is the high-level JavaScript wrapper around the WASM-compiled version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
async function mkAPI() {
|
||||||
|
|
||||||
|
const sizeof_GuMapItor = 4;
|
||||||
|
const offsetof_GuMapItor_fn = 0;
|
||||||
|
|
||||||
|
var asm = null;
|
||||||
|
var wasmTable = null;
|
||||||
|
var freeTableIndexes = [];
|
||||||
|
|
||||||
|
function setErrNo(value) {
|
||||||
|
HEAP32[asm.__errno_location() >> 2] = value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function abortOnCannotGrowMemory(requestedSize) {
|
||||||
|
abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -s INITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function _emscripten_resize_heap(requestedSize) {
|
||||||
|
var oldSize = HEAPU8.length;
|
||||||
|
requestedSize = requestedSize >>> 0;
|
||||||
|
abortOnCannotGrowMemory(requestedSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
var tempRet0 = 0;
|
||||||
|
var urlData = {};
|
||||||
|
var fdData = {};
|
||||||
|
var fdMax = 0;
|
||||||
|
var asmLibraryArg = {
|
||||||
|
"__syscall_fcntl64":
|
||||||
|
function (fd, cmd, varargs) {
|
||||||
|
setErrNo(134);
|
||||||
|
return -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
"__syscall_ioctl":
|
||||||
|
function (fd, op, varargs) {
|
||||||
|
setErrNo(134);
|
||||||
|
return -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
"__syscall_open":
|
||||||
|
function (pathPtr, flags, varargs) {
|
||||||
|
const path = UTF8ToString(pathPtr);
|
||||||
|
const data = urlData[path];
|
||||||
|
if (data == null) {
|
||||||
|
setErrNo(129);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fdMax++;
|
||||||
|
fdData[fdMax] = {data: data, pos: 0};
|
||||||
|
delete urlData[path];
|
||||||
|
return fdMax;
|
||||||
|
},
|
||||||
|
|
||||||
|
"_munmap_js":
|
||||||
|
function (addr, len, prot, flags, fd, offset) {
|
||||||
|
setErrNo(134);
|
||||||
|
return -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
"abort":
|
||||||
|
function () {
|
||||||
|
console.log('native code called abort()');
|
||||||
|
},
|
||||||
|
|
||||||
|
"emscripten_memcpy_big":
|
||||||
|
function (dest, src, num) {
|
||||||
|
HEAPU8.copyWithin(dest, src, src + num);
|
||||||
|
},
|
||||||
|
|
||||||
|
"emscripten_resize_heap":
|
||||||
|
function _emscripten_resize_heap(requestedSize) {
|
||||||
|
var oldSize = HEAPU8.length;
|
||||||
|
requestedSize = requestedSize >>> 0;
|
||||||
|
abortOnCannotGrowMemory(requestedSize);
|
||||||
|
},
|
||||||
|
|
||||||
|
"fd_close":
|
||||||
|
function (fd) {
|
||||||
|
delete fdData[fd];
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
"fd_read":
|
||||||
|
function (fd, iov, iovcnt, pnum) {
|
||||||
|
const info = fdData[fd];
|
||||||
|
if (info == null) {
|
||||||
|
setErrNo(121);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
let num = 0;
|
||||||
|
for (let i = 0; i < iovcnt; i++) {
|
||||||
|
const ptr = HEAP32[(((iov)+(i*8))>>2)];
|
||||||
|
const len = HEAP32[(((iov)+(i*8 + 4))>>2)];
|
||||||
|
|
||||||
|
let cnt = 0;
|
||||||
|
while (cnt < len && info.pos < info.data.length) {
|
||||||
|
HEAP8[ptr+cnt] = info.data[info.pos];
|
||||||
|
info.pos++
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
num += cnt;
|
||||||
|
if (cnt < len) break; // nothing more to read
|
||||||
|
}
|
||||||
|
|
||||||
|
HEAP32[((pnum)>>2)] = num;
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
"fd_seek":
|
||||||
|
function (fd, offset_low, offset_high, whence, newOffset) {
|
||||||
|
setErrNo(134);
|
||||||
|
return -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
"fd_write":
|
||||||
|
function _fd_write(fd, iov, iovcnt, pnum) {
|
||||||
|
setErrNo(134);
|
||||||
|
return -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
"setTempRet0":
|
||||||
|
function (value) {
|
||||||
|
tempRet0 = value;
|
||||||
|
},
|
||||||
|
|
||||||
|
"__assert_fail":
|
||||||
|
function (condition, filename, line, func) {
|
||||||
|
abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wraps a JS function as a wasm function with a given signature.
|
||||||
|
function convertJsFunctionToWasm(func, sig) {
|
||||||
|
|
||||||
|
// If the type reflection proposal is available, use the new
|
||||||
|
// "WebAssembly.Function" constructor.
|
||||||
|
// Otherwise, construct a minimal wasm module importing the JS function and
|
||||||
|
// re-exporting it.
|
||||||
|
if (typeof WebAssembly.Function == "function") {
|
||||||
|
var typeNames = {
|
||||||
|
'i': 'i32',
|
||||||
|
'j': 'i64',
|
||||||
|
'f': 'f32',
|
||||||
|
'd': 'f64'
|
||||||
|
};
|
||||||
|
var type = {
|
||||||
|
parameters: [],
|
||||||
|
results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
|
||||||
|
};
|
||||||
|
for (var i = 1; i < sig.length; ++i) {
|
||||||
|
type.parameters.push(typeNames[sig[i]]);
|
||||||
|
}
|
||||||
|
return new WebAssembly.Function(type, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The module is static, with the exception of the type section, which is
|
||||||
|
// generated based on the signature passed in.
|
||||||
|
var typeSection = [
|
||||||
|
0x01, // id: section,
|
||||||
|
0x00, // length: 0 (placeholder)
|
||||||
|
0x01, // count: 1
|
||||||
|
0x60, // form: func
|
||||||
|
];
|
||||||
|
var sigRet = sig.slice(0, 1);
|
||||||
|
var sigParam = sig.slice(1);
|
||||||
|
var typeCodes = {
|
||||||
|
'i': 0x7f, // i32
|
||||||
|
'j': 0x7e, // i64
|
||||||
|
'f': 0x7d, // f32
|
||||||
|
'd': 0x7c, // f64
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parameters, length + signatures
|
||||||
|
typeSection.push(sigParam.length);
|
||||||
|
for (var i = 0; i < sigParam.length; ++i) {
|
||||||
|
typeSection.push(typeCodes[sigParam[i]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return values, length + signatures
|
||||||
|
// With no multi-return in MVP, either 0 (void) or 1 (anything else)
|
||||||
|
if (sigRet == 'v') {
|
||||||
|
typeSection.push(0x00);
|
||||||
|
} else {
|
||||||
|
typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the overall length of the type section back into the section header
|
||||||
|
// (excepting the 2 bytes for the section id and length)
|
||||||
|
typeSection[1] = typeSection.length - 2;
|
||||||
|
|
||||||
|
// Rest of the module is static
|
||||||
|
var bytes = new Uint8Array([
|
||||||
|
0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
|
||||||
|
0x01, 0x00, 0x00, 0x00, // version: 1
|
||||||
|
].concat(typeSection, [
|
||||||
|
0x02, 0x07, // import section
|
||||||
|
// (import "e" "f" (func 0 (type 0)))
|
||||||
|
0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
|
||||||
|
0x07, 0x05, // export section
|
||||||
|
// (export "f" (func 0 (type 0)))
|
||||||
|
0x01, 0x01, 0x66, 0x00, 0x00,
|
||||||
|
]));
|
||||||
|
|
||||||
|
// We can compile this wasm module synchronously because it is very small.
|
||||||
|
// This accepts an import (at "e.f"), that it reroutes to an export (at "f")
|
||||||
|
var module = new WebAssembly.Module(bytes);
|
||||||
|
var instance = new WebAssembly.Instance(module, {
|
||||||
|
'e': {'f': func}
|
||||||
|
});
|
||||||
|
var wrappedFunc = instance.exports['f'];
|
||||||
|
return wrappedFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFunction(func, sig) {
|
||||||
|
func = convertJsFunctionToWasm(func, sig);
|
||||||
|
|
||||||
|
let index;
|
||||||
|
|
||||||
|
// Reuse a free index if there is one, otherwise grow.
|
||||||
|
if (freeTableIndexes.length) {
|
||||||
|
index = freeTableIndexes.pop();
|
||||||
|
} else {
|
||||||
|
// Grow the table
|
||||||
|
try {
|
||||||
|
wasmTable.grow(1);
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof RangeError)) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
|
||||||
|
}
|
||||||
|
index = wasmTable.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wasmTable.set(index, func);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFunction(index) {
|
||||||
|
freeTableIndexes.push(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch("pgf.wasm", { credentials: 'same-origin' });
|
||||||
|
|
||||||
|
const info = {
|
||||||
|
'env': asmLibraryArg,
|
||||||
|
'wasi_snapshot_preview1': asmLibraryArg,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Suppress closure warning here since the upstream definition for
|
||||||
|
// instantiateStreaming only allows Promise<Repsponse> rather than
|
||||||
|
// an actual Response.
|
||||||
|
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
|
||||||
|
/** @suppress {checkTypes} */
|
||||||
|
const result = await WebAssembly.instantiateStreaming(response, info);
|
||||||
|
|
||||||
|
asm = result["instance"].exports;
|
||||||
|
wasmTable = asm['__indirect_function_table'];
|
||||||
|
const buf = asm['memory'].buffer;
|
||||||
|
const HEAP8 = new Int8Array(buf);
|
||||||
|
const HEAP16 = new Int16Array(buf);
|
||||||
|
const HEAP32 = new Int32Array(buf);
|
||||||
|
const HEAPU8 = new Uint8Array(buf);
|
||||||
|
const HEAPU16 = new Uint16Array(buf);
|
||||||
|
const HEAPU32 = new Uint32Array(buf);
|
||||||
|
const HEAPF32 = new Float32Array(buf);
|
||||||
|
const HEAPF64 = new Float64Array(buf);
|
||||||
|
|
||||||
|
// Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
|
||||||
|
function lengthBytesUTF8(str) {
|
||||||
|
var len = 0;
|
||||||
|
for (var i = 0; i < str.length; ++i) {
|
||||||
|
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
|
||||||
|
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
||||||
|
var u = str.charCodeAt(i); // possibly a lead surrogate
|
||||||
|
if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
|
||||||
|
if (u <= 0x7F) ++len;
|
||||||
|
else if (u <= 0x7FF) len += 2;
|
||||||
|
else if (u <= 0xFFFF) len += 3;
|
||||||
|
else len += 4;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
|
||||||
|
if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
var startIdx = outIdx;
|
||||||
|
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
|
||||||
|
for (var i = 0; i < str.length; ++i) {
|
||||||
|
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
|
||||||
|
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
||||||
|
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
|
||||||
|
var u = str.charCodeAt(i); // possibly a lead surrogate
|
||||||
|
if (u >= 0xD800 && u <= 0xDFFF) {
|
||||||
|
var u1 = str.charCodeAt(++i);
|
||||||
|
u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
|
||||||
|
}
|
||||||
|
if (u <= 0x7F) {
|
||||||
|
if (outIdx >= endIdx) break;
|
||||||
|
heap[outIdx++] = u;
|
||||||
|
} else if (u <= 0x7FF) {
|
||||||
|
if (outIdx + 1 >= endIdx) break;
|
||||||
|
heap[outIdx++] = 0xC0 | (u >> 6);
|
||||||
|
heap[outIdx++] = 0x80 | (u & 63);
|
||||||
|
} else if (u <= 0xFFFF) {
|
||||||
|
if (outIdx + 2 >= endIdx) break;
|
||||||
|
heap[outIdx++] = 0xE0 | (u >> 12);
|
||||||
|
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
||||||
|
heap[outIdx++] = 0x80 | (u & 63);
|
||||||
|
} else {
|
||||||
|
if (outIdx + 3 >= endIdx) break;
|
||||||
|
if (u > 0x10FFFF) warnOnce('Invalid Unicode code point 0x' + u.toString(16) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).');
|
||||||
|
heap[outIdx++] = 0xF0 | (u >> 18);
|
||||||
|
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
|
||||||
|
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
||||||
|
heap[outIdx++] = 0x80 | (u & 63);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Null-terminate the pointer to the buffer.
|
||||||
|
heap[outIdx] = 0;
|
||||||
|
return outIdx - startIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
function allocateUTF8(pool,str) {
|
||||||
|
var size = lengthBytesUTF8(str) + 1;
|
||||||
|
var ptr = asm.gu_malloc(pool,size);
|
||||||
|
if (ptr) stringToUTF8Array(str, HEAP8, ptr, size);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} idx
|
||||||
|
* @param {number=} maxBytesToRead
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
function UTF8ArrayToString(heap, idx, maxBytesToRead) {
|
||||||
|
var endIdx = idx + maxBytesToRead;
|
||||||
|
var endPtr = idx;
|
||||||
|
// TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
|
||||||
|
// Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
|
||||||
|
// (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity)
|
||||||
|
while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
|
||||||
|
|
||||||
|
if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
|
||||||
|
return UTF8Decoder.decode(heap.subarray(idx, endPtr));
|
||||||
|
} else {
|
||||||
|
var str = '';
|
||||||
|
// If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
|
||||||
|
while (idx < endPtr) {
|
||||||
|
// For UTF8 byte structure, see:
|
||||||
|
// http://en.wikipedia.org/wiki/UTF-8#Description
|
||||||
|
// https://www.ietf.org/rfc/rfc2279.txt
|
||||||
|
// https://tools.ietf.org/html/rfc3629
|
||||||
|
var u0 = heap[idx++];
|
||||||
|
if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
|
||||||
|
var u1 = heap[idx++] & 63;
|
||||||
|
if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
|
||||||
|
var u2 = heap[idx++] & 63;
|
||||||
|
if ((u0 & 0xF0) == 0xE0) {
|
||||||
|
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
||||||
|
} else {
|
||||||
|
if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte 0x' + u0.toString(16) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
|
||||||
|
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u0 < 0x10000) {
|
||||||
|
str += String.fromCharCode(u0);
|
||||||
|
} else {
|
||||||
|
var ch = u0 - 0x10000;
|
||||||
|
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function UTF8ToString(ptr, maxBytesToRead) {
|
||||||
|
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const GuErrnoStrPtr = asm.malloc(8);
|
||||||
|
stringToUTF8Array("GuErrno", HEAP8, GuErrnoStrPtr, 8);
|
||||||
|
|
||||||
|
const PgfExnStrPtr = asm.malloc(8);
|
||||||
|
stringToUTF8Array("PgfExn", HEAP8, PgfExnStrPtr, 8);
|
||||||
|
|
||||||
|
function pgfError(err) {
|
||||||
|
if (asm.gu_exn_caught_(err, GuErrnoStrPtr)) {
|
||||||
|
errDataPtr = asm.gu_exn_caught_data(err);
|
||||||
|
return new Error("errno="+HEAP32[errDataPtr >> 2]);
|
||||||
|
} else if (asm.gu_exn_caught_(err, PgfExnStrPtr)) {
|
||||||
|
msgPtr = asm.gu_exn_caught_data(err);
|
||||||
|
return new Error(UTF8ToString(msgPtr));
|
||||||
|
}
|
||||||
|
return new Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const registry = new FinalizationRegistry((pool) => {
|
||||||
|
asm.gu_pool_free(pool);
|
||||||
|
});
|
||||||
|
|
||||||
|
function PGF(pgfPtr,name,pool) {
|
||||||
|
this.pgfPtr = pgfPtr;
|
||||||
|
this.abstractName = name;
|
||||||
|
this.pool = pool;
|
||||||
|
this.languages = {};
|
||||||
|
registry.register(this,pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Concr(pgf,concrPtr,name) {
|
||||||
|
this.pgf = pgf;
|
||||||
|
this.name = name;
|
||||||
|
this.concrPtr = concrPtr;
|
||||||
|
}
|
||||||
|
Concr.prototype.linearize = function(expr) {
|
||||||
|
const tmp_pool = asm.gu_new_pool();
|
||||||
|
const err = asm.gu_new_exn(tmp_pool);
|
||||||
|
const sb = asm.gu_new_string_buf(tmp_pool);
|
||||||
|
const out = asm.gu_string_buf_out(sb);
|
||||||
|
|
||||||
|
asm.pgf_linearize(this.concrPtr, expr.exprPtr, out, err);
|
||||||
|
if (asm.gu_exn_is_raised(err)) {
|
||||||
|
const e = pgfError(err);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
const strPtr = asm.gu_string_buf_data(sb);
|
||||||
|
const len = asm.gu_string_buf_length(sb);
|
||||||
|
const str = UTF8ToString(strPtr,len);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readPGF(pgfURL) {
|
||||||
|
const response = await fetch(pgfURL);
|
||||||
|
urlData[pgfURL] = new Int8Array(await response.arrayBuffer());
|
||||||
|
|
||||||
|
const pool = asm.gu_new_pool();
|
||||||
|
|
||||||
|
const tmp_pool = asm.gu_new_pool();
|
||||||
|
const err = asm.gu_new_exn(tmp_pool);
|
||||||
|
const strPtr = allocateUTF8(tmp_pool,pgfURL);
|
||||||
|
const pgfPtr = asm.pgf_read(strPtr,pool,err);
|
||||||
|
if (asm.gu_exn_is_raised(err)) {
|
||||||
|
const e = pgfError(err);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
const namePtr = asm.pgf_abstract_name(pgfPtr);
|
||||||
|
const abstractName = UTF8ToString(namePtr);
|
||||||
|
|
||||||
|
const pgf = new PGF(pgfPtr,abstractName,pool);
|
||||||
|
|
||||||
|
const itor = asm.gu_malloc(tmp_pool,sizeof_GuMapItor);
|
||||||
|
const fn =
|
||||||
|
addFunction(
|
||||||
|
(itor,namePtr,concrPtrPtr,err) => {
|
||||||
|
const name = UTF8ToString(namePtr);
|
||||||
|
const concrPtr = HEAP32[concrPtrPtr >> 2];
|
||||||
|
pgf.languages[name] = new Concr(pgf,concrPtr,name);
|
||||||
|
},
|
||||||
|
"viiii"
|
||||||
|
);
|
||||||
|
HEAP32[(itor+offsetof_GuMapItor_fn) >> 2] = fn;
|
||||||
|
asm.pgf_iter_languages(pgfPtr,itor,err);
|
||||||
|
removeFunction(fn);
|
||||||
|
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
return pgf;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Expr(exprPtr,pool) {
|
||||||
|
this.exprPtr = exprPtr;
|
||||||
|
this.pool = pool;
|
||||||
|
registry.register(this,pool);
|
||||||
|
}
|
||||||
|
Expr.prototype.toString = function() {
|
||||||
|
const tmp_pool = asm.gu_new_pool();
|
||||||
|
|
||||||
|
const sb = asm.gu_new_string_buf(tmp_pool);
|
||||||
|
const out = asm.gu_string_buf_out(sb);
|
||||||
|
const err = asm.gu_new_exn(tmp_pool);
|
||||||
|
asm.pgf_print_expr(this.exprPtr, 0, 0, out, err);
|
||||||
|
if (asm.gu_exn_is_raised(err)) {
|
||||||
|
const e = pgfError(err);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
const strPtr = asm.gu_string_buf_data(sb);
|
||||||
|
const len = asm.gu_string_buf_length(sb);
|
||||||
|
const str = UTF8ToString(strPtr,len);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
Expr.prototype.arity = function(expr) {
|
||||||
|
return asm.pgf_expr_arity(this.expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function readExpr(exprStr) {
|
||||||
|
const tmp_pool = asm.gu_new_pool();
|
||||||
|
|
||||||
|
const strPtr = allocateUTF8(tmp_pool,exprStr);
|
||||||
|
const in_ = asm.gu_data_in(strPtr, exprStr.length, tmp_pool);
|
||||||
|
const err = asm.gu_new_exn(tmp_pool);
|
||||||
|
const pool = asm.gu_new_pool();
|
||||||
|
const expr = asm.pgf_read_expr(in_, pool, tmp_pool, err);
|
||||||
|
asm.gu_pool_free(tmp_pool);
|
||||||
|
|
||||||
|
if (asm.gu_exn_is_raised(err)) {
|
||||||
|
throw pgfError(err);
|
||||||
|
}
|
||||||
|
if (expr == 0) {
|
||||||
|
throw new Error('Expression cannot be parsed');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Expr(expr,pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { readPGF, readExpr };
|
||||||
|
}
|
||||||
|
|
||||||
|
// This allows us to use both from Node and in browser
|
||||||
|
if (typeof module != 'undefined') {
|
||||||
|
module.exports = mkAPI;
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 201 B |
Binary file not shown.
|
Before Width: | Height: | Size: 229 B |
@@ -1,252 +0,0 @@
|
|||||||
body {
|
|
||||||
font-family:arial,helvetica,sans-serif;
|
|
||||||
font-size:12px;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#wrapper {
|
|
||||||
width:740px;
|
|
||||||
height:520px;
|
|
||||||
margin:auto 50px;
|
|
||||||
border:1px solid gray;
|
|
||||||
padding:10px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#absFrame {
|
|
||||||
width:250px;
|
|
||||||
height:250px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
#conFrame {
|
|
||||||
width:436px;
|
|
||||||
height:250px;
|
|
||||||
margin-left:10px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
white-space: normal;
|
|
||||||
overflow:auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#actFrame {
|
|
||||||
width:250px;
|
|
||||||
height:170px;
|
|
||||||
margin-top:10px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
overflow:auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#refFrame {
|
|
||||||
width:436px;
|
|
||||||
height:170px;
|
|
||||||
margin-left:10px;
|
|
||||||
margin-top:10px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
overflow:auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#messageFrame {
|
|
||||||
width:506px;
|
|
||||||
height:15px;
|
|
||||||
margin-top:10px;
|
|
||||||
margin-right:10px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#clipboardFrame {
|
|
||||||
width:180px;
|
|
||||||
height:15px;
|
|
||||||
margin-top:10px;
|
|
||||||
padding:10px;
|
|
||||||
border:1px solid gray;
|
|
||||||
float:left;
|
|
||||||
overflow:auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tree {
|
|
||||||
left: -10px;
|
|
||||||
top: -10px;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 10px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
position: relative;
|
|
||||||
list-style: none;
|
|
||||||
margin-left: 20px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.tree-menu {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.tree:link, a.tree:visited, a.tree:active {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.tree:hover {
|
|
||||||
color: blue;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: underline;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
text-decoration: none;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.treeSelected:hover {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
text-decoration: underline;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.treeGray:link, a.treeGray:visited, a.treeGray:active {
|
|
||||||
color: silver;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.treeGray:hover {
|
|
||||||
color: silver;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
margin-right:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.action, table.refinement, table.wrapper, table.tree, table.language {
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
border-style: none;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border-spacing: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.selected {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.unavailable, tr.closed {
|
|
||||||
color: silver;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.unavailable:hover {
|
|
||||||
color: silver;
|
|
||||||
background-color: #3366CC;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.action, tr.refinement, tr.wrapper, tr.tree {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.action:hover, tr.refinement:hover, tr.wrapper:hover, tr.tree:hover {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.action {
|
|
||||||
width: 220px;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.refinement, td.wrapper, td.tree {
|
|
||||||
width: 515px;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.hotKey {
|
|
||||||
width: 30px;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.language {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
margin: 1px;
|
|
||||||
padding: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.language:hover {
|
|
||||||
color: blue;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: underline;
|
|
||||||
margin: 1px;
|
|
||||||
padding: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.selected {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
margin: 1px;
|
|
||||||
padding: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.selected:hover {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
text-decoration: underline;
|
|
||||||
margin: 1px;
|
|
||||||
padding: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin-bottom: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.normal {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
padding-left: 2px;
|
|
||||||
padding-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.edit {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
border:2px inset;
|
|
||||||
padding-left: 2px;
|
|
||||||
padding-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.selected {
|
|
||||||
color: white;
|
|
||||||
background-color: #3366CC;
|
|
||||||
text-decoration: none;
|
|
||||||
padding-left: 2px;
|
|
||||||
padding-right: 2px;
|
|
||||||
}
|
|
||||||
33
src/runtime/javascript/test-node.js
Normal file
33
src/runtime/javascript/test-node.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const Module = require('./.libs/pgf.js');
|
||||||
|
const JSPGF = require('./jspgf.js')(Module);
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
Module.onRuntimeInitialized = () => {
|
||||||
|
|
||||||
|
// Read PGF path from args
|
||||||
|
if (process.argv.length > 2) {
|
||||||
|
const pgfPathHost = process.argv[2];
|
||||||
|
|
||||||
|
// Copy file into filesystem
|
||||||
|
const pgfPathFS = '/tmp/' + path.basename(pgfPathHost);
|
||||||
|
const rawPgf = fs.readFileSync(pgfPathHost);
|
||||||
|
Module.FS.writeFile(pgfPathFS, rawPgf);
|
||||||
|
|
||||||
|
// Read PGF
|
||||||
|
const pgf = JSPGF.readPGF(pgfPathFS);
|
||||||
|
|
||||||
|
// Print its name
|
||||||
|
console.log(JSPGF.abstractName(pgf));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse expression
|
||||||
|
const expr = JSPGF.readExpr("Pred (Another (x f))");
|
||||||
|
|
||||||
|
// Show it
|
||||||
|
console.log(JSPGF.showExpr(expr));
|
||||||
|
|
||||||
|
// Print its arity
|
||||||
|
console.log('arity', JSPGF.arity(expr));
|
||||||
|
}
|
||||||
|
|
||||||
13
src/runtime/javascript/test-web.html
Normal file
13
src/runtime/javascript/test-web.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="./jspgf.js"></script>
|
||||||
|
<script type="text/javascript" src="./test-web.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
21
src/runtime/javascript/test-web.js
Normal file
21
src/runtime/javascript/test-web.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
mkAPI().then((pgf) => {
|
||||||
|
// Parse expression
|
||||||
|
const expr = pgf.readExpr("Pred (This Fish) Fresh");
|
||||||
|
|
||||||
|
// Show it
|
||||||
|
console.log(expr.toString());
|
||||||
|
|
||||||
|
// Print its arity
|
||||||
|
console.log('arity', expr.arity());
|
||||||
|
|
||||||
|
pgf.readPGF("Foods.pgf").then((gr) => {
|
||||||
|
// Print the grammar name
|
||||||
|
console.log(gr.abstractName);
|
||||||
|
|
||||||
|
// Access a language and print the concrete name
|
||||||
|
console.log(gr.languages["FoodsEng"].name);
|
||||||
|
|
||||||
|
// Linearize an expression
|
||||||
|
console.log(gr.languages["FoodsEng"].linearize(expr));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
body {
|
|
||||||
color: black;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dt {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl dd {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.fromLang dt {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.toLang {
|
|
||||||
border-width: 1px 0 0 0;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #c0c0c0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.toLang dt {
|
|
||||||
color: #c0c0c0;
|
|
||||||
display: block;
|
|
||||||
float: left;
|
|
||||||
width: 5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dl.toLang dd {
|
|
||||||
border-width: 0 0 1px 0;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #c0c0c0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
list-style-type: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="translator.css" />
|
|
||||||
<script type="text/javascript" src="gflib.js"></script>
|
|
||||||
<script type="text/javascript" src="grammar.js"></script>
|
|
||||||
<script type="text/javascript" src="translator.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
/* CHANGE ME */
|
|
||||||
var grammar = Foods;
|
|
||||||
|
|
||||||
function updateTranslation () {
|
|
||||||
var input = document.getElementById('inputText').value;
|
|
||||||
var fromLang = document.getElementById('fromLang').value;
|
|
||||||
var toLang = document.getElementById('toLang').value;
|
|
||||||
var output = document.getElementById('output');
|
|
||||||
var translation = grammar.translate(input, fromLang, toLang);
|
|
||||||
removeChildren(output);
|
|
||||||
output.appendChild(formatTranslation(translation));
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateLangs () {
|
|
||||||
var f = document.getElementById('fromLang');
|
|
||||||
var t = document.getElementById('toLang');
|
|
||||||
for (var c in grammar.concretes) {
|
|
||||||
addOption(f, c, c);
|
|
||||||
addOption(t, c, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<title>Web-based GF Translator</title>
|
|
||||||
</head>
|
|
||||||
<body onload="populateLangs(grammar, 'fromLang', 'toLang')">
|
|
||||||
<form id="translate">
|
|
||||||
<p>
|
|
||||||
<input type="text" name="inputText" id="inputText" value="this cheese is warm" size="50" />
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
From: <select name="fromLang" id="fromLang" onchange=""><option value="">Any language</option></select>
|
|
||||||
To: <select name="toLang" id="toLang"><option value="">All languages</option></select>
|
|
||||||
<input type="button" value="Translate" onclick="updateTranslation()" />
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
<div id="output"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
function formatTranslation (outputs) {
|
|
||||||
var dl1 = document.createElement("dl");
|
|
||||||
dl1.className = "fromLang";
|
|
||||||
for (var fromLang in outputs) {
|
|
||||||
var ul = document.createElement("ul");
|
|
||||||
addDefinition(dl1, document.createTextNode(fromLang), ul);
|
|
||||||
for (var i in outputs[fromLang]) {
|
|
||||||
var dl2 = document.createElement("dl");
|
|
||||||
dl2.className = "toLang";
|
|
||||||
for (var toLang in outputs[fromLang][i]) {
|
|
||||||
addDefinition(dl2, document.createTextNode(toLang), document.createTextNode(outputs[fromLang][i][toLang]));
|
|
||||||
}
|
|
||||||
addItem(ul, dl2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dl1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DOM utilities for specific tags */
|
|
||||||
|
|
||||||
function addDefinition (dl, t, d) {
|
|
||||||
var dt = document.createElement("dt");
|
|
||||||
dt.appendChild(t);
|
|
||||||
dl.appendChild(dt);
|
|
||||||
var dd = document.createElement("dd");
|
|
||||||
dd.appendChild(d);
|
|
||||||
dl.appendChild(dd);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addItem (ul, i) {
|
|
||||||
var li = document.createElement("li");
|
|
||||||
li.appendChild(i);
|
|
||||||
ul.appendChild(li);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addOption (select, value, content) {
|
|
||||||
var option = document.createElement("option");
|
|
||||||
option.value = value;
|
|
||||||
option.appendChild(document.createTextNode(content));
|
|
||||||
select.appendChild(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* General DOM utilities */
|
|
||||||
|
|
||||||
/* Removes all the children of a node */
|
|
||||||
function removeChildren(node) {
|
|
||||||
while (node.hasChildNodes()) {
|
|
||||||
node.removeChild(node.firstChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
152
src/runtime/python/README.org
Normal file
152
src/runtime/python/README.org
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
* INSTALL
|
||||||
|
|
||||||
|
You will need the python-devel package or similar.
|
||||||
|
|
||||||
|
You must have installed the PGF C runtime (see ../c/INSTALL)
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
$ python setup.py build
|
||||||
|
$ sudo python setup.py install
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* Apple Silicon
|
||||||
|
|
||||||
|
The following install instructions were written with the following config in mind:
|
||||||
|
|
||||||
|
| OS | Hardware | GF |
|
||||||
|
|-----------------------+----------+--------------------------+
|
||||||
|
| MacOS Monterey 12.2.1 | Apple M1 | 3.11 from binary package |
|
||||||
|
|
||||||
|
We assume that you may have installed GF as a binary package downloaded from Github.
|
||||||
|
|
||||||
|
From that starting point, try all the solutions below, in sequence, until you achieve success.
|
||||||
|
|
||||||
|
** Validation Goal
|
||||||
|
|
||||||
|
Our goal is to be able to
|
||||||
|
- run python 3
|
||||||
|
- import pgf
|
||||||
|
- type "pgf."
|
||||||
|
- hit tab
|
||||||
|
|
||||||
|
and get this:
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
>>> import pgf
|
||||||
|
>>> pgf.
|
||||||
|
pgf.BIND( pgf.Concr( pgf.Iter( pgf.PGFError( pgf.Type( pgf.readExpr( pgf.readType(
|
||||||
|
pgf.Bracket( pgf.Expr( pgf.PGF( pgf.ParseError( pgf.TypeError( pgf.readPGF(
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
When that works, we can consider the Python PGF bindings to be installed successfully.
|
||||||
|
|
||||||
|
** The GF binary package won't install
|
||||||
|
|
||||||
|
We assume you've tried [[https://github.com/GrammaticalFramework/gf-core/releases][downloading a binary package]].
|
||||||
|
|
||||||
|
If MacOS is being secure, go to System Preferences, Security & Privacy, General, and click Open Anyway.
|
||||||
|
|
||||||
|
** gu/mem.h file not found
|
||||||
|
|
||||||
|
Maybe you tried running something like ~pip install pgf~ or ~pip3 install pgf~.
|
||||||
|
|
||||||
|
Did you get this error?
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
python3 setup.py build
|
||||||
|
running build
|
||||||
|
running build_ext
|
||||||
|
creating build/temp.macosx-12-arm64-3.9
|
||||||
|
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c pypgf.c -o build/temp.macosx-12-arm64-3.9/pypgf.o -std=c99
|
||||||
|
pypgf.c:5:10: fatal error: 'gu/mem.h' file not found
|
||||||
|
#include <gu/mem.h>
|
||||||
|
^~~~~~~~~~
|
||||||
|
1 error generated.
|
||||||
|
error: command '/usr/bin/clang' failed with exit code 1
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
Solution:
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
$ EXTRA_INCLUDE_DIRS=/usr/local/include EXTRA_LIB_DIRS=/usr/local/lib pip install pgf
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
This should tell the build where to find the include and lib files it needs to compile:
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
$ ls /usr/local/include/gu
|
||||||
|
assert.h choice.h enum.h file.h hash.h map.h out.h seq.h sysdeps.h utf8.h
|
||||||
|
bits.h defs.h exn.h fun.h in.h mem.h prime.h string.h ucs.h variant.h
|
||||||
|
|
||||||
|
$ ls /usr/local/lib/libgu*
|
||||||
|
/usr/local/lib/libgu.0.dylib /usr/local/lib/libgu.a /usr/local/lib/libgu.dylib /usr/local/lib/libgu.la
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
If those files don't exist, or you get the following error, you will need to rebuild the C runtime.
|
||||||
|
|
||||||
|
** symbol not found in flat namespace
|
||||||
|
|
||||||
|
Did you get this error?
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
Python 3.9.10 (main, Jan 15 2022, 11:40:53)
|
||||||
|
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
|
||||||
|
Type "help", "copyright", "credits" or "license" for more information.
|
||||||
|
>>> import pgf
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "<stdin>", line 1, in <module>
|
||||||
|
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/pgf.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_gu_alloc_variant'
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
This may be a sign that you're trying to get binaries and libraries compiled with different compilers to play nicely. We're trying to get three things to align:
|
||||||
|
|
||||||
|
- the Python interpreter
|
||||||
|
- the C runtime libraries
|
||||||
|
- the Python pgf libraries
|
||||||
|
|
||||||
|
Solution:
|
||||||
|
|
||||||
|
Maybe your Python isn't the Apple-provided Python. In the above error message we see ~python3~ is provided by Homebrew. Assuming you prefer to keep things this way, we'll try to rebuild things to match your Python.
|
||||||
|
|
||||||
|
Rebuilding needs a C compiler. The Apple-provided system ~clang~ is preferred. If you have multiple ~clang~ compilers installed, try disabling the others. For example, if your ~clang~ was provided by nix, run ~nix-env --uninstall clang~. Similarly for brew.
|
||||||
|
|
||||||
|
Then try rebuilding the C runtime.
|
||||||
|
|
||||||
|
** How to re-build the C runtime
|
||||||
|
|
||||||
|
Maybe the C runtime is missing from ~/usr/local/lib~, or maybe the version you have installed is causing the "symbol not found" error.
|
||||||
|
|
||||||
|
Build the C runtime by following the instructions in ~gf-core/src/runtime/c/INSTALL~.
|
||||||
|
|
||||||
|
After a successful ~make install~, rebuild the Python bindings.
|
||||||
|
|
||||||
|
** How to re-build the Python bindings using pip
|
||||||
|
|
||||||
|
Sometimes a ~pip install pgf~ will decline to recompile, because a cached wheel exists.
|
||||||
|
|
||||||
|
To return to a more pristine state,
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
pip uninstall pgf
|
||||||
|
pip cache remove pgf
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
You may need to ~sudo~ some of the above commands.
|
||||||
|
|
||||||
|
Then you can repeat
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
$ EXTRA_INCLUDE_DIRS=/usr/local/include EXTRA_LIB_DIRS=/usr/local/lib pip install pgf
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
** How to re-build the Python bindings manually
|
||||||
|
|
||||||
|
If the ~pip install pgf~ just isn't working, try building it directly in ~gf-core/src/runtime/python~:
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
$ python setup.py build
|
||||||
|
$ sudo python setup.py install
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
You may need to add the ~EXTRA~ environment prefixes as shown in previous commands.
|
||||||
|
|
||||||
@@ -1155,6 +1155,80 @@ Iter_fetch_expr(IterObject* self)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
} BINDObject;
|
||||||
|
|
||||||
|
static PyObject *BIND_instance = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
BIND_dealloc(PyTypeObject *self)
|
||||||
|
{
|
||||||
|
BIND_instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
BIND_repr(BINDObject *self)
|
||||||
|
{
|
||||||
|
return PyString_FromString("pgf.BIND");
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
BIND_str(BINDObject *self)
|
||||||
|
{
|
||||||
|
return PyString_FromString("&+");
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
BIND_alloc(PyTypeObject *self, Py_ssize_t nitems)
|
||||||
|
{
|
||||||
|
if (BIND_instance == NULL)
|
||||||
|
BIND_instance = PyType_GenericAlloc(self, nitems);
|
||||||
|
return BIND_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyTypeObject pgf_BINDType = {
|
||||||
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
|
//0, /*ob_size*/
|
||||||
|
"pgf.BINDType", /*tp_name*/
|
||||||
|
sizeof(BINDObject), /*tp_basicsize*/
|
||||||
|
0, /*tp_itemsize*/
|
||||||
|
(destructor) BIND_dealloc, /*tp_dealloc*/
|
||||||
|
0, /*tp_print*/
|
||||||
|
0, /*tp_getattr*/
|
||||||
|
0, /*tp_setattr*/
|
||||||
|
0, /*tp_compare*/
|
||||||
|
(reprfunc) BIND_repr, /*tp_repr*/
|
||||||
|
0, /*tp_as_number*/
|
||||||
|
0, /*tp_as_sequence*/
|
||||||
|
0, /*tp_as_mapping*/
|
||||||
|
0, /*tp_hash */
|
||||||
|
0, /*tp_call*/
|
||||||
|
(reprfunc) BIND_str, /*tp_str*/
|
||||||
|
0, /*tp_getattro*/
|
||||||
|
0, /*tp_setattro*/
|
||||||
|
0, /*tp_as_buffer*/
|
||||||
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||||
|
"a marker for BIND in a bracketed string", /*tp_doc*/
|
||||||
|
0, /*tp_traverse */
|
||||||
|
0, /*tp_clear */
|
||||||
|
0, /*tp_richcompare */
|
||||||
|
0, /*tp_weaklistoffset */
|
||||||
|
0, /*tp_iter */
|
||||||
|
0, /*tp_iternext */
|
||||||
|
0, /*tp_methods */
|
||||||
|
0, /*tp_members */
|
||||||
|
0, /*tp_getset */
|
||||||
|
0, /*tp_base */
|
||||||
|
0, /*tp_dict */
|
||||||
|
0, /*tp_descr_get */
|
||||||
|
0, /*tp_descr_set */
|
||||||
|
0, /*tp_dictoffset */
|
||||||
|
0, /*tp_init */
|
||||||
|
BIND_alloc, /*tp_alloc */
|
||||||
|
0, /*tp_new */
|
||||||
|
};
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
Iter_fetch_token(IterObject* self)
|
Iter_fetch_token(IterObject* self)
|
||||||
{
|
{
|
||||||
@@ -1162,7 +1236,9 @@ Iter_fetch_token(IterObject* self)
|
|||||||
if (tp == NULL)
|
if (tp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
PyObject* py_tok = PyString_FromString(tp->tok);
|
PyObject* py_tok =
|
||||||
|
(tp->tok != NULL) ? PyString_FromString(tp->tok)
|
||||||
|
: pgf_BINDType.tp_alloc(&pgf_BINDType, 0);
|
||||||
PyObject* py_cat = PyString_FromString(tp->cat);
|
PyObject* py_cat = PyString_FromString(tp->cat);
|
||||||
PyObject* py_fun = PyString_FromString(tp->fun);
|
PyObject* py_fun = PyString_FromString(tp->fun);
|
||||||
PyObject* res = Py_BuildValue("(f,O,O,O)", tp->prob, py_tok, py_cat, py_fun);
|
PyObject* res = Py_BuildValue("(f,O,O,O)", tp->prob, py_tok, py_cat, py_fun);
|
||||||
@@ -1599,16 +1675,18 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds)
|
|||||||
static IterObject*
|
static IterObject*
|
||||||
Concr_complete(ConcrObject* self, PyObject *args, PyObject *keywds)
|
Concr_complete(ConcrObject* self, PyObject *args, PyObject *keywds)
|
||||||
{
|
{
|
||||||
static char *kwlist[] = {"sentence", "cat", "prefix", "n", NULL};
|
static char *kwlist[] = {"sentence", "cat", "prefix", "n", NULL};
|
||||||
|
|
||||||
const char *sentence = NULL;
|
PyObject* sentence0 = NULL;
|
||||||
|
char* sentence = NULL;
|
||||||
PyObject* start = NULL;
|
PyObject* start = NULL;
|
||||||
GuString prefix = "";
|
GuString prefix = "";
|
||||||
int max_count = -1;
|
bool prefix_bind = false;
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|Osi", kwlist,
|
int max_count = -1;
|
||||||
&sentence, &start,
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|Osi", kwlist,
|
||||||
&prefix, &max_count))
|
&sentence0, &start,
|
||||||
return NULL;
|
&prefix, &max_count))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
IterObject* pyres = (IterObject*)
|
IterObject* pyres = (IterObject*)
|
||||||
pgf_IterType.tp_alloc(&pgf_IterType, 0);
|
pgf_IterType.tp_alloc(&pgf_IterType, 0);
|
||||||
@@ -1630,6 +1708,20 @@ Concr_complete(ConcrObject* self, PyObject *args, PyObject *keywds)
|
|||||||
|
|
||||||
GuExn* parse_err = gu_new_exn(tmp_pool);
|
GuExn* parse_err = gu_new_exn(tmp_pool);
|
||||||
|
|
||||||
|
if (PyTuple_Check(sentence0) &&
|
||||||
|
PyTuple_GET_SIZE(sentence0) == 2 &&
|
||||||
|
PyTuple_GET_ITEM(sentence0,1) == pgf_BINDType.tp_alloc(&pgf_BINDType, 0))
|
||||||
|
{
|
||||||
|
sentence0 = PyTuple_GET_ITEM(sentence0,0);
|
||||||
|
prefix_bind = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PyUnicode_Check(sentence0)) {
|
||||||
|
sentence = PyUnicode_AsUTF8(sentence0);
|
||||||
|
} else {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "The sentence must be either a string or a tuple of string and pgf.BIND");
|
||||||
|
}
|
||||||
|
|
||||||
PgfType* type;
|
PgfType* type;
|
||||||
if (start == NULL) {
|
if (start == NULL) {
|
||||||
type = pgf_start_cat(self->grammar->pgf, pyres->pool);
|
type = pgf_start_cat(self->grammar->pgf, pyres->pool);
|
||||||
@@ -1642,7 +1734,7 @@ Concr_complete(ConcrObject* self, PyObject *args, PyObject *keywds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pyres->res =
|
pyres->res =
|
||||||
pgf_complete(self->concr, type, sentence, prefix, parse_err, pyres->pool);
|
pgf_complete(self->concr, type, sentence, prefix, prefix_bind, parse_err, pyres->pool);
|
||||||
|
|
||||||
if (!gu_ok(parse_err)) {
|
if (!gu_ok(parse_err)) {
|
||||||
Py_DECREF(pyres);
|
Py_DECREF(pyres);
|
||||||
@@ -2077,58 +2169,6 @@ static PyTypeObject pgf_BracketType = {
|
|||||||
0, /*tp_new */
|
0, /*tp_new */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PyObject_HEAD
|
|
||||||
} BINDObject;
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
BIND_repr(BINDObject *self)
|
|
||||||
{
|
|
||||||
return PyString_FromString("&+");
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyTypeObject pgf_BINDType = {
|
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
|
||||||
//0, /*ob_size*/
|
|
||||||
"pgf.BIND", /*tp_name*/
|
|
||||||
sizeof(BINDObject), /*tp_basicsize*/
|
|
||||||
0, /*tp_itemsize*/
|
|
||||||
0, /*tp_dealloc*/
|
|
||||||
0, /*tp_print*/
|
|
||||||
0, /*tp_getattr*/
|
|
||||||
0, /*tp_setattr*/
|
|
||||||
0, /*tp_compare*/
|
|
||||||
0, /*tp_repr*/
|
|
||||||
0, /*tp_as_number*/
|
|
||||||
0, /*tp_as_sequence*/
|
|
||||||
0, /*tp_as_mapping*/
|
|
||||||
0, /*tp_hash */
|
|
||||||
0, /*tp_call*/
|
|
||||||
(reprfunc) BIND_repr, /*tp_str*/
|
|
||||||
0, /*tp_getattro*/
|
|
||||||
0, /*tp_setattro*/
|
|
||||||
0, /*tp_as_buffer*/
|
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
||||||
"a marker for BIND in a bracketed string", /*tp_doc*/
|
|
||||||
0, /*tp_traverse */
|
|
||||||
0, /*tp_clear */
|
|
||||||
0, /*tp_richcompare */
|
|
||||||
0, /*tp_weaklistoffset */
|
|
||||||
0, /*tp_iter */
|
|
||||||
0, /*tp_iternext */
|
|
||||||
0, /*tp_methods */
|
|
||||||
0, /*tp_members */
|
|
||||||
0, /*tp_getset */
|
|
||||||
0, /*tp_base */
|
|
||||||
0, /*tp_dict */
|
|
||||||
0, /*tp_descr_get */
|
|
||||||
0, /*tp_descr_set */
|
|
||||||
0, /*tp_dictoffset */
|
|
||||||
0, /*tp_init */
|
|
||||||
0, /*tp_alloc */
|
|
||||||
0, /*tp_new */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PgfLinFuncs* funcs;
|
PgfLinFuncs* funcs;
|
||||||
GuBuf* stack;
|
GuBuf* stack;
|
||||||
@@ -2726,6 +2766,11 @@ static PyMethodDef Concr_methods[] = {
|
|||||||
},
|
},
|
||||||
{"complete", (PyCFunction)Concr_complete, METH_VARARGS | METH_KEYWORDS,
|
{"complete", (PyCFunction)Concr_complete, METH_VARARGS | METH_KEYWORDS,
|
||||||
"Parses a partial string and returns a list with the top n possible next tokens"
|
"Parses a partial string and returns a list with the top n possible next tokens"
|
||||||
|
"Named arguments:\n"
|
||||||
|
"- sentence (string or a (string,pgf.BIND) tuple. The later indicates that the sentence ends with a BIND token)\n"
|
||||||
|
"- cat (string); OPTIONAL, default: the startcat of the grammar\n"
|
||||||
|
"- prefix (string); OPTIONAL, the prefix of predicted tokens"
|
||||||
|
"- n (int), max. number of predicted tokens"
|
||||||
},
|
},
|
||||||
{"parseval", (PyCFunction)Concr_parseval, METH_VARARGS,
|
{"parseval", (PyCFunction)Concr_parseval, METH_VARARGS,
|
||||||
"Computes precision, recall and exact match for the parser on a given abstract tree"
|
"Computes precision, recall and exact match for the parser on a given abstract tree"
|
||||||
@@ -3670,7 +3715,7 @@ MOD_INIT(pgf)
|
|||||||
PyModule_AddObject(m, "Bracket", (PyObject *) &pgf_BracketType);
|
PyModule_AddObject(m, "Bracket", (PyObject *) &pgf_BracketType);
|
||||||
Py_INCREF(&pgf_BracketType);
|
Py_INCREF(&pgf_BracketType);
|
||||||
|
|
||||||
PyModule_AddObject(m, "BIND", (PyObject *) &pgf_BINDType);
|
PyModule_AddObject(m, "BIND", pgf_BINDType.tp_alloc(&pgf_BINDType, 0));
|
||||||
Py_INCREF(&pgf_BINDType);
|
Py_INCREF(&pgf_BINDType);
|
||||||
|
|
||||||
return MOD_SUCCESS_VAL(m);
|
return MOD_SUCCESS_VAL(m);
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
# Project moved
|
|
||||||
|
|
||||||
The GF TypeScript runtime has been moved to the repository:
|
|
||||||
<https://github.com/GrammaticalFramework/gf-typescript>
|
|
||||||
|
|
||||||
If you are looking for an updated version of the JavaScript runtime,
|
|
||||||
you should also look there.
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
(bilingual document editor)
|
(bilingual document editor)
|
||||||
<!--<li><a href="wc.html">Wide Coverage Translation Demo</a>-->
|
<!--<li><a href="wc.html">Wide Coverage Translation Demo</a>-->
|
||||||
<li><a href="gfmorpho/">Word inflection with smart paradigms</a>
|
<li><a href="gfmorpho/">Word inflection with smart paradigms</a>
|
||||||
<li><a href="https://cloud.grammaticalframework.org/wordnet">GF WordNet</a> (an online browser and editor for the WordNet lexicon)</li>
|
<li><a href="wordnet/">GF WordNet</a> (an online browser and editor for the WordNet lexicon)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>Documentation</h2>
|
<h2>Documentation</h2>
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
resolver: lts-18.0 # ghc 8.10.4
|
|
||||||
|
|
||||||
extra-deps:
|
|
||||||
- network-2.6.3.6
|
|
||||||
- httpd-shed-0.4.0.3
|
|
||||||
- cgi-3001.5.0.0@sha256:3d1193a328d5f627a021a0ef3927c1ae41dd341e32dba612fed52d0e3a6df056,2990
|
|
||||||
- json-0.10@sha256:d9fc6b07ce92b8894825a17d2cf14799856767eb30c8bf55962baa579207d799,3210
|
|
||||||
- multipart-0.2.0@sha256:b8770e3ff6089be4dd089a8250894b31287cca671f3d258190a505f9351fa8a9,1084
|
|
||||||
|
|
||||||
# flags:
|
|
||||||
# gf:
|
|
||||||
# c-runtime: true
|
|
||||||
# extra-lib-dirs:
|
|
||||||
# - /usr/local/lib
|
|
||||||
12
stack-ghc8.10.7.yaml
Normal file
12
stack-ghc8.10.7.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
resolver: lts-18.27 # ghc 8.10.7
|
||||||
|
|
||||||
|
extra-deps:
|
||||||
|
- network-2.6.3.6
|
||||||
|
- httpd-shed-0.4.0.3
|
||||||
|
|
||||||
|
# flags:
|
||||||
|
# gf:
|
||||||
|
# server: true
|
||||||
|
# c-runtime: true
|
||||||
|
# extra-lib-dirs:
|
||||||
|
# - /usr/local/lib
|
||||||
14
stack-ghc9.0.2.yaml
Normal file
14
stack-ghc9.0.2.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
resolver: lts-19.6
|
||||||
|
|
||||||
|
extra-deps:
|
||||||
|
# - network-2.6.3.6
|
||||||
|
# - httpd-shed-0.4.0.3
|
||||||
|
# - cgi-3001.5.0.0@sha256:3d1193a328d5f627a021a0ef3927c1ae41dd341e32dba612fed52d0e3a6df056,2990
|
||||||
|
# - json-0.10@sha256:d9fc6b07ce92b8894825a17d2cf14799856767eb30c8bf55962baa579207d799,3210
|
||||||
|
# - multipart-0.2.0@sha256:b8770e3ff6089be4dd089a8250894b31287cca671f3d258190a505f9351fa8a9,1084
|
||||||
|
|
||||||
|
# flags:
|
||||||
|
# gf:
|
||||||
|
# c-runtime: true
|
||||||
|
# extra-lib-dirs:
|
||||||
|
# - /usr/local/lib
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
# This default stack file is a copy of stack-ghc8.10.4.yaml
|
# This default stack file is a copy of stack-ghc8.10.7.yaml
|
||||||
# But committing a symlink can be problematic on Windows, so it's a real copy.
|
# But committing a symlink can be problematic on Windows, so it's a real copy.
|
||||||
# See: https://github.com/GrammaticalFramework/gf-core/pull/106
|
# See: https://github.com/GrammaticalFramework/gf-core/pull/106
|
||||||
|
resolver: lts-18.27 # ghc 8.10.7
|
||||||
resolver: lts-18.0 # ghc 8.10.4
|
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- network-2.6.3.6
|
- network-2.6.3.6
|
||||||
- httpd-shed-0.4.0.3
|
- httpd-shed-0.4.0.3
|
||||||
- cgi-3001.5.0.0@sha256:3d1193a328d5f627a021a0ef3927c1ae41dd341e32dba612fed52d0e3a6df056,2990
|
|
||||||
- json-0.10@sha256:d9fc6b07ce92b8894825a17d2cf14799856767eb30c8bf55962baa579207d799,3210
|
|
||||||
- multipart-0.2.0@sha256:b8770e3ff6089be4dd089a8250894b31287cca671f3d258190a505f9351fa8a9,1084
|
|
||||||
|
|
||||||
# flags:
|
# flags:
|
||||||
# gf:
|
# gf:
|
||||||
|
# server: true
|
||||||
# c-runtime: true
|
# c-runtime: true
|
||||||
# extra-lib-dirs:
|
# extra-lib-dirs:
|
||||||
# - /usr/local/lib
|
# - /usr/local/lib
|
||||||
|
|||||||
@@ -1,2 +1,12 @@
|
|||||||
i -retain testsuite/compiler/compute/Variants.gf
|
i -retain testsuite/compiler/compute/Variants.gf
|
||||||
cc hello
|
cc hello
|
||||||
|
cc <\x -> x++x : Str -> Str> ("a"|"b")
|
||||||
|
cc <\x -> x : Str -> Str> ("a"|"b")
|
||||||
|
cc <\x -> "c" : Str -> Str> ("a"|"b")
|
||||||
|
cc <let x = ("a"|"b") in x++x : Str>
|
||||||
|
cc <let x = ("a"|"b") in x : Str>
|
||||||
|
cc <let x = ("a"|"b") in "c" : Str>
|
||||||
|
cc <\x -> x.p1++x.p1 : Str*Str -> Str> <"a"|"b","c">
|
||||||
|
cc <\x -> x.p1 : Str*Str -> Str> <"a"|"b","c">
|
||||||
|
cc <\x -> x.p2++x.p2 : Str*Str -> Str> <"a"|"b","c">
|
||||||
|
cc <\x -> x.p2 : Str*Str -> Str> <"a"|"b","c">
|
||||||
|
|||||||
@@ -1 +1,11 @@
|
|||||||
variants {"hello"; "hello" ++ "hello"}
|
variants {"hello"; "hello" ++ "hello"}
|
||||||
|
variants {"a" ++ "a"; "b" ++ "b"}
|
||||||
|
variants {"a"; "b"}
|
||||||
|
"c"
|
||||||
|
variants {"a"; "b"} ++ variants {"a"; "b"}
|
||||||
|
variants {"a"; "b"}
|
||||||
|
"c"
|
||||||
|
variants {"a"; "b"} ++ variants {"a"; "b"}
|
||||||
|
variants {"a"; "b"}
|
||||||
|
"c" ++ "c"
|
||||||
|
"c"
|
||||||
|
|||||||
Reference in New Issue
Block a user