On Sunday, October 30, 2016 at 11:25:18 AM UTC-5, Edward K. Ream wrote:
Here, I'll be thinking out loud about how to make code generation work when
> using the new-style importers.
>
This is also an Engineering Notebook post. Feel free to ignore.
*Status Report*
As expected, a line-oriented approach simplifies much of the code.
However, keeping the details straight is still challenging. Recursive
parsing is tricky, but I have lots of experience with such code.
Code generation drives appears to drive all aspects of the code, including
parsing. The simplest thing that could possibly work may be:
1. Ref lines (@others or section references) will never be indented in the
top-level nodes.
2. All other ref lines will be indented by the amount implied by @tabwidth.
3. When computing the text of a block, all lines will be unindented by the
cumulative value of all ancestor refs. Underindented lines will be
represented by Leo's (ugly) underindented escapes, possibly only for
"strict" languages like python.
The advantage of this scheme is that should usually (always?) produce a
perfect import of all lines. The disadvantage is that it could produce lots
of escapes.
Alternatively, it would be possible to eliminate all escapes by looking
ahead to see whether indenting a ref line is possible. This will eliminate
escapes, but could cause generated code to look like:
class MyClass:
@others # no indentation.
This will "penalize" all methods that *are* properly indented. All lines
of properly indented nodes will start with "extra" whitespace.
This scheme would require three-pass code generation. The first pass
produces blocks. The second computes the indentations needed for ref
lines. The third produces outline nodes. I'll try hard to avoid this way.
*Summary*
Parsing input files into nodes is tricky, especially when using @others.
Using section refs is easier.
The simplest code generation when using @others will be to use "standard"
indentation for @others. This implies generating escapes for underindented
lines. I'll attempt this next.
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.