Answer to Exercise 63

| ANSWER TO EXERCISE 63
| The trick is to convert "fly in amber'' into "fly fly amber'' (a harmless name) before the parser gets under way.
    [ BeforeParsing i j;
      for (i=parse->1,j=2:j<i:j++)
      {   wn=j-1;
          if (NextWord()=='fly' && NextWord()=='in' && NextWord()=='amber')
              parse-->(j*2-1) = 'fly';
      }
    ];

Back to the exercise in section 24

Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.