Add a Lua code generator

This is based on the JS generator, with a lot of inspiration from Ellen
Spertus's blockly-lua: https://github.com/espertus/blockly-lua

All unit tests pass with Lua 5.3.2.
This commit is contained in:
Rodrigo Queiro
2016-02-04 16:54:52 +01:00
parent 0db36f3866
commit a5d3f340e5
19 changed files with 2090 additions and 2 deletions

View File

@@ -244,7 +244,7 @@ Code.LANG = Code.getLang();
* List of tab names.
* @private
*/
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'xml'];
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'lua', 'xml'];
Code.selected = 'blocks';
@@ -341,6 +341,14 @@ Code.renderContent = function() {
code = prettyPrintOne(code, 'dart');
content.innerHTML = code;
}
} else if (content.id == 'content_lua') {
code = Blockly.Lua.workspaceToCode(Code.workspace);
content.textContent = code;
if (typeof prettyPrintOne == 'function') {
code = content.innerHTML;
code = prettyPrintOne(code, 'lua');
content.innerHTML = code;
}
}
};

View File

@@ -12,6 +12,7 @@
<script src="../../python_compressed.js"></script>
<script src="../../php_compressed.js"></script>
<script src="../../dart_compressed.js"></script>
<script src="../../lua_compressed.js"></script>
<script src="code.js"></script>
</head>
<body>
@@ -41,6 +42,8 @@
<td class="tabmin">&nbsp;</td>
<td id="tab_dart" class="taboff">Dart</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_lua" class="taboff">Lua</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_xml" class="taboff">XML</td>
<td class="tabmax">
<button id="trashButton" class="notext" title="...">
@@ -67,6 +70,7 @@
<pre id="content_php" class="content"></pre>
<pre id="content_python" class="content"></pre>
<pre id="content_dart" class="content"></pre>
<pre id="content_lua" class="content"></pre>
<textarea id="content_xml" class="content" wrap="off"></textarea>
<xml id="toolbox" style="display: none">