@rshirohara/rekurke-parse
Version:
rekurke plugin to add support for parsing kakuyomu novel format.
208 lines • 4.84 kB
TypeScript
export interface FilePosition {
offset: number;
line: number;
column: number;
}
export interface FileRange {
start: FilePosition;
end: FilePosition;
source: string;
}
export interface LiteralExpectation {
type: "literal";
text: string;
ignoreCase: boolean;
}
export interface ClassParts extends Array<string | ClassParts> {
}
export interface ClassExpectation {
type: "class";
parts: ClassParts;
inverted: boolean;
ignoreCase: boolean;
}
export interface AnyExpectation {
type: "any";
}
export interface EndExpectation {
type: "end";
}
export interface OtherExpectation {
type: "other";
description: string;
}
export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
declare class _PeggySyntaxError extends Error {
static buildMessage(expected: Expectation[], found: string | null): string;
message: string;
expected: Expectation[];
found: string | null;
location: FileRange;
name: string;
constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
format(sources: {
source?: any;
text: string;
}[]): string;
}
export interface TraceEvent {
type: string;
rule: string;
result?: any;
location: FileRange;
}
export interface ParseOptions {
filename?: string;
startRule?: "Root";
tracer?: any;
[key: string]: any;
}
export type ParseFunction = <Options extends ParseOptions>(input: string, options?: Options) => Options extends {
startRule: infer StartRule;
} ? StartRule extends "Root" ? Root : Root : Root;
export declare const parse: ParseFunction;
export declare const PeggySyntaxError: typeof _PeggySyntaxError;
export type PeggySyntaxError = _PeggySyntaxError;
export type Root = {
type: "root";
children: (ParagraphMargin | Paragraph)[];
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type ParagraphMargin = {
type: "paragraphMargin";
size: number;
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type Paragraph = {
type: "paragraph";
children: any[];
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type EscapedLeft = {
type: "text";
value: string;
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type Emphasis = {
type: "emphasis";
value: EmphasisText;
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type EmphasisLeft = Left[];
export type EmphasisRight = Right[];
export type EmphasisText = string;
export type Ruby = {
type: "ruby";
value: RubyStart;
ruby: RubyBody;
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type RubyStart = RubyStartVert | RubyStartAuto;
export type RubyStartAuto = string;
export type RubyStartVert = string;
export type RubyBody = string;
export type RubyTextAuto = [string, undefined];
export type Break = {
type: "break";
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type Text = {
type: "text";
value: string;
position: {
start: {
offset: number;
line: number;
column: number;
};
end: {
offset: number;
line: number;
column: number;
};
};
};
export type Break_1 = "\r\n" | "\n";
export type Left = "\u300a";
export type Right = "\u300b";
export type Text_1 = string;
export type Vertical = string;
export {};
//# sourceMappingURL=parser.peg.d.ts.map