securemark 0.296.3 → 0.296.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,18 +7,17 @@ export function str(pattern: string | RegExp, after?: string | RegExp): Parser<s
7
7
  return matcher(pattern, true, after ? tester(after, false) : undefined);
8
8
  }
9
9
 
10
- export function strs(pattern: string, limit?: number): StrParser;
11
- export function strs(pattern: string, limit: number = -1): Parser<string> {
12
- assert(pattern);
10
+ export function strs(char: string, min?: number, max?: number): StrParser;
11
+ export function strs(char: string, min: number = 1, max: number = -1): Parser<string> {
12
+ assert(char.length === 1);
13
13
  return ({ context }) => {
14
- const { source } = context;
15
- let acc = '';
16
- for (let i = 0; i !== limit && context.position < source.length && source.startsWith(pattern, context.position); ++i) {
17
- acc += pattern;
18
- context.position += pattern.length;
14
+ const { source, position } = context;
15
+ let cnt = 0;
16
+ for (; cnt !== max && context.position < source.length && source[context.position] === char; ++cnt) {
17
+ context.position += char.length;
19
18
  }
20
- return acc
21
- ? new List([new Node(acc)])
19
+ return cnt >= min
20
+ ? new List([new Node(source.slice(position, context.position))])
22
21
  : undefined;
23
22
  };
24
23
  }
@@ -8,10 +8,11 @@ export import UnescapableSourceParser = SourceParser.UnescapableSourceParser;
8
8
  export import StrParser = SourceParser.StrParser;
9
9
  export import ContentLineParser = SourceParser.ContentLineParser;
10
10
  export import EmptyLineParser = SourceParser.EmptyLineParser;
11
+ export import EmptySegmentParser = SourceParser.EmptySegmentParser;
11
12
  export import AnyLineParser = SourceParser.AnyLineParser;
12
13
 
13
14
  export { text, txt } from './source/text';
14
15
  export { escsource } from './source/escapable';
15
16
  export { unescsource } from './source/unescapable';
16
17
  export { str, strs } from './source/str';
17
- export { contentline, emptyline, anyline } from './source/line';
18
+ export { contentline, emptyline, emptysegment, anyline } from './source/line';