On Wednesday, November 27, 2019 at 7:07:21 AM UTC-6, Edward K. Ream wrote:

QQQ
1. A FormattedValue node represents a single token (a formatted string) 
that corresponds to an arbitrarily large subtree of parse nodes.

2. A JoinedStr node is a single tree node that corresponds to arbitrarily 
many tokens.

3. Parse trees can contain nested FormattedValue and JoinedStr nodes.
QQQ

Actually, things are a bit more complicated than this :-)

Happily, I now understand a crucial distinction:

- A *single *Str node represents the concatenation of multiple *plain *
strings.
- A JoinedStr node exists only when at least f-string is present in the 
concatenated f-strings.


*About advance_str*

At last the purpose of advance_str has become clear. It must scan *one or 
more* string tokens until the *accumulated *tokens are exactly equal to 
self.node.s.

This far from trivial, even when only only plain strings are involved. 
Indeed, self.node.s is a *plain *string, but 'string' tokens contain reprs! 
Sheesh.

A new* result_str* helper handles the complications. It strips leading and 
trailing quotes and corrects inner escaped quotes. More work *might *be 
needed in result_str to handle f-strings.  Or not...


*Status and summary*

Today's work has greatly clarified what must be done. Success is 
inevitable. 

advance_str is now the simplest thing that could possibly work. It 
correctly handles all plain (non f-string) tokens. It still fails when 
handling concatenated f-strings.

advance_str and its helper raise AssignLinksError when something unexpected 
happens. These are important sanity checks, and they simplifies debugging.

All of my "small" unit tests now pass, except the one specifically designed 
to fail on concatenated f-strings.

Despite this progress, significant new invention is needed. This is 
grueling work. I'll not speculate about schedule ;-)

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/031fa9a0-57a7-4cd6-89e9-4e9ea35393ad%40googlegroups.com.

Reply via email to