You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
11 KiB

4 years ago
  1. // Generated by dts-bundle v0.7.3
  2. declare module 'regexpp' {
  3. import * as AST from "regexpp/ast";
  4. import { RegExpParser } from "regexpp/parser";
  5. import { RegExpValidator } from "regexpp/validator";
  6. import { RegExpVisitor } from "regexpp/visitor";
  7. export { AST, RegExpParser, RegExpValidator };
  8. export function parseRegExpLiteral(source: string | RegExp, options?: RegExpParser.Options): AST.RegExpLiteral;
  9. export function validateRegExpLiteral(source: string, options?: RegExpValidator.Options): void;
  10. export function visitRegExpAST(node: AST.Node, handlers: RegExpVisitor.Handlers): void;
  11. }
  12. declare module 'regexpp/ast' {
  13. export type Node = BranchNode | LeafNode;
  14. export type BranchNode = RegExpLiteral | Pattern | Alternative | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion | CharacterClassRange;
  15. export type LeafNode = BoundaryAssertion | CharacterSet | Character | Backreference | Flags;
  16. export type Element = Assertion | Quantifier | QuantifiableElement;
  17. export type QuantifiableElement = Group | CapturingGroup | CharacterClass | CharacterSet | Character | Backreference | LookaheadAssertion;
  18. export type CharacterClassElement = EscapeCharacterSet | UnicodePropertyCharacterSet | Character | CharacterClassRange;
  19. export interface NodeBase {
  20. type: Node["type"];
  21. parent: Node["parent"];
  22. start: number;
  23. end: number;
  24. raw: string;
  25. }
  26. export interface RegExpLiteral extends NodeBase {
  27. type: "RegExpLiteral";
  28. parent: null;
  29. pattern: Pattern;
  30. flags: Flags;
  31. }
  32. export interface Pattern extends NodeBase {
  33. type: "Pattern";
  34. parent: RegExpLiteral | null;
  35. alternatives: Alternative[];
  36. }
  37. export interface Alternative extends NodeBase {
  38. type: "Alternative";
  39. parent: Pattern | Group | CapturingGroup | LookaroundAssertion;
  40. elements: Element[];
  41. }
  42. export interface Group extends NodeBase {
  43. type: "Group";
  44. parent: Alternative | Quantifier;
  45. alternatives: Alternative[];
  46. }
  47. export interface CapturingGroup extends NodeBase {
  48. type: "CapturingGroup";
  49. parent: Alternative | Quantifier;
  50. name: string | null;
  51. alternatives: Alternative[];
  52. references: Backreference[];
  53. }
  54. export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion;
  55. export interface LookaheadAssertion extends NodeBase {
  56. type: "Assertion";
  57. parent: Alternative | Quantifier;
  58. kind: "lookahead";
  59. negate: boolean;
  60. alternatives: Alternative[];
  61. }
  62. export interface LookbehindAssertion extends NodeBase {
  63. type: "Assertion";
  64. parent: Alternative;
  65. kind: "lookbehind";
  66. negate: boolean;
  67. alternatives: Alternative[];
  68. }
  69. export interface Quantifier extends NodeBase {
  70. type: "Quantifier";
  71. parent: Alternative;
  72. min: number;
  73. max: number;
  74. greedy: boolean;
  75. element: QuantifiableElement;
  76. }
  77. export interface CharacterClass extends NodeBase {
  78. type: "CharacterClass";
  79. parent: Alternative | Quantifier;
  80. negate: boolean;
  81. elements: CharacterClassElement[];
  82. }
  83. export interface CharacterClassRange extends NodeBase {
  84. type: "CharacterClassRange";
  85. parent: CharacterClass;
  86. min: Character;
  87. max: Character;
  88. }
  89. export type Assertion = BoundaryAssertion | LookaroundAssertion;
  90. export type BoundaryAssertion = EdgeAssertion | WordBoundaryAssertion;
  91. export interface EdgeAssertion extends NodeBase {
  92. type: "Assertion";
  93. parent: Alternative | Quantifier;
  94. kind: "start" | "end";
  95. }
  96. export interface WordBoundaryAssertion extends NodeBase {
  97. type: "Assertion";
  98. parent: Alternative | Quantifier;
  99. kind: "word";
  100. negate: boolean;
  101. }
  102. export type CharacterSet = AnyCharacterSet | EscapeCharacterSet | UnicodePropertyCharacterSet;
  103. export interface AnyCharacterSet extends NodeBase {
  104. type: "CharacterSet";
  105. parent: Alternative | Quantifier;
  106. kind: "any";
  107. }
  108. export interface EscapeCharacterSet extends NodeBase {
  109. type: "CharacterSet";
  110. parent: Alternative | Quantifier | CharacterClass;
  111. kind: "digit" | "space" | "word";
  112. negate: boolean;
  113. }
  114. export interface UnicodePropertyCharacterSet extends NodeBase {
  115. type: "CharacterSet";
  116. parent: Alternative | Quantifier | CharacterClass;
  117. kind: "property";
  118. key: string;
  119. value: string | null;
  120. negate: boolean;
  121. }
  122. export interface Character extends NodeBase {
  123. type: "Character";
  124. parent: Alternative | Quantifier | CharacterClass | CharacterClassRange;
  125. value: number;
  126. }
  127. export interface Backreference extends NodeBase {
  128. type: "Backreference";
  129. parent: Alternative | Quantifier;
  130. ref: number | string;
  131. resolved: CapturingGroup;
  132. }
  133. export interface Flags extends NodeBase {
  134. type: "Flags";
  135. parent: RegExpLiteral | null;
  136. dotAll: boolean;
  137. global: boolean;
  138. ignoreCase: boolean;
  139. multiline: boolean;
  140. sticky: boolean;
  141. unicode: boolean;
  142. }
  143. }
  144. declare module 'regexpp/parser' {
  145. import { Flags, RegExpLiteral, Pattern } from "regexpp/ast";
  146. import { EcmaVersion } from "regexpp/ecma-versions";
  147. export namespace RegExpParser {
  148. interface Options {
  149. strict?: boolean;
  150. ecmaVersion?: EcmaVersion;
  151. }
  152. }
  153. export class RegExpParser {
  154. constructor(options?: RegExpParser.Options);
  155. parseLiteral(source: string, start?: number, end?: number): RegExpLiteral;
  156. parseFlags(source: string, start?: number, end?: number): Flags;
  157. parsePattern(source: string, start?: number, end?: number, uFlag?: boolean): Pattern;
  158. }
  159. }
  160. declare module 'regexpp/validator' {
  161. import { EcmaVersion } from "regexpp/ecma-versions";
  162. export namespace RegExpValidator {
  163. interface Options {
  164. strict?: boolean;
  165. ecmaVersion?: EcmaVersion;
  166. onLiteralEnter?(start: number): void;
  167. onLiteralLeave?(start: number, end: number): void;
  168. onFlags?(start: number, end: number, global: boolean, ignoreCase: boolean, multiline: boolean, unicode: boolean, sticky: boolean, dotAll: boolean): void;
  169. onPatternEnter?(start: number): void;
  170. onPatternLeave?(start: number, end: number): void;
  171. onDisjunctionEnter?(start: number): void;
  172. onDisjunctionLeave?(start: number, end: number): void;
  173. onAlternativeEnter?(start: number, index: number): void;
  174. onAlternativeLeave?(start: number, end: number, index: number): void;
  175. onGroupEnter?(start: number): void;
  176. onGroupLeave?(start: number, end: number): void;
  177. onCapturingGroupEnter?(start: number, name: string | null): void;
  178. onCapturingGroupLeave?(start: number, end: number, name: string | null): void;
  179. onQuantifier?(start: number, end: number, min: number, max: number, greedy: boolean): void;
  180. onLookaroundAssertionEnter?(start: number, kind: "lookahead" | "lookbehind", negate: boolean): void;
  181. onLookaroundAssertionLeave?(start: number, end: number, kind: "lookahead" | "lookbehind", negate: boolean): void;
  182. onEdgeAssertion?(start: number, end: number, kind: "start" | "end"): void;
  183. onWordBoundaryAssertion?(start: number, end: number, kind: "word", negate: boolean): void;
  184. onAnyCharacterSet?(start: number, end: number, kind: "any"): void;
  185. onEscapeCharacterSet?(start: number, end: number, kind: "digit" | "space" | "word", negate: boolean): void;
  186. onUnicodePropertyCharacterSet?(start: number, end: number, kind: "property", key: string, value: string | null, negate: boolean): void;
  187. onCharacter?(start: number, end: number, value: number): void;
  188. onBackreference?(start: number, end: number, ref: number | string): void;
  189. onCharacterClassEnter?(start: number, negate: boolean): void;
  190. onCharacterClassLeave?(start: number, end: number, negate: boolean): void;
  191. onCharacterClassRange?(start: number, end: number, min: number, max: number): void;
  192. }
  193. }
  194. export class RegExpValidator {
  195. constructor(options?: RegExpValidator.Options);
  196. validateLiteral(source: string, start?: number, end?: number): void;
  197. validateFlags(source: string, start?: number, end?: number): void;
  198. validatePattern(source: string, start?: number, end?: number, uFlag?: boolean): void;
  199. }
  200. }
  201. declare module 'regexpp/visitor' {
  202. import { Alternative, Assertion, Backreference, CapturingGroup, Character, CharacterClass, CharacterClassRange, CharacterSet, Flags, Group, Node, Pattern, Quantifier, RegExpLiteral } from "regexpp/ast";
  203. export class RegExpVisitor {
  204. constructor(handlers: RegExpVisitor.Handlers);
  205. visit(node: Node): void;
  206. }
  207. export namespace RegExpVisitor {
  208. interface Handlers {
  209. onAlternativeEnter?(node: Alternative): void;
  210. onAlternativeLeave?(node: Alternative): void;
  211. onAssertionEnter?(node: Assertion): void;
  212. onAssertionLeave?(node: Assertion): void;
  213. onBackreferenceEnter?(node: Backreference): void;
  214. onBackreferenceLeave?(node: Backreference): void;
  215. onCapturingGroupEnter?(node: CapturingGroup): void;
  216. onCapturingGroupLeave?(node: CapturingGroup): void;
  217. onCharacterEnter?(node: Character): void;
  218. onCharacterLeave?(node: Character): void;
  219. onCharacterClassEnter?(node: CharacterClass): void;
  220. onCharacterClassLeave?(node: CharacterClass): void;
  221. onCharacterClassRangeEnter?(node: CharacterClassRange): void;
  222. onCharacterClassRangeLeave?(node: CharacterClassRange): void;
  223. onCharacterSetEnter?(node: CharacterSet): void;
  224. onCharacterSetLeave?(node: CharacterSet): void;
  225. onFlagsEnter?(node: Flags): void;
  226. onFlagsLeave?(node: Flags): void;
  227. onGroupEnter?(node: Group): void;
  228. onGroupLeave?(node: Group): void;
  229. onPatternEnter?(node: Pattern): void;
  230. onPatternLeave?(node: Pattern): void;
  231. onQuantifierEnter?(node: Quantifier): void;
  232. onQuantifierLeave?(node: Quantifier): void;
  233. onRegExpLiteralEnter?(node: RegExpLiteral): void;
  234. onRegExpLiteralLeave?(node: RegExpLiteral): void;
  235. }
  236. }
  237. }
  238. declare module 'regexpp/ecma-versions' {
  239. export type EcmaVersion = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
  240. }