-
-
Save starakaj/4ea3aa2850fe3870bd9130b4f56e7136 to your computer and use it in GitHub Desktop.
Creating statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translateSource(data: string, outPath: string) { | |
let paintFunctionStatements: Statement[] = []; | |
const parser = new html2.Parser({ | |
onopentag(name: string, attribs: {[s: string]: string}) { | |
if (name === "rect") { | |
const statements = makeStatementsFromRectAttribs(attribs); | |
paintFunctionStatemens = paintFunctionStatements.concat(statements); | |
} | |
} | |
}); | |
parser.parseComplete(data); | |
const program: Program = makePaintProgramForStatements(paintFunctionStatements); | |
const outputString = generate(program); | |
fs.writeFile(outPath, outputString, { encoding: "utf8" }, () => { | |
console.log(`Wrote output to ${outPath}`); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment