本文整理汇总了TypeScript中@jonggrang/parsing.co函数的典型用法代码示例。如果您正苦于以下问题:TypeScript co函数的具体用法?TypeScript co怎么用?TypeScript co使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了co函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: optNH4cH4
function optNH4cH4(n: number): PS.Parser<string> {
return PS.option('', PS.co(function* () {
const a1: string = yield countMinMax(0, n, h4c).map(joinStr);
const a2: string = yield h4;
return PS.pure(a1 + a2);
}));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:7,代码来源:parsing.ts
示例2:
const ipv6addrz: PS.Parser<string> = PS.co(function* () {
const ip: string = yield ipv6address;
const t: string = yield PS.option('', PS.attempt(PS.co(function* () {
const e: string = yield PS.string('%25');
const z: string = yield zoneid;
return PS.pure(e + z);
})));
return PS.pure(ip + t);
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:parsing.ts
示例3: sequenceP
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256
];
const hexDigitChar: PS.Parser<string> = PS.satisfy(isHexDigitAt);
const escaped: PS.Parser<string> = sequenceP([ PS.char('%'), hexDigitChar, hexDigitChar ]).map(arrjoinStr);
const subDelims = PS.oneOf(['!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=']);
const unreservedChar = PS.satisfy(isUnreserved);
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 + ':');
});
const userinfo: PS.Parser<string> = PS.co(function* () {
const uu: L.List<string> = yield PS.many(uchar(';:&=+$,'));
yield PS.char('@');
return PS.pure(joinStr(uu) + '@');
});
const ipvFuture: PS.Parser<string> = PS.co(function* () {
const h: string = yield PS.between(PS.char('v'), PS.char('.'), hexDigitChar);
const a: string = yield PS.many1(PS.satisfy(isIpvFutureChar)).map(joinStr);
return PS.pure(`v${h}.${a}`);
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:30,代码来源:parsing.ts
示例4: digits
if (ix !== -1 && ix === pos) {
return P.right({ result: i as Month, suffix: { str, pos: pos + 3 }});
}
}
return P.left({ pos, error: new PS.ParseError('Expected one of month name') });
});
const date: PS.Parser<[number, Month, Day]> = PS.co(function* () {
let d = yield digits(1, 2);
yield PS.optional(PS.whiteSpace);
let m = yield month;
yield PS.optional(PS.whiteSpace);
let y = yield digits(2, 4);
if (y >= 70 && y <= 99) {
y += 1900;
} else if (y >= 0 && y <= 69) {
y += 2000;
}
return PS.pure([y, m, d]);
});
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))));
开发者ID:syaiful6,项目名称:jonggrang,代码行数:31,代码来源:date.ts
注:本文中的@jonggrang/parsing.co函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论