for-parser.js 634 B

123456789101112131415161718192021
  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. times: action.times,
  10. items: action.items != null ? resolveValue(action.items, variableContext) : null,
  11. body: action.body ? parseActions(action.body) : [],
  12. }
  13. return Object.assign({}, action, parsed)
  14. }
  15. async function execute() {
  16. return { success: true }
  17. }
  18. module.exports = { types, parse, execute }