private String generateProgram(String programName, BlocklyProgramAndConfigTransformer data) { String sourceCode = Ast2JavaScriptVisitor.generate( data.getBrickConfiguration(), data.getProgramTransformer().getTree()); SimCompilerWorkflow.LOG.info("generating javascript code"); return sourceCode; }
/** * - take the program given<br> * - generate the AST<br> * - typecheck the AST, execute sanity checks, check a matching brick configuration<br> * - generate source code in the right language for the robot<br> * - and return it * * @param token the credential the end user (at the terminal) and the brick have both agreed to * use * @param programName name of the program * @param programText source of the program * @param configurationText the hardware configuration source that describes characteristic data * of the robot * @return the generated source code; null in case of an error */ @Override public String generateSourceCode( IRobotFactory factory, String token, String programName, String programText, String configurationText) { BlocklyProgramAndConfigTransformer data = BlocklyProgramAndConfigTransformer.transform(factory, programText, configurationText); if (data.getErrorMessage() != null) { return null; } return generateProgram(programName, data); }