diff --git a/debian/rules b/debian/rules
index 428801e94..36e6ce706 100755
--- a/debian/rules
+++ b/debian/rules
@@ -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
diff --git a/download/index.md b/download/index.md
index 78df9d38e..e1d3322c1 100644
--- a/download/index.md
+++ b/download/index.md
@@ -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` |
**Features**
diff --git a/gf.cabal b/gf.cabal
index e7a5e100d..156f6518d 100644
--- a/gf.cabal
+++ b/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
diff --git a/index.html b/index.html
index decea87d6..b053de68b 100644
--- a/index.html
+++ b/index.html
@@ -29,9 +29,9 @@
@@ -152,9 +152,9 @@ least one, it may help you to get a first idea of what GF is.
Applications & Availability
GF can be used for building
- translation systems,
- multilingual web gadgets,
- natural-language interfaces,
+ translation systems,
+ multilingual web gadgets,
+ natural-language interfaces,
dialogue systems, and
natural language resources.
@@ -210,7 +210,7 @@ least one, it may help you to get a first idea of what GF is.
We run the IRC channel #gf on the Freenode network, where you are welcome to look for help with small questions or just start a general discussion.
You can open a web chat
- or browse the channel logs.
+ or browse the channel logs.
If you have a larger question which the community may benefit from, we recommend you ask it on the mailing list.
@@ -224,7 +224,7 @@ least one, it may help you to get a first idea of what GF is.
- 2018-12-03
-
- Sixth GF Summer School in Stellenbosch (South Africa), 3–14 December 2018
+ Sixth GF Summer School in Stellenbosch (South Africa), 3–14 December 2018
- 2018-12-02
-
@@ -248,7 +248,7 @@ least one, it may help you to get a first idea of what GF is.
GF is moving to GitHub.
- 2017-03-13
-
- GF Summer School in Riga (Latvia), 14-25 August 2017
+ GF Summer School in Riga (Latvia), 14-25 August 2017
@@ -268,7 +268,7 @@ least one, it may help you to get a first idea of what GF is.
-
- GF-Alfa:
+ GF-Alfa:
natural language interface to formal proofs
-
@@ -293,11 +293,11 @@ least one, it may help you to get a first idea of what GF is.
Functional Morphology
-
- MOLTO:
+ MOLTO:
multilingual online translation
-
- REMU:
+ REMU:
reliable multilingual digital communication
diff --git a/src/compiler/GF/Compile/Export.hs b/src/compiler/GF/Compile/Export.hs
index e0811d40d..7d3337e3d 100644
--- a/src/compiler/GF/Compile/Export.hs
+++ b/src/compiler/GF/Compile/Export.hs
@@ -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)
diff --git a/src/compiler/GF/Compile/PGFtoJSON.hs b/src/compiler/GF/Compile/PGFtoJSON.hs
new file mode 100644
index 000000000..e634dae67
--- /dev/null
+++ b/src/compiler/GF/Compile/PGFtoJSON.hs
@@ -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
diff --git a/src/compiler/GF/Compile/pgf.schema.json b/src/compiler/GF/Compile/pgf.schema.json
new file mode 100644
index 000000000..2058e9a70
--- /dev/null
+++ b/src/compiler/GF/Compile/pgf.schema.json
@@ -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"
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/compiler/GF/Infra/Option.hs b/src/compiler/GF/Infra/Option.hs
index 7e1c22b9d..7455c83c4 100644
--- a/src/compiler/GF/Infra/Option.hs
+++ b/src/compiler/GF/Infra/Option.hs
@@ -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)"),
diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc
index fd77dbbf7..a41c915f1 100644
--- a/src/runtime/haskell-bind/PGF2.hsc
+++ b/src/runtime/haskell-bind/PGF2.hsc
@@ -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))
diff --git a/src/runtime/javascript/DEPRECATED.md b/src/runtime/javascript/DEPRECATED.md
index a4a8993c6..83f4e51d6 100644
--- a/src/runtime/javascript/DEPRECATED.md
+++ b/src/runtime/javascript/DEPRECATED.md
@@ -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 .
diff --git a/src/runtime/typescript/.eslintrc b/src/runtime/typescript/.eslintrc
deleted file mode 100644
index c0fa0b95e..000000000
--- a/src/runtime/typescript/.eslintrc
+++ /dev/null
@@ -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": "^_" }],
- }
-}
diff --git a/src/runtime/typescript/MOVED.md b/src/runtime/typescript/MOVED.md
new file mode 100644
index 000000000..3648aa226
--- /dev/null
+++ b/src/runtime/typescript/MOVED.md
@@ -0,0 +1,7 @@
+# Project moved
+
+The GF TypeScript runtime has been moved to the repository:
+
+
+If you are looking for an updated version of the JavaScript runtime,
+you should also look there.
diff --git a/src/runtime/typescript/README.md b/src/runtime/typescript/README.md
deleted file mode 100644
index e7905af89..000000000
--- a/src/runtime/typescript/README.md
+++ /dev/null
@@ -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).
diff --git a/src/runtime/typescript/gflib.ts b/src/runtime/typescript/gflib.ts
deleted file mode 100644
index 52865e969..000000000
--- a/src/runtime/typescript/gflib.ts
+++ /dev/null
@@ -1,1619 +0,0 @@
-/**
- * gflib.ts
- *
- * by John J. Camilleri
- *
- * A port of the pure JavaScript runtime (/src/runtime/javascript/gflib.js) into TypeScript
- */
-
-/**
- * A GF grammar is one abstract and multiple concretes
- */
-class GFGrammar { // eslint-disable-line @typescript-eslint/no-unused-vars
- public abstract: GFAbstract
- public concretes: {[key: string]: GFConcrete}
-
- public constructor(abstract: GFAbstract, concretes: {[key: string]: GFConcrete}) {
- this.abstract = abstract
- this.concretes = concretes
- }
-
- public translate(
- input: string,
- fromLang: string,
- toLang: string
- ): {[key: string]: {[key: string]: string}[]} {
- let outputs: {[key: string]: {[key: string]: string}[]} = {}
- let fromConcs = this.concretes
- if (fromLang) {
- fromConcs = {}
- fromConcs[fromLang] = this.concretes[fromLang]
- }
- let toConcs = this.concretes
- if (toLang) {
- toConcs = {}
- toConcs[toLang] = this.concretes[toLang]
- }
- for (let c1 in fromConcs) {
- let concrete = this.concretes[c1]
- let trees = concrete.parseString(input, this.abstract.startcat)
- if (trees.length > 0) {
- outputs[c1] = []
- for (let i in trees) {
- outputs[c1][i] = {}
- for (let c2 in toConcs) {
- outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i])
- }
- }
- }
- }
- return outputs
- }
-}
-
-/**
- * Abstract Syntax Tree
- */
-class Fun {
- public name: string
- public args: Fun[]
- public type?: string // only used for meta variables
-
- public constructor(name: string, ...args: Fun[]) {
- this.name = name
- this.args = []
- for (let i = 1; i < args.length; i++) {
- this.args[i-1] = args[i]
- }
- }
-
- public print(): string {
- return this.show(0)
- }
-
- public show(prec: number): string {
- if (this.isMeta()) {
- if (isUndefined(this.type)) {
- return '?'
- } else {
- let s = '?:' + this.type
- if (prec > 0) {
- s = '(' + s + ')'
- }
- return s
- }
- } else {
- let s = this.name
- let cs = this.args
- for (let i in cs) {
- s += ' ' + (isUndefined(cs[i]) ? 'undefined' : cs[i].show(1))
- }
- if (prec > 0 && cs.length > 0) {
- s = '(' + s + ')'
- }
- return s
- }
- }
-
- public getArg(i: number): Fun {
- return this.args[i]
- }
-
- public setArg(i: number, c: Fun): void {
- this.args[i] = c
- }
-
- public isMeta(): boolean {
- return this.name == '?'
- }
-
- public isComplete(): boolean {
- if (this.isMeta()) {
- return false
- } else {
- for (let i in this.args) {
- if (!this.args[i].isComplete()) {
- return false
- }
- }
- return true
- }
- }
-
- public isLiteral(): boolean {
- return (/^[\"\-\d]/).test(this.name)
- }
-
- public isString(): boolean {
- return (/^\".*\"$/).test(this.name)
- }
-
- public isInt(): boolean {
- return (/^\-?\d+$/).test(this.name)
- }
-
- public isFloat(): boolean {
- return (/^\-?\d*(\.\d*)?$/).test(this.name) && this.name != '.' && this.name != '-.'
- }
-
- public isEqual(obj: Fun): boolean {
- if (this.name != obj.name)
- return false
-
- for (let i in this.args) {
- if (!this.args[i].isEqual(obj.args[i]))
- return false
- }
-
- return true
- }
-}
-
-/**
- * Abstract syntax
- */
-class GFAbstract {
- public startcat: string
- private types: {[key: string]: Type} // key is function name
-
- public constructor(startcat: string, types: {[key: string]: Type}) {
- this.startcat = startcat
- this.types = types
- }
-
- public addType(fun: string, args: string[], cat: string): void {
- this.types[fun] = new Type(args, cat)
- }
-
- public getArgs(fun: string): string[] {
- return this.types[fun].args
- }
-
- public getCat(fun: string): string {
- return this.types[fun].cat
- }
-
- // Annotate (only) meta variables
- private annotate(tree: Fun, type?: string): Fun {
- let typ: Type | undefined = this.types[tree.name]
- if (tree.isMeta()) {
- tree.type = type
- } else if (!isUndefined(typ)) {
- for (let i in tree.args) {
- this.annotate(tree.args[i], typ.args[i])
- }
- }
- return tree
- }
-
- public handleLiterals(tree: Fun, type: string): Fun {
- if (tree.name != '?') {
- if (type == 'String' || type == 'Int' || type == 'Float') {
- tree.name = type + '_Literal_' + tree.name
- } else {
- let typ = this.types[tree.name]
- for (let i in tree.args) {
- this.handleLiterals(tree.args[i], typ.args[i])
- }
- }
- }
- return tree
- }
-
- // Hack to get around the fact that our SISR doesn't build real Fun objects.
- public copyTree(x: Fun): Fun {
- let t = new Fun(x.name)
- if (!isUndefined(x.type)) {
- t.type = x.type
- }
- let cs = x.args
- if (!isUndefined(cs)) {
- for (let i = 0; i < cs.length; i++) {
- t.setArg(i, this.copyTree(cs[i]))
- }
- }
- return t
- }
-
- public parseTree(str: string, type?: string): Fun | null {
- let pt = this.parseTree_(str.match(/[\w\u00C0-\u00FF\'\.\"]+|\(|\)|\?|\:/g) || [], 0)
- return pt ? this.annotate(pt, type) : null
- }
-
- private parseTree_(tokens: string[], prec: number): Fun | null {
- if (tokens.length == 0 || tokens[0] == ')') {
- return null
- }
- let t = tokens.shift()
- if (!t) return null
- if (t == '(') {
- let tree = this.parseTree_(tokens, 0)
- tokens.shift()
- return tree
- } else if (t == '?') {
- // let tree = this.parseTree_(tokens, 0)
- return new Fun('?')
- } else {
- let tree = new Fun(t)
- if (prec == 0) {
- let c: Fun | null
- let i: number
- for (i = 0; (c = this.parseTree_(tokens, 1)) !== null; i++) {
- tree.setArg(i,c)
- }
- }
- return tree
- }
- }
-}
-
-/**
- * Type
- */
-class Type {
- public args: string[]
- public cat: string
-
- public constructor(args: string[], cat: string) {
- this.args = args
- this.cat = cat
- }
-}
-
-/**
- * Concrete syntax
- */
-class GFConcrete {
- public flags: {[key: string]: string}
- // private productions: {[key: number]: Rule[]}
- private functions: CncFun[]
- // private sequences: Sym[][]
- public startCats: {[key: string]: {s: number; e: number}}
- public totalFIds: number
- public pproductions: {[key: number]: Rule[]}
- private lproductions: {[key: string]: {fid: FId; fun: CncFun}[]}
-
- public constructor(
- flags: {[key: string]: string},
- productions: {[key: number]: Rule[]},
- functions: CncFun[],
- sequences: Sym[][],
- startCats: {[key: string]: {s: number; e: number}},
- totalFIds: number
- ) {
- this.flags = flags
- // this.productions = productions
- this.functions = functions
- // this.sequences = sequences
- this.startCats = startCats
- this.totalFIds = totalFIds
-
- this.pproductions = productions
- this.lproductions = {}
-
- for (let fid0 in productions) {
- let fid: number = parseInt(fid0)
- for (let i in productions[fid]) {
- let rule = productions[fid][i]
-
- if (rule.id == 'Apply') {
- rule = rule as Apply
- let fun: CncFun = this.functions[rule.fun as FId]
- let lproductions = this.lproductions
-
- rule.fun = fun
-
- let register = function (args: PArg[], key: string, i: number): void {
- if (i < args.length) {
- let c = 0
- let arg = args[i].fid
-
- for (let k in productions[arg]) {
- let rule = productions[arg][k]
- if (rule.id == 'Coerce') {
- rule = rule as Coerce
- register(args, key + '_' + rule.arg, i+1)
- c++
- }
- }
-
- if (c == 0) {
- register(args, key + '_' + arg, i+1)
- }
- } else {
- let set = lproductions[key]
- if (set == null) {
- set = []
- lproductions[key] = set
- }
- set.push({fun: fun, fid: fid})
- }
- }
- register(rule.args, rule.fun.name, 0)
- }
- }
- }
-
- for (let fun of functions) {
- for (let j in fun.lins) {
- fun.lins[j] = sequences[fun.lins[j] as number]
- }
- }
-
- }
-
- private linearizeSyms(tree: Fun, tag: string): {fid: FId; table: Sym[][]}[] {
- let res = []
-
- if (tree.isString()) {
- let sym = new SymKS(tree.name)
- sym.tag = tag
- res.push({fid: -1, table: [[sym]]})
- } else if (tree.isInt()) {
- let sym = new SymKS(tree.name)
- sym.tag = tag
- res.push({fid: -2, table: [[sym]]})
- } else if (tree.isFloat()) {
- let sym = new SymKS(tree.name)
- sym.tag = tag
- res.push({fid: -3, table: [[sym]]})
- } else if (tree.isMeta()) {
- // TODO: Use lindef here
- let cat = this.startCats[tree.type as string]
-
- let sym = new SymKS(tree.name)
- sym.tag = tag
-
- for (let fid = cat.s; fid <= cat.e; fid++) {
- res.push({fid: fid, table: [[sym]]})
- }
- } else {
- let cs: {fid: FId; table: Sym[][]}[] = []
- for (let i in tree.args) {
- // TODO: we should handle the case for nondeterministic linearization
- cs.push(this.linearizeSyms(tree.args[i],tag + '-' + i)[0])
- }
- let key = tree.name
- for (let i in cs) {
- if (isUndefined(cs[i])) {
- // Some arguments into this function are undefined
- console.warn(`${tree.args[i].name} is undefined`)
- return [{
- fid: -5, // signal to parent that I cannot lin properly
- table: [[new SymKS(`[${tree.name}]`).tagWith(tag)]]
- }]
- } else if (cs[i].fid === -5) {
- // My child cannot lin properly, just find first matching rule for me
- // TODO probably not general enough
- for (let k in this.lproductions) {
- if (k.includes(tree.name)) {
- key = k
- break
- }
- }
- break
- } else {
- key = key + '_' + cs[i].fid
- }
- }
-
- for (let i in this.lproductions[key]) {
- let rule = this.lproductions[key][i]
- let row: {fid: FId; table: Sym[][]} = {
- fid: rule.fid,
- table: []
- }
- for (let j in rule.fun.lins) {
- let lin = rule.fun.lins[j] as Sym[]
- let toks: Sym[] = []
- row.table[j] = toks
-
- lin.forEach((sym0: Sym): void => {
- switch (sym0.id) {
- case 'Arg':
- case 'Lit': {
- let sym = sym0 as SymCat | SymLit
- let ts = cs[sym.i].table[sym.label]
- for (let l in ts) {
- toks.push(ts[l])
- }
- break
- }
- case 'KS':
- case 'KP': {
- let sym = sym0 as SymKS | SymKP
- toks.push(sym.tagWith(tag))
- break
- }
- }
- })
- }
- res.push(row)
- }
- }
-
- return res
- }
-
- private syms2toks(syms: Sym[]): TaggedString[] {
- let ts: TaggedString[] = []
- for (let i = 0; i < syms.length; i++) {
- let sym0 = syms[i]
- switch (sym0.id) {
- case 'KS': {
- let sym = sym0 as SymKS
- for (let j in sym.tokens) {
- ts.push(new TaggedString(sym.tokens[j], sym.tag as string))
- }
- break
- }
- case 'KP': {
- let sym = sym0 as SymKP
- let addedAlt = false
- if (i < syms.length-1) {
- let nextSym = syms[i+1]
- if (nextSym.id == 'KS') {
- let nextToken = (nextSym as SymKS).tokens[0]
- sym.alts.forEach((alt: Alt): void => {
- // consider alts here (for handling pre)
- if (alt.prefixes.some((p: string): boolean => nextToken.startsWith(p))) {
- alt.tokens.forEach((symks: SymKS): void => {
- symks.tokens.forEach((t: string): void => {
- ts.push(new TaggedString(t, sym.tag as string))
- })
- })
- addedAlt = true
- return
- }
- })
- }
- }
- if (addedAlt) break
- // Fall through here when no alts (or none apply)
- sym.tokens.forEach((symks: SymKS): void => {
- symks.tokens.forEach((t: string): void => {
- ts.push(new TaggedString(t, sym.tag as string))
- })
- })
- break
- }
- }
- }
- return ts
- }
-
- public linearizeAll(tree: Fun): string[] {
- return this.linearizeSyms(tree,'0').map((r): string => {
- return this.unlex(this.syms2toks(r.table[0]))
- })
- }
-
- public linearize(tree: Fun): string {
- let res = this.linearizeSyms(tree,'0')
- if (res.length > 0)
- return this.unlex(this.syms2toks(res[0].table[0]))
- else
- return ''
- }
-
- public tagAndLinearize(tree: Fun): TaggedString[] {
- let res = this.linearizeSyms(tree,'0')
- if (res.length > 0)
- return this.syms2toks(res[0].table[0])
- else
- return []
- }
-
- private unlex(ts: TaggedString[]): string {
- if (ts.length == 0) {
- return ''
- }
-
- let noSpaceAfter = /^[\(\-\[]/
- let noSpaceBefore = /^[\.\,\?\!\)\:\;\-\]]/
-
- let s = ''
- for (let i = 0; i < ts.length; i++) {
- let t: string = ts[i].s
- let after: string | null = i < ts.length-1 ? ts[i+1].s : null
- s += t
- if (after != null
- && !t.match(noSpaceAfter)
- && !after.match(noSpaceBefore)
- ) {
- s += ' '
- }
- }
- return s
- }
-
- // private tagIt(obj: Taggable, tag: string): Taggable {
- // if (isString(obj)) {
- // let o = new String(obj)
- // o.setTag(tag)
- // return o
- // } else {
- // let me = arguments.callee
- // if (arguments.length == 2) {
- // me.prototype = obj
- // let o = new me()
- // o.tag = tag
- // return o
- // }
- // }
- // }
-
- // public showRules(): string {
- // let ruleStr = []
- // ruleStr.push('')
- // for (let i = 0, j = this.rules.length; i < j; i++) {
- // ruleStr.push(this.rules[i].show())
- // }
- // return ruleStr.join('')
- // }
-
- private tokenize(string: string): string[] {
- let inToken = false
- let start = 0
- let end: number
- let tokens = []
-
- let i: number
- for (i = 0; i < string.length; i++) {
- if (string.charAt(i) == ' ' // space
- || string.charAt(i) == '\f' // form feed
- || string.charAt(i) == '\n' // newline
- || string.charAt(i) == '\r' // return
- || string.charAt(i) == '\t' // horizontal tab
- || string.charAt(i) == '\v' // vertical tab
- || string.charAt(i) == String.fromCharCode(160) //
- ) {
- if (inToken) {
- end = i-1
- inToken = false
- tokens.push(string.substr(start,end-start+1))
- }
- } else {
- if (!inToken) {
- start = i
- inToken = true
- }
- }
- }
-
- if (inToken) {
- end = i-1
- inToken = false
- tokens.push(string.substr(start,end-start+1))
- }
-
- return tokens
- }
-
- public parseString(string: string, cat: string): Fun[] {
- let tokens = this.tokenize(string)
-
- let ps = new ParseState(this, cat)
- for (let i in tokens) {
- if (!ps.next(tokens[i]))
- return []
- }
- return ps.extractTrees()
- }
-
- public complete(
- input: string,
- cat: string
- ): {consumed: string[]; suggestions: string[]} {
- // Parameter defaults
- if (input == null) input = ''
- // if (cat == null) cat = grammar.abstract.startcat
-
- // Tokenise input string & remove empty tokens
- let tokens = input.trim().split(' ')
- for (let i = tokens.length - 1; i >= 0; i--) {
- if (tokens[i] == '') {
- tokens.splice(i, 1)
- }
- }
-
- // Capture last token as it may be partial
- let current = tokens.pop()
- if (current == null) current = ''
-
- // Init parse state objects.
- // ps2 is used for testing whether the final token is parsable or not.
- let ps = new ParseState(this, cat)
- let ps2 = new ParseState(this, cat)
-
- // Iterate over tokens, feed one by one to parser
- for (let i = 0; i < tokens.length ; i++) {
- if (!ps.next(tokens[i])) {
- return { 'consumed': [], 'suggestions': [] } // Incorrect parse, nothing to suggest
- }
- ps2.next(tokens[i]) // also consume token in ps2
- }
-
- // Attempt to also parse current, knowing it may be incomplete
- if (ps2.next(current)) {
- ps.next(current)
- tokens.push(current)
- current = ''
- }
-
- // Parse is successful so far, now get suggestions
- let acc = ps.complete(current)
-
- // Format into just a list of strings & return
- let suggs: string[] = []
- if (acc.value) {
- acc.value.forEach((a: ActiveItem): void =>{
- a.seq.forEach((s: Sym): void => {
- switch (s.id) {
- case 'KS': {
- (s as SymKS).tokens.forEach((t: string): void => {
- suggs.push(t)
- })
- break
- }
- case 'KP': {
- (s as SymKP).tokens.forEach((symks: SymKS): void => {
- symks.tokens.forEach((t: string): void => {
- suggs.push(t)
- })
- })
- break
- }
- }
- })
- })
- }
-
- // Note: return used tokens too
- return { 'consumed' : tokens, 'suggestions' : suggs }
- }
-}
-
-/**
- * A string with a tag
- * This avoids modifying the String prototype, which was messy
- */
-class TaggedString {
- public s: string
- public tag: string
-
- public constructor(s: string, tag: string) {
- this.s = s
- this.tag = tag
- }
-}
-
-/**
- * Function ID
- */
-type FId = number
-
-/**
- * Rule
- */
-type Rule = Apply | Coerce | Const
-
-/**
- * Apply
- */
-class Apply {
- public id: string
- public fun: FId | CncFun
- public args: PArg[]
-
- public constructor(fun: FId | CncFun, args: PArg[]) {
- this.id = 'Apply'
- this.fun = fun
- this.args = args
- }
-
- public show(cat: string): string {
- let recStr = []
- recStr.push(cat, ' -> ', (this.fun as CncFun).name, ' [', this.args, ']')
- return recStr.join('')
- }
-
- public isEqual(obj: Apply): boolean {
- if (this.id != obj.id || this.fun != obj.fun || this.args.length != obj.args.length)
- return false
-
- for (let i in this.args) {
- if (this.args[i] != obj.args[i])
- return false
- }
-
- return true
- }
-}
-
-/**
- * Coerce
- */
-class Coerce {
- public id: string
- public arg: FId
-
- public constructor(arg: FId) {
- this.id = 'Coerce'
- this.arg = arg
- }
-
- public show(cat: string): string {
- let recStr = []
- recStr.push(cat, ' -> _ [', this.arg, ']')
- return recStr.join('')
- }
-}
-
-/**
- * PArg
- */
-class PArg {
- public fid: FId
- public hypos: FId[]
-
- public constructor(...hypos: FId[]) {
- this.fid = hypos[hypos.length-1]
- if (hypos.length > 1)
- this.hypos = hypos.slice(0, hypos.length-1)
- else
- this.hypos = []
- }
-}
-
-/**
- * Const
- */
-class Const {
- public id: string
- public lit: Fun
- public toks: string[]
-
- public constructor(lit: Fun, toks: string[]) {
- this.id = 'Const'
- this.lit = lit
- this.toks = toks
- }
-
- public show(cat: string): string {
- let recStr = []
- recStr.push(cat, ' -> ', this.lit.print())
- return recStr.join('')
- }
-
- public isEqual(obj: Const): boolean {
- if (this.id != obj.id || this.lit.isEqual(obj.lit) || this.toks.length != obj.toks.length)
- return false
-
- for (let i in this.toks) {
- if (this.toks[i] != obj.toks[i])
- return false
- }
-
- return true
- }
-}
-
-/**
- * CncFun
- */
-class CncFun {
- public name: string
- public lins: number[] | Sym[][]
-
- public constructor(name: string, lins: FId[]) {
- this.name = name
- this.lins = lins
- }
-}
-
-/**
- * Sym: Definition of symbols present in linearization records
- */
-type Sym = SymCat | SymKS | SymKP | SymLit
-
-/**
- * SymCat: Object to represent argument projections in grammar rules
- */
-class SymCat {
- public id: string
- public i: number
- public label: number
-
- public constructor(i: number, label: number) {
- this.id = 'Arg'
- this.i = i
- this.label = label
- }
-
- public show(): string {
- let argStr = []
- argStr.push(this.i, this.label)
- return argStr.join('.')
- }
-}
-
-/**
- * SymKS: Object to represent terminals in grammar rules
- */
-class SymKS {
- public id: string
- public tokens: string[]
- public tag?: string
-
- public constructor(...tokens: string[]) {
- this.id = 'KS'
- this.tokens = tokens
- }
-
- public show(): string {
- let terminalStr = []
- terminalStr.push('"', this.tokens, '"')
- return terminalStr.join('')
- }
-
- public tagWith(tag: string): SymKS {
- let s = new SymKS()
- s.tokens = [...this.tokens] // copy array
- s.tag = tag
- return s
- }
-}
-
-/**
- * SymKP: Object to represent pre in grammar rules
- */
-class SymKP {
- public id: string
- public tokens: SymKS[]
- public alts: Alt[]
- public tag?: string
-
- public constructor(tokens: SymKS[], alts: Alt[]) {
- this.id = 'KP'
- this.tokens = tokens
- this.alts = alts
- }
-
- public show(): string {
- let terminalStr = []
- terminalStr.push('"', this.tokens, '"')
- return terminalStr.join('')
- }
-
- public tagWith(tag: string): SymKP {
- let s = new SymKP([...this.tokens], [...this.alts]) // copy arguments
- s.tag = tag
- return s
- }
-}
-
-/**
- * Alt
- */
-class Alt {
- public tokens: SymKS[]
- public prefixes: string[]
-
- public constructor(tokens: SymKS[], prefixes: string[]) {
- this.tokens = tokens
- this.prefixes = prefixes
- }
-}
-
-/**
- * SymLit: Object to represent pre in grammar rules
- */
-class SymLit {
- public id: string
- public i: number
- public label: number
-
- public constructor(i: number, label: number) {
- this.id = 'Lit'
- this.i = i
- this.label = label
- }
-
- public getId(): string {
- return this.id
- }
-
- public show(): string {
- let argStr = []
- argStr.push(this.i, this.label)
- return argStr.join('.')
- }
-}
-
-/**
- * Trie
- */
-class Trie {
- public value: T[] | null
- private items: {[key: string]: Trie}
-
- public constructor() {
- this.value = null
- this.items = {}
- }
-
- public insertChain(keys: string[], obj: T[]): void {
- let node: Trie = this
- keys.forEach((key: string): void => {
- let nnode = node.items[key]
- if (nnode == null) {
- nnode = new Trie()
- node.items[key] = nnode
- }
- node = nnode
- })
- node.value = obj
- }
-
- public insertChain1(keys: string[], obj: T): void {
- let node: Trie = this
- keys.forEach((key: string): void => {
- let nnode = node.items[key]
- if (nnode == null) {
- nnode = new Trie()
- node.items[key] = nnode
- }
- node = nnode
- })
- if (node.value == null)
- node.value = [obj]
- else
- node.value.push(obj)
- }
-
- public lookup(key: string): Trie {
- return this.items[key]
- }
-
- public isEmpty(): boolean {
- if (this.value != null)
- return false
-
- for (let _ in this.items) {
- return false
- }
-
- return true
- }
-}
-
-/**
- * ParseState
- */
-class ParseState {
- private concrete: GFConcrete
- private startCat: string
- private items: Trie
- private chart: Chart
-
- public constructor(concrete: GFConcrete, startCat: string) {
- this.concrete = concrete
- this.startCat = startCat
- this.items = new Trie()
- this.chart = new Chart(concrete)
-
- let items = []
-
- let fids = concrete.startCats[startCat]
- if (fids != null) {
- let fid: FId
- for (fid = fids.s; fid <= fids.e; fid++) {
- let exProds = this.chart.expandForest(fid)
- for (let j in exProds) {
- let rule = exProds[j] as Apply
- let fun = rule.fun as CncFun
- for (let lbl in fun.lins) {
- items.push(new ActiveItem(
- 0,
- 0,
- rule.fun as CncFun,
- fun.lins[lbl] as Sym[],
- rule.args,
- fid,
- parseInt(lbl))
- )
- }
- }
- }
- }
-
- this.items.insertChain([], items)
- }
-
- public next(token: string): boolean {
- let acc = this.items.lookup(token)
- if (acc == null) {
- acc = new Trie()
- }
- this.process(
- this.items.value,
- function (fid: FId): Const | null {
- switch (fid) {
- // String
- case -1:
- return new Const(new Fun('"'+token+'"'), [token])
- // Integer
- case -2: {
- let x = parseInt(token,10)
- if (token == '0' || (x != 0 && !isNaN(x)))
- return new Const(new Fun(token), [token])
- else
- return null
- }
- // Float
- case -3: {
- let x = parseFloat(token)
- if (token == '0' || token == '0.0' || (x != 0 && !isNaN(x)))
- return new Const(new Fun(token), [token])
- else
- return null
- }
- }
-
- return null
- },
- function (tokens: string[], item: ActiveItem): void {
- if (tokens[0] == token) {
- let tokens1 = []
- for (let i = 1; i < tokens.length; i++) {
- tokens1[i-1] = tokens[i]
- }
- acc.insertChain1(tokens1, item)
- }
- }
- )
-
- this.items = acc
- this.chart.shift()
-
- return !this.items.isEmpty()
- }
-
- /**
- * For a ParseState and a partial input, return all possible completions
- * Based closely on ParseState.next()
- * currentToken could be empty or a partial string
- */
- public complete(currentToken: string): Trie {
-
- // Initialise accumulator for suggestions
- let acc = this.items.lookup(currentToken)
- if (acc == null)
- acc = new Trie()
-
- this.process(
- // Items
- this.items.value,
-
- // Deal with literal categories
- function (_fid: FId): null {
- // Always return null, as suggested by Krasimir
- return null
- },
-
- // Takes an array of tokens and populates the accumulator
- function (tokens: string[], item: ActiveItem): void {
- if (currentToken == '' || tokens[0].indexOf(currentToken) == 0) { //if begins with...
- let tokens1 = []
- for (let i = 1; i < tokens.length; i++) {
- tokens1[i-1] = tokens[i]
- }
- acc.insertChain1(tokens1, item)
- }
- }
- )
-
- // Return matches
- return acc
- }
-
- public extractTrees(): Fun[] {
- this.process(
- this.items.value,
- function (_fid: FId): null {
- return null
- },
- function (_tokens: string[], _item: ActiveItem): void {
- }
- )
-
- let totalFIds = this.concrete.totalFIds
- let forest = this.chart.forest
-
- function go(fid: FId): Fun[] {
- if (fid < totalFIds) {
- return [new Fun('?')]
- } else {
- let trees: Fun[] = []
-
- let rules = forest[fid] // could be undefined
- for (let j in rules) {
- let rule: Rule = rules[j]
- if (rule.id == 'Const') {
- trees.push((rule as Const).lit)
- } else {
- rule = rule as Apply
- let arg_ix: number[] = []
- let arg_ts: Fun[][] = []
- for (let k in rule.args) {
- arg_ix[k] = 0
- arg_ts[k] = go(rule.args[k].fid)
- }
-
- while (true) {
- let t = new Fun((rule.fun as CncFun).name)
- for (let k = 0; k < arg_ts.length; k++) {
- t.setArg(k,arg_ts[k][arg_ix[k]])
- }
- trees.push(t)
-
- let i = 0
- while (i < arg_ts.length) {
- arg_ix[i]++
- if (arg_ix[i] < arg_ts[i].length)
- break
-
- arg_ix[i] = 0
- i++
- }
-
- if (i >= arg_ts.length)
- break
- }
- }
- }
-
- return trees
- }
- }
-
- let trees = []
- let fids = this.concrete.startCats[this.startCat]
- if (fids != null) {
- for (let fid0 = fids.s; fid0 <= fids.e; fid0++) {
-
- let labels: {[key: number]: boolean} = {}
- let rules = this.chart.expandForest(fid0)
- rules.forEach((rule): void => {
- for (let lbl in (rule.fun as CncFun).lins) {
- labels[lbl] = true
- }
- })
-
- for (let lbl0 in labels) {
- let lbl: number = parseInt(lbl0)
- let fid = this.chart.lookupPC(fid0, lbl, 0)
- let arg_ts = go(fid)
- for (let i in arg_ts) {
- let isMember = false
- for (let j in trees) {
- if (arg_ts[i].isEqual(trees[j])) {
- isMember = true
- break
- }
- }
-
- if (!isMember)
- trees.push(arg_ts[i])
- }
- }
- }
- }
-
- return trees
- }
-
- private process(
- agenda: ActiveItem[] | null,
- literalCallback: (fid: FId) => Const | null, // this is right
- tokenCallback: (tokens: string[], item: ActiveItem) => void
- ): void {
- if (agenda != null) {
- while (agenda.length > 0) {
- let item = agenda.pop() as ActiveItem
- let lin = item.seq
-
- if (item.dot < lin.length) {
- let sym0 = lin[item.dot]
- switch (sym0.id) {
- case 'Arg': {
- let sym = sym0 as SymCat
- let fid = item.args[sym.i].fid
- let label = sym.label
-
- let items = this.chart.lookupAC(fid,label)
- if (items == null) {
- let rules = this.chart.expandForest(fid)
- for (let j in rules) {
- let rule = rules[j] as Apply
- agenda.push(new ActiveItem(
- this.chart.offset,
- 0,
- rule.fun as CncFun,
- ((rule.fun as CncFun).lins as Sym[][])[label],
- rule.args,
- fid,
- label)
- )
- }
- this.chart.insertAC(fid,label,[item])
- } else {
- let isMember = false
- for (let j in items) {
- if (items[j].isEqual(item)) {
- isMember = true
- break
- }
- }
-
- if (!isMember) {
- items.push(item)
-
- let fid2 = this.chart.lookupPC(fid,label,this.chart.offset)
- if (fid2 != null) {
- agenda.push(item.shiftOverArg(sym.i,fid2))
- }
- }
- }
- break
- }
- case 'KS': {
- let sym = sym0 as SymKS
- tokenCallback(sym.tokens, item.shiftOverTokn())
- break
- }
- case 'KP': {
- let sym = sym0 as SymKP
- let pitem = item.shiftOverTokn()
- sym.tokens.forEach((symks: SymKS): void => { // TODO not sure if this is right
- tokenCallback(symks.tokens, pitem)
- })
- sym.alts.forEach((alt: Alt): void => {
- // tokenCallback(alt.tokens, pitem)
- alt.tokens.forEach((symks: SymKS): void => { // TODO not sure if this is right
- tokenCallback(symks.tokens, pitem)
- })
- })
- break
- }
- case 'Lit': {
- let sym = sym0 as SymLit
- let fid = item.args[sym.i].fid
- let rules = this.chart.forest[fid]
- if (rules != null) {
- tokenCallback((rules[0] as Const).toks, item.shiftOverTokn())
- } else {
- let rule = literalCallback(fid)
- if (rule != null) {
- fid = this.chart.nextId++
- this.chart.forest[fid] = [rule]
- tokenCallback(rule.toks, item.shiftOverArg(sym.i, fid))
- }
- }
- break
- }
- }
- } else {
- let fid = this.chart.lookupPC(item.fid,item.lbl,item.offset)
- if (fid == null) {
- fid = this.chart.nextId++
-
- let items = this.chart.lookupACo(item.offset,item.fid,item.lbl)
- if (items != null) {
- items.forEach((pitem: ActiveItem): void => {
- let i = (pitem.seq[pitem.dot] as SymCat).i
- agenda.push(pitem.shiftOverArg(i,fid))
- })
- }
-
- this.chart.insertPC(item.fid,item.lbl,item.offset,fid)
- this.chart.forest[fid] = [new Apply(item.fun,item.args)]
- } else {
- let labels = this.chart.labelsAC(fid)
- if (labels != null) {
- for (let lbl in labels) {
- agenda.push(new ActiveItem(
- this.chart.offset,
- 0,
- item.fun,
- item.fun.lins[lbl] as Sym[],
- item.args,
- fid,
- parseInt(lbl))
- )
- }
- }
-
- let rules = this.chart.forest[fid]
- let rule = new Apply(item.fun,item.args)
-
- let isMember = false
- rules.forEach((rule1): void => {
- if ((rule1 as Apply).isEqual(rule)) // TODO might need to check if Coerce here
- isMember = true
- })
-
- if (!isMember)
- rules.push(rule)
- }
- }
- }
- }
- }
-}
-
-/**
- * Map of label to list of ActiveItems
- */
-interface ActiveItemMap {[key: number]: ActiveItem[]}
-
-/**
- * Chart
- */
-class Chart {
- // private active: {[key: number]: ActiveItem} // key: FId
- private active: {[key: number]: ActiveItemMap} // key: FId
- private actives: {[key: number]: ActiveItemMap}[] // key: FId
- private passive: {[key: string]: FId}
- public forest: {[key: number]: Rule[]} // key: FId
- public nextId: number
- public offset: number
-
- public constructor(concrete: GFConcrete) {
- this.active = {}
- this.actives = []
- this.passive = {}
- this.forest = {}
- this.nextId = concrete.totalFIds
- this.offset = 0
-
- for (let fid in concrete.pproductions) {
- this.forest[fid] = concrete.pproductions[fid]
- }
- }
-
- public lookupAC(fid: FId, label: number): ActiveItem[] | null {
- let tmp = this.active[fid]
- if (tmp == null)
- return null
- return tmp[label]
- }
-
- public lookupACo(offset: number, fid: FId, label: number): ActiveItem[] | null {
- let tmp: ActiveItemMap
-
- if (offset == this.offset)
- tmp = this.active[fid]
- else
- tmp = this.actives[offset][fid]
-
- if (tmp == null)
- return null
-
- return tmp[label]
- }
-
- public labelsAC(fid: FId): ActiveItemMap {
- return this.active[fid]
- }
-
- public insertAC(fid: FId, label: number, items: ActiveItem[]): void {
- let tmp: ActiveItemMap = this.active[fid]
- if (tmp == null) {
- tmp = {}
- this.active[fid] = tmp
- }
- tmp[label] = items
- }
-
- public lookupPC(fid: FId, label: number, offset: number): FId {
- let key = fid+'.'+label+'-'+offset
- return this.passive[key]
- }
-
- public insertPC(fid1: FId, label: number, offset: number, fid2: FId): void {
- let key = fid1+'.'+label+'-'+offset
- this.passive[key] = fid2
- }
-
- public shift(): void {
- this.actives.push(this.active)
- this.active = {}
- this.passive = {}
- this.offset++
- }
-
- public expandForest(fid: FId): Apply[] {
- let rules: Apply[] = []
- let forest = this.forest
-
- let go = function (rules0: Rule[]): void {
- for (let i in rules0) {
- let rule = rules0[i]
- switch (rule.id) {
- case 'Apply':
- rules.push(rule as Apply)
- break
- case 'Coerce':
- go(forest[(rule as Coerce).arg])
- break
- }
- }
- }
-
- go(this.forest[fid])
- return rules
- }
-}
-
-/**
- * ActiveItem
- */
-class ActiveItem {
- public offset: number
- public dot: number
- public fun: CncFun
- public seq: Sym[]
- public args: PArg[]
- public fid: FId
- public lbl: number
-
- public constructor(
- offset: number,
- dot: number,
- fun: CncFun,
- seq: Sym[],
- args: PArg[],
- fid: FId,
- lbl: number
- ) {
- this.offset = offset
- this.dot = dot
- this.fun = fun
- this.seq = seq
- this.args = args
- this.fid = fid
- this.lbl = lbl
- }
-
- public isEqual(obj: ActiveItem): boolean {
- return (this.offset== obj.offset &&
- this.dot == obj.dot &&
- this.fun == obj.fun &&
- this.seq == obj.seq &&
- this.args == obj.args &&
- this.fid == obj.fid &&
- this.lbl == obj.lbl)
- }
-
- public shiftOverArg(i: number, fid: FId): ActiveItem {
- let nargs: PArg[] = []
- for (let k in this.args) {
- nargs[k] = this.args[k]
- }
- nargs[i] = new PArg(fid)
- return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,nargs,this.fid,this.lbl)
- }
-
- public shiftOverTokn(): ActiveItem {
- return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,this.args,this.fid,this.lbl)
- }
-}
-
-/**
- * Utilities
- */
-
-/* from Remedial JavaScript by Douglas Crockford, http://javascript.crockford.com/remedial.html */
-// function isString(a: any): boolean {
-// return typeof a == 'string' || a instanceof String
-// }
-// function isArray(a: any): boolean {
-// return a && typeof a == 'object' && a.constructor == Array
-// }
-function isUndefined(a: any): boolean { // eslint-disable-line @typescript-eslint/no-explicit-any
- return typeof a == 'undefined'
-}
-// function isBoolean(a: any): boolean {
-// return typeof a == 'boolean'
-// }
-// function isNumber(a: any): boolean {
-// return typeof a == 'number' && isFinite(a)
-// }
-// function isFunction(a: any): boolean {
-// return typeof a == 'function'
-// }
-// function dumpObject (obj: any): string {
-// if (isUndefined(obj)) {
-// return 'undefined'
-// } else if (isString(obj)) {
-// return '"' + obj.toString() + '"' // FIXME: escape
-// } else if (isBoolean(obj) || isNumber(obj)) {
-// return obj.toString()
-// } else if (isArray(obj)) {
-// let x = '['
-// for (let i = 0; i < obj.length; i++) {
-// x += dumpObject(obj[i])
-// if (i < obj.length-1) {
-// x += ','
-// }
-// }
-// return x + ']'
-// } else {
-// let x = '{'
-// for (let y in obj) {
-// x += y + '=' + dumpObject(obj[y]) + ';'
-// }
-// return x + '}'
-// }
-// }
-
-/**
- * Polyfills for older targets
- */
-
-interface String {
- startsWith: (search: string, pos?: number) => boolean;
- includes: (search: string, start?: number) => boolean;
-}
-
-// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith#Polyfill
-if (!String.prototype.startsWith) {
- Object.defineProperty(String.prototype, 'startsWith', {
- value: function(search: string, pos?: number): boolean {
- pos = !pos || pos < 0 ? 0 : +pos
- return this.substring(pos, pos + search.length) === search
- }
- })
-}
-// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
-if (!String.prototype.includes) {
- Object.defineProperty(String.prototype, 'includes', {
- value: function(search: string, start?: number): boolean {
- 'use strict'
- if (typeof start !== 'number') {
- start = 0
- }
-
- if (start + search.length > this.length) {
- return false
- } else {
- return this.indexOf(search, start) !== -1
- }
- }
- })
-}
-
-/**
- * gflib.ts as a module
- * If you want to make this into a proper module, uncomment this:
- */
-
-// export {
-// GFGrammar,
-// GFAbstract,
-// GFConcrete,
-// Fun,
-// Type,
-// Apply,
-// Coerce,
-// PArg,
-// Const,
-// CncFun,
-// SymCat,
-// SymKS,
-// SymKP,
-// SymLit,
-// Alt,
-// }
diff --git a/src/runtime/typescript/js/gflib.js b/src/runtime/typescript/js/gflib.js
deleted file mode 100644
index 7c6352705..000000000
--- a/src/runtime/typescript/js/gflib.js
+++ /dev/null
@@ -1,1164 +0,0 @@
-"use strict";
-var GFGrammar = (function () {
- function GFGrammar(abstract, concretes) {
- this.abstract = abstract;
- this.concretes = concretes;
- }
- GFGrammar.prototype.translate = function (input, fromLang, toLang) {
- var outputs = {};
- var fromConcs = this.concretes;
- if (fromLang) {
- fromConcs = {};
- fromConcs[fromLang] = this.concretes[fromLang];
- }
- var toConcs = this.concretes;
- if (toLang) {
- toConcs = {};
- toConcs[toLang] = this.concretes[toLang];
- }
- for (var c1 in fromConcs) {
- var concrete = this.concretes[c1];
- var trees = concrete.parseString(input, this.abstract.startcat);
- if (trees.length > 0) {
- outputs[c1] = [];
- for (var i in trees) {
- outputs[c1][i] = {};
- for (var c2 in toConcs) {
- outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i]);
- }
- }
- }
- }
- return outputs;
- };
- return GFGrammar;
-}());
-var Fun = (function () {
- function Fun(name) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- this.name = name;
- this.args = [];
- for (var i = 1; i < args.length; i++) {
- this.args[i - 1] = args[i];
- }
- }
- Fun.prototype.print = function () {
- return this.show(0);
- };
- Fun.prototype.show = function (prec) {
- if (this.isMeta()) {
- if (isUndefined(this.type)) {
- return '?';
- }
- else {
- var s = '?:' + this.type;
- if (prec > 0) {
- s = '(' + s + ')';
- }
- return s;
- }
- }
- else {
- var s = this.name;
- var cs = this.args;
- for (var i in cs) {
- s += ' ' + (isUndefined(cs[i]) ? 'undefined' : cs[i].show(1));
- }
- if (prec > 0 && cs.length > 0) {
- s = '(' + s + ')';
- }
- return s;
- }
- };
- Fun.prototype.getArg = function (i) {
- return this.args[i];
- };
- Fun.prototype.setArg = function (i, c) {
- this.args[i] = c;
- };
- Fun.prototype.isMeta = function () {
- return this.name == '?';
- };
- Fun.prototype.isComplete = function () {
- if (this.isMeta()) {
- return false;
- }
- else {
- for (var i in this.args) {
- if (!this.args[i].isComplete()) {
- return false;
- }
- }
- return true;
- }
- };
- Fun.prototype.isLiteral = function () {
- return (/^[\"\-\d]/).test(this.name);
- };
- Fun.prototype.isString = function () {
- return (/^\".*\"$/).test(this.name);
- };
- Fun.prototype.isInt = function () {
- return (/^\-?\d+$/).test(this.name);
- };
- Fun.prototype.isFloat = function () {
- return (/^\-?\d*(\.\d*)?$/).test(this.name) && this.name != '.' && this.name != '-.';
- };
- Fun.prototype.isEqual = function (obj) {
- if (this.name != obj.name)
- return false;
- for (var i in this.args) {
- if (!this.args[i].isEqual(obj.args[i]))
- return false;
- }
- return true;
- };
- return Fun;
-}());
-var GFAbstract = (function () {
- function GFAbstract(startcat, types) {
- this.startcat = startcat;
- this.types = types;
- }
- GFAbstract.prototype.addType = function (fun, args, cat) {
- this.types[fun] = new Type(args, cat);
- };
- GFAbstract.prototype.getArgs = function (fun) {
- return this.types[fun].args;
- };
- GFAbstract.prototype.getCat = function (fun) {
- return this.types[fun].cat;
- };
- GFAbstract.prototype.annotate = function (tree, type) {
- var typ = this.types[tree.name];
- if (tree.isMeta()) {
- tree.type = type;
- }
- else if (!isUndefined(typ)) {
- for (var i in tree.args) {
- this.annotate(tree.args[i], typ.args[i]);
- }
- }
- return tree;
- };
- GFAbstract.prototype.handleLiterals = function (tree, type) {
- if (tree.name != '?') {
- if (type == 'String' || type == 'Int' || type == 'Float') {
- tree.name = type + '_Literal_' + tree.name;
- }
- else {
- var typ = this.types[tree.name];
- for (var i in tree.args) {
- this.handleLiterals(tree.args[i], typ.args[i]);
- }
- }
- }
- return tree;
- };
- GFAbstract.prototype.copyTree = function (x) {
- var t = new Fun(x.name);
- if (!isUndefined(x.type)) {
- t.type = x.type;
- }
- var cs = x.args;
- if (!isUndefined(cs)) {
- for (var i = 0; i < cs.length; i++) {
- t.setArg(i, this.copyTree(cs[i]));
- }
- }
- return t;
- };
- GFAbstract.prototype.parseTree = function (str, type) {
- var pt = this.parseTree_(str.match(/[\w\u00C0-\u00FF\'\.\"]+|\(|\)|\?|\:/g) || [], 0);
- return pt ? this.annotate(pt, type) : null;
- };
- GFAbstract.prototype.parseTree_ = function (tokens, prec) {
- if (tokens.length == 0 || tokens[0] == ')') {
- return null;
- }
- var t = tokens.shift();
- if (!t)
- return null;
- if (t == '(') {
- var tree = this.parseTree_(tokens, 0);
- tokens.shift();
- return tree;
- }
- else if (t == '?') {
- return new Fun('?');
- }
- else {
- var tree = new Fun(t);
- if (prec == 0) {
- var c = void 0;
- var i = void 0;
- for (i = 0; (c = this.parseTree_(tokens, 1)) !== null; i++) {
- tree.setArg(i, c);
- }
- }
- return tree;
- }
- };
- return GFAbstract;
-}());
-var Type = (function () {
- function Type(args, cat) {
- this.args = args;
- this.cat = cat;
- }
- return Type;
-}());
-var GFConcrete = (function () {
- function GFConcrete(flags, productions, functions, sequences, startCats, totalFIds) {
- this.flags = flags;
- this.functions = functions;
- this.startCats = startCats;
- this.totalFIds = totalFIds;
- this.pproductions = productions;
- this.lproductions = {};
- var _loop_1 = function (fid0) {
- var fid = parseInt(fid0);
- var _loop_2 = function (i) {
- var rule = productions[fid][i];
- if (rule.id == 'Apply') {
- rule = rule;
- var fun_1 = this_1.functions[rule.fun];
- var lproductions_1 = this_1.lproductions;
- rule.fun = fun_1;
- var register_1 = function (args, key, i) {
- if (i < args.length) {
- var c = 0;
- var arg = args[i].fid;
- for (var k in productions[arg]) {
- var rule_1 = productions[arg][k];
- if (rule_1.id == 'Coerce') {
- rule_1 = rule_1;
- register_1(args, key + '_' + rule_1.arg, i + 1);
- c++;
- }
- }
- if (c == 0) {
- register_1(args, key + '_' + arg, i + 1);
- }
- }
- else {
- var set = lproductions_1[key];
- if (set == null) {
- set = [];
- lproductions_1[key] = set;
- }
- set.push({ fun: fun_1, fid: fid });
- }
- };
- register_1(rule.args, rule.fun.name, 0);
- }
- };
- for (var i in productions[fid]) {
- _loop_2(i);
- }
- };
- var this_1 = this;
- for (var fid0 in productions) {
- _loop_1(fid0);
- }
- for (var _i = 0, functions_1 = functions; _i < functions_1.length; _i++) {
- var fun = functions_1[_i];
- for (var j in fun.lins) {
- fun.lins[j] = sequences[fun.lins[j]];
- }
- }
- }
- GFConcrete.prototype.linearizeSyms = function (tree, tag) {
- var res = [];
- if (tree.isString()) {
- var sym = new SymKS(tree.name);
- sym.tag = tag;
- res.push({ fid: -1, table: [[sym]] });
- }
- else if (tree.isInt()) {
- var sym = new SymKS(tree.name);
- sym.tag = tag;
- res.push({ fid: -2, table: [[sym]] });
- }
- else if (tree.isFloat()) {
- var sym = new SymKS(tree.name);
- sym.tag = tag;
- res.push({ fid: -3, table: [[sym]] });
- }
- else if (tree.isMeta()) {
- var cat = this.startCats[tree.type];
- var sym = new SymKS(tree.name);
- sym.tag = tag;
- for (var fid = cat.s; fid <= cat.e; fid++) {
- res.push({ fid: fid, table: [[sym]] });
- }
- }
- else {
- var cs_1 = [];
- for (var i in tree.args) {
- cs_1.push(this.linearizeSyms(tree.args[i], tag + '-' + i)[0]);
- }
- var key = tree.name;
- for (var i in cs_1) {
- if (isUndefined(cs_1[i])) {
- console.warn(tree.args[i].name + " is undefined");
- return [{
- fid: -5,
- table: [[new SymKS("[" + tree.name + "]").tagWith(tag)]]
- }];
- }
- else if (cs_1[i].fid === -5) {
- for (var k in this.lproductions) {
- if (k.includes(tree.name)) {
- key = k;
- break;
- }
- }
- break;
- }
- else {
- key = key + '_' + cs_1[i].fid;
- }
- }
- for (var i in this.lproductions[key]) {
- var rule = this.lproductions[key][i];
- var row = {
- fid: rule.fid,
- table: []
- };
- var _loop_3 = function (j) {
- var lin = rule.fun.lins[j];
- var toks = [];
- row.table[j] = toks;
- lin.forEach(function (sym0) {
- switch (sym0.id) {
- case 'Arg':
- case 'Lit': {
- var sym = sym0;
- var ts = cs_1[sym.i].table[sym.label];
- for (var l in ts) {
- toks.push(ts[l]);
- }
- break;
- }
- case 'KS':
- case 'KP': {
- var sym = sym0;
- toks.push(sym.tagWith(tag));
- break;
- }
- }
- });
- };
- for (var j in rule.fun.lins) {
- _loop_3(j);
- }
- res.push(row);
- }
- }
- return res;
- };
- GFConcrete.prototype.syms2toks = function (syms) {
- var ts = [];
- var _loop_4 = function (i) {
- var sym0 = syms[i];
- switch (sym0.id) {
- case 'KS': {
- var sym = sym0;
- for (var j in sym.tokens) {
- ts.push(new TaggedString(sym.tokens[j], sym.tag));
- }
- break;
- }
- case 'KP': {
- var sym_1 = sym0;
- var addedAlt_1 = false;
- if (i < syms.length - 1) {
- var nextSym = syms[i + 1];
- if (nextSym.id == 'KS') {
- var nextToken_1 = nextSym.tokens[0];
- sym_1.alts.forEach(function (alt) {
- if (alt.prefixes.some(function (p) { return nextToken_1.startsWith(p); })) {
- alt.tokens.forEach(function (symks) {
- symks.tokens.forEach(function (t) {
- ts.push(new TaggedString(t, sym_1.tag));
- });
- });
- addedAlt_1 = true;
- return;
- }
- });
- }
- }
- if (addedAlt_1)
- break;
- sym_1.tokens.forEach(function (symks) {
- symks.tokens.forEach(function (t) {
- ts.push(new TaggedString(t, sym_1.tag));
- });
- });
- break;
- }
- }
- };
- for (var i = 0; i < syms.length; i++) {
- _loop_4(i);
- }
- return ts;
- };
- GFConcrete.prototype.linearizeAll = function (tree) {
- var _this = this;
- return this.linearizeSyms(tree, '0').map(function (r) {
- return _this.unlex(_this.syms2toks(r.table[0]));
- });
- };
- GFConcrete.prototype.linearize = function (tree) {
- var res = this.linearizeSyms(tree, '0');
- if (res.length > 0)
- return this.unlex(this.syms2toks(res[0].table[0]));
- else
- return '';
- };
- GFConcrete.prototype.tagAndLinearize = function (tree) {
- var res = this.linearizeSyms(tree, '0');
- if (res.length > 0)
- return this.syms2toks(res[0].table[0]);
- else
- return [];
- };
- GFConcrete.prototype.unlex = function (ts) {
- if (ts.length == 0) {
- return '';
- }
- var noSpaceAfter = /^[\(\-\[]/;
- var noSpaceBefore = /^[\.\,\?\!\)\:\;\-\]]/;
- var s = '';
- for (var i = 0; i < ts.length; i++) {
- var t = ts[i].s;
- var after = i < ts.length - 1 ? ts[i + 1].s : null;
- s += t;
- if (after != null
- && !t.match(noSpaceAfter)
- && !after.match(noSpaceBefore)) {
- s += ' ';
- }
- }
- return s;
- };
- GFConcrete.prototype.tokenize = function (string) {
- var inToken = false;
- var start = 0;
- var end;
- var tokens = [];
- var i;
- for (i = 0; i < string.length; i++) {
- if (string.charAt(i) == ' '
- || string.charAt(i) == '\f'
- || string.charAt(i) == '\n'
- || string.charAt(i) == '\r'
- || string.charAt(i) == '\t'
- || string.charAt(i) == '\v'
- || string.charAt(i) == String.fromCharCode(160)) {
- if (inToken) {
- end = i - 1;
- inToken = false;
- tokens.push(string.substr(start, end - start + 1));
- }
- }
- else {
- if (!inToken) {
- start = i;
- inToken = true;
- }
- }
- }
- if (inToken) {
- end = i - 1;
- inToken = false;
- tokens.push(string.substr(start, end - start + 1));
- }
- return tokens;
- };
- GFConcrete.prototype.parseString = function (string, cat) {
- var tokens = this.tokenize(string);
- var ps = new ParseState(this, cat);
- for (var i in tokens) {
- if (!ps.next(tokens[i]))
- return [];
- }
- return ps.extractTrees();
- };
- GFConcrete.prototype.complete = function (input, cat) {
- if (input == null)
- input = '';
- var tokens = input.trim().split(' ');
- for (var i = tokens.length - 1; i >= 0; i--) {
- if (tokens[i] == '') {
- tokens.splice(i, 1);
- }
- }
- var current = tokens.pop();
- if (current == null)
- current = '';
- var ps = new ParseState(this, cat);
- var ps2 = new ParseState(this, cat);
- for (var i = 0; i < tokens.length; i++) {
- if (!ps.next(tokens[i])) {
- return { 'consumed': [], 'suggestions': [] };
- }
- ps2.next(tokens[i]);
- }
- if (ps2.next(current)) {
- ps.next(current);
- tokens.push(current);
- current = '';
- }
- var acc = ps.complete(current);
- var suggs = [];
- if (acc.value) {
- acc.value.forEach(function (a) {
- a.seq.forEach(function (s) {
- switch (s.id) {
- case 'KS': {
- s.tokens.forEach(function (t) {
- suggs.push(t);
- });
- break;
- }
- case 'KP': {
- s.tokens.forEach(function (symks) {
- symks.tokens.forEach(function (t) {
- suggs.push(t);
- });
- });
- break;
- }
- }
- });
- });
- }
- return { 'consumed': tokens, 'suggestions': suggs };
- };
- return GFConcrete;
-}());
-var TaggedString = (function () {
- function TaggedString(s, tag) {
- this.s = s;
- this.tag = tag;
- }
- return TaggedString;
-}());
-var Apply = (function () {
- function Apply(fun, args) {
- this.id = 'Apply';
- this.fun = fun;
- this.args = args;
- }
- Apply.prototype.show = function (cat) {
- var recStr = [];
- recStr.push(cat, ' -> ', this.fun.name, ' [', this.args, ']');
- return recStr.join('');
- };
- Apply.prototype.isEqual = function (obj) {
- if (this.id != obj.id || this.fun != obj.fun || this.args.length != obj.args.length)
- return false;
- for (var i in this.args) {
- if (this.args[i] != obj.args[i])
- return false;
- }
- return true;
- };
- return Apply;
-}());
-var Coerce = (function () {
- function Coerce(arg) {
- this.id = 'Coerce';
- this.arg = arg;
- }
- Coerce.prototype.show = function (cat) {
- var recStr = [];
- recStr.push(cat, ' -> _ [', this.arg, ']');
- return recStr.join('');
- };
- return Coerce;
-}());
-var PArg = (function () {
- function PArg() {
- var hypos = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- hypos[_i] = arguments[_i];
- }
- this.fid = hypos[hypos.length - 1];
- if (hypos.length > 1)
- this.hypos = hypos.slice(0, hypos.length - 1);
- else
- this.hypos = [];
- }
- return PArg;
-}());
-var Const = (function () {
- function Const(lit, toks) {
- this.id = 'Const';
- this.lit = lit;
- this.toks = toks;
- }
- Const.prototype.show = function (cat) {
- var recStr = [];
- recStr.push(cat, ' -> ', this.lit.print());
- return recStr.join('');
- };
- Const.prototype.isEqual = function (obj) {
- if (this.id != obj.id || this.lit.isEqual(obj.lit) || this.toks.length != obj.toks.length)
- return false;
- for (var i in this.toks) {
- if (this.toks[i] != obj.toks[i])
- return false;
- }
- return true;
- };
- return Const;
-}());
-var CncFun = (function () {
- function CncFun(name, lins) {
- this.name = name;
- this.lins = lins;
- }
- return CncFun;
-}());
-var SymCat = (function () {
- function SymCat(i, label) {
- this.id = 'Arg';
- this.i = i;
- this.label = label;
- }
- SymCat.prototype.show = function () {
- var argStr = [];
- argStr.push(this.i, this.label);
- return argStr.join('.');
- };
- return SymCat;
-}());
-var SymKS = (function () {
- function SymKS() {
- var tokens = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- tokens[_i] = arguments[_i];
- }
- this.id = 'KS';
- this.tokens = tokens;
- }
- SymKS.prototype.show = function () {
- var terminalStr = [];
- terminalStr.push('"', this.tokens, '"');
- return terminalStr.join('');
- };
- SymKS.prototype.tagWith = function (tag) {
- var s = new SymKS();
- s.tokens = this.tokens.slice();
- s.tag = tag;
- return s;
- };
- return SymKS;
-}());
-var SymKP = (function () {
- function SymKP(tokens, alts) {
- this.id = 'KP';
- this.tokens = tokens;
- this.alts = alts;
- }
- SymKP.prototype.show = function () {
- var terminalStr = [];
- terminalStr.push('"', this.tokens, '"');
- return terminalStr.join('');
- };
- SymKP.prototype.tagWith = function (tag) {
- var s = new SymKP(this.tokens.slice(), this.alts.slice());
- s.tag = tag;
- return s;
- };
- return SymKP;
-}());
-var Alt = (function () {
- function Alt(tokens, prefixes) {
- this.tokens = tokens;
- this.prefixes = prefixes;
- }
- return Alt;
-}());
-var SymLit = (function () {
- function SymLit(i, label) {
- this.id = 'Lit';
- this.i = i;
- this.label = label;
- }
- SymLit.prototype.getId = function () {
- return this.id;
- };
- SymLit.prototype.show = function () {
- var argStr = [];
- argStr.push(this.i, this.label);
- return argStr.join('.');
- };
- return SymLit;
-}());
-var Trie = (function () {
- function Trie() {
- this.value = null;
- this.items = {};
- }
- Trie.prototype.insertChain = function (keys, obj) {
- var node = this;
- keys.forEach(function (key) {
- var nnode = node.items[key];
- if (nnode == null) {
- nnode = new Trie();
- node.items[key] = nnode;
- }
- node = nnode;
- });
- node.value = obj;
- };
- Trie.prototype.insertChain1 = function (keys, obj) {
- var node = this;
- keys.forEach(function (key) {
- var nnode = node.items[key];
- if (nnode == null) {
- nnode = new Trie();
- node.items[key] = nnode;
- }
- node = nnode;
- });
- if (node.value == null)
- node.value = [obj];
- else
- node.value.push(obj);
- };
- Trie.prototype.lookup = function (key) {
- return this.items[key];
- };
- Trie.prototype.isEmpty = function () {
- if (this.value != null)
- return false;
- for (var _ in this.items) {
- return false;
- }
- return true;
- };
- return Trie;
-}());
-var ParseState = (function () {
- function ParseState(concrete, startCat) {
- this.concrete = concrete;
- this.startCat = startCat;
- this.items = new Trie();
- this.chart = new Chart(concrete);
- var items = [];
- var fids = concrete.startCats[startCat];
- if (fids != null) {
- var fid = void 0;
- for (fid = fids.s; fid <= fids.e; fid++) {
- var exProds = this.chart.expandForest(fid);
- for (var j in exProds) {
- var rule = exProds[j];
- var fun = rule.fun;
- for (var lbl in fun.lins) {
- items.push(new ActiveItem(0, 0, rule.fun, fun.lins[lbl], rule.args, fid, parseInt(lbl)));
- }
- }
- }
- }
- this.items.insertChain([], items);
- }
- ParseState.prototype.next = function (token) {
- var acc = this.items.lookup(token);
- if (acc == null) {
- acc = new Trie();
- }
- this.process(this.items.value, function (fid) {
- switch (fid) {
- case -1:
- return new Const(new Fun('"' + token + '"'), [token]);
- case -2: {
- var x = parseInt(token, 10);
- if (token == '0' || (x != 0 && !isNaN(x)))
- return new Const(new Fun(token), [token]);
- else
- return null;
- }
- case -3: {
- var x = parseFloat(token);
- if (token == '0' || token == '0.0' || (x != 0 && !isNaN(x)))
- return new Const(new Fun(token), [token]);
- else
- return null;
- }
- }
- return null;
- }, function (tokens, item) {
- if (tokens[0] == token) {
- var tokens1 = [];
- for (var i = 1; i < tokens.length; i++) {
- tokens1[i - 1] = tokens[i];
- }
- acc.insertChain1(tokens1, item);
- }
- });
- this.items = acc;
- this.chart.shift();
- return !this.items.isEmpty();
- };
- ParseState.prototype.complete = function (currentToken) {
- var acc = this.items.lookup(currentToken);
- if (acc == null)
- acc = new Trie();
- this.process(this.items.value, function (_fid) {
- return null;
- }, function (tokens, item) {
- if (currentToken == '' || tokens[0].indexOf(currentToken) == 0) {
- var tokens1 = [];
- for (var i = 1; i < tokens.length; i++) {
- tokens1[i - 1] = tokens[i];
- }
- acc.insertChain1(tokens1, item);
- }
- });
- return acc;
- };
- ParseState.prototype.extractTrees = function () {
- this.process(this.items.value, function (_fid) {
- return null;
- }, function (_tokens, _item) {
- });
- var totalFIds = this.concrete.totalFIds;
- var forest = this.chart.forest;
- function go(fid) {
- if (fid < totalFIds) {
- return [new Fun('?')];
- }
- else {
- var trees_1 = [];
- var rules = forest[fid];
- for (var j in rules) {
- var rule = rules[j];
- if (rule.id == 'Const') {
- trees_1.push(rule.lit);
- }
- else {
- rule = rule;
- var arg_ix = [];
- var arg_ts = [];
- for (var k in rule.args) {
- arg_ix[k] = 0;
- arg_ts[k] = go(rule.args[k].fid);
- }
- while (true) {
- var t = new Fun(rule.fun.name);
- for (var k = 0; k < arg_ts.length; k++) {
- t.setArg(k, arg_ts[k][arg_ix[k]]);
- }
- trees_1.push(t);
- var i = 0;
- while (i < arg_ts.length) {
- arg_ix[i]++;
- if (arg_ix[i] < arg_ts[i].length)
- break;
- arg_ix[i] = 0;
- i++;
- }
- if (i >= arg_ts.length)
- break;
- }
- }
- }
- return trees_1;
- }
- }
- var trees = [];
- var fids = this.concrete.startCats[this.startCat];
- if (fids != null) {
- var _loop_5 = function (fid0) {
- var labels = {};
- var rules = this_2.chart.expandForest(fid0);
- rules.forEach(function (rule) {
- for (var lbl in rule.fun.lins) {
- labels[lbl] = true;
- }
- });
- for (var lbl0 in labels) {
- var lbl = parseInt(lbl0);
- var fid = this_2.chart.lookupPC(fid0, lbl, 0);
- var arg_ts = go(fid);
- for (var i in arg_ts) {
- var isMember = false;
- for (var j in trees) {
- if (arg_ts[i].isEqual(trees[j])) {
- isMember = true;
- break;
- }
- }
- if (!isMember)
- trees.push(arg_ts[i]);
- }
- }
- };
- var this_2 = this;
- for (var fid0 = fids.s; fid0 <= fids.e; fid0++) {
- _loop_5(fid0);
- }
- }
- return trees;
- };
- ParseState.prototype.process = function (agenda, literalCallback, tokenCallback) {
- if (agenda != null) {
- var _loop_6 = function () {
- var item = agenda.pop();
- var lin = item.seq;
- if (item.dot < lin.length) {
- var sym0 = lin[item.dot];
- switch (sym0.id) {
- case 'Arg': {
- var sym = sym0;
- var fid = item.args[sym.i].fid;
- var label = sym.label;
- var items = this_3.chart.lookupAC(fid, label);
- if (items == null) {
- var rules = this_3.chart.expandForest(fid);
- for (var j in rules) {
- var rule = rules[j];
- agenda.push(new ActiveItem(this_3.chart.offset, 0, rule.fun, rule.fun.lins[label], rule.args, fid, label));
- }
- this_3.chart.insertAC(fid, label, [item]);
- }
- else {
- var isMember = false;
- for (var j in items) {
- if (items[j].isEqual(item)) {
- isMember = true;
- break;
- }
- }
- if (!isMember) {
- items.push(item);
- var fid2 = this_3.chart.lookupPC(fid, label, this_3.chart.offset);
- if (fid2 != null) {
- agenda.push(item.shiftOverArg(sym.i, fid2));
- }
- }
- }
- break;
- }
- case 'KS': {
- var sym = sym0;
- tokenCallback(sym.tokens, item.shiftOverTokn());
- break;
- }
- case 'KP': {
- var sym = sym0;
- var pitem_1 = item.shiftOverTokn();
- sym.tokens.forEach(function (symks) {
- tokenCallback(symks.tokens, pitem_1);
- });
- sym.alts.forEach(function (alt) {
- alt.tokens.forEach(function (symks) {
- tokenCallback(symks.tokens, pitem_1);
- });
- });
- break;
- }
- case 'Lit': {
- var sym = sym0;
- var fid = item.args[sym.i].fid;
- var rules = this_3.chart.forest[fid];
- if (rules != null) {
- tokenCallback(rules[0].toks, item.shiftOverTokn());
- }
- else {
- var rule = literalCallback(fid);
- if (rule != null) {
- fid = this_3.chart.nextId++;
- this_3.chart.forest[fid] = [rule];
- tokenCallback(rule.toks, item.shiftOverArg(sym.i, fid));
- }
- }
- break;
- }
- }
- }
- else {
- var fid_1 = this_3.chart.lookupPC(item.fid, item.lbl, item.offset);
- if (fid_1 == null) {
- fid_1 = this_3.chart.nextId++;
- var items = this_3.chart.lookupACo(item.offset, item.fid, item.lbl);
- if (items != null) {
- items.forEach(function (pitem) {
- var i = pitem.seq[pitem.dot].i;
- agenda.push(pitem.shiftOverArg(i, fid_1));
- });
- }
- this_3.chart.insertPC(item.fid, item.lbl, item.offset, fid_1);
- this_3.chart.forest[fid_1] = [new Apply(item.fun, item.args)];
- }
- else {
- var labels = this_3.chart.labelsAC(fid_1);
- if (labels != null) {
- for (var lbl in labels) {
- agenda.push(new ActiveItem(this_3.chart.offset, 0, item.fun, item.fun.lins[lbl], item.args, fid_1, parseInt(lbl)));
- }
- }
- var rules = this_3.chart.forest[fid_1];
- var rule_2 = new Apply(item.fun, item.args);
- var isMember_1 = false;
- rules.forEach(function (rule1) {
- if (rule1.isEqual(rule_2))
- isMember_1 = true;
- });
- if (!isMember_1)
- rules.push(rule_2);
- }
- }
- };
- var this_3 = this;
- while (agenda.length > 0) {
- _loop_6();
- }
- }
- };
- return ParseState;
-}());
-var Chart = (function () {
- function Chart(concrete) {
- this.active = {};
- this.actives = [];
- this.passive = {};
- this.forest = {};
- this.nextId = concrete.totalFIds;
- this.offset = 0;
- for (var fid in concrete.pproductions) {
- this.forest[fid] = concrete.pproductions[fid];
- }
- }
- Chart.prototype.lookupAC = function (fid, label) {
- var tmp = this.active[fid];
- if (tmp == null)
- return null;
- return tmp[label];
- };
- Chart.prototype.lookupACo = function (offset, fid, label) {
- var tmp;
- if (offset == this.offset)
- tmp = this.active[fid];
- else
- tmp = this.actives[offset][fid];
- if (tmp == null)
- return null;
- return tmp[label];
- };
- Chart.prototype.labelsAC = function (fid) {
- return this.active[fid];
- };
- Chart.prototype.insertAC = function (fid, label, items) {
- var tmp = this.active[fid];
- if (tmp == null) {
- tmp = {};
- this.active[fid] = tmp;
- }
- tmp[label] = items;
- };
- Chart.prototype.lookupPC = function (fid, label, offset) {
- var key = fid + '.' + label + '-' + offset;
- return this.passive[key];
- };
- Chart.prototype.insertPC = function (fid1, label, offset, fid2) {
- var key = fid1 + '.' + label + '-' + offset;
- this.passive[key] = fid2;
- };
- Chart.prototype.shift = function () {
- this.actives.push(this.active);
- this.active = {};
- this.passive = {};
- this.offset++;
- };
- Chart.prototype.expandForest = function (fid) {
- var rules = [];
- var forest = this.forest;
- var go = function (rules0) {
- for (var i in rules0) {
- var rule = rules0[i];
- switch (rule.id) {
- case 'Apply':
- rules.push(rule);
- break;
- case 'Coerce':
- go(forest[rule.arg]);
- break;
- }
- }
- };
- go(this.forest[fid]);
- return rules;
- };
- return Chart;
-}());
-var ActiveItem = (function () {
- function ActiveItem(offset, dot, fun, seq, args, fid, lbl) {
- this.offset = offset;
- this.dot = dot;
- this.fun = fun;
- this.seq = seq;
- this.args = args;
- this.fid = fid;
- this.lbl = lbl;
- }
- ActiveItem.prototype.isEqual = function (obj) {
- return (this.offset == obj.offset &&
- this.dot == obj.dot &&
- this.fun == obj.fun &&
- this.seq == obj.seq &&
- this.args == obj.args &&
- this.fid == obj.fid &&
- this.lbl == obj.lbl);
- };
- ActiveItem.prototype.shiftOverArg = function (i, fid) {
- var nargs = [];
- for (var k in this.args) {
- nargs[k] = this.args[k];
- }
- nargs[i] = new PArg(fid);
- return new ActiveItem(this.offset, this.dot + 1, this.fun, this.seq, nargs, this.fid, this.lbl);
- };
- ActiveItem.prototype.shiftOverTokn = function () {
- return new ActiveItem(this.offset, this.dot + 1, this.fun, this.seq, this.args, this.fid, this.lbl);
- };
- return ActiveItem;
-}());
-function isUndefined(a) {
- return typeof a == 'undefined';
-}
-if (!String.prototype.startsWith) {
- Object.defineProperty(String.prototype, 'startsWith', {
- value: function (search, pos) {
- pos = !pos || pos < 0 ? 0 : +pos;
- return this.substring(pos, pos + search.length) === search;
- }
- });
-}
-if (!String.prototype.includes) {
- Object.defineProperty(String.prototype, 'includes', {
- value: function (search, start) {
- 'use strict';
- if (typeof start !== 'number') {
- start = 0;
- }
- if (start + search.length > this.length) {
- return false;
- }
- else {
- return this.indexOf(search, start) !== -1;
- }
- }
- });
-}
-//# sourceMappingURL=gflib.js.map
\ No newline at end of file
diff --git a/src/runtime/typescript/js/gflib.js.map b/src/runtime/typescript/js/gflib.js.map
deleted file mode 100644
index fbc04aca3..000000000
--- a/src/runtime/typescript/js/gflib.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"gflib.js","sourceRoot":"","sources":["../gflib.ts"],"names":[],"mappings":";AAWA;IAIE,mBAAmB,QAAoB,EAAE,SAAsC;QAC7E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,6BAAS,GAAhB,UACE,KAAa,EACb,QAAgB,EAChB,MAAc;QAEd,IAAI,OAAO,GAA+C,EAAE,CAAA;QAC5D,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAC9B,IAAI,QAAQ,EAAE;YACZ,SAAS,GAAG,EAAE,CAAA;YACd,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;SAC/C;QACD,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAA;QAC5B,IAAI,MAAM,EAAE;YACV,OAAO,GAAG,EAAE,CAAA;YACZ,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;SACzC;QACD,KAAK,IAAI,EAA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,EAAE;gBAC7B,KAAK,GAAG,CAAC,CAAA;aACV;YAED,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE;gBACvC,OAAO,KAAK,CAAA;aACb;iBAAM;gBACL,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;aAC1C;QACH,CAAC;KACF,CAAC,CAAA;CACH"}
\ No newline at end of file
diff --git a/src/runtime/typescript/tsconfig.json b/src/runtime/typescript/tsconfig.json
deleted file mode 100644
index 2b2a77099..000000000
--- a/src/runtime/typescript/tsconfig.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "compilerOptions": {
- "module": "none",
- "target": "es3",
- "strict": true,
- "noImplicitAny": true,
- "removeComments": true,
- "outDir": "js",
- "sourceMap": true
- },
- "compileOnSave": true
-}
diff --git a/src/www/minibar/about.html b/src/www/minibar/about.html
index 7c127fe5f..87df72e00 100644
--- a/src/www/minibar/about.html
+++ b/src/www/minibar/about.html
@@ -10,8 +10,10 @@
+
+
Minibar is an alternative implementation of the
GF web app
Fridge Poetry.
@@ -233,14 +235,23 @@ Some implementation details:
category names.
[Added 2013-04-02] Minibar now remembers from one visit to the next
the selected set of target languages for each grammar.
+ [Added 2019-08-05] Minibar can now display grammar documentation.
+ The documentation is taken from a file called
+ Grammar.pgf_info, located
+ next to the Grammar.pgf 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 More info button (or the i button). The documentation
+ can contain HTML markup. Blank lines are treated as paragraph breaks.
-
+
+