本文整理汇总了TypeScript中@jonggrang/parsing.char函数的典型用法代码示例。如果您正苦于以下问题:TypeScript char函数的具体用法?TypeScript char怎么用?TypeScript char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了char函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
export const uri: PS.Parser<URI> = PS.co(function* () {
const us: string = yield PS.attempt(uscheme);
const [ua, up]: [Maybe<URIAuth>, string] = yield hierPart;
const uq: string = yield PS.option('', PS.char('?').chain(() => uquery));
const uf: string = yield PS.option('', PS.char('#').chain(() => ufragment));
return PS.pure(mkURI(us, ua, up, uq, uf));
});
示例2: notMatching
export const relativeRef: PS.Parser<URI> = PS.co(function* () {
yield notMatching(uscheme);
const [ua, path]: [Maybe<URIAuth>, string] = yield relativePart;
const uq: string = yield PS.option('', PS.char('?').chain(() => uquery));
const uf: string = yield PS.option('', PS.char('#').chain(() => ufragment));
return PS.pure(mkURI('', ua, path, uq, uf));
});
示例3: notFollowedBy
const ipv4address: PS.Parser<string> = PS.co(function* () {
const a1: string = yield decOctet;
yield PS.char('.');
const a2: string = yield decOctet;
yield PS.char('.');
const a3: string = yield decOctet;
yield PS.char('.');
const a4: string = yield decOctet;
yield notFollowedBy(nameChar);
return PS.pure(`${a1}.${a2}.${a3}.${a4}`);
});
示例4: digits
const time: PS.Parser<[number, number, number]> = PS.co(function* () {
let h = yield digits(2, 2);
yield PS.char(':');
let m = yield digits(2, 2);
// the seconds fields is optional
let s = yield PS.option(0, PS.attempt(PS.char(':').chain(() => digits(2, 2))));
if (h > 23 || m > 59 || s > 59) {
return PS.fail('hour, minute and seconds must be in valid range');
}
return PS.pure([h, m, s]);
});
示例5: oneThenMany
const uscheme: PS.Parser<string> = PS.co(function* () {
const s: string = yield oneThenMany(PS.anyLetter, PS.satisfy(isSchemeChar)).map(joinStr);
yield PS.char(':');
return PS.pure(s + ':');
});