(blocklySource)
| 645 | } |
| 646 | |
| 647 | function doParse (blocklySource) { |
| 648 | const { parse } = window.esper.plugins.babylon.babylon |
| 649 | if (/^continue;\s*/.test(blocklySource)) return { type: 'ContinueStatement' } |
| 650 | if (/^break;\s*/.test(blocklySource)) return { type: 'BreakStatement' } |
| 651 | if (/^return;\s*/.test(blocklySource)) return { type: 'ReturnStatement' } |
| 652 | if (/^'';\s*/.test(blocklySource)) return { type: 'StringLiteral' } |
| 653 | |
| 654 | const ast = parse(blocklySource, { errorRecovery: true }) |
| 655 | if (ast.program.body.length !== 1) return null |
| 656 | let node = ast.program.body[0] |
| 657 | if (!node) return ast |
| 658 | let expression = false |
| 659 | if (node.type === 'ExpressionStatement') { |
| 660 | expression = true |
| 661 | node = node.expression |
| 662 | } |
| 663 | return { ...node, expression } |
| 664 | } |
| 665 | |
| 666 | function nextify (arr, ctx) { |
| 667 | let result |
no outgoing calls
no test coverage detected