Merge pull request #28046 from pheromonez/master

[moo] Allow rules to consist of an array of sub-rules
This commit is contained in:
Benjamin Lichtman
2018-08-13 14:48:23 -07:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -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 {
+10
View File
@@ -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) },
],
// ...
});