On Jun 2, 9:50 am, "Edward K. Ream" <[email protected]> wrote:
> On Jun 2, 6:52 am, "Edward K. Ream" <[email protected]> wrote:
>
> > In short, Leo's node structure drastically simplifies the patterns to
> > be discovered.  That's the insight.
>
> With this insight, I am heavily revising the recursive import script I
> use to study other programs.

This is going very well.  The general plan has been fully vindicated.
Notes:

1. Testing revealed several problems with the original fixers.  All
such problems were easily fixed, and were localized to one particular
fixer.

2. Conceivably, the whole post-pass machinery could be integrated into
leoImport.py.  General fixers would be methods of a base class;
language-specific fixers would be part of subclasses.

3. Most interestingly, import all the files in python26/Lib/lib2to3
exposed some real problems with the import code.

A. My favorite is this fail from lib2to3/tests/data/
py2_test_grammar.py, the method testPrintStmt::

    self.assertEqual(sys.stdout.getvalue(), '''\
\\-41 2 3
\\-41 2 3
\\-41 1 1
\\-41 2 3
\\-41 2 3
\\-41 1 1
\\-4hello world
\\-4''')

The \\- convention allows Leo outlines to represent underindented
lines.  There are escapes for lines that start with \, but clearly
there must also be escapes for lines that start with any digit.  Here,
the leading "1" on each line is being sucked into the underindent
count.

B. I hacked the leoAtFile.write method with a flag that tells it to
ignore what look like section references.  This method is used by the
"perfect import check".  Clearly, in this case, the write code must
ignore section references.  This fixes a long standing bug.

C. Similarly, the same flag must tell leoAtFile.write to ignore what
look like Leo directives, especially @[space] and @doc.

All these fails will be easy to fix.  I might get to them today.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to