本文整理汇总了TypeScript中vs/editor/common/modes/lineStream.LineStream.setTokenRules方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LineStream.setTokenRules方法的具体用法?TypeScript LineStream.setTokenRules怎么用?TypeScript LineStream.setTokenRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/modes/lineStream.LineStream
的用法示例。
在下文中一共展示了LineStream.setTokenRules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('next & goBack', () => {
var lineStream = new LineStream('albert, bart, charlie, damon, erich');
lineStream.setTokenRules(',', ' ');
assert.equal(lineStream.peekToken(), 'albert');
assert.equal(lineStream.next(), 'a');
assert.equal(lineStream.next(), 'l');
assert.equal(lineStream.next(), 'b');
assert.equal(lineStream.nextToken(), 'ert');
lineStream.goBack(6);
assert.equal(lineStream.nextToken(), 'albert');
assert.equal(lineStream.next(), ',');
lineStream.goBack(7);
assert.equal(lineStream.nextToken(), 'albert');
assert.equal(lineStream.nextToken(), ',');
assert.equal(lineStream.next(), ' ');
assert.equal(lineStream.next(), 'b');
assert.equal(lineStream.next(), 'a');
lineStream.goBack(3);
assert.equal(lineStream.nextToken(), 'bart');
lineStream.goBack(5);
assert.equal(lineStream.next(), ' ');
lineStream.advanceToEOS();
assert.throws(() => { lineStream.peekToken(); });
assert.throws(() => { lineStream.peek(); });
});
示例2: newTokenStream
function newTokenStream(source, separators, whitespace) {
var lineStream = new LineStream(source);
lineStream.setTokenRules(separators, whitespace);
return lineStream;
}