Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Refers

    [|Refers| works out whether the word at number wnum can refer to the object
    |obj|, returning true or false. The standard method is to see if the word
    is listed under the |name| property for the object, but this is more
    complex in languages other than English.]

    To decide if the word at (position - a number) can refer to (obj - an object) (this is Refers):
        if the obj is nothing, no;
        if the inflected nouns option is active, decide per non-English rules if the word at the position refers to the obj;
        let k be the parser's current word position; [saves]
        now the parser's current word position is the position;
        let the current word be the next word if any;
        now the parser's current word position is k; [restores]
        let the names be the current names list;
        if the names are currently a rule: [ rare ]
            let the names be the current names list rule considered for the current word and the obj;
            if the names are an invalid list, decide on whether or not the names as a truth state;
        if the current word is listed in the names of the obj, yes.
        
    [ Refers obj wnum wd k l m;
    if (obj == 0) rfalse;

    #Ifdef LanguageRefers;
    k = LanguageRefers(obj,wnum); if (k >= 0) return k;
    #Endif; ! LanguageRefers

    k = wn; wn = wnum; wd = NextWordStopped(); wn = k;

    if (parser_inflection >= 256) {
    k = indirect(parser_inflection, obj, wd);
    if (k >= 0) return k;
    m = -k;
    }
    else
    m = parser_inflection;
    k = obj.&m; l = (obj.#m)/WORDSIZE-1;
    for (m=0 : m<=l : m++)
    if (wd == k-->m) rtrue;
    rfalse;
    ]

    To decide if (word - an understood word) is understood as (obj - an object) per its (names - an understood word valued property) (this is WordInProperty):
        if the word is listed in the names of the obj, yes.

    [ WordInProperty wd obj prop k l m;
    k = obj.&prop; l = (obj.#prop)/WORDSIZE-1;
    for (m=0 : m<=l : m++)
    if (wd == k-->m) rtrue;
    rfalse;
    ]