MCPcopy Create free account
hub / github.com/codecombat/codecombat / doParse

Function doParse

app/lib/code-to-blocks.js:647–664  ·  view source on GitHub ↗
(blocklySource)

Source from the content-addressed store, hash-verified

645}
646
647function 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
666function nextify (arr, ctx) {
667 let result

Callers 1

prepareBlockIntelligenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected