@spellu/engine
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "@spellu/engine", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "description": "Spellu is a parser combinator engine.", | ||
"engines": { | ||
"node": "~13" | ||
"node": ">=14" | ||
}, | ||
@@ -26,3 +26,4 @@ "scripts": { | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"gitHead": "3948db0a104f8c2f0a248d112f0f5adb249d54f0" | ||
} |
declare namespace spellu { | ||
type Dictionary<V> = { | ||
function tap<T, R extends T>(object: T, ...callbacks: ((object: T) => void)[]): R; | ||
function cascade<T>(...callbacks: ((...args: any[]) => void)[]): (...args: any[]) => void; | ||
function pipe<T, R>(value: T, c1: (arg: T) => R): R; | ||
function pipe<T1, T2, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => R): R; | ||
function pipe<T1, T2, T3, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T3, c3: (arg: T3) => R): R; | ||
function pipe<T1, T2, T3, T4, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T3, c3: (arg: T3) => T4, c4: (arg: T4) => R): R; | ||
function pipe<T1, T2, T3, T4, T5, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T3, c3: (arg: T3) => T4, c4: (arg: T4) => T5, c5: (arg: T5) => R): R; | ||
function pipe<T1, T2, T3, T4, T5, T6, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T3, c3: (arg: T3) => T4, c4: (arg: T4) => T5, c5: (arg: T5) => T6, c6: (arg: T6) => R): R; | ||
function pipe<T1, T2, T3, T4, T5, T6, T7, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T3, c3: (arg: T3) => T4, c4: (arg: T4) => T5, c5: (arg: T5) => T6, c6: (arg: T6) => T7, c7: (arg: T7) => R): R; | ||
function pipe<T1, T2, T3, T4, T5, T6, T7, T8, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T4, c3: (arg: T3) => T4, c4: (arg: T4) => T5, c5: (arg: T5) => T6, c6: (arg: T6) => T7, c7: (arg: T7) => T8, c8: (arg: T8) => R): R; | ||
function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9, R>(value: T1, c1: (arg: T1) => T2, c2: (arg: T2) => T4, c3: (arg: T3) => T4, c4: (arg: T4) => T5, c5: (arg: T5) => T6, c6: (arg: T6) => T7, c7: (arg: T7) => T8, c8: (arg: T8) => T9, c9: (arg: T9) => R): R; | ||
function wrapInArray<T>(v: T | T[]): T[]; | ||
function flattenArray<T>(array: T[], level: number): T[]; | ||
} | ||
declare namespace spellu { | ||
type Dictionary<V = any> = { | ||
[name: string]: V; | ||
}; | ||
interface TextRange { | ||
source: number; | ||
begin: number; | ||
end: number; | ||
} | ||
interface Location { | ||
interface Position2D { | ||
lineNo: number; | ||
@@ -19,4 +35,4 @@ columnNo: number; | ||
syntax: string; | ||
raw: string; | ||
cooked: string; | ||
literal: string; | ||
value: string; | ||
comments?: Comment[]; | ||
@@ -42,4 +58,9 @@ } | ||
interface Rule { | ||
sticky?: boolean; | ||
parser: string; | ||
test?: { | ||
polarity: boolean; | ||
offset?: number; | ||
parser: string; | ||
argument?: any; | ||
}; | ||
parser: string | [string, string]; | ||
argument?: any; | ||
@@ -49,31 +70,49 @@ options?: {}; | ||
optional?: boolean; | ||
pick?: number; | ||
flat?: number; | ||
entered?: (machine: Machine) => void; | ||
leaved?: (machine: Machine) => void; | ||
parsed?: (result: any) => void; | ||
} | ||
interface TokenArgument { | ||
syntax: string; | ||
pattern: string | RegExp; | ||
label?: string; | ||
error?: boolean; | ||
capture?: number; | ||
value?: string; | ||
} | ||
interface Processor { | ||
recipe: Recipe; | ||
parts: Dictionary<(_: any) => any>; | ||
parts: Dictionary<(_: any) => any> | ((machine: Machine) => Dictionary<(_: any) => any>); | ||
} | ||
class SpelluError extends Error { | ||
} | ||
class InterfaceError extends SpelluError { | ||
} | ||
} | ||
declare namespace spellu { | ||
function createToken(syntax: string, position: number, raw: string, cooked: string): Token; | ||
function createIndentation(syntax: Syntax.Indentation | Syntax.Samedent | Syntax.Indent | Syntax.Outdent, position: number, raw: string, level: number): Indentation; | ||
function createNode<N extends Node>(scaned: Node | (Node | null)[] | any, syntax: string, properties: {}): N; | ||
function createToken(syntax: string, source: number, position: number, literal: string, value: string): Token; | ||
function createIndentation(syntax: Syntax.Indentation | Syntax.Samedent | Syntax.Indent | Syntax.Outdent, source: number, position: number, literal: string, level: number): Indentation; | ||
function createNode<N extends Node>(tree: Node | (Node | null)[] | any, syntax: string, properties: {}): N; | ||
function changeNode<N1 extends Node, N2 extends N1>(node: N1, syntax: string, properties?: {}): N2; | ||
function combineTextRange(tree: Node | (Node | null)[] | null): TextRange; | ||
} | ||
declare namespace spellu { | ||
interface SourceOptions { | ||
normalize?: boolean; | ||
normalize: boolean; | ||
tabWidth: number; | ||
} | ||
class Source { | ||
readonly number: number; | ||
readonly input: string; | ||
readonly location: string; | ||
protected tabWidth: number; | ||
readonly tabWidth: number; | ||
protected linePositions?: number[]; | ||
constructor(input: string, location: string, options?: SourceOptions); | ||
constructor(number: number, input: string, location: string, options?: Partial<SourceOptions>); | ||
protected normalizeSource(string: string): string; | ||
protected stripUtf8Bom(string: string): string; | ||
protected normalizeNewLine(string: string): string; | ||
protected addTrailNewLine(string: string): string; | ||
stream(position?: number): SourceStream; | ||
position2d(position: number): Location; | ||
substring(begin: number, end?: number): string; | ||
position2d(position: number): Position2D; | ||
getColumnNo(line: string, columnIndex: number): number; | ||
@@ -92,6 +131,7 @@ getLinePositions(): number[]; | ||
class SourceStream { | ||
readonly source: number; | ||
readonly input: string; | ||
readonly length: number; | ||
position: number; | ||
constructor(input: string, options?: SourceStreamOptions); | ||
constructor(source: number, input: string, { length, position }?: SourceStreamOptions); | ||
clone(): SourceStream; | ||
@@ -125,5 +165,5 @@ charCodeAt(offset?: number): number; | ||
type TextPrinterOptions = { | ||
space?: string; | ||
indent?: number | 'tab'; | ||
lineBreak?: string; | ||
space: string; | ||
indent: number | 'tab'; | ||
lineBreak: string; | ||
}; | ||
@@ -133,10 +173,10 @@ class TextPrinter { | ||
_space: string; | ||
_lineBreak: string; | ||
_indent: number | 'tab'; | ||
_lineBreak: string; | ||
_lines: string[]; | ||
_indentLevel: number; | ||
_line: string; | ||
_(condition?: boolean): this; | ||
indentUp(level?: number): this; | ||
indentDown(level?: number): this; | ||
_(condition?: boolean): this; | ||
text(...texts: (string | undefined)[]): this; | ||
@@ -150,2 +190,44 @@ quote(quote: string, text: string): this; | ||
declare namespace spellu { | ||
interface Log { | ||
level: string; | ||
message: string; | ||
module?: string; | ||
source?: { | ||
location: string; | ||
position: Position2D; | ||
}; | ||
additionals?: string[]; | ||
} | ||
type LogWriter = (logs: Log[]) => void; | ||
class Logger { | ||
constructor(writer: LogWriter); | ||
writer: LogWriter; | ||
info(message: string, data: Partial<Log>): this; | ||
notice(message: string, data: Partial<Log>): this; | ||
error(message: string, data: Partial<Log>): this; | ||
} | ||
function logger(writer?: LogWriter): Logger; | ||
namespace logger { | ||
var console: (logs: Log[]) => void; | ||
} | ||
} | ||
declare namespace spellu { | ||
class AssertionError extends SpelluError { | ||
} | ||
class AssertionMatcher { | ||
constructor(actual: any); | ||
protected _actual: any; | ||
shouldBe(type: string): this; | ||
shouldBeString(): this; | ||
shouldBeArray(): this; | ||
toBe(expected: any): this; | ||
} | ||
function assert(actual: any): AssertionMatcher; | ||
namespace assert { | ||
function enable(): typeof assert; | ||
function disable(): typeof assert; | ||
} | ||
function check(message: string, routine: () => void): void; | ||
} | ||
declare namespace spellu { | ||
interface Expected { | ||
@@ -162,6 +244,10 @@ position: number; | ||
resolve<T>(left?: (diagnosis: F) => T, right?: (value: S) => T): T | null; | ||
source: number; | ||
position: number; | ||
} | ||
class Success<V> implements ParsedValue<V, never> { | ||
constructor(source: number, position: number, value: V); | ||
readonly source: number; | ||
readonly position: number; | ||
readonly value: V; | ||
constructor(value: V); | ||
isSuccess(): this is Success<V>; | ||
@@ -175,4 +261,6 @@ isFailure(): this is Failure<never>; | ||
class Failure<V> implements ParsedValue<never, V> { | ||
constructor(source: number, position: number, value: V); | ||
readonly source: number; | ||
readonly position: number; | ||
readonly value: V; | ||
constructor(value: V); | ||
isSuccess(): this is Success<never>; | ||
@@ -222,3 +310,3 @@ isFailure(): this is Failure<V>; | ||
accept<T>(callback: (value: V) => T): Parser<T>; | ||
log(callback?: (result: ParserResult<V>) => any, depth?: number): Parser<V>; | ||
log(callback?: (result: ParserResult<V>) => any, depth?: number | null): Parser<V>; | ||
} | ||
@@ -232,14 +320,20 @@ const SPACE_PATTERN: RegExp; | ||
result: ParserResult<any>; | ||
state: Dictionary<any>; | ||
state: Dictionary; | ||
} | ||
interface MachineOptions { | ||
debug?: boolean; | ||
memorable?: boolean; | ||
maxRepeat?: number; | ||
spacePattern?: RegExp; | ||
debug: boolean; | ||
memorable: boolean; | ||
maxRepeat: number; | ||
spacePattern: RegExp; | ||
} | ||
class Machine { | ||
constructor(input: SourceStream, cluster: Dictionary<Board>, options?: MachineOptions); | ||
constructor(input: SourceStream, sources: { | ||
[id: number]: Source; | ||
}, processors: Processor[], store?: Dictionary, options?: Partial<MachineOptions>); | ||
input: SourceStream; | ||
sources: { | ||
[id: number]: Source; | ||
}; | ||
cluster: Dictionary<Board>; | ||
store: Dictionary; | ||
debug: boolean; | ||
@@ -273,2 +367,5 @@ memorable: boolean; | ||
clearExpectedRules(): void; | ||
sliceText(range: TextRange): string; | ||
sliceWholeText(tree: Node | (Node | null)[] | null): string; | ||
combineToken(syntax: string, tree: Node | (Node | null)[] | null): Token; | ||
} | ||
@@ -289,6 +386,7 @@ } | ||
rule(name: string): Parser<any> | null; | ||
firstRule(): Parser<any> | null; | ||
firstRule(): Parser<any>; | ||
commentRule(): Parser<any> | null; | ||
} | ||
function prepare(processor: Processor): Board; | ||
function prepare(machine: Machine, processor: Processor): Board; | ||
function createParser(board: Board, parser: string | [string, string], argument: any, options?: any): Parser<any>; | ||
} | ||
@@ -300,39 +398,52 @@ declare namespace spellu { | ||
function delay<V>(box: ParserBox<V>, ...args: any[]): Parser<V>; | ||
interface TokenPattern { | ||
syntax: string; | ||
pattern: string | RegExp; | ||
label?: string; | ||
capture?: number; | ||
value?: string; | ||
function P<V>(box: ParserBox<V>, ...args: any[]): Parser<V>; | ||
namespace P { | ||
function always(): Parser<undefined>; | ||
function always<V>(value: V): Parser<V>; | ||
function never<V>(message_?: string): Parser<V>; | ||
function start<V>(parser: Parser<V>): Parser<V>; | ||
function end(): Parser<null>; | ||
function space(syntax?: string): Parser<Token>; | ||
function comment(): Parser<Comment[]>; | ||
function token(argument: TokenArgument | TokenArgument[]): Parser<Token>; | ||
function annex(argument: TokenArgument | TokenArgument[]): Parser<Token>; | ||
function string(syntax: string, pattern: string): Parser<Token>; | ||
function regex(syntax: string, pattern: string | RegExp): Parser<Token>; | ||
function eol(): Parser<Comment[]>; | ||
function ruleRef<V>(rulePath: string | string[]): Parser<V>; | ||
function and<V1>(p1: Parser<V1>): Parser<V1>; | ||
function and<V1, V2>(p1: Parser<V1>, p2: Parser<V2>): Parser<[V1, V2]>; | ||
function and<V1, V2, V3>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>): Parser<[V1, V2, V3]>; | ||
function and<V1, V2, V3, V4>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>): Parser<[V1, V2, V3, V4]>; | ||
function and<V1, V2, V3, V4, V5>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>): Parser<[V1, V2, V3, V4, V5]>; | ||
function and<V1, V2, V3, V4, V5, V6>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>): Parser<[V1, V2, V3, V4, V5, V6]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>): Parser<[V1, V2, V3, V4, V5, V6, V7]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7, V8>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>): Parser<[V1, V2, V3, V4, V5, V6, V7, V8]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7, V8, V9>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>, p9: Parser<V9>): Parser<[V1, V2, V3, V4, V5, V6, V7, V8, V9]>; | ||
function and(...parsers: Parser<any>[]): Parser<any[]>; | ||
function or<V1>(p1: Parser<V1>): Parser<V1>; | ||
function or<V1, V2>(p1: Parser<V1>, p2: Parser<V2>): Parser<V1 | V2>; | ||
function or<V1, V2, V3>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>): Parser<V1 | V2 | V3>; | ||
function or<V1, V2, V3, V4>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>): Parser<V1 | V2 | V3 | V4>; | ||
function or<V1, V2, V3, V4, V5>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>): Parser<V1 | V2 | V3 | V4 | V5>; | ||
function or<V1, V2, V3, V4, V5, V6>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>): Parser<V1 | V2 | V3 | V4 | V5 | V6>; | ||
function or<V1, V2, V3, V4, V5, V6, V7>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7>; | ||
function or<V1, V2, V3, V4, V5, V6, V7, V8>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8>; | ||
function or<V1, V2, V3, V4, V5, V6, V7, V8, V9>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>, p9: Parser<V9>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9>; | ||
function or(...parsers: Parser<any>[]): Parser<any>; | ||
function optional<V>(parser: Parser<V>): Parser<V | null>; | ||
function many<V>(parser: Parser<V>, min: number, max?: number): Parser<V[]>; | ||
function repeat<V, S>(valueParser: Parser<V>, sepalatorParser: Parser<S>, options: { | ||
allowTrailingSeparator: boolean; | ||
multiplicity?: number; | ||
}): Parser<V[]>; | ||
function alternate<V, C>(valueParser: Parser<V>, combinorParser: Parser<C>): Parser<(V | C)[]>; | ||
function block<V>(parser: Parser<V>): Parser<V[]>; | ||
function indent(): Parser<Indentation>; | ||
function outdent(): Parser<Indentation>; | ||
function samedent(): Parser<Indentation>; | ||
function test<V>(polarity: boolean, offset: number, testParser: Parser<any>, parser: Parser<V>): Parser<V>; | ||
function not<V>(parser: Parser<V>): Parser<null>; | ||
function recover<V>(parser: Parser<V>, callback: (machine: Machine) => void): Parser<V>; | ||
} | ||
function token(sticky: boolean, pattern: TokenPattern | TokenPattern[]): Parser<Token>; | ||
function block<V>(parser: Parser<V>): Parser<V[]>; | ||
function indent(): Parser<Indentation>; | ||
function outdent(): Parser<Indentation>; | ||
function samedent(): Parser<Indentation>; | ||
function eol(): Parser<Comment[]>; | ||
function ruleRef<V>(rulePath: string): Parser<V>; | ||
function and<V1>(p1: Parser<V1>): Parser<V1>; | ||
function and<V1, V2>(p1: Parser<V1>, p2: Parser<V2>): Parser<[V1, V2]>; | ||
function and<V1, V2, V3>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>): Parser<[V1, V2, V3]>; | ||
function and<V1, V2, V3, V4>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>): Parser<[V1, V2, V3, V4]>; | ||
function and<V1, V2, V3, V4, V5>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>): Parser<[V1, V2, V3, V4, V5]>; | ||
function and<V1, V2, V3, V4, V5, V6>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>): Parser<[V1, V2, V3, V4, V5, V6]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>): Parser<[V1, V2, V3, V4, V5, V6, V7]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7, V8>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>): Parser<[V1, V2, V3, V4, V5, V6, V7, V8]>; | ||
function and<V1, V2, V3, V4, V5, V6, V7, V8, V9>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>, p9: Parser<V9>): Parser<[V1, V2, V3, V4, V5, V6, V7, V8, V9]>; | ||
function and(...parsers: Parser<any>[]): Parser<any[]>; | ||
function or<V1>(p1: Parser<V1>): Parser<V1>; | ||
function or<V1, V2>(p1: Parser<V1>, p2: Parser<V2>): Parser<V1 | V2>; | ||
function or<V1, V2, V3>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>): Parser<V1 | V2 | V3>; | ||
function or<V1, V2, V3, V4>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>): Parser<V1 | V2 | V3 | V4>; | ||
function or<V1, V2, V3, V4, V5>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>): Parser<V1 | V2 | V3 | V4 | V5>; | ||
function or<V1, V2, V3, V4, V5, V6>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>): Parser<V1 | V2 | V3 | V4 | V5 | V6>; | ||
function or<V1, V2, V3, V4, V5, V6, V7>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7>; | ||
function or<V1, V2, V3, V4, V5, V6, V7, V8>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8>; | ||
function or<V1, V2, V3, V4, V5, V6, V7, V8, V9>(p1: Parser<V1>, p2: Parser<V2>, p3: Parser<V3>, p4: Parser<V4>, p5: Parser<V5>, p6: Parser<V6>, p7: Parser<V7>, p8: Parser<V8>, p9: Parser<V9>): Parser<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9>; | ||
function or(...parsers: Parser<any>[]): Parser<any>; | ||
function optional<V>(parser: Parser<V>): Parser<V | null>; | ||
function many<V>(parser: Parser<V>, min: number, max?: number): Parser<V[]>; | ||
function recover<V>(parser: Parser<V>, callback: (machine: Machine) => void): Parser<V>; | ||
} | ||
@@ -580,48 +691,40 @@ declare namespace spellu { | ||
declare namespace spellu { | ||
function $<V>(box: ParserBox<V>, ...args: any[]): Parser<V>; | ||
namespace $ { | ||
function always(): Parser<undefined>; | ||
function always<V>(value: V): Parser<V>; | ||
function never<V>(message_?: string): Parser<V>; | ||
function start<V>(parser: Parser<V>): Parser<V>; | ||
function end(): Parser<null>; | ||
function not<V>(parser: Parser<V>): Parser<null>; | ||
function repeat<V, S>(valueParser: Parser<V>, sepalatorParser: Parser<S>, options: { | ||
allowTrailingSeparator: boolean; | ||
multiplicity?: number; | ||
}): Parser<V[]>; | ||
function alternate<V, C>(valueParser: Parser<V>, combinorParser: Parser<C>): Parser<(V | C)[]>; | ||
function any(syntax: string): Parser<Token>; | ||
function comment(): Parser<Comment[]>; | ||
function string(syntax: string, string: string): Parser<Token>; | ||
function regex(syntax: string, pattern: string | RegExp, index?: number): Parser<Token>; | ||
function token(pattern: TokenPattern | TokenPattern[]): Parser<Token>; | ||
function annex(pattern: TokenPattern | TokenPattern[]): Parser<Token>; | ||
function block<V>(parser: Parser<V>): Parser<V[] | null>; | ||
function indent(): Parser<Indentation>; | ||
function outdent(): Parser<Indentation>; | ||
function samedent(): Parser<Indentation>; | ||
function eol(): Parser<Comment[]>; | ||
function tap<T>(object: T, callback: (object: T) => void): T; | ||
function node<N extends Node>(scaned: Node | (Node | null)[] | any, syntax: string, properties: {}): N; | ||
} | ||
function source(string: string, location?: string): Source; | ||
} | ||
declare namespace spellu { | ||
function source(string: string, location?: string): Source; | ||
function convertToLogMessage(source: Source, diagnoses: Diagnosis[]): Log[]; | ||
function displayLogMessage(logWriter: LogWriter, source: Source, diagnoses: Diagnosis[]): void; | ||
} | ||
declare namespace spellu { | ||
const enum MatchType { | ||
LeftHandMatch = 0, | ||
WholeMatch = 1 | ||
} | ||
type ScanOptions = { | ||
boards?: Board[]; | ||
startPosition?: number; | ||
wholeMatch?: boolean; | ||
processors: Processor[]; | ||
startPosition: number; | ||
matchType: MatchType; | ||
store: Dictionary; | ||
machineOptions: Partial<MachineOptions>; | ||
}; | ||
function scan<V>(ruleOrParser: string | Parser<V>, source: Source, options?: ScanOptions): Success<V> | Failure<Diagnosis[]>; | ||
class ScanFailure { | ||
constructor(source: Source, diagnoses: Diagnosis[]); | ||
source: Source; | ||
diagnoses: Diagnosis[]; | ||
getDiagnosisMessages(): Log[]; | ||
writeDiagnosisMessagesTo(logWriter?: LogWriter): null; | ||
} | ||
function scan<V>(source: Source, ruleOrParser: string | Parser<V>, options?: Partial<ScanOptions>): V; | ||
function scanAsync<V>(source: Source, ruleOrParser: string | Parser<V>, options?: Partial<ScanOptions>): Promise<V>; | ||
} | ||
declare namespace spellu { | ||
function build<V>(ruleOrParser: string | Parser<V>, source: Source, options?: ScanOptions): V | null; | ||
type ParseOptions = { | ||
logWriter: LogWriter; | ||
}; | ||
function parse<V>(source: Source, ruleOrParser: string | Parser<V>, options: Partial<ScanOptions & ParseOptions>): V | null; | ||
} | ||
declare namespace spellu { | ||
type TraceOptions = ScanOptions & { | ||
state?: any; | ||
color?: boolean; | ||
type TraceOptions = { | ||
state: any; | ||
color: boolean; | ||
}; | ||
@@ -632,3 +735,3 @@ class TraceResult { | ||
} | ||
function trace<V>(ruleOrParser: string | Parser<V>, source: Source, options_?: TraceOptions): TraceResult; | ||
function trace<V>(source: Source, ruleOrParser: string | Parser<V>, options?: Partial<ScanOptions & TraceOptions>): TraceResult; | ||
} | ||
@@ -639,2 +742,2 @@ declare namespace spellu { | ||
export default spellu; | ||
export declare const $: typeof spellu.$; | ||
export declare const $: typeof spellu.P; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126636
2618