Interactive Parsing

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Primes and Character correspondence

    Include (-

    !Constant TEST_CONVERTER;

    Array prime_list --> 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103; ! numbered 0 to 25

    [ PrimeFromCharacter ch ;
        if (ch == '.' or ',') return 0;
        if (ch >=65 && ch <= 90) ch = ch + 32;
        ch = ch - 97;
        if (ch < 0 || ch > 25)
            return 103;
        return prime_list-->ch;
    ];
    -) before "Parser.i6t".