#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

# How do you substitute AA but not AAA, AAAA, AAAAA etc.?

Posts: 22
`    ignore sub A' A' A;    sub A' A by A.alt;    sub A A' by A.alt;`
Doesn't work for AAAA, AAAAAA etc
Tagged:

• Posts: 286
lookup ChainingContext1 {
ignore context (A.alt) A (A);
ignore context (A) A;
context A (A);
sub 0 Ligature1;
}

lookup Ligature1 {
sub A -> A.alt;
}

• Posts: 662
What is the desired result?
• Posts: 157
edited July 2015
The marked subrun (A' A') in the ignore statement differs from the subrun (A') in the sub statements. So the ignore does not apply to subs.
• Posts: 905
If you only want to change the first two in a sequence, but not any subsequent repetitions, then this should work:

`feature calt {    ignore sub A.alt A.alt A';    ignore sub A A';    sub A' A by A.alt;    sub A.alt A' by A.alt;    } calt;`

But if you want to change two and only two, and not any member of a longer sequence, then you need to add another ignore sub:

`feature calt {    ignore sub A.alt A.alt A';    ignore sub A A';    ignore sub A' A A;    sub A' A by A.alt;    sub A.alt A' by A.alt;    } calt;`

• Posts: 22
@ everyone: Sorry, I should have been clearer:)

What I want is:
A A -> A.alt A.alt
A A A -> A A A
A A A A -> A A A A
etc.

so not e.g.
A A A -> A.alt A.alt A
A A A A -> A.alt A.alt A A

Inspired by the answers I've played around a bit and not the prettiest solution but this seem to work:
ignore sub A' A A;
ignore sub A A' A;
ignore sub A A A';
sub A' A by A.alt;
sub A A' by A.alt;
• Posts: 662
that shouldn't work. The last substitution is not possible as the first A is already substituted to A.alt by the time this line will be applied.
• Posts: 22
@Georg Seifert Sorry, typo. Should be

`ignore sub A' A A;ignore sub A A' A;ignore sub A A A';sub A' A by A.alt;sub A.alt A' by A.alt;`
• Posts: 1,948
edited July 2015
feature calt {

lookup first {
sub A A' by A.alt ;
} first;

lookup second {
sub A A.alt' A by A ;
} second;

} calt;
• Posts: 209
You have to understand that substitutions are done one after the other, so when the first substitution is done subsequent substitutions need to be aware of what was previously changed.
• Posts: 22
@Adrien Tétar Yep, I know - I typed it wrong:) Did you see my updated reply to Georg?
• Posts: 22
@Nick Shinn Looks elegant but wouldn't that result in:

A A -> A A.alt

and not

A A -> A.alt A.alt

or am I missing something?
• Posts: 209
I see it now, it should work.
• Posts: 22
@Adrien Tétar Cheers. Figured that, since we posted at the same time:)
• Posts: 905
Basically the same as my second example.
• Posts: 22
@Kent Lew it sure is. I'm new to this...