当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tparse.sequence函数代码示例

本文整理汇总了TypeScript中tparse.sequence函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sequence函数的具体用法?TypeScript sequence怎么用?TypeScript sequence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sequence函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: parseBinaryExpressionWith

function parseBinaryExpressionWith(subParser: Parser<ExpressionAST>, operators: string[][]) {
  return sequence(
    subParser,
    sequence(parseOperator(flattenSort(operators)), subParser).repeat()
  )
    .map(([first, rest]) => buildBinaryExpression(operators, first, rest));
}
开发者ID:seanchas116,项目名称:macaron,代码行数:7,代码来源:operator.ts

示例2: lazy

var parseIdentifierAssignable: Parser<AssignableAST> = lazy(() =>
  sequence(
    parseIdentifier,
    parseTypeExpression.mayBe()
  )
    .withRange()
    .map(([[name, type], range]) => new IdentifierAssignableAST(range, name, type))
开发者ID:seanchas116,项目名称:macaron,代码行数:7,代码来源:assignable.ts

示例3: sequence

function separated<T>(parser: Parser<T>) {
  return sequence(
      __.thenTake(parser.mayBe()),
      ___.thenTake(parser).repeat().thenSkip(__)
    )
    .map(([first, rest]) => first ? [first].concat(rest) : []);
}
开发者ID:seanchas116,项目名称:macaron,代码行数:7,代码来源:common.ts

示例4: parsePostfixWith

function parsePostfixWith(subParser: Parser<ExpressionAST>, postfixParsers: Parser<(value: ExpressionAST) => ExpressionAST>[]) {
  return sequence(
    subParser,
    choose(...postfixParsers).repeat()
  )
    .map(([value, postfixes]) =>
      postfixes.reduce((current, postfix) => postfix(current), value)
    );
}
开发者ID:seanchas116,项目名称:macaron,代码行数:9,代码来源:postfix.ts

示例5: lazy

var parseUnnamedFunction = lazy(() =>
  sequence(
    parseParameterList,
    keyword("=>").thenTake(parseBlock)
  )
    .withRange()
    .map(([[parameters, expressions], range]) =>
      new FunctionAST(range, new IdentifierAST(range, ""), [], parameters, null, expressions)
    )
开发者ID:seanchas116,项目名称:macaron,代码行数:9,代码来源:function.ts

示例6: lazy

var parseIfExpression: Parser<ExpressionAST> = lazy(() =>
  keyword("if").thenTake(
    sequence(
      parseExpression,
      parseBlock,
      parseElse.mayBe()
    )
      .withRange()
      .map(([[cond, ifTrue, ifFalse], range]) => new IfAST(range, cond, ifTrue, ifFalse || []))
  )
开发者ID:seanchas116,项目名称:macaron,代码行数:10,代码来源:control.ts

示例7: lazy

var parseMethodDeclaration = lazy(() =>
  sequence(
    parseIdentifier,
    parseParameterList,
    parseTypeExpression
  )
    .withRange()
    .map(([[name, params, returnType], range]) =>
      new FunctionAST(range, name, [], params, returnType, null)
    )
开发者ID:seanchas116,项目名称:macaron,代码行数:10,代码来源:class.ts

示例8: parseUnaryExpressionWith

function parseUnaryExpressionWith(subParser: Parser<ExpressionAST>, operators: string[][]) {
  return choose(
    subParser,
    sequence(
      parseOperator(flattenSort(operators)),
      subParser
    )
      .withRange()
      .map(([[operator, operand], range]) => new UnaryAST(range, operator, operand))
  );
}
开发者ID:seanchas116,项目名称:macaron,代码行数:11,代码来源:operator.ts


注:本文中的tparse.sequence函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。