forked from GitHub/gf-core
Switch to 'standard' linting
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: [
|
|
||||||
'@typescript-eslint',
|
|
||||||
],
|
|
||||||
extends: [
|
extends: [
|
||||||
'eslint:recommended',
|
'standard-with-typescript'
|
||||||
'plugin:@typescript-eslint/recommended',
|
],
|
||||||
]
|
parserOptions: {
|
||||||
|
project: './tsconfig.json'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const errs: ErrorInfo[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
lookup(errno: number): string | undefined {
|
lookup (errno: number): string | undefined {
|
||||||
return errs.find(err => err.errno === errno)?.description
|
return errs.find(err => err.errno === errno)?.description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import errno from './errno'
|
import errno from './errno'
|
||||||
import ffi from 'ffi-napi'
|
import ffi from 'ffi-napi'
|
||||||
import ref, { Pointer } from 'ref-napi'
|
import ref, { Pointer } from 'ref-napi'
|
||||||
@@ -50,7 +52,6 @@ const PgfUnmarshallerPtr = ref.refType(PgfUnmarshaller)
|
|||||||
const PgfMarshaller = ref.types.void // TODO
|
const PgfMarshaller = ref.types.void // TODO
|
||||||
const PgfMarshallerPtr = ref.refType(PgfMarshaller)
|
const PgfMarshallerPtr = ref.refType(PgfMarshaller)
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// TypeScript Types
|
// TypeScript Types
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ interface PgfExnType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PGFError extends Error {
|
class PGFError extends Error {
|
||||||
constructor(message: string) {
|
constructor (message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
// https://stackoverflow.com/a/65243177/98600
|
// https://stackoverflow.com/a/65243177/98600
|
||||||
Object.setPrototypeOf(this, PGFError.prototype)
|
Object.setPrototypeOf(this, PGFError.prototype)
|
||||||
@@ -72,44 +73,44 @@ class PGFError extends Error {
|
|||||||
// FFI
|
// FFI
|
||||||
|
|
||||||
const runtime = ffi.Library('libpgf', {
|
const runtime = ffi.Library('libpgf', {
|
||||||
'pgf_read_pgf': [ PgfDBPtr, [ ref.types.CString, PgfRevisionPtr, PgfExnPtr ] ],
|
pgf_read_pgf: [PgfDBPtr, [ref.types.CString, PgfRevisionPtr, PgfExnPtr]],
|
||||||
'pgf_boot_ngf': [ PgfDBPtr, [ ref.types.CString, ref.types.CString, PgfRevisionPtr, PgfExnPtr ] ],
|
pgf_boot_ngf: [PgfDBPtr, [ref.types.CString, ref.types.CString, PgfRevisionPtr, PgfExnPtr]],
|
||||||
'pgf_read_ngf': [ PgfDBPtr, [ ref.types.CString, PgfRevisionPtr, PgfExnPtr ] ],
|
pgf_read_ngf: [PgfDBPtr, [ref.types.CString, PgfRevisionPtr, PgfExnPtr]],
|
||||||
'pgf_new_ngf': [ PgfDBPtr, [ PgfTextPtr, ref.types.CString, PgfRevisionPtr, PgfExnPtr ] ],
|
pgf_new_ngf: [PgfDBPtr, [PgfTextPtr, ref.types.CString, PgfRevisionPtr, PgfExnPtr]],
|
||||||
'pgf_write_pgf': [ ref.types.void, [ ref.types.CString, PgfDBPtr, PgfRevision, PgfExnPtr ] ],
|
pgf_write_pgf: [ref.types.void, [ref.types.CString, PgfDBPtr, PgfRevision, PgfExnPtr]],
|
||||||
|
|
||||||
'pgf_free_revision': [ ref.types.void, [ PgfDBPtr, PgfRevision ] ],
|
pgf_free_revision: [ref.types.void, [PgfDBPtr, PgfRevision]],
|
||||||
|
|
||||||
'pgf_abstract_name': [ PgfTextPtr, [ PgfDBPtr, PgfRevision, PgfExnPtr ] ],
|
pgf_abstract_name: [PgfTextPtr, [PgfDBPtr, PgfRevision, PgfExnPtr]],
|
||||||
'pgf_iter_categories': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfItorPtr, PgfExnPtr ] ],
|
pgf_iter_categories: [ref.types.void, [PgfDBPtr, PgfRevision, PgfItorPtr, PgfExnPtr]],
|
||||||
'pgf_start_cat': [ PgfType, [ PgfDBPtr, PgfRevision, PgfUnmarshallerPtr, PgfExnPtr ] ],
|
pgf_start_cat: [PgfType, [PgfDBPtr, PgfRevision, PgfUnmarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_category_context': [ PgfTypeHypoPtr, [ PgfDBPtr, PgfRevision, PgfTextPtr, ref.refType(ref.types.size_t), PgfUnmarshallerPtr, PgfExnPtr ] ],
|
pgf_category_context: [PgfTypeHypoPtr, [PgfDBPtr, PgfRevision, PgfTextPtr, ref.refType(ref.types.size_t), PgfUnmarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_category_prob': [ prob_t, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_category_prob: [prob_t, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_iter_functions': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfItorPtr, PgfExnPtr ] ],
|
pgf_iter_functions: [ref.types.void, [PgfDBPtr, PgfRevision, PgfItorPtr, PgfExnPtr]],
|
||||||
'pgf_iter_functions_by_cat': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfItorPtr, PgfExnPtr ] ],
|
pgf_iter_functions_by_cat: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfItorPtr, PgfExnPtr]],
|
||||||
'pgf_function_type': [ PgfType, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr ] ],
|
pgf_function_type: [PgfType, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_function_is_constructor': [ ref.types.int, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_function_is_constructor: [ref.types.int, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_function_prob': [ prob_t, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_function_prob: [prob_t, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_print_expr': [ PgfTextPtr, [ PgfExpr, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr ] ],
|
pgf_print_expr: [PgfTextPtr, [PgfExpr, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr]],
|
||||||
'pgf_read_expr': [ PgfExpr, [ PgfTextPtr, PgfUnmarshallerPtr ] ],
|
pgf_read_expr: [PgfExpr, [PgfTextPtr, PgfUnmarshallerPtr]],
|
||||||
'pgf_read_expr_ex': [ PgfExpr, [ PgfTextPtr, ref.refType(ref.types.CString), PgfUnmarshallerPtr ] ],
|
pgf_read_expr_ex: [PgfExpr, [PgfTextPtr, ref.refType(ref.types.CString), PgfUnmarshallerPtr]],
|
||||||
'pgf_expr_prob': [ prob_t, [ PgfDBPtr, PgfRevision, PgfExpr, PgfMarshallerPtr, PgfExnPtr ] ],
|
pgf_expr_prob: [prob_t, [PgfDBPtr, PgfRevision, PgfExpr, PgfMarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_print_type': [ PgfTextPtr, [ PgfType, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr ] ],
|
pgf_print_type: [PgfTextPtr, [PgfType, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr]],
|
||||||
'pgf_print_context': [ PgfTextPtr, [ size_t, PgfTypeHypoPtr, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr ] ],
|
pgf_print_context: [PgfTextPtr, [size_t, PgfTypeHypoPtr, PgfPrintContextPtr, ref.types.int, PgfMarshallerPtr]],
|
||||||
'pgf_read_type': [ PgfType, [ PgfTextPtr, PgfUnmarshallerPtr ] ],
|
pgf_read_type: [PgfType, [PgfTextPtr, PgfUnmarshallerPtr]],
|
||||||
|
|
||||||
'pgf_clone_revision': [ PgfRevision, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_clone_revision: [PgfRevision, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_commit_revision': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfExnPtr ] ],
|
pgf_commit_revision: [ref.types.void, [PgfDBPtr, PgfRevision, PgfExnPtr]],
|
||||||
'pgf_checkout_revision': [ PgfRevision, [ PgfDBPtr, PgfTextPtr, PgfExnPtr ] ],
|
pgf_checkout_revision: [PgfRevision, [PgfDBPtr, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_create_function': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfType, size_t, prob_t, PgfMarshallerPtr, PgfExnPtr ] ],
|
pgf_create_function: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfType, size_t, prob_t, PgfMarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_drop_function': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_drop_function: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
'pgf_create_category': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, size_t, PgfTypeHypoPtr, prob_t, PgfMarshallerPtr, PgfExnPtr ] ],
|
pgf_create_category: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, size_t, PgfTypeHypoPtr, prob_t, PgfMarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_drop_category': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr ] ],
|
pgf_drop_category: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfExnPtr]],
|
||||||
|
|
||||||
'pgf_get_global_flag': [ PgfLiteral, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr ] ],
|
pgf_get_global_flag: [PgfLiteral, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_set_global_flag': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfLiteral, PgfMarshallerPtr, PgfExnPtr ] ],
|
pgf_set_global_flag: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfLiteral, PgfMarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_get_abstract_flag': [ PgfLiteral, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr ] ],
|
pgf_get_abstract_flag: [PgfLiteral, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfUnmarshallerPtr, PgfExnPtr]],
|
||||||
'pgf_set_abstract_flag': [ ref.types.void, [ PgfDBPtr, PgfRevision, PgfTextPtr, PgfLiteral, PgfMarshallerPtr, PgfExnPtr ] ],
|
pgf_set_abstract_flag: [ref.types.void, [PgfDBPtr, PgfRevision, PgfTextPtr, PgfLiteral, PgfMarshallerPtr, PgfExnPtr]]
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -123,7 +124,7 @@ function handleError (err: StructObject<PgfExnType>): void {
|
|||||||
// PGF_EXN_SYSTEM_ERROR
|
// PGF_EXN_SYSTEM_ERROR
|
||||||
case 1: {
|
case 1: {
|
||||||
const desc = errno.lookup(err.code)
|
const desc = errno.lookup(err.code)
|
||||||
throw new Error(`${desc}: ${err.msg}`)
|
throw new Error(`${desc as string}: ${err.msg as string}`)
|
||||||
}
|
}
|
||||||
// PGF_EXN_PGF_ERROR
|
// PGF_EXN_PGF_ERROR
|
||||||
case 2:
|
case 2:
|
||||||
@@ -172,7 +173,7 @@ export class PGFGrammar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAbstractName (): string {
|
getAbstractName (): string {
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const txt = runtime.pgf_abstract_name(this.db, this.revision.deref(), err.ref())
|
const txt = runtime.pgf_abstract_name(this.db, this.revision.deref(), err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return PgfText_AsString(txt)
|
return PgfText_AsString(txt)
|
||||||
@@ -180,12 +181,12 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
getCategories (): string[] {
|
getCategories (): string[] {
|
||||||
const cats: string[] = []
|
const cats: string[] = []
|
||||||
const callback = ffi.Callback(ref.types.void, [ PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr ],
|
const callback = ffi.Callback(ref.types.void, [PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr],
|
||||||
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
const k = PgfText_AsString(key)
|
const k = PgfText_AsString(key)
|
||||||
cats.push(k)
|
cats.push(k)
|
||||||
})
|
})
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
runtime.pgf_iter_categories(this.db, this.revision.deref(), callback.ref() as Pointer<void>, err.ref())
|
runtime.pgf_iter_categories(this.db, this.revision.deref(), callback.ref() as Pointer<void>, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return cats
|
return cats
|
||||||
@@ -193,12 +194,12 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
getFunctions (): string[] {
|
getFunctions (): string[] {
|
||||||
const funs: string[] = []
|
const funs: string[] = []
|
||||||
const callback = ffi.Callback(ref.types.void, [ PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr ],
|
const callback = ffi.Callback(ref.types.void, [PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr],
|
||||||
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
const k = PgfText_AsString(key)
|
const k = PgfText_AsString(key)
|
||||||
funs.push(k)
|
funs.push(k)
|
||||||
})
|
})
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
runtime.pgf_iter_functions(this.db, this.revision.deref(), callback.ref() as Pointer<void>, err.ref())
|
runtime.pgf_iter_functions(this.db, this.revision.deref(), callback.ref() as Pointer<void>, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return funs
|
return funs
|
||||||
@@ -206,7 +207,7 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
categoryProbability (cat: string): number | undefined {
|
categoryProbability (cat: string): number | undefined {
|
||||||
const catname = PgfText_FromString(cat)
|
const catname = PgfText_FromString(cat)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const prob = runtime.pgf_category_prob(this.db, this.revision.deref(), catname, err.ref())
|
const prob = runtime.pgf_category_prob(this.db, this.revision.deref(), catname, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
if (prob === Infinity) {
|
if (prob === Infinity) {
|
||||||
@@ -218,7 +219,7 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
functionProbability (fun: string): number | undefined {
|
functionProbability (fun: string): number | undefined {
|
||||||
const funname = PgfText_FromString(fun)
|
const funname = PgfText_FromString(fun)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const prob = runtime.pgf_function_prob(this.db, this.revision.deref(), funname, err.ref())
|
const prob = runtime.pgf_function_prob(this.db, this.revision.deref(), funname, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
if (prob === Infinity) {
|
if (prob === Infinity) {
|
||||||
@@ -230,7 +231,7 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
functionIsConstructor (fun: string): boolean {
|
functionIsConstructor (fun: string): boolean {
|
||||||
const funname = PgfText_FromString(fun)
|
const funname = PgfText_FromString(fun)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const isCon = runtime.pgf_function_is_constructor(this.db, this.revision.deref(), funname, err.ref())
|
const isCon = runtime.pgf_function_is_constructor(this.db, this.revision.deref(), funname, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return Boolean(isCon)
|
return Boolean(isCon)
|
||||||
@@ -239,12 +240,12 @@ export class PGFGrammar {
|
|||||||
functionsByCategory (cat: string): string[] {
|
functionsByCategory (cat: string): string[] {
|
||||||
const catname = PgfText_FromString(cat)
|
const catname = PgfText_FromString(cat)
|
||||||
const funs: string[] = []
|
const funs: string[] = []
|
||||||
const callback = ffi.Callback(ref.types.void, [ PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr ],
|
const callback = ffi.Callback(ref.types.void, [PgfItorPtr, PgfTextPtr, voidPtr, PgfExnPtr],
|
||||||
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
function (self: Pointer<any>, key: Pointer<any>, value: Pointer<any>, err: Pointer<any>) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
const k = PgfText_AsString(key)
|
const k = PgfText_AsString(key)
|
||||||
funs.push(k)
|
funs.push(k)
|
||||||
})
|
})
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
runtime.pgf_iter_functions_by_cat(this.db, this.revision.deref(), catname, callback.ref() as Pointer<void>, err.ref())
|
runtime.pgf_iter_functions_by_cat(this.db, this.revision.deref(), catname, callback.ref() as Pointer<void>, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return funs
|
return funs
|
||||||
@@ -256,7 +257,7 @@ export class PGFGrammar {
|
|||||||
|
|
||||||
function readPGF (path: string): PGFGrammar {
|
function readPGF (path: string): PGFGrammar {
|
||||||
const rev = ref.alloc(PgfRevisionPtr)
|
const rev = ref.alloc(PgfRevisionPtr)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const db = runtime.pgf_read_pgf(path, rev, err.ref())
|
const db = runtime.pgf_read_pgf(path, rev, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return new PGFGrammar(db, rev)
|
return new PGFGrammar(db, rev)
|
||||||
@@ -264,7 +265,7 @@ function readPGF (path: string): PGFGrammar {
|
|||||||
|
|
||||||
function bootNGF (pgf_path: string, ngf_path: string): PGFGrammar {
|
function bootNGF (pgf_path: string, ngf_path: string): PGFGrammar {
|
||||||
const rev = ref.alloc(PgfRevisionPtr)
|
const rev = ref.alloc(PgfRevisionPtr)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const db = runtime.pgf_boot_ngf(pgf_path, ngf_path, rev, err.ref())
|
const db = runtime.pgf_boot_ngf(pgf_path, ngf_path, rev, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return new PGFGrammar(db, rev)
|
return new PGFGrammar(db, rev)
|
||||||
@@ -272,7 +273,7 @@ function bootNGF (pgf_path: string, ngf_path: string): PGFGrammar {
|
|||||||
|
|
||||||
function readNGF (path: string): PGFGrammar {
|
function readNGF (path: string): PGFGrammar {
|
||||||
const rev = ref.alloc(PgfRevisionPtr)
|
const rev = ref.alloc(PgfRevisionPtr)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const db = runtime.pgf_read_ngf(path, rev, err.ref())
|
const db = runtime.pgf_read_ngf(path, rev, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return new PGFGrammar(db, rev)
|
return new PGFGrammar(db, rev)
|
||||||
@@ -282,7 +283,7 @@ function newNGF (abstract_name: string, path?: string): PGFGrammar {
|
|||||||
const absname = PgfText_FromString(abstract_name)
|
const absname = PgfText_FromString(abstract_name)
|
||||||
const fpath = path != null ? path : null
|
const fpath = path != null ? path : null
|
||||||
const rev = ref.alloc(PgfRevisionPtr)
|
const rev = ref.alloc(PgfRevisionPtr)
|
||||||
const err = new PgfExn
|
const err = new PgfExn()
|
||||||
const db = runtime.pgf_new_ngf(absname, fpath, rev, err.ref())
|
const db = runtime.pgf_new_ngf(absname, fpath, rev, err.ref())
|
||||||
handleError(err)
|
handleError(err)
|
||||||
return new PGFGrammar(db, rev)
|
return new PGFGrammar(db, rev)
|
||||||
|
|||||||
917
src/runtime/javascript/package-lock.json
generated
917
src/runtime/javascript/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,10 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
||||||
"@typescript-eslint/parser": "^4.32.0",
|
"@typescript-eslint/parser": "^4.32.0",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
|
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||||
|
"eslint-plugin-import": "^2.24.2",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"jest": "^27.2.4",
|
"jest": "^27.2.4",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
|
|||||||
@@ -154,11 +154,11 @@ describe('abstract syntax', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('categories', () => {
|
test('categories', () => {
|
||||||
expect(gr.getCategories()).toEqual(['Float','Int','N','P','S','String'])
|
expect(gr.getCategories()).toEqual(['Float', 'Int', 'N', 'P', 'S', 'String'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('functions', () => {
|
test('functions', () => {
|
||||||
expect(gr.getFunctions()).toEqual(['c','ind','s','z'])
|
expect(gr.getFunctions()).toEqual(['c', 'ind', 's', 'z'])
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('function is constructor', () => {
|
describe('function is constructor', () => {
|
||||||
@@ -178,7 +178,7 @@ describe('abstract syntax', () => {
|
|||||||
|
|
||||||
describe('functions by category', () => {
|
describe('functions by category', () => {
|
||||||
test('N', () => {
|
test('N', () => {
|
||||||
expect(gr.functionsByCategory('N')).toEqual(['s','z'])
|
expect(gr.functionsByCategory('N')).toEqual(['s', 'z'])
|
||||||
})
|
})
|
||||||
test('S', () => {
|
test('S', () => {
|
||||||
expect(gr.functionsByCategory('S')).toEqual(['c'])
|
expect(gr.functionsByCategory('S')).toEqual(['c'])
|
||||||
|
|||||||
Reference in New Issue
Block a user