UNPKG

cream-and-sugar

Version:

A deliciously functional syntax for JavaScript with native support for JSX

26 lines (24 loc) 767 B
import { compile, nodes, groupPolymorphs } from '../utils'; /* * Loop over all nodes in the program body and call * compile for each one. Make sure we have a shared string * to contain the output. */ compile(nodes.ProgramNode, function () { const newBody = groupPolymorphs(this.body); this.shared.output = ''; this.shared.insertSemis = true; // Turn this off when we're going to manually handle it this.shared.refs = -1; this.shared.lookups = -1; this.shared.prevLookup = ''; this.shared.disableLookupResets = false; newBody.forEach(node => { try { node.compile(); } catch (err) { console.log(`Error: Could not compile ${node.type ? node.type : 'node ' + JSON.stringify(node)}`); throw err; } }); return ''; });