On Wed, Jan 17, 2018 at 3:54 AM, vitalije <[email protected]> wrote:

Regarding js importing, after some research about the topic, I concluded it
> is not possible/practical to make perfect js importer that can fully import
> javascript code on its own.
>

​I have reached the opposite conclusion.  Yesterday I fixed two minor bugs
in the importer.  One was a rare special case in the base linescanner.py
code, the other added support for the new backtick syntax to the javascript
scanner.

As a result, all the .js files in LeoVue import correctly and reasonably. I
know of no javascript files that can not be imported correctly.  Please
report any problems.

It's important to keep up with javascript, and the present code base is
easily up to the task.  As for jsx, a variant of the js importer should be
easy enough to do.

Doing it right would require building complete AI for this problem space
> and perhaps dealing with neural networks feeding them with big data
> collected from github and other source code repositories.
>

​The present code does the required AI.  I documented the code last year on
leo-editor.  The javascript importer is remarkably simple.  It consists
only of three overrides:

1. js_i.scan_line & helpers
2. js_i.starts_block
3. js_i.clean_headline

js_i.scan_line handles the crazy complexities of javascript *token*
scanning.  All scan_line methods return the state at the *end* of the
scanned line.  Typically a function or class can only be recognized if the
end of the *previous* line is not in a state (comment, string, etc.), but
as I re-read the code it appears that this is done implicitly.

js_i.starts_block returns true if the line should start a new node. This is
tricky code, but it appears to work.

js_i.clean_headline is easy code, with no implications for other code.

The other part of the puzzle is the JS_ScanState class.  It keeps track of
context and counts of parents and curly brackets.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to