mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-30 10:35:22 +08:00
Allow rules to consist of an array of sub-rules
This commit is contained in:
2
types/moo/index.d.ts
vendored
2
types/moo/index.d.ts
vendored
@@ -50,7 +50,7 @@ export interface Rule {
|
||||
};
|
||||
}
|
||||
export interface Rules {
|
||||
[x: string]: RegExp | string | string[] | Rule;
|
||||
[x: string]: RegExp | string | string[] | Rule | Rule[];
|
||||
}
|
||||
|
||||
export interface Lexer {
|
||||
|
||||
@@ -75,3 +75,13 @@ lexer.next();
|
||||
lexer.next();
|
||||
lexer.reset('a different line\n', info);
|
||||
lexer.next();
|
||||
|
||||
// Transform: https://github.com/no-context/moo#transform
|
||||
moo.compile({
|
||||
STRING: [
|
||||
{ match: /"""[^]*?"""/, lineBreaks: true, value: x => x.slice(3, -3) },
|
||||
{ match: /"(?:\\["\\rn]|[^"\\])*?"/, lineBreaks: true, value: x => x.slice(1, -1) },
|
||||
{ match: /'(?:\\['\\rn]|[^'\\])*?'/, lineBreaks: true, value: x => x.slice(1, -1) },
|
||||
],
|
||||
// ...
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user