UNPKG

@rshirohara/repixe-parse

Version:
257 lines 6.27 kB
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: FlowContent[]; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type FlowContent = Heading | PageBreak | Paragraph; export type Heading = { type: "heading"; children: HeadingText; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type HeadingStart = [Left, "chapter:", Space[]]; export type HeadingText = any[]; export type HeadingEnd = [Space[], Right]; export type PageBreak = { type: "pageBreak"; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type PBBody = "[newpage]"; export type Paragraph = { type: "paragraph"; children: any[]; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type PhrasingContent = Break | Image | Link | PageReference | InlinePhrasingContent; export type Break = { type: "break"; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type Image = { [k: string]: string | number | ImageId | { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type ImageStart = [Left, "pixivimage:"]; export type ImageId = string; export type ImagePage = string; export type Link = { type: "link"; url: LinkUrl; children: LinkText; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type LinkStart = [Left, Left, "jumpuri:", Space[]]; export type LinkText = InlinePhrasingContent[]; export type LinkNext = [Space[], Next, HalfWidthSpace[]]; export type LinkUrl = string; export type LinkEnd = [HalfWidthSpace[], Right, Right]; export type PageReference = { type: "pageReference"; pageNumber: number; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type PRStart = [Left, "jump:"]; export type PRPage = string; export type InlinePhrasingContent = Ruby | Text; export type Ruby = { type: "ruby"; value: RubyText; ruby: RubyBody; position: { start: { offset: number; line: number; column: number; }; end: { offset: number; line: number; column: number; }; }; }; export type RubyStart = [Left, Left, "rb:", Space[]]; export type RubyText = string; export type RubyNext = [Space[], Next, Space[]]; export type RubyBody = string; export type RubyEnd = [Space[], Right, Right]; 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 Text_1 = string; export type Left = "["; export type Right = "]"; export type Next = ">"; export type Hyphen = "-"; export type FullWidthSpace = "\u3000"; export type HalfWidthSpace = " "; export type Space = string; export type UrlText = string; export {}; //# sourceMappingURL=parser.peg.d.ts.map