mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Update TypeScript definitions for gflib.js
Still not 100% tested: best solution will really be to rewrite gflib.js in TypeScript and at the same time use ES modules
This commit is contained in:
44
src/runtime/typescript/gflib.d.ts
vendored
44
src/runtime/typescript/gflib.d.ts
vendored
@@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* gflib.dt.s
|
* gflib.d.ts
|
||||||
*
|
*
|
||||||
* by John J. Camilleri
|
* by John J. Camilleri
|
||||||
*
|
*
|
||||||
* TypeScript type definitions for the "original" JS GF runtime (GF:src/runtime/javascript/gflib.js)
|
* TypeScript type definitions for the pure JavaScript runtime (/src/runtime/javascript/gflib.js)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Note: the String prototype is extended with:
|
// Note: the String prototype is extended with:
|
||||||
@@ -86,7 +86,7 @@ declare class GFConcrete {
|
|||||||
flags: {[key: string]: string}
|
flags: {[key: string]: string}
|
||||||
productions: {[key: number]: ApplyOrCoerce[]}
|
productions: {[key: number]: ApplyOrCoerce[]}
|
||||||
functions: CncFun[]
|
functions: CncFun[]
|
||||||
sequences: Array<Array<Sym>>
|
sequences: Sym[][]
|
||||||
startCats: {[key: string]: {s: number, e: number}}
|
startCats: {[key: string]: {s: number, e: number}}
|
||||||
totalFIds: number
|
totalFIds: number
|
||||||
pproductions: {[key: number]: ApplyOrCoerce[]}
|
pproductions: {[key: number]: ApplyOrCoerce[]}
|
||||||
@@ -96,12 +96,12 @@ declare class GFConcrete {
|
|||||||
flags: {[key: string]: string},
|
flags: {[key: string]: string},
|
||||||
productions: {[key: number]: ApplyOrCoerce[]},
|
productions: {[key: number]: ApplyOrCoerce[]},
|
||||||
functions: CncFun[],
|
functions: CncFun[],
|
||||||
sequences: Array<Array<Sym>>,
|
sequences: Sym[][],
|
||||||
startCats: {[key: string]: {s: number, e: number}},
|
startCats: {[key: string]: {s: number, e: number}},
|
||||||
totalFIds: number
|
totalFIds: number
|
||||||
)
|
)
|
||||||
|
|
||||||
linearizeSyms(tree: Fun, tag: string): Array<{fid: FId, table: any}>
|
linearizeSyms(tree: Fun, tag: string): {fid: FId, table: any}[]
|
||||||
syms2toks(syms: Sym[]): string[]
|
syms2toks(syms: Sym[]): string[]
|
||||||
linearizeAll(tree: Fun): string[]
|
linearizeAll(tree: Fun): string[]
|
||||||
linearize(tree: Fun): string
|
linearize(tree: Fun): string
|
||||||
@@ -257,9 +257,9 @@ declare class Trie {
|
|||||||
value: any
|
value: any
|
||||||
items: Trie[]
|
items: Trie[]
|
||||||
|
|
||||||
insertChain(keys, obj): void
|
insertChain(keys: string[], obj: any): void
|
||||||
insertChain1(keys, obj): void
|
insertChain1(keys: string[], obj: any): void
|
||||||
lookup(key, obj): any
|
lookup(key: string, obj: any): any
|
||||||
isEmpty(): boolean
|
isEmpty(): boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ declare class ParseState {
|
|||||||
complete(correntToken: string): Trie
|
complete(correntToken: string): Trie
|
||||||
extractTrees(): any[]
|
extractTrees(): any[]
|
||||||
process(
|
process(
|
||||||
agenda,
|
agenda: ActiveItem[],
|
||||||
literalCallback: (fid: FId) => any,
|
literalCallback: (fid: FId) => any,
|
||||||
tokenCallback: (tokens: string[], item: any) => any
|
tokenCallback: (tokens: string[], item: any) => any
|
||||||
): void
|
): void
|
||||||
@@ -288,25 +288,25 @@ declare class ParseState {
|
|||||||
* Chart
|
* Chart
|
||||||
*/
|
*/
|
||||||
declare class Chart {
|
declare class Chart {
|
||||||
active: any
|
active: {[key: number]: ActiveItem} // key: FId
|
||||||
actives: {[key: number]: any}
|
actives: {[key: number]: ActiveItem}[] // key: FId
|
||||||
passive: any
|
passive: {[key: string]: FId}
|
||||||
forest: {[key: number]: ApplyOrCoerce[]}
|
forest: {[key: number]: ApplyOrCoerce[]} // key: FId
|
||||||
nextId: number
|
nextId: number
|
||||||
offset: number
|
offset: number
|
||||||
|
|
||||||
constructor(concrete: GFConcrete)
|
constructor(concrete: GFConcrete)
|
||||||
|
|
||||||
lookupAC(fid: FId,label)
|
lookupAC(fid: FId, label: number): ActiveItem[]
|
||||||
lookupACo(offset, fid: FId, label)
|
lookupACo(offset: number, fid: FId, label: number): ActiveItem[]
|
||||||
|
|
||||||
labelsAC(fid: FId)
|
labelsAC(fid: FId): ActiveItem
|
||||||
insertAC(fid: FId, label, items): void
|
insertAC(fid: FId, label: number, items: any[]): void
|
||||||
|
|
||||||
lookupPC(fid: FId, label, offset)
|
lookupPC(fid: FId, label: number, offset: number): FId
|
||||||
insertPC(fid1: FId, label, offset, fid2: FId): void
|
insertPC(fid1: FId, label: number, offset: number, fid2: FId): void
|
||||||
shift(): void
|
shift(): void
|
||||||
expandForest(fid: FId): any[]
|
expandForest(fid: FId): Apply[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,7 +316,7 @@ declare class ActiveItem {
|
|||||||
offset: number
|
offset: number
|
||||||
dot: number
|
dot: number
|
||||||
fun: CncFun
|
fun: CncFun
|
||||||
seq: Array<Sym>
|
seq: Sym[]
|
||||||
args: PArg[]
|
args: PArg[]
|
||||||
fid: FId
|
fid: FId
|
||||||
lbl: number
|
lbl: number
|
||||||
@@ -325,7 +325,7 @@ declare class ActiveItem {
|
|||||||
offset: number,
|
offset: number,
|
||||||
dot: number,
|
dot: number,
|
||||||
fun: CncFun,
|
fun: CncFun,
|
||||||
seq: Array<Sym>,
|
seq: Sym[],
|
||||||
args: PArg[],
|
args: PArg[],
|
||||||
fid: FId,
|
fid: FId,
|
||||||
lbl: number
|
lbl: number
|
||||||
|
|||||||
Reference in New Issue
Block a user