mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
More type fixes in gflib.ts after setting noImplicitAny
This commit is contained in:
@@ -30,8 +30,8 @@ export class GFGrammar {
|
|||||||
input: string,
|
input: string,
|
||||||
fromLang: string,
|
fromLang: string,
|
||||||
toLang: string
|
toLang: string
|
||||||
): {[key: string]: {[key: string]: string}} {
|
): {[key: string]: {[key: string]: string}[]} {
|
||||||
let outputs = {}
|
let outputs: {[key: string]: {[key: string]: string}[]} = {}
|
||||||
let fromConcs = this.concretes
|
let fromConcs = this.concretes
|
||||||
if (fromLang) {
|
if (fromLang) {
|
||||||
fromConcs = {}
|
fromConcs = {}
|
||||||
@@ -48,7 +48,7 @@ export class GFGrammar {
|
|||||||
if (trees.length > 0) {
|
if (trees.length > 0) {
|
||||||
outputs[c1] = []
|
outputs[c1] = []
|
||||||
for (let i in trees) {
|
for (let i in trees) {
|
||||||
outputs[c1][i] = new Object()
|
outputs[c1][i] = {}
|
||||||
for (let c2 in toConcs) {
|
for (let c2 in toConcs) {
|
||||||
outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i])
|
outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i])
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ class GFConcrete {
|
|||||||
res.push({fid: fid, table: [[sym]]})
|
res.push({fid: fid, table: [[sym]]})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let cs = []
|
let cs: {fid: FId; table: Sym[][]}[] = []
|
||||||
for (let i in tree.args) {
|
for (let i in tree.args) {
|
||||||
// TODO: we should handle the case for nondeterministic linearization
|
// TODO: we should handle the case for nondeterministic linearization
|
||||||
cs.push(this.linearizeSyms(tree.args[i],tag + '-' + i)[0])
|
cs.push(this.linearizeSyms(tree.args[i],tag + '-' + i)[0])
|
||||||
@@ -385,13 +385,13 @@ class GFConcrete {
|
|||||||
|
|
||||||
for (let i in this.lproductions[key]) {
|
for (let i in this.lproductions[key]) {
|
||||||
let rule = this.lproductions[key][i]
|
let rule = this.lproductions[key][i]
|
||||||
let row = {
|
let row: {fid: FId; table: Sym[][]} = {
|
||||||
fid: rule.fid,
|
fid: rule.fid,
|
||||||
table: []
|
table: []
|
||||||
}
|
}
|
||||||
for (let j in rule.fun.lins) {
|
for (let j in rule.fun.lins) {
|
||||||
let lin = rule.fun.lins[j] as Sym[]
|
let lin = rule.fun.lins[j] as Sym[]
|
||||||
let toks = []
|
let toks: Sym[] = []
|
||||||
row.table[j] = toks
|
row.table[j] = toks
|
||||||
|
|
||||||
lin.forEach((sym0: Sym): void => {
|
lin.forEach((sym0: Sym): void => {
|
||||||
@@ -422,7 +422,7 @@ class GFConcrete {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private syms2toks(syms: Sym[]): string[] {
|
private syms2toks(syms: Sym[]): string[] {
|
||||||
let ts = []
|
let ts: string[] = []
|
||||||
syms.forEach((sym0: Sym): void => {
|
syms.forEach((sym0: Sym): void => {
|
||||||
switch (sym0.id) {
|
switch (sym0.id) {
|
||||||
case 'KS': {
|
case 'KS': {
|
||||||
@@ -850,36 +850,36 @@ class SymLit {
|
|||||||
*/
|
*/
|
||||||
class Trie<T> {
|
class Trie<T> {
|
||||||
public value: T[]
|
public value: T[]
|
||||||
private items: Trie<T>[]
|
private items: {[key: string]: Trie<T>}
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
this.value = null
|
this.value = null
|
||||||
this.items = []
|
this.items = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public insertChain(keys: string[], obj: T[]): void {
|
public insertChain(keys: string[], obj: T[]): void {
|
||||||
let node = this
|
let node: Trie<T> = this
|
||||||
for (let i in keys) {
|
keys.forEach((key: string): void => {
|
||||||
let nnode = node.items[keys[i]]
|
let nnode = node.items[key]
|
||||||
if (nnode == null) {
|
if (nnode == null) {
|
||||||
nnode = new Trie()
|
nnode = new Trie()
|
||||||
node.items[keys[i]] = nnode
|
node.items[key] = nnode
|
||||||
}
|
}
|
||||||
node = nnode
|
node = nnode
|
||||||
}
|
})
|
||||||
node.value = obj
|
node.value = obj
|
||||||
}
|
}
|
||||||
|
|
||||||
public insertChain1(keys: string[], obj: T): void {
|
public insertChain1(keys: string[], obj: T): void {
|
||||||
let node = this
|
let node: Trie<T> = this
|
||||||
for (let i in keys) {
|
keys.forEach((key: string): void => {
|
||||||
let nnode = node.items[keys[i]]
|
let nnode = node.items[key]
|
||||||
if (nnode == null) {
|
if (nnode == null) {
|
||||||
nnode = new Trie()
|
nnode = new Trie()
|
||||||
node.items[keys[i]] = nnode
|
node.items[key] = nnode
|
||||||
}
|
}
|
||||||
node = nnode
|
node = nnode
|
||||||
}
|
})
|
||||||
if (node.value == null)
|
if (node.value == null)
|
||||||
node.value = [obj]
|
node.value = [obj]
|
||||||
else
|
else
|
||||||
@@ -1049,7 +1049,7 @@ class ParseState {
|
|||||||
if (fid < totalFIds) {
|
if (fid < totalFIds) {
|
||||||
return [new Fun('?')]
|
return [new Fun('?')]
|
||||||
} else {
|
} else {
|
||||||
let trees = []
|
let trees: Fun[] = []
|
||||||
|
|
||||||
let rules = forest[fid]
|
let rules = forest[fid]
|
||||||
rules.forEach((rule: Rule): void => {
|
rules.forEach((rule: Rule): void => {
|
||||||
@@ -1057,8 +1057,8 @@ class ParseState {
|
|||||||
trees.push((rule as Const).lit)
|
trees.push((rule as Const).lit)
|
||||||
} else {
|
} else {
|
||||||
rule = rule as Apply
|
rule = rule as Apply
|
||||||
let arg_ix = []
|
let arg_ix: number[] = []
|
||||||
let arg_ts = []
|
let arg_ts: Fun[][] = []
|
||||||
for (let k in rule.args) {
|
for (let k in rule.args) {
|
||||||
arg_ix[k] = 0
|
arg_ix[k] = 0
|
||||||
arg_ts[k] = go(rule.args[k].fid)
|
arg_ts[k] = go(rule.args[k].fid)
|
||||||
@@ -1343,7 +1343,7 @@ class Chart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public expandForest(fid: FId): Apply[] {
|
public expandForest(fid: FId): Apply[] {
|
||||||
let rules = []
|
let rules: Apply[] = []
|
||||||
let forest = this.forest
|
let forest = this.forest
|
||||||
|
|
||||||
let go = function (rules0: Rule[]): void {
|
let go = function (rules0: Rule[]): void {
|
||||||
@@ -1351,7 +1351,7 @@ class Chart {
|
|||||||
let rule = rules0[i]
|
let rule = rules0[i]
|
||||||
switch (rule.id) {
|
switch (rule.id) {
|
||||||
case 'Apply':
|
case 'Apply':
|
||||||
rules.push(rule)
|
rules.push(rule as Apply)
|
||||||
break
|
break
|
||||||
case 'Coerce':
|
case 'Coerce':
|
||||||
go(forest[(rule as Coerce).arg])
|
go(forest[(rule as Coerce).arg])
|
||||||
@@ -1406,7 +1406,7 @@ class ActiveItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public shiftOverArg(i: number, fid: FId): ActiveItem {
|
public shiftOverArg(i: number, fid: FId): ActiveItem {
|
||||||
let nargs = []
|
let nargs: PArg[] = []
|
||||||
for (let k in this.args) {
|
for (let k in this.args) {
|
||||||
nargs[k] = this.args[k]
|
nargs[k] = this.args[k]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noImplicitAny": false
|
"noImplicitAny": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user