for-parser.js 675 B

12345678910111213141516171819202122
  1. /** 语句:for 循环(解析在此,执行在 sequence-runner) */
  2. const types = ['for']
  3. function parse(action, parseContext) {
  4. const { resolveValue, parseActions } = parseContext
  5. const variableContext = parseContext.variableContext || {}
  6. const parsed = {
  7. type: 'for',
  8. variable: action.variable,
  9. indexVariable: action.indexVariable,
  10. times: action.times,
  11. items: action.items != null ? resolveValue(action.items, variableContext) : null,
  12. body: action.body ? parseActions(action.body) : [],
  13. }
  14. return Object.assign({}, action, parsed)
  15. }
  16. async function execute() {
  17. return { success: true }
  18. }
  19. module.exports = { types, parse, execute }