本文整理匯總了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(''))