johnlumley / jwiXML

An iXML processor for JavaScript and SaxonJS
MIT License
13 stars 0 forks source link

Insertion not done when occurring in separator of repetition #10

Open GuntherRademacher opened 3 months ago

GuntherRademacher commented 3 months ago

GuntherRademacher/markup-blitz#10 mentions several alternate formulations of a rule that includes an insertion as part of the separator of a repetition.

I happened to try those on jwiXML.xhtml, and found that for none of those variants the insertion is actually done. In contrast to that, the b-list shown in GuntherRademacher/markup-blitz#9, where the insertion is in a separate rule, works as expected.

Just thought you might want to know. Thanks for providing the webpage, by the way.

johnlumley commented 3 months ago

Thanks Gunther, I’m currently on vacation and will look at this when I return in about a week. Might be worth adding some tests to the iXML test suite.

Sent from my iPad

On 27 May 2024, at 20:34, Gunther Rademacher @.***> wrote:

 GuntherRademacher/markup-blitz#10 mentions several alternate formulations of a rule that includes an insertion as part of the separator of a repetition.

I happened to try those on jwiXML.xhtml, and found that for none of those variants the insertion is actually done. In contrast to that, the variant shown in GuntherRademacher/markup-blitz#9, where the insertion is in a separate rule, works as expected.

Just thought you might want to know. Thanks for supplying the webpage, by the way.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

johnlumley commented 2 months ago

Funny that

S: "a"++(-",",+#20).

gives <S>a a a</S> from a,a,a

But in your example #10 I get a result:

<input>
   <A a-list="x"/>
   <A a-list="xyz"/>
   <B b-list="x"/>
   <B b-list="xyz"/>
</input>

Removing the attribute mark on b-list, and changing the insertion to a printable string doesn't get the insertion appearing. Will have to look a little more closely, but it's puzzling.

More intriguingly:

A: -'A', rs, b-list,stop.
B = -'B', rs, b-list,stop.
{@a-list = name ++ rs.}
@b-list = name ++ (rs, +#20).

gives

<input>
   <A b-list="f g h"/>
   <B b-list="x y z"/>
</input>

but uncommenting the @a-list rule yields:

<input>
   <A b-list="fgh"/>
   <B b-list="xyz"/>
</input>

even though the @a-list rule is not referenced! Food for thought (after finishing my Balisage paper!)

johnlumley commented 2 months ago

I've found the error - the compiling of the rules into canonical form builds name ++ rs into a nonterminal name-plus-sep which is also the non-terminal referred to by name ++ (rs, +#20) (and of course it finds name-plus-sep already exists so uses that). Swapping the order of the @a-list and @b-list rules restores the inserted spaces. Now I know the cause I can work on a fix.