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

    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:

Comments

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

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

  • What is the desired result?
  • 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.
  • Kent LewKent Lew Posts: 874
    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;


  • @ 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;
  • 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.
  • @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;
  • Nick ShinnNick Shinn Posts: 1,404
    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;
  • attarattar 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.
  • @Adrien Tétar Yep, I know - I typed it wrong:) Did you see my updated reply to Georg?
  • @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?
  • attarattar Posts: 209
    I see it now, it should work.
  • @Adrien Tétar Cheers. Figured that, since we posted at the same time:)
  • Kent LewKent Lew Posts: 874
    Basically the same as my second example.
  • @Kent Lew it sure is. I'm new to this...
    :smile: 
Sign In or Register to comment.