Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing parserm.h

TryGivenObject (lines 3223-3329)

3223  !  TryGivenObject tries to match as many words as possible in what has been
3224  !  typed to the given object, obj.  If it manages any words matched at all,
3225  !  it calls MakeMatch to say so, then returns the number of words (or 1
3226  !  if it was a match because of inadequate input).
3227  ! ----------------------------------------------------------------------------
3228   
3229  [ TryGivenObject obj threshold k w j;
3230   
3231  #ifdef DEBUG;
3232     if (parser_trace>=5)
3233         print "    Trying ", (the) obj, " (", obj, ") at word ", wn, "^";
3234  #endif;
3235   
3236     dict_flags_of_noun = 0;
3237   
3238  !  If input has run out then always match, with only quality 0 (this saves
3239  !  time).
3240   
3241     if (wn > num_words)
3242     {   if (indef_mode ~= 0)
3243             dict_flags_of_noun = $$01110000;  ! Reject "plural" bit
3244         MakeMatch(obj,0);
3245         #ifdef DEBUG;
3246         if (parser_trace>=5)
3247         print "    Matched (0)^";
3248         #endif;
3249         return 1;
3250     }
3251   
3252  !  Ask the object to parse itself if necessary, sitting up and taking notice
3253  !  if it says the plural was used:
3254   
3255     if (obj.parse_name~=0)
3256     {   parser_action = NULL; j=wn;
3257         k=RunRoutines(obj,parse_name);
3258         if (k>0)
3259         {   wn=j+k;
3260             .MMbyPN;
3261   
3262             if (parser_action == ##PluralFound)
3263                 dict_flags_of_noun = dict_flags_of_noun | 4;
3264   
3265             if (dict_flags_of_noun & 4)
3266             {   if (~~allow_plurals) k=0;
3267                 else
3268                 {   if (indef_mode==0)
3269                     {   indef_mode=1; indef_type=0; indef_wanted=0; }
3270                     indef_type = indef_type | PLURAL_BIT;
3271                     if (indef_wanted==0) indef_wanted=100;
3272                 }
3273             }
3274   
3275             #ifdef DEBUG;
3276                 if (parser_trace>=5)
3277                 {   print "    Matched (", k, ")^";
3278                 }
3279             #endif;
3280             MakeMatch(obj,k);
3281             return k;
3282         }
3283         if (k==0) jump NoWordsMatch;
3284     }
3285   
3286  !  The default algorithm is simply to count up how many words pass the
3287  !  Refers test:
3288   
3289     parser_action = NULL;
3290   
3291     w = NounWord();
3292   
3293     if (w==1 && player==obj) { k=1; jump MMbyPN; }
3294   
3295     if (w>=2 && w<128 && (LanguagePronouns-->w == obj))
3296     {   k=1; jump MMbyPN; }
3297   
3298     j=--wn;
3299     threshold = ParseNoun(obj);
3300  #ifdef DEBUG;
3301     if (threshold>=0 && parser_trace>=5)
3302         print "    ParseNoun returned ", threshold, "^";
3303  #endif;
3304     if (threshold<0) wn++;
3305     if (threshold>0) { k=threshold; jump MMbyPN; }
3306   
3307     if (threshold==0 || Refers(obj,wn-1)==0)
3308     {   .NoWordsMatch;
3309         if (indef_mode~=0)
3310         {   k=0; parser_action=NULL; jump MMbyPN;
3311         }
3312         rfalse;
3313     }
3314   
3315     if (threshold<0)
3316     {   threshold=1;
3317         dict_flags_of_noun = (w->#dict_par1) & $$01110100;
3318         w = NextWord();
3319         while (Refers(obj, wn-1))
3320         {   threshold++;
3321             if (w)
3322                 dict_flags_of_noun = dict_flags_of_noun
3323                                      | ((w->#dict_par1) & $$01110100);
3324             w = NextWord();
3325         }
3326     }
3327   
3328     k = threshold; jump MMbyPN;
3329  ];


Last updated 27 February 2004. This web site has not been fully supported since April 2008. Information may be out of date. This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.