List and tuple convertor, use comma to separate when the length is greater than 3
@@ -2147,26 +2147,11 @@ PythonToBlocks.prototype.convertElements = function(key, values) {
* ctx: expr_context_ty
*
*/
-
-// return with many blocks, not use for the time being
-
-/*PythonToBlocks.prototype.List = function(node) {
- var elts = node.elts;
- var ctx = node.ctx;
-
- return block("lists_create_with_noreturn", node.lineno, {},
- this.convertElements("ADD", elts)
- , {
- "inline": "true",
- }, {
- "@items": elts.length
- });
-}
-*/
-
PythonToBlocks.prototype.List = function(node) {
var elts = node.elts;
+ if (elts.length > 3){
+ // return with one block & comma seperated
var valueList = [];
var s = this.getSourceCode(elts).split('\n')[node.lineno-1];
if (s.length > 0){
@@ -2182,22 +2167,9 @@ PythonToBlocks.prototype.List = function(node) {
}, {
});
-}
-
-/*
- * elts: asdl_seq
- * ctx: expr_context_ty
- */
-
-// return with many blocks, not use for the time being
-
-/*
-PythonToBlocks.prototype.Tuple = function(node)
-{
- var elts = node.elts;
- var ctx = node.ctx;
-
- return block("tuple_create_with_noreturn", node.lineno, {},
+ }else{
+ // return with many blocks
+ return block("lists_create_with_noreturn", node.lineno, {},
this.convertElements("ADD", elts)
, {
"inline": "true",
@@ -2205,12 +2177,18 @@ PythonToBlocks.prototype.Tuple = function(node)
"@items": elts.length
});
}
-*/
+}
+/*
+ * elts: asdl_seq
+ * ctx: expr_context_ty
+ */
PythonToBlocks.prototype.Tuple = function(node)
{
var elts = node.elts;
+ if (elts.length > 3){
+ // return with one block & comma seperated
var valueList = [];
var s = this.getSourceCode(elts).split('\n')[node.lineno-1];
if (s.length > 0){
@@ -2227,6 +2205,17 @@ PythonToBlocks.prototype.Tuple = function(node)
});
}
+ else{
+ // return with many blocks
+ return block("tuple_create_with_noreturn", node.lineno, {},
+ this.convertElements("ADD", elts)
+ , {
+ "inline": "true",
+ }, {
+ "@items": elts.length
+ });
+ }
+}
/*
* elts: asdl_seq
