FYI: Recent improvements to the TypeScript and Rust importers

56 views
Skip to first unread message

Edward K. Ream

unread,
Jun 23, 2020, 11:08:09 AM6/23/20
to leo-editor
Typescript importer improvements

- Create separate nodes for 'export' functions, 'export enum' and 'export const enum'.

Rust importer improvements

- Remove more cruft from headlines.

- Move trailing comments and macro lines from to the start of the next node in outline order.

The presence of @others prevents lines from being moved out of any node. In theory, comments and/or macros immediately preceding @others could be moved to the next node, but it would take AI to know whether that is really wanted. But there is a new workaround...

The move-lines-to-next-node command

For rust, you can search for @others. If you find lines that you think should be moved to the next node, select those lines and use Leo's new move-lines-to-next-node command. This command is undoable.

For nodes containing @others, trailing comment lines belong to the next sibling, if there is a next sibling. Comment lines immediately preceding @others belong to the next child (if the comment applies to a single node). Otherwise the comments preceding @others should not be moved. They apply to all child nodes.

Summary

I am studying mini_leo (a rust program) and leoInteg (a typescript program). Leo's importers now work well for both. All comments and suggestions welcome.

Edward

vitalije

unread,
Jun 23, 2020, 2:06:42 PM6/23/20
to leo-editor

I am studying mini_leo (a rust program)
 
I am sorry for the mess that mini_leo currently is in. While studying just keep in mind it is far from its original idea. There is almost no documentation, no comments in the code and it contains traces from many different experiments. You might be puzzled by some code pieces that actually are just residuum of past experiments.

Also I plan to rewrite rust parsing code using the python code from my #1598 efforts in Leo (once I finish it). I believe this code is better than the present rust version and it handles unknownAttributes too. Anyway present rust code gives just a taste of what might be possible to achieve.

I haven't decided yet, which GUI framework to use for mini_leo. There are no standard GUI for rust applications yet, although there are many experiments in this area. Most likely candidate for now is using rust as back-end web server and creating GUI front-end in web browser. I've recently written several single page web applications using elm programming language and it was a very pleasant experience to work in elm. I plan to write about these experiences once I got more time. I've finally understood the real benefit of typed languages. I still like python and its dynamic typing, but now I see that creating good types can really simplify code.

With well designed types it is sometimes possible to banish all invalid states and make them impossible to happen. If the invalid states can't exist, there is no need later to check for them and code becomes much simpler. When there is a possibility to create an invalid state then in every piece of code that deals with the state there must be a check for these invalid states and those checks and guards are complicating every function. I haven't tried to use this technique in rust yet, but I guess it should be possible. Perhaps it is a natural thing to do in rust and I just missed the opportunity to use it before. I'll be writing more about this.

Vitalije

Edward K. Ream

unread,
Jun 23, 2020, 4:34:18 PM6/23/20
to leo-editor
On Tue, Jun 23, 2020 at 1:06 PM vitalije <vita...@gmail.com> wrote:

I am studying mini_leo (a rust program)
 
I am sorry for the mess that mini_leo currently is in.

Don't be sorry :-) It's a start!

Edward

Félix

unread,
Jun 23, 2020, 5:24:18 PM6/23/20
to leo-editor


Typescript importer improvements
- Create separate nodes for 'export' functions, 'export enum' and 'export const enum'.

This is great! I'm eager to add all my code into my Leo project file so importing with sections and separate nodes for those will save some time! Also, typescript is overcoming coffescript and becoming quite the standard now : https://trends.google.com/trends/explore?date=today%205-y&geo=US&q=%2Fm%2F0hjc5m0,%2Fm%2F0n50hxv

Edward K. Ream

unread,
Jun 23, 2020, 5:41:10 PM6/23/20
to leo-editor
On Tue, Jun 23, 2020 at 4:24 PM Félix <felix...@gmail.com> wrote:


Typescript importer improvements
- Create separate nodes for 'export' functions, 'export enum' and 'export const enum'.

This is great! I'm eager to add all my code into my Leo project file so importing with sections and separate nodes for those will save some time!

Glad you like it.
Also, typescript is overcoming coffescript and becoming quite the standard now : https://trends.google.com/trends/explore?date=today%205-y&geo=US&q=%2Fm%2F0hjc5m0,%2Fm%2F0n50hxv

Good to know. I personally don't care much. Am I correct that vs-code has explicit support for ts?

Edward

Félix

unread,
Jun 23, 2020, 6:14:17 PM6/23/20
to leo-editor
Yes indeed it does.

Edward K. Ream

unread,
Jun 24, 2020, 6:28:08 AM6/24/20
to leo-editor
On Tue, Jun 23, 2020 at 5:14 PM Félix <felix...@gmail.com> wrote:

>> Am I correct that vs-code has explicit support for ts?

> Yes indeed it does.

Thanks for the clarification.

Edward

Edward K. Ream

unread,
Jun 24, 2020, 9:57:47 AM6/24/20
to leo-editor
On Tuesday, June 23, 2020 at 3:34:18 PM UTC-5, Edward K. Ream wrote:

On Tue, Jun 23, 2020 at 1:06 PM vitalije wrote:

I am studying mini_leo (a rust program)
 
I am sorry for the mess that mini_leo currently is in.

Don't be sorry :-) It's a start!

I am wondering whether you might be willing to "back translate" the mini_leo code relating to leoNodes.py from rust back to python?

That is, I suspect you may have found considerably simpler way of updating v.children and v.parents when modifying the outline. Does this idea make sense to you?

Edward

vitalije

unread,
Jun 24, 2020, 11:58:04 AM6/24/20
to leo-editor


I am wondering whether you might be willing to "back translate" the mini_leo code relating to leoNodes.py from rust back to python?

That is, I suspect you may have found considerably simpler way of updating v.children and v.parents when modifying the outline. Does this idea make sense to you?

Edward

I am really glad you ask for it. I have made some experiments before which have a very similar model using built using cython.

Attached to this message is Leo outline containing experimental code.

HTH Vitalije
cdelta-ref.leo

Edward K. Ream

unread,
Jun 25, 2020, 12:16:01 PM6/25/20
to leo-editor
On Wed, Jun 24, 2020 at 10:58 AM vitalije <vita...@gmail.com> wrote:

I am wondering whether you might be willing to "back translate" the mini_leo code relating to leoNodes.py from rust back to python?

That is, I suspect you may have found considerably simpler way of updating v.children and v.parents when modifying the outline. Does this idea make sense to you?

I am really glad you ask for it. I have made some experiments before which have a very similar model using built using cython.

Attached to this message is Leo outline containing experimental code.

Thanks! When you can, a theory of operation would be helpful.

Edward
Reply all
Reply to author
Forward
0 new messages