UNPKG

gfd3

Version:

API for d3 trees with gf

119 lines (118 loc) 2.85 kB
import * as d3 from 'd3'; interface Grammar { abstract: AbstractGrammar; concretes: { [key: string]: ConcreteGrammar; }; } interface AbstractGrammar { name: string; startcat: string; funs: { [key: string]: { args: string[]; cat: string; }; }; } export interface GrammarNode { name: string; children?: GrammarNode[]; type: 'cat' | 'fun'; funs?: string[]; originalName?: string; concreteFunctions?: { [key: string]: string[]; }; } interface Production { type: string; fid: number; args: Arg[]; } interface Arg { type: string; hypos: any[]; fid: number; } interface ConcreteFunction { name: string; lins: number[]; } type Sequence = SymCat | SymKS | SymLit; interface SymCat { type: 'SymCat'; args: number[]; } interface SymKS { type: 'SymKS'; args: string[]; } interface SymLit { type: 'SymLit'; args: number[]; } interface AbstractGrammar { name: string; startcat: string; funs: { [key: string]: { args: string[]; cat: string; }; }; } export interface ConcreteGrammar { flags: { language: string; }; productions: { [key: string]: Production[]; }; functions: ConcreteFunction[]; sequences: Sequence[][]; categories: { [key: string]: { start: number; end: number; }; }; totalfids: number; } interface ConcreteFunctionWithLin extends ConcreteFunction { resolvedLins?: string[]; } interface ConcreteGrammarWithLin extends ConcreteGrammar { functions: ConcreteFunctionWithLin[]; resolvedSequences: string[]; } interface GrammarWithLin extends Grammar { concretes: { [key: string]: ConcreteGrammarWithLin; }; } export declare class GFD3 { private grammar; private abstractAST; private grammarMode; private selectedConcrete; loadGrammarFromFile(file: File): Promise<void>; loadGrammarFromURL(url: string): Promise<void>; private setGrammar; private transformAbstractToTree; getGrammar(): Grammar | null; getAbstractAST(): GrammarNode | null; getConcreteLanguages(): string[]; setGrammarMode(mode: 'abstract' | 'concrete'): void; getGrammarMode(): 'abstract' | 'concrete'; setSelectedConcrete(language: string): void; getSelectedConcrete(): string | null; getOptionsForNode(node: GrammarNode): string[]; updateNodeName(node: GrammarNode, newName: string): void; resetNodeName(node: GrammarNode): void; parseLins(lins: number[], sequences: Sequence[][]): string; resolveSequence(sequence: Sequence[], cats: string[]): string; replaceLins(): GrammarWithLin; getTreeData(): d3.HierarchyNode<GrammarNode> | null; } export {};