[Microbit-Python] Exporting JavaScript from TouchDevelop / Block Editor

Carlos P.A. carlos.p.a.87 at gmail.com
Mon May 30 14:37:29 EDT 2016


I only spent a couple of nights (basically just cutting down the microsoft
stuff around blockly and adding the general python generator), so I didn't
really get far at all. It will generate Python code as long as you don't
add any of the microbit-specific blocks, as I have not worked on any of the
new block generators.

In my original conception I wanted to be able to export the blocks from the
microsoft touch develop version and import them to generate python from the
same program, but I quickly realised there was some block incompatibilities
with the micropython microbit api and kind of lost interested and worked on
other stuff instead.

You should be able to generate some javascript as easily as python though,
but you would have to create generator for all the microbit-specific blocks.


On 30 May 2016 at 19:12, Andrew Ferguson <andrewferguson500 at gmail.com>
wrote:

> I was hoping that there would be a simple 'translateToJavascript();'
> function to generate the code necessary to run in the simulator from the
> code contained in the JSZ file that can be downloaded. Evidently it's more
> complicated than that!
>
> I also looked at your microbit-blocks-python repo, and tried to make that
> generate Python, with the view of 'if this works then I'll see if it can
> export JS'. However, I keep getting 'TypeError: b is undefined'. Did you
> ever get that to work?
>
> Thanks,
> Andrew
>
>
> On 30/05/16 17:58, Carlos P.A. wrote:
>
> I guess it depends on what you'd like to do exactly, having a very crude
> look at the code it seems that it goes through the following calls:
>
>
> https://github.com/Microsoft/TouchDevelop/blob/c810e73f6b11fc256b5f16719e97bdef86f2ff83/www/blockly/blockly-main.ts#L637
>
> https://github.com/Microsoft/TouchDevelop/blob/89b1653b4ccfe5d4bca9c7f3511d28c6a0eda3df/editor/external.ts#L633
>
> https://github.com/Microsoft/TouchDevelop/blob/89b1653b4ccfe5d4bca9c7f3511d28c6a0eda3df/editor/external.ts#L307
>
> So you can have a look at how the AST.compiler works, but I'm not quite
> sure what you are planning to do with that, so kind of hard to find out if
> you can "access"/extract it for your purposes.
>
>
>
> On 30 May 2016 at 17:37, Andrew Ferguson <andrewferguson500 at gmail.com>
> wrote:
>
>> I did have a look in there, but I couldn't see anything obvious that does
>> the translation. There's some docs on the TouchDevelop website that talk
>> about exporting regular (non microbit) scripts to NodeJS, but I couldn't
>> seem to find the 'export' feature that was mentioned.
>>
>>
>> On 30/05/16 17:33, Carlos P.A. wrote:
>>
>> Not exactly a small repository to explore, but I would assume all the
>> front end code will be contained here:
>> https://github.com/Microsoft/TouchDevelop
>>
>>
>>
>> On 30 May 2016 at 17:30, Andrew Ferguson < <andrewferguson500 at gmail.com>
>> andrewferguson500 at gmail.com> wrote:
>>
>>> Not a python-related question but...
>>>
>>> Is there a way to access the JavaScript generated by TouchDevelop /
>>> Block Editor when it is run in the online simulator? Writing a converter
>>> would be possible, but I'm fairly sure that somewhere in the TouchDevelop
>>> code it is translated to JavaScript, and I don't want to reinvent the wheel.
>>> _______________________________________________
>>> Microbit mailing list
>>> Microbit at python.org
>>> https://mail.python.org/mailman/listinfo/microbit
>>>
>>
>>
>>
>> _______________________________________________
>> Microbit mailing listMicrobit at python.orghttps://mail.python.org/mailman/listinfo/microbit
>>
>>
>>
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
>>
>>
>
>
> _______________________________________________
> Microbit mailing listMicrobit at python.orghttps://mail.python.org/mailman/listinfo/microbit
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160530/8ae489b1/attachment-0001.html>


More information about the Microbit mailing list