forked from GitHub/gf-core
Merge branch 'master' of https://github.com/GrammaticalFramework/gf-core
This commit is contained in:
4
debian/rules
vendored
4
debian/rules
vendored
@@ -26,8 +26,8 @@ override_dh_auto_build:
|
||||
cd src/runtime/python && EXTRA_INCLUDE_DIRS=$(CURDIR)/src/runtime/c EXTRA_LIB_DIRS=$(CURDIR)/src/runtime/c/.libs python setup.py build
|
||||
cd src/runtime/java && make CFLAGS="-I$(CURDIR)/src/runtime/c -L$(CURDIR)/src/runtime/c/.libs" INSTALL_PATH=/usr/lib
|
||||
echo $(SET_LDL)
|
||||
$(SET_LDL) cabal build # builds gf, fails to build example grammars
|
||||
PATH=$(CURDIR)/dist/build/gf:$$PATH && make -C ../gf-rgl build
|
||||
-$(SET_LDL) cabal build # builds gf, fails to build example grammars
|
||||
export $(SET_LDL); PATH=$(CURDIR)/dist/build/gf:$$PATH && make -C ../gf-rgl build
|
||||
GF_LIB_PATH=$(CURDIR)/../gf-rgl/dist $(SET_LDL) cabal build # have RGL now, ok to build example grammars
|
||||
make html
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ These binary packages include both the GF core (compiler and runtime) as well as
|
||||
| Platform | Download | Features | How to install |
|
||||
|:----------------|:---------------------------------------------------|:---------------|:-----------------------------------|
|
||||
| macOS | [gf-3.10.pkg](gf-3.10.pkg) | GF, S, C, J, P | Double-click on the package icon |
|
||||
| Raspbian 10 (buster) | [gf\_3.10-2\_armhf.deb](gf_3.10-2_armhf.deb) | GF,S,C,J,P | `sudo dpkg -i gf_3.10-2_armhf.deb` |
|
||||
| Ubuntu (32-bit) | [gf\_3.10-2\_i386.deb](gf_3.10-2_i386.deb) | GF, S, C, J, P | `sudo dpkg -i gf_3.10-2_i386.deb` |
|
||||
| Ubuntu (64-bit) | [gf\_3.10-2\_amd64.deb](gf_3.10-2_amd64.deb) | GF, S, C, J, P | `sudo dpkg -i gf_3.10-2_amd64.deb` |
|
||||
| Windows | [gf-3.10-bin-windows.zip](gf-3.10-bin-windows.zip) | GF, S | `unzip gf-3.10-bin-windows.zip` |
|
||||
|
||||
<!--
|
||||
| macOS | [gf-3.10-bin-intel-mac.tar.gz](gf-3.10-bin-intel-mac.tar.gz) | GF,S,C,J,P | `sudo tar -C /usr/local -zxf gf-3.10-bin-intel-mac.tar.gz` |
|
||||
| Raspbian 9.1 | [gf\_3.10-1\_armhf.deb](gf_3.10-1_armhf.deb) | GF,S,C,J,P | `sudo dpkg -i gf_3.10-1_armhf.deb` |
|
||||
-->
|
||||
|
||||
**Features**
|
||||
|
||||
1
gf.cabal
1
gf.cabal
@@ -194,6 +194,7 @@ Library
|
||||
GF.Compile.GrammarToCanonical
|
||||
GF.Grammar.CanonicalJSON
|
||||
GF.Compile.PGFtoJS
|
||||
GF.Compile.PGFtoJSON
|
||||
GF.Compile.PGFtoProlog
|
||||
GF.Compile.PGFtoPython
|
||||
GF.Compile.ReadFiles
|
||||
|
||||
24
index.html
24
index.html
@@ -29,9 +29,9 @@
|
||||
<ul class="mb-2">
|
||||
<li><a href="https://www.youtube.com/watch?v=x1LFbDQhbso">Google Tech Talk</a></li>
|
||||
<li>
|
||||
<a href="http://cloud.grammaticalframework.org/">
|
||||
<a href="//cloud.grammaticalframework.org/">
|
||||
GF Cloud
|
||||
<img src="http://www.grammaticalframework.org/src/www/P/gf-cloud.png" style="height:30px" class="ml-2" alt="Cloud logo">
|
||||
<img src="src/www/P/gf-cloud.png" style="height:30px" class="ml-2" alt="Cloud logo">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -83,7 +83,7 @@
|
||||
<li><a href="http://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="doc/gf-people.html">Authors</a></li>
|
||||
<li><a href="http://school.grammaticalframework.org/2018/">Summer School</a></li>
|
||||
<li><a href="//school.grammaticalframework.org/2018/">Summer School</a></li>
|
||||
</ul>
|
||||
<a href="https://github.com/GrammaticalFramework/" class="btn btn-primary ml-3">
|
||||
<i class="fab fa-github mr-1"></i>
|
||||
@@ -152,9 +152,9 @@ least one, it may help you to get a first idea of what GF is.
|
||||
<h2>Applications & Availability</h2>
|
||||
<p>
|
||||
GF can be used for building
|
||||
<a href="http://cloud.grammaticalframework.org/translator/">translation systems</a>,
|
||||
<a href="http://cloud.grammaticalframework.org/minibar/minibar.html">multilingual web gadgets</a>,
|
||||
<a href="http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">natural-language interfaces</a>,
|
||||
<a href="//cloud.grammaticalframework.org/translator/">translation systems</a>,
|
||||
<a href="//cloud.grammaticalframework.org/minibar/minibar.html">multilingual web gadgets</a>,
|
||||
<a href="http://www.cse.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">natural-language interfaces</a>,
|
||||
<a href="http://www.youtube.com/watch?v=1bfaYHWS6zU">dialogue systems</a>, and
|
||||
<a href="lib/doc/synopsis/index.html">natural language resources</a>.
|
||||
</p>
|
||||
@@ -210,7 +210,7 @@ least one, it may help you to get a first idea of what GF is.
|
||||
<p>
|
||||
We run the IRC channel <strong><code>#gf</code></strong> on the Freenode network, where you are welcome to look for help with small questions or just start a general discussion.
|
||||
You can <a href="https://webchat.freenode.net/?channels=gf">open a web chat</a>
|
||||
or <a href="http://www.grammaticalframework.org/irc/">browse the channel logs</a>.
|
||||
or <a href="/irc/">browse the channel logs</a>.
|
||||
</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>.
|
||||
@@ -224,7 +224,7 @@ least one, it may help you to get a first idea of what GF is.
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3 text-center text-nowrap">2018-12-03</dt>
|
||||
<dd class="col-sm-9">
|
||||
<a href="http://school.grammaticalframework.org/2018/">Sixth GF Summer School</a> in Stellenbosch (South Africa), 3–14 December 2018
|
||||
<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">
|
||||
@@ -248,7 +248,7 @@ least one, it may help you to get a first idea of what GF is.
|
||||
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="http://school.grammaticalframework.org/2017/">GF Summer School</a> in Riga (Latvia), 14-25 August 2017
|
||||
<a href="//school.grammaticalframework.org/2017/">GF Summer School</a> in Riga (Latvia), 14-25 August 2017
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@@ -268,7 +268,7 @@ least one, it may help you to get a first idea of what GF is.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">GF-Alfa</a>:
|
||||
<a href="http://www.cse.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">GF-Alfa</a>:
|
||||
natural language interface to formal proofs
|
||||
</li>
|
||||
<li>
|
||||
@@ -293,11 +293,11 @@ least one, it may help you to get a first idea of what GF is.
|
||||
<a href="http://www.cse.chalmers.se/alumni/markus/FM/">Functional Morphology</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.molto-project.eu">MOLTO</a>:
|
||||
<a href="//www.molto-project.eu">MOLTO</a>:
|
||||
multilingual online translation
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://remu.grammaticalframework.org">REMU</a>:
|
||||
<a href="//remu.grammaticalframework.org">REMU</a>:
|
||||
reliable multilingual digital communication
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -7,6 +7,7 @@ import GF.Compile.PGFtoHaskell
|
||||
import GF.Compile.PGFtoJava
|
||||
import GF.Compile.PGFtoProlog
|
||||
import GF.Compile.PGFtoJS
|
||||
import GF.Compile.PGFtoJSON
|
||||
import GF.Compile.PGFtoPython
|
||||
import GF.Infra.Option
|
||||
--import GF.Speech.CFG
|
||||
@@ -38,6 +39,7 @@ exportPGF opts fmt pgf =
|
||||
FmtCanonicalGF -> [] -- canon "gf" (render80 . abstract2canonical)
|
||||
FmtCanonicalJson-> []
|
||||
FmtJavaScript -> multi "js" pgf2js
|
||||
FmtJSON -> multi "json" pgf2json
|
||||
FmtPython -> multi "py" pgf2python
|
||||
FmtHaskell -> multi "hs" (grammar2haskell opts name)
|
||||
FmtJava -> multi "java" (grammar2java opts name)
|
||||
|
||||
156
src/compiler/GF/Compile/PGFtoJSON.hs
Normal file
156
src/compiler/GF/Compile/PGFtoJSON.hs
Normal file
@@ -0,0 +1,156 @@
|
||||
module GF.Compile.PGFtoJSON (pgf2json) where
|
||||
|
||||
import PGF (showCId)
|
||||
import qualified PGF.Internal as M
|
||||
import PGF.Internal (
|
||||
Abstr,
|
||||
CId,
|
||||
CncCat(..),
|
||||
CncFun(..),
|
||||
Concr,
|
||||
DotPos,
|
||||
Equation(..),
|
||||
Literal(..),
|
||||
PArg(..),
|
||||
PGF,
|
||||
Production(..),
|
||||
Symbol(..),
|
||||
Type,
|
||||
absname,
|
||||
abstract,
|
||||
cflags,
|
||||
cnccats,
|
||||
cncfuns,
|
||||
concretes,
|
||||
funs,
|
||||
productions,
|
||||
sequences,
|
||||
totalCats
|
||||
)
|
||||
|
||||
import qualified Text.JSON as JSON
|
||||
import Text.JSON (JSValue(..))
|
||||
|
||||
import qualified Data.Array.IArray as Array
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.IntMap as IntMap
|
||||
|
||||
pgf2json :: PGF -> String
|
||||
pgf2json pgf =
|
||||
JSON.encode $ JSON.makeObj
|
||||
[ ("abstract", json_abstract)
|
||||
, ("concretes", json_concretes)
|
||||
]
|
||||
where
|
||||
n = showCId $ absname pgf
|
||||
as = abstract pgf
|
||||
cs = Map.assocs (concretes pgf)
|
||||
start = showCId $ M.lookStartCat pgf
|
||||
json_abstract = abstract2json n start as
|
||||
json_concretes = JSON.makeObj $ map concrete2json cs
|
||||
|
||||
abstract2json :: String -> String -> Abstr -> JSValue
|
||||
abstract2json name start ds =
|
||||
JSON.makeObj
|
||||
[ ("name", mkJSStr name)
|
||||
, ("startcat", mkJSStr start)
|
||||
, ("funs", JSON.makeObj $ map absdef2json (Map.assocs (funs ds)))
|
||||
]
|
||||
|
||||
absdef2json :: (CId,(Type,Int,Maybe ([Equation],[[M.Instr]]),Double)) -> (String,JSValue)
|
||||
absdef2json (f,(typ,_,_,_)) = (showCId f,sig)
|
||||
where
|
||||
(args,cat) = M.catSkeleton typ
|
||||
sig = JSON.makeObj
|
||||
[ ("args", JSArray $ map (mkJSStr.showCId) args)
|
||||
, ("cat", mkJSStr $ showCId cat)
|
||||
]
|
||||
|
||||
lit2json :: Literal -> JSValue
|
||||
lit2json (LStr s) = mkJSStr s
|
||||
lit2json (LInt n) = mkJSInt n
|
||||
lit2json (LFlt d) = JSRational True (toRational d)
|
||||
|
||||
concrete2json :: (CId,Concr) -> (String,JSValue)
|
||||
concrete2json (c,cnc) = (showCId c,obj)
|
||||
where
|
||||
obj = JSON.makeObj
|
||||
[ ("flags", JSON.makeObj [ (showCId k, lit2json v) | (k,v) <- Map.toList (cflags cnc) ])
|
||||
, ("productions", JSON.makeObj [ (show cat, JSArray (map frule2json (Set.toList set))) | (cat,set) <- IntMap.toList (productions cnc)])
|
||||
, ("functions", JSArray (map ffun2json (Array.elems (cncfuns cnc))))
|
||||
, ("sequences", JSArray (map seq2json (Array.elems (sequences cnc))))
|
||||
, ("categories", JSON.makeObj $ map cats2json (Map.assocs (cnccats cnc)))
|
||||
, ("totalfids", mkJSInt (totalCats cnc))
|
||||
]
|
||||
|
||||
cats2json :: (CId, CncCat) -> (String,JSValue)
|
||||
cats2json (c,CncCat start end _) = (showCId c, ixs)
|
||||
where
|
||||
ixs = JSON.makeObj
|
||||
[ ("start", mkJSInt start)
|
||||
, ("end", mkJSInt end)
|
||||
]
|
||||
|
||||
frule2json :: Production -> JSValue
|
||||
frule2json (PApply fid args) =
|
||||
JSON.makeObj
|
||||
[ ("type", mkJSStr "Apply")
|
||||
, ("fid", mkJSInt fid)
|
||||
, ("args", JSArray (map farg2json args))
|
||||
]
|
||||
frule2json (PCoerce arg) =
|
||||
JSON.makeObj
|
||||
[ ("type", mkJSStr "Coerce")
|
||||
, ("arg", mkJSInt arg)
|
||||
]
|
||||
|
||||
farg2json :: PArg -> JSValue
|
||||
farg2json (PArg hypos fid) =
|
||||
JSON.makeObj
|
||||
[ ("type", mkJSStr "PArg")
|
||||
, ("hypos", JSArray $ map (mkJSInt . snd) hypos)
|
||||
, ("fid", mkJSInt fid)
|
||||
]
|
||||
|
||||
ffun2json :: CncFun -> JSValue
|
||||
ffun2json (CncFun f lins) =
|
||||
JSON.makeObj
|
||||
[ ("name", mkJSStr $ showCId f)
|
||||
, ("lins", JSArray (map mkJSInt (Array.elems lins)))
|
||||
]
|
||||
|
||||
seq2json :: Array.Array DotPos Symbol -> JSValue
|
||||
seq2json seq = JSArray [sym2json s | s <- Array.elems seq]
|
||||
|
||||
sym2json :: Symbol -> JSValue
|
||||
sym2json (SymCat n l) = new "SymCat" [mkJSInt n, mkJSInt l]
|
||||
sym2json (SymLit n l) = new "SymLit" [mkJSInt n, mkJSInt l]
|
||||
sym2json (SymVar n l) = new "SymVar" [mkJSInt n, mkJSInt l]
|
||||
sym2json (SymKS t) = new "SymKS" [mkJSStr t]
|
||||
sym2json (SymKP ts alts) = new "SymKP" [JSArray (map sym2json ts), JSArray (map alt2json alts)]
|
||||
sym2json SymBIND = new "SymKS" [mkJSStr "&+"]
|
||||
sym2json SymSOFT_BIND = new "SymKS" [mkJSStr "&+"]
|
||||
sym2json SymSOFT_SPACE = new "SymKS" [mkJSStr "&+"]
|
||||
sym2json SymCAPIT = new "SymKS" [mkJSStr "&|"]
|
||||
sym2json SymALL_CAPIT = new "SymKS" [mkJSStr "&|"]
|
||||
sym2json SymNE = new "SymNE" []
|
||||
|
||||
alt2json :: ([Symbol],[String]) -> JSValue
|
||||
alt2json (ps,ts) = new "Alt" [JSArray (map sym2json ps), JSArray (map mkJSStr ts)]
|
||||
|
||||
new :: String -> [JSValue] -> JSValue
|
||||
new f xs =
|
||||
JSON.makeObj
|
||||
[ ("type", mkJSStr f)
|
||||
, ("args", JSArray xs)
|
||||
]
|
||||
|
||||
-- | Make JSON value from string
|
||||
mkJSStr :: String -> JSValue
|
||||
mkJSStr = JSString . JSON.toJSString
|
||||
|
||||
-- | Make JSON value from integer
|
||||
mkJSInt :: Integral a => a -> JSValue
|
||||
mkJSInt = JSRational False . toRational
|
||||
232
src/compiler/GF/Compile/pgf.schema.json
Normal file
232
src/compiler/GF/Compile/pgf.schema.json
Normal file
@@ -0,0 +1,232 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://grammaticalframework.org/pgf.schema.json",
|
||||
"type": "object",
|
||||
"title": "PGF JSON Schema",
|
||||
"required": [
|
||||
"abstract",
|
||||
"concretes"
|
||||
],
|
||||
"properties": {
|
||||
"abstract": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"startcat",
|
||||
"funs"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"startcat": {
|
||||
"type": "string"
|
||||
},
|
||||
"funs": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"args",
|
||||
"cat"
|
||||
],
|
||||
"properties": {
|
||||
"args": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"cat": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"concretes": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"required": [
|
||||
"flags",
|
||||
"productions",
|
||||
"functions",
|
||||
"sequences",
|
||||
"categories",
|
||||
"totalfids"
|
||||
],
|
||||
"properties": {
|
||||
"flags": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": ["string", "number"]
|
||||
}
|
||||
},
|
||||
"productions": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/apply"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/coerce"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"functions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"title": "CncFun",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"lins": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sequences": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/sym"
|
||||
}
|
||||
}
|
||||
},
|
||||
"categories": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"title": "CncCat",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"start",
|
||||
"end"
|
||||
],
|
||||
"properties": {
|
||||
"start": {
|
||||
"type": "integer"
|
||||
},
|
||||
"end": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"totalfids": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"apply": {
|
||||
"required": [
|
||||
"type",
|
||||
"fid",
|
||||
"args"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["Apply"]
|
||||
},
|
||||
"fid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"args": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/parg"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"coerce": {
|
||||
"required": [
|
||||
"type",
|
||||
"arg"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["Coerce"]
|
||||
},
|
||||
"arg": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parg": {
|
||||
"required": [
|
||||
"type",
|
||||
"hypos",
|
||||
"fid"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["PArg"]
|
||||
},
|
||||
"hypos": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"fid": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sym": {
|
||||
"title": "Sym",
|
||||
"required": [
|
||||
"type",
|
||||
"args"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"SymCat",
|
||||
"SymLit",
|
||||
"SymVar",
|
||||
"SymKS",
|
||||
"SymKP",
|
||||
"SymNE"
|
||||
]
|
||||
},
|
||||
"args": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/sym"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ data OutputFormat = FmtPGFPretty
|
||||
| FmtCanonicalGF
|
||||
| FmtCanonicalJson
|
||||
| FmtJavaScript
|
||||
| FmtJSON
|
||||
| FmtPython
|
||||
| FmtHaskell
|
||||
| FmtJava
|
||||
@@ -328,7 +329,7 @@ optDescr =
|
||||
Option ['f'] ["output-format"] (ReqArg outFmt "FMT")
|
||||
(unlines ["Output format. FMT can be one of:",
|
||||
"Canonical GF grammar: canonical_gf, canonical_json, (and haskell with option --haskell=concrete)",
|
||||
"Multiple concrete: pgf (default), js, pgf_pretty, prolog, python, ...", -- gar,
|
||||
"Multiple concrete: pgf (default), json, js, pgf_pretty, prolog, python, ...", -- gar,
|
||||
"Single concrete only: bnf, ebnf, fa, gsl, jsgf, regexp, slf, srgs_xml, srgs_abnf, vxml, ....", -- cf, lbnf,
|
||||
"Abstract only: haskell, ..."]), -- prolog_abs,
|
||||
Option [] ["sisr"] (ReqArg sisrFmt "FMT")
|
||||
@@ -474,6 +475,7 @@ outputFormatsExpl =
|
||||
(("canonical_gf", FmtCanonicalGF),"Canonical GF source files"),
|
||||
(("canonical_json", FmtCanonicalJson),"Canonical JSON source files"),
|
||||
(("js", FmtJavaScript),"JavaScript (whole grammar)"),
|
||||
(("json", FmtJSON),"JSON (whole grammar)"),
|
||||
(("python", FmtPython),"Python (whole grammar)"),
|
||||
(("haskell", FmtHaskell),"Haskell (abstract syntax)"),
|
||||
(("java", FmtJava),"Java (abstract syntax)"),
|
||||
|
||||
@@ -168,8 +168,6 @@ languages p =
|
||||
concr <- fmap (\ptr -> Concr ptr (touchPGF p)) $ peek (castPtr value)
|
||||
writeIORef ref $! Map.insert name concr langs
|
||||
|
||||
-- | The abstract language name is the name of the top-level
|
||||
-- abstract module
|
||||
concreteName :: Concr -> ConcName
|
||||
concreteName c = unsafePerformIO (peekUtf8CString =<< pgf_concrete_name (concr c))
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# Deprecation notice
|
||||
|
||||
As of June 2019, this JavaScript version of the GF runtime is considered deprecated,
|
||||
in favour of the TypeScript version in `../typescript/gflib.ts`.
|
||||
|
||||
If you don't want/need TypeScript and are just looking for a ready-to-use JavaScript version,
|
||||
see `../typescript/js/gflib.js` which is generated directly from the TypeScript version.
|
||||
in favour of the TypeScript version in <https://github.com/GrammaticalFramework/gf-typescript>.
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": ["plugin:@typescript-eslint/recommended"],
|
||||
"rules": {
|
||||
"indent": "off",
|
||||
"@typescript-eslint/indent": ["warn", 2],
|
||||
"@typescript-eslint/no-use-before-define": ["error", {
|
||||
"functions": false,
|
||||
"classes": false
|
||||
}],
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["warn", "never"],
|
||||
"quotes": ["warn", "single"],
|
||||
"@typescript-eslint/camelcase": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
|
||||
}
|
||||
}
|
||||
7
src/runtime/typescript/MOVED.md
Normal file
7
src/runtime/typescript/MOVED.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# 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.
|
||||
@@ -1,31 +0,0 @@
|
||||
# GF TypeScript Runtime
|
||||
|
||||
`gflib.ts` is a TypeScript implementation of the GF runtime.
|
||||
It is ported from an older JavaScript implementation [`gflib.js`](../javascript/gflib.js),
|
||||
with some improvements.
|
||||
|
||||
Importantly, all **future** updates will only be made to this TypeScript version.
|
||||
|
||||
## Applicability
|
||||
|
||||
This runtime allows you use GF in pure JavaScript, and thus have GF-powered apps without the need for a server backend.
|
||||
However, it has not been actively maintained as the other runtimes have been.
|
||||
So its features are limited and it is not efficient, making it really only useful for smaller grammars.
|
||||
|
||||
## Using
|
||||
|
||||
`gflib.ts` can be transpiled to JavaScript by running `tsc` in this folder (of course you need TypeScript installed).
|
||||
It has no module dependencies.
|
||||
You can then include the generated `js/gflib.js` file in your application as usual.
|
||||
|
||||
_This generated JavaScript version is also included under version control,
|
||||
to make it easy for someone to use without having to install TypeScript._
|
||||
|
||||
Your GF grammar should be compiled with: `gf --make --output-format=js`
|
||||
|
||||
For an example of a working web application using the JavaScript runtime, see `../javascript`.
|
||||
|
||||
## What happened to `gflib.d.ts`?
|
||||
|
||||
There was once a file here called `gflib.d.ts`, which contained TypeScript type definitions for the **old** `gflib.js`.
|
||||
Since the runtime is now ported to TypeScript, those type definitions are no longer necessary (plus they contained many errors).
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "none",
|
||||
"target": "es3",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"outDir": "js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"compileOnSave": true
|
||||
}
|
||||
@@ -10,8 +10,10 @@
|
||||
</head>
|
||||
|
||||
<body class=minibar>
|
||||
<header>
|
||||
<h1>About Minibar</h1>
|
||||
|
||||
</header>
|
||||
<main>
|
||||
<a href="minibar.html">Minibar</a> is an alternative implementation of the
|
||||
<a href="http://www.grammaticalframework.org/">GF</a> web app
|
||||
<a href="http://www.grammaticalframework.org:41296/fridge/">Fridge Poetry</a>.
|
||||
@@ -233,14 +235,23 @@ Some implementation details:
|
||||
category names.
|
||||
<li>[Added 2013-04-02] Minibar now remembers from one visit to the next
|
||||
the selected set of target languages for each grammar.
|
||||
<li>[Added 2019-08-05] Minibar can now display grammar documentation.
|
||||
The documentation is taken from a file called
|
||||
<var>Grammar</var><code>.pgf_info</code>, located
|
||||
next to the <var>Grammar</var><code>.pgf</code> file on the server.
|
||||
The first line of the documentation is displayed below the menu bar in
|
||||
the minibar. The rest of the documentation is displayed when you press
|
||||
the <b>More info</b> button (or the <b>i</b> button). The documentation
|
||||
can contain HTML markup. Blank lines are treated as paragraph breaks.
|
||||
</ul>
|
||||
|
||||
</main>
|
||||
<footer>
|
||||
<hr>
|
||||
<div class=modtime><small>
|
||||
<!-- hhmts start -->Last modified: Tue Apr 2 15:49:32 CEST 2013 <!-- hhmts end -->
|
||||
<!-- hhmts start -->Last modified: Mon Aug 5 15:22:46 CEST 2019 <!-- hhmts end -->
|
||||
</small></div>
|
||||
<address>
|
||||
<a href="http://www.cse.chalmers.se/~hallgren/">TH</a>
|
||||
<img src="http://www.altocumulus.org/~hallgren/online.cgi?icon" alt="">
|
||||
<a href="http://www.cse.chalmers.se/~hallgren/">Thomas Hallgren</a>
|
||||
</address>
|
||||
</footer>
|
||||
</body> </html>
|
||||
|
||||
@@ -10,6 +10,7 @@ h1:first-child, h2:first-child { margin-top: 0; margin-bottom: 1ex; }
|
||||
th, td { vertical-align: baseline; text-align: left; }
|
||||
|
||||
div.menubar { font-family: sans-serif; font-size: small; }
|
||||
div.infobar { margin: 5px; }
|
||||
|
||||
div#surface {
|
||||
min-height: 3ex;
|
||||
|
||||
@@ -53,13 +53,14 @@ function Minibar(server,opts) {
|
||||
/* --- Creating user interface elements --------------------------------- */
|
||||
|
||||
this.menubar=div_class("menubar");
|
||||
this.infobar=div_class("infobar");
|
||||
this.extra=div_id("extra");
|
||||
|
||||
this.minibar=element(this.options.target);
|
||||
this.minibar.innerHTML="";
|
||||
with(this) {
|
||||
appendChildren(menubar,[input.menus,translations.menus,input.buttons])
|
||||
appendChildren(minibar,[menubar,input.main,translations.main,extra]);
|
||||
appendChildren(minibar,[menubar,infobar,input.main,translations.main,extra]);
|
||||
if(options.help_url)
|
||||
menubar.appendChild(button("Help",bind(open_help,this)));
|
||||
append_extra_buttons(extra,options);
|
||||
@@ -205,6 +206,30 @@ Minibar.prototype.change_grammar=function(grammar_info) {
|
||||
t.grammar=grammar_info;
|
||||
t.input.change_grammar(grammar_info)
|
||||
t.translations.change_grammar(grammar_info)
|
||||
t.get_pgf_info()
|
||||
}
|
||||
|
||||
Minibar.prototype.get_pgf_info=function() {
|
||||
var t=this;
|
||||
var info_url=t.server.current_grammar_url+"_info";
|
||||
clear(t.infobar)
|
||||
t.pgf_info=null;
|
||||
ajax_http_get(info_url,bind(t.show_pgf_info,t),function(){})
|
||||
}
|
||||
|
||||
Minibar.prototype.show_pgf_info=function(info) {
|
||||
var t=this;
|
||||
var cnt=0;
|
||||
console.log(info)
|
||||
info=info.split("\n");
|
||||
for(var i=0;i<info.length;i++) {
|
||||
if(info[i]=="") info[i]="<p>"
|
||||
else cnt++
|
||||
}
|
||||
t.pgf_info=info.join("\n")
|
||||
t.infobar.innerHTML=info[0]+" "
|
||||
if(cnt>1)
|
||||
t.infobar.appendChild(button("More info",bind(t.show_grammarinfo,t)))
|
||||
}
|
||||
|
||||
Minibar.prototype.show_grammarinfo=function() {
|
||||
@@ -241,7 +266,10 @@ Minibar.prototype.show_grammarinfo=function() {
|
||||
|
||||
var cats=wrap("div",text(g.categories.join(", ")))
|
||||
var funs=wrap("div",text(g.functions.join(", ")))
|
||||
var btn=button("More info",more)
|
||||
var btn=button("Show more details",more)
|
||||
|
||||
var info=empty("div")
|
||||
if(t.pgf_info) info.innerHTML=t.pgf_info
|
||||
|
||||
clear(t.translations.main)
|
||||
var hdr=[text(g.name)]
|
||||
@@ -249,8 +277,11 @@ Minibar.prototype.show_grammarinfo=function() {
|
||||
hdr.push(text(" "))
|
||||
hdr.push(wrap("small",text("("+g.lastmodified+")")))
|
||||
}
|
||||
|
||||
appendChildren(this.translations.main,
|
||||
[wrap("h3",hdr),
|
||||
info,
|
||||
text("The categories and functions in the grammar are listed below."),
|
||||
btn,
|
||||
wrap("h4",text("Start category")), text(g.startcat || ""),
|
||||
wrap("h4",text("Categories")), cats,
|
||||
|
||||
Reference in New Issue
Block a user