本文整理汇总了TypeScript中parsimmon.alt函数的典型用法代码示例。如果您正苦于以下问题:TypeScript alt函数的具体用法?TypeScript alt怎么用?TypeScript alt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了alt函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Comparison: function(r) {
return parsimmon.alt(
parsimmon.seqMap(r.ValueExpression, r.IsNullOperator, (p, o) => [o, p]),
parsimmon.seqMap(
r.ValueExpression,
r.ComparisonOperator,
r.ValueExpression,
(p, o, v) => [o, p, v]
),
parsimmon.seqMap(
r.ValueExpression,
r.LikeOperator,
r.ValueExpression.skip(
parsimmon
.regexp(/escape/i)
.result("ESCAPE")
.skip(parsimmon.whitespace)
.desc("ESCAPE")
),
r.ValueExpression,
(a, b, c, d) => [b, a, c, d]
),
parsimmon.seqMap(
r.ValueExpression,
r.LikeOperator,
r.ValueExpression,
(a, b, c) => [b, a, c]
)
);
},
示例2:
const newParser: P.Parser<string> = P.lazy(() =>
P.alt(
consumeEnd ? parser.result('') : P.lookahead(parser),
P.seqMap(
P.any,
newParser,
(s, next) => s + next))
示例3: nodeMap
const param = P.lazy(() => nodeMap(
S.Param,
P.string('{param')
.then(spaced(identifierName)),
P.alt(
spaced(attribute.many()).skip(rbrace).then(bodyFor('param')),
spaced(colon).then(expression(closingBrace)))
));
示例4: closeCmd
const bodyParser: P.Parser<S.Body> = P.lazy(() =>
html.then(P.alt(
closeCmd(name).result([]),
P.alt(...inter.map(openCmd))
.result([])
.then(bodyParser),
P.seqMap(
P.alt(
literal,
call,
letStatement,
otherCmd('if', 'elseif', 'else'),
otherCmd('foreach', 'ifempty'),
otherCmd('msg', 'fallbackmsg'),
otherCmd('switch'),
interpolation('{', '}')),
bodyParser,
reverseJoin)))
示例5: lazy
const anyBlock: Parser<string> = lazy(() =>
seq(
string('{'), // Let's not eat whitespace around the braces.
alt(
anyBlock,
regex(/[^{}]+/)
).many().map(ss => ss.join('')),
string('}')
).map(ss => ss.join(''))