blob: eff40377ba0a0f4c252eccad077828a6e9dba5c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import * as assert from 'assert';
import { Node } from './base';
/**
* This node consumes number of characters specified by state's property with
* name `field` from the input, and forwards execution to `otherwise` node.
*/
export class Consume extends Node {
/**
* @param field State's property name
*/
constructor(public readonly field: string) {
super('consume_' + field);
if (/^_/.test(field)) {
throw new Error(`Can't use internal field in \`consume()\`: "${field}"`);
}
}
}
|