@npmstuff/argdown-core
Version:
A pluggable parser for the Argdown argumentation syntax
216 lines (215 loc) • 6.94 kB
TypeScript
import { RuleNames } from "../RuleNames";
import { IToken } from "chevrotain";
export declare enum ArgdownTypes {
EQUIVALENCE_CLASS = "equivalence-class",
STATEMENT = "statement",
STATEMENT_REFERENCE = "statement-reference",
ARGUMENT = "argument",
RELATION = "relation",
INFERENCE = "inference",
STATEMENT_MAP_NODE = "statement-map-node",
ARGUMENT_MAP_NODE = "argument-map-node",
GROUP_MAP_NODE = "group-map-node",
MAP_EDGE = "map-edge",
SECTION = "section",
RULE_NODE = "rule-node",
TOKEN_NODE = "token-node"
}
export declare enum RelationType {
ATTACK = "attack",
SUPPORT = "support",
ENTAILS = "entails",
CONTRARY = "contrary",
CONTRADICTORY = "contradictory",
UNDERCUT = "undercut"
}
export interface IRange {
type: RangeType;
start: number;
stop: number;
title?: string;
url?: string;
tag?: string;
}
export declare enum RangeType {
BOLD = "bold",
ITALIC = "italic",
LINK = "link",
TAG = "tag",
STATEMENT_MENTION = "statement-mention",
ARGUMENT_MENTION = "argument-mention",
SPECIAL_CHAR = "special-char"
}
export interface HasTitle {
title?: string;
}
export interface HasText {
text?: string;
ranges?: IRange[];
}
export interface HasRelations {
relations?: IRelation[];
}
export interface HasTags {
tags?: string[];
}
export interface HasData {
data?: any;
}
export interface HasLocation {
startLine?: number;
endLine?: number;
startOffset?: number;
endOffset?: number;
startColumn?: number;
endColumn?: number;
}
export interface HasSection {
section?: ISection | null;
}
export interface HasColor {
color?: string;
}
export interface HasFontColor {
fontColor?: string;
}
export interface IRuleNode extends HasLocation, HasData, HasText, HasTags, HasTitle {
type: ArgdownTypes.RULE_NODE;
name: RuleNames;
children?: IAstNode[];
statement?: IStatement;
statementNr?: number;
level?: number;
section?: ISection;
argument?: IArgument;
relation?: IRelation;
equivalenceClass?: IEquivalenceClass;
inference?: IInference;
trailingWhitespace?: string;
}
export declare namespace IRuleNode {
const create: (name: RuleNames, children: IAstNode[]) => IRuleNode;
}
export interface ITokenNode extends IToken, HasTitle, HasData, HasText {
trailingWhitespace?: string;
url?: string;
tag?: string;
}
export declare type IAstNode = IRuleNode | ITokenNode;
export interface IArgument extends HasTitle, HasRelations, HasTags, HasData, HasLocation, HasSection, HasColor, HasFontColor {
type: ArgdownTypes.ARGUMENT;
pcs: IPCSStatement[];
members: IArgumentDescription[];
}
export declare namespace IArgument {
const getCanonicalMember: (a: IArgument) => IStatement | undefined;
const getCanonicalMemberText: (a: IArgument) => string | undefined;
}
export interface IStatement extends HasTitle, HasTags, HasData, HasLocation, HasSection, HasText {
type: ArgdownTypes.STATEMENT;
role?: StatementRole;
isReference?: boolean;
isTopLevel?: boolean;
}
export declare enum StatementRole {
PREMISE = "premise",
INTERMEDIARY_CONCLUSION = "intermediary-conclusion",
MAIN_CONCLUSION = "main-conclusion",
ARGUMENT_DESCRIPTION = "argument-description",
TOP_LEVEL_STATEMENT = "top-level-statement",
RELATION_STATEMENT = "relation-statement"
}
export interface IPCSStatement extends IStatement {
role: StatementRole.PREMISE | StatementRole.MAIN_CONCLUSION | StatementRole.INTERMEDIARY_CONCLUSION;
argumentTitle?: string;
}
export interface IConclusion extends IPCSStatement {
role: StatementRole.INTERMEDIARY_CONCLUSION | StatementRole.MAIN_CONCLUSION;
inference?: IInference;
}
export interface IArgumentDescription extends IStatement {
role: StatementRole.ARGUMENT_DESCRIPTION;
pcs?: IPCSStatement[];
}
export interface IEquivalenceClass extends HasTitle, HasRelations, HasTags, HasData, HasLocation, HasSection, HasColor, HasFontColor {
type: ArgdownTypes.EQUIVALENCE_CLASS;
members: IStatement[];
isUsedAsPremise?: boolean;
isUsedAsMainConclusion?: boolean;
isUsedAsIntermediaryConclusion?: boolean;
isUsedAsTopLevelStatement?: boolean;
isUsedAsRelationStatement?: boolean;
}
export declare namespace IEquivalenceClass {
const create: (title: string) => IEquivalenceClass;
const getCanonicalMember: (ec: IEquivalenceClass) => IStatement | undefined;
const getCanonicalMemberText: (ec: IEquivalenceClass) => string | undefined;
}
export interface IInference extends HasTitle, HasRelations, HasData, HasLocation, HasSection {
type: ArgdownTypes.INFERENCE;
inferenceRules?: string[];
argumentTitle?: string;
conclusionIndex?: number;
}
export declare type RelationMember = IArgument | IEquivalenceClass | IInference;
export interface IRelation extends HasColor {
type: ArgdownTypes.RELATION;
from?: RelationMember;
to?: RelationMember;
relationType: RelationType;
occurrences: IRuleNode[];
}
export declare namespace IRelation {
const toString: (r: IRelation) => string;
const isSymmetric: (r: IRelation) => boolean;
}
export interface ISection extends HasTitle, HasTags, HasText, HasLocation, HasData, HasColor, HasFontColor {
type: ArgdownTypes.SECTION;
id: string;
level: number;
children: ISection[];
parent?: ISection;
heading?: IRuleNode;
isClosed?: boolean;
isGroup?: boolean;
}
export declare type MapNodeType = ArgdownTypes.STATEMENT_MAP_NODE | ArgdownTypes.ARGUMENT_MAP_NODE | ArgdownTypes.GROUP_MAP_NODE;
export interface IMapNode extends HasTitle, HasTags, HasColor, HasFontColor {
type: MapNodeType;
labelTitle?: string;
labelTitleRanges?: IRange[];
labelText?: string;
labelTextRanges?: IRange[];
id: string;
images?: string[];
}
export interface IGroupMapNode extends IMapNode {
type: ArgdownTypes.GROUP_MAP_NODE;
level?: number;
children?: IMapNode[];
parent?: string;
section?: ISection;
isClosed?: boolean;
}
export interface IMapEdge extends HasColor {
type: ArgdownTypes.MAP_EDGE;
id: string;
from: IMapNode;
to: IMapNode;
fromEquivalenceClass?: IEquivalenceClass;
toEquivalenceClass?: IEquivalenceClass;
relationType: RelationType;
}
export declare namespace IMapEdge {
const toString: (e: IMapEdge) => string;
}
export interface IMap {
nodes: IMapNode[];
edges: IMapEdge[];
}
export declare const isGroupMapNode: (n: IMapNode) => n is IGroupMapNode;
export declare const isRuleNode: (n: IAstNode) => n is IRuleNode;
export declare const isTokenNode: (n: IAstNode) => n is ITokenNode;
export declare const isReconstructed: (a: IArgument) => boolean;
export declare const isConclusion: (s: IStatement) => s is IConclusion;
export declare const isPCSStatement: (s: IStatement) => s is IPCSStatement;