Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing parserm.h

AnalyseToken (lines 557-646)

0557  Object  selfobj "(self object)"
0558    with  short_name  [;  return L__M(##Miscellany, 18); ],
0559          description [;  return L__M(##Miscellany, 19); ],
0560          before NULL,
0561          after NULL,
0562          life NULL,
0563          each_turn NULL,
0564          time_out NULL,
0565          describe NULL,
0566          add_to_scope 0,
0567          capacity 100,
0568          parse_name 0,
0569          orders 0,
0570          number 0,
0571          before_implicit NULL,
0572    has   concealed animate proper transparent;
0573   
0574  ! ============================================================================
0575  !  The definition of the token-numbering system used by Inform.
0576  ! ----------------------------------------------------------------------------
0577   
0578  Constant ILLEGAL_TT         = 0;    ! Types of grammar token: illegal
0579  Constant ELEMENTARY_TT      = 1;    !     (one of those below)
0580  Constant PREPOSITION_TT     = 2;    !     e.g. 'into'
0581  Constant ROUTINE_FILTER_TT  = 3;    !     e.g. noun=CagedCreature
0582  Constant ATTR_FILTER_TT     = 4;    !     e.g. edible
0583  Constant SCOPE_TT           = 5;    !     e.g. scope=Spells
0584  Constant GPR_TT             = 6;    !     a general parsing routine
0585   
0586  Constant NOUN_TOKEN         = 0;    ! The elementary grammar tokens, and
0587  Constant HELD_TOKEN         = 1;    ! the numbers compiled by Inform to
0588  Constant MULTI_TOKEN        = 2;    ! encode them
0589  Constant MULTIHELD_TOKEN    = 3;
0590  Constant MULTIEXCEPT_TOKEN  = 4;
0591  Constant MULTIINSIDE_TOKEN  = 5;
0592  Constant CREATURE_TOKEN     = 6;
0593  Constant SPECIAL_TOKEN      = 7;
0594  Constant NUMBER_TOKEN       = 8;
0595  Constant TOPIC_TOKEN        = 9;
0596   
0597   
0598  Constant GPR_FAIL           = -1;   ! Return values from General Parsing
0599  Constant GPR_PREPOSITION    = 0;    ! Routines
0600  Constant GPR_NUMBER         = 1;
0601  Constant GPR_MULTIPLE       = 2;
0602  Constant GPR_REPARSE        = REPARSE_CODE;
0603  Constant GPR_NOUN           = $ff00;
0604  Constant GPR_HELD           = $ff01;
0605  Constant GPR_MULTI          = $ff02;
0606  Constant GPR_MULTIHELD      = $ff03;
0607  Constant GPR_MULTIEXCEPT    = $ff04;
0608  Constant GPR_MULTIINSIDE    = $ff05;
0609  Constant GPR_CREATURE       = $ff06;
0610   
0611  Constant ENDIT_TOKEN        = 15;   ! Value used to mean "end of grammar line"
0612   
0613  #Iftrue (Grammar__Version == 1);
0614   
0615  [ AnalyseToken token m;
0616      found_tdata = token;
0617      if (token < 0)   { found_ttype = ILLEGAL_TT; return; }
0618      if (token <= 8)  { found_ttype = ELEMENTARY_TT; return; }
0619      if (token < 15)  { found_ttype = ILLEGAL_TT; return; }
0620      if (token == 15) { found_ttype = ELEMENTARY_TT; return; }
0621      if (token < 48)  { found_ttype = ROUTINE_FILTER_TT;
0622                         found_tdata = token - 16;
0623                         return;
0624      }
0625      if (token < 80)  { found_ttype = GPR_TT;
0626                         found_tdata = #preactions_table-->(token-48);
0627                         return;
0628      }
0629      if (token < 128) { found_ttype = SCOPE_TT;
0630                         found_tdata = #preactions_table-->(token-80);
0631                         return;
0632      }
0633      if (token < 180) { found_ttype = ATTR_FILTER_TT;
0634                         found_tdata = token - 128;
0635                         return;
0636      }
0637   
0638      found_ttype = PREPOSITION_TT;
0639      m = #adjectives_table;
0640      for (::) {
0641          if (token == m-->1) { found_tdata = m-->0; return; }
0642          m = m+4;
0643      }
0644      m = #adjectives_table; RunTimeError(1);
0645      found_tdata = m;
0646  ];


Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.