On Fri, Dec 3, 2021 at 3:42 AM vitalije <[email protected]> wrote:
> Attached to this message is an improved version of this script, which
doesn't "wish away the difficulties", but does full import.
Excellent work. Imo, the complexity of this script is roughly comparable
to the complexity of the present code generators:
- close_defs is comparable to end_previous_blocks. end_previous_blocks is a
bit shorter but contains more "if" statements.
- The way your code generates @others is particularly clever. There are
two cases:
1. In split_root:
def body(a, b):
return ''.join(lines[a-1:b and (b-1)])
nodes = find_node_borders(txt)
a, b, h = nodes[0]
root.b = f'{body(a, b)}@others\n{body(nodes[-1][0], None)}'
2. In split_class:
def indent(x):
return ' '*ind + x
nlines = [x[ind:] if len(x) > ind else x for x in lines[1:]]
txt = ''.join(nlines)
nodes = find_node_borders(txt)
a, b, h = nodes[0]
def body(a, b):
return ''.join(nlines[a-1:b and (b-1)])
b1 = ''.join(lines[a:b]) + indent('@others\n')
*Other comments*
The generated nodes look good enough for a prototype. The post-pass would
improve the result.
find_node_borders will be faster than the tokenizer driven by the table in
py_i.get_new_dict, but not enough to matter.
*Summary*
Many thanks for this script. The way it handles @others convinces me that
your approach is sound.
Imo, the complexity of your code generators is comparable to the complexity
of mine.
I am putting the finishing touches on the new python generator. I will
complete my present work in a day or so.
I'll be happy to consider a pull request containing your work. My
conditions of satisfaction:
1. I must be convinced that the new code is *substantially* better than the
present code. Yes, this condition increases the risk to you. Perhaps we can
vote on which code is better, but we can only vote once we all can see the
two final versions.
2. The PR must use the framework established by the Importer class. The PR
need not use the existing tokenizer.
3. The PR should include a TestPython class containing all the existing
tests, except for tests that test code that no longer exists.
4. The TestPython class should fully cover mk_py_importer.
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 view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/CAMF8tS22XJRn9Q6Z%2Bi3qEb8cKE6rLDPnoLZE-yCyMmFGtTz5aQ%40mail.gmail.com.