1 {//-------------------------------------------------------------------------}
3 {Copyright (C) 1990, 2009 - Apogee Software, Ltd. }
5 {This file is part of Supernova. Supernova is free software; you can }
6 {redistribute it and/or modify it under the terms of the GNU General Public }
7 {License as published by the Free Software Foundation; either version 2 }
8 {of the License, or (at your option) any later version. }
10 {This program is distributed in the hope that it will be useful, }
11 {but WITHOUT ANY WARRANTY; without even the implied warranty of }
12 {MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. }
14 {See the GNU General Public License for more details. }
16 {You should have received a copy of the GNU General Public License }
17 {along with this program; if not, write to the Free Software }
18 {Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.}
20 {Original Source: 1990 Scott Miller }
21 {Prepared for public release: 03/19/09 - Joe Siegler, Apogee Software, Ltd. }
23 {//-------------------------------------------------------------------------}
24 {*****************************************************************************}
27 {* This include file to Adgame contains the word parser commands. *}
28 {* Copyright 1984 Pending *}
29 {*****************************************************************************}
32 procedure RR(RoomNum : integer);
34 seek(rooms1,RoomNum);seek(rooms2,RoomNum);
35 READ(rooms1,text1);READ(rooms2,text2);
40 procedure RS(RoomNum : integer);
43 seek(Special1,RoomNum);seek(Special2,RoomNum);
44 READ(Special1,text1);READ(Special2,text2);
48 procedure RL(RoomNum : integer);
58 procedure Format(var input : Str80);
59 procedure D(A:Str16; B: Byte);
60 begin while pos(A,input)<>0 do delete(input,pos(A,input),B) end;
61 begin input:=input+' '; insert(' ',input,1);
62 d(' of ',3); d(' go ',3); d('''',1); d('"',1); d(',',1);
63 d(' a ',2); d('?',1); d('!',1); d(';',1); d('#',1);
64 d(' the ',4); d('fly ',4); d('drive ',6); d('run ',4);
65 d('walk ',5); d('travel ',7); d('please ',7); d('room ',5);
66 d('crawl se',6); d('crawl nw',6); d('steer ',6); d('crawl n ',6);
67 d('crawl s ',6); d('crawl e',6); d('crawl w',6); d('that ',5);
68 d('first ',6); d('second ',7); d('number ',7);
69 d('this ',5); d('game ',5); d('i want to ',10); d(' my ',3); d('big ',4);
70 d('those ',6); d('them ',5); d('broken ',7); d('large ',6);
71 d('huge ',5); d('small ',6); d('tiny ',5);d('little ',7); d('within ',4);
72 d('yes ',3); d('no ',2); d('wade ',4); d('swim ',4);
73 while pos('examine ',input)>0 do delete(input,pos('examine ',input)+2,5);
74 while pos('into ',input)>0 do delete(input,pos('into ',input)+2,2);
75 while pos('. ',input)>0 do delete(input,pos('. ',input)+1,1);
76 while pos('inside ',input)>0 do delete(input,pos('inside ',input)+2,4);
77 d(' .',1); d(' ',1); d('..',1);
78 if(input[1]='.')then delete(input,1,1);
79 while(length(input)>0)and(input[1]=' ')do delete(input,1,1);
80 while(length(input)>0)and(input[length(input)]=' ')do
81 delete(input,length(input),1);
82 if(input='')or(input[1]='.')then writeln('Whoops!')
86 procedure Chop(var input : Str80);
90 if length(input) >0 then
96 while(input[j]<>' ')and(input[j]<>'.')do begin
100 if length(Word) >7 then
103 j:=j+(7-length(Word));
104 delete(input,l,length(Word));
109 until (j-1)=length(input);
110 delete(input,length(input),1)
115 procedure LowerCase(var input : Str80);
118 if length(input) > 0 then
119 for j:=1 to length(input) do
120 if(input[j] in ['A'..'Z'])then
121 input[j]:=chr(ord(input[j])+32)
125 procedure FindVerb (var input:Str80;var Word:Str16;var Verb:integer);
126 var j, k, r : integer;
131 while input[j]<>' ' do begin
135 if length(Word+' ')<length(input)then begin
136 Word:=Word+' '; j:=j+1;
137 while input[j]<>' ' do begin
151 until (v[r,k]=Q)or(k=10)
154 if(pos(' ',Word)<>0)and(Verb=Null)then
156 delete(Word,pos(' ',Word),8);
164 until (v[r,k]=Q)or(k=10)
167 delete(input,length(input),1);
168 if Verb<>Null then delete(input,1,length(Word));
169 if input[1]=' 'then delete(input,1,1)
173 procedure FindNoun(var input:Str80;var Word:Str16;var Noun:integer);
174 var j, k, t : integer;
179 while input[j]<>' ' do begin
183 if length(Word+' ')<length(input)then begin
184 Word:=Word+' ';j:=j+1;
185 while input[j]<>' ' do begin
199 until (n[t,k]=Q)or(k=10)
202 if(pos(' ',Word)<>0)and(Noun=Null)then
204 delete(Word,pos(' ',Word),8);
212 until (n[t,k]=Q)or(k=10)
215 delete(input,length(input),1);
216 if Noun<>Null then delete(input,1,length(Word));
217 if input[1]=' 'then delete(input,1,1)
221 procedure FindSep(var input : Str80; var h : Str16);
227 while input[j]<>' ' do begin
231 if pos(' '+h+' ',' crawl on at to in off with within into '+
232 ' above against through beside behind around across '+
233 ' inside from by under using near over onto down ') >0 then
235 delete(input,length(input),1);
236 delete(input,1,length(h));
237 if input[1]=' ' then delete(input,1,1);
238 if(h='on')or(h='around')or(h='above')or(h='over')or(h='onto')
240 if(h='inside')or(h='within')or(h='through')or(h='into')or(h='down')
242 if(h='using')then h:='with';
243 if(h='beside')or(h='by')then h:='near';
244 if(h='against')then h:='at';
245 if(h='across')then h:='over'
250 delete(input,length(input),1)
255 procedure Check(var SepWord : Str16);
258 Verb:=Null; Noun:=Null; Noun2:=Null; DialNum:=Null; Flag:='?';
260 if length(input)>0then
262 FindVerb(input,Word,Verb);
264 if(length(input)>0)and not(Verb in [31,53,63])then
266 FindNoun(input,Word,Noun);
267 If(Noun<>Null)then LastNoun:=n[noun,1];
269 if(Verb in[0,8,9,21,36,6,7,15,17,32,26])and(length(input)=0)then
272 if(Verb in[36,15])then Verb:=9
275 if(Verb in[0,8,21,36,37,29,9,39,6,15,7,17,32,26,40])then
276 if length(input)>0 then
278 if(Verb=9)then Verb:=29 else ;
279 FindSep(input,SepWord);
281 if length(input)>0 then
284 val(input,DialNum,j);
289 FindNoun(input,Word,Noun2);
291 if length(input)>0 then
297 FindVerb(input,Word,Verb);
298 if Verb=Null then Flag:='n'
303 if(Verb=39)and((SepWord='to')or(SepWord='off'))then
304 Flag:='g' else Flag:='e'
311 if length(input)>0 then
312 begin FindVerb(input,Word,j);if j<>Null then Flag:='b' else
313 begin FindSep(input,SepWord);if SepWord<>'s' then Flag:='b' else
314 begin FindNoun(input,Word,j);if j<>Null then Flag:='h' end end;
315 if Flag='?' then Flag:='v'
321 FindVerb(input,Word,Verb);
322 if Verb=Null then Flag:='n'
327 if Verb in OneWordCommands then Flag:='g'
331 FindNoun(input,Word,Noun2);
332 If Noun2=Null then Flag:='v'
337 'v','n':if pos(' '+Word+' ',' crawl on at to in off with within into '+
338 ' above against through beside behind around down '+
339 ' inside by under using near over onto top below '+
340 ' from away want across ')>0 then begin
341 write('The word ''',Word);RL(393)end
342 else writeln('
\81u',Word,'
\81v
\82Æ
\82¢
\82¤
\8c¾
\97t
\82Í
\82í
\82©
\82ç
\82È
\82¢
\81B');
344 if pos(' ',Word)>0 then delete(Word,pos(' ',Word),9);
345 writeln('You can''t use the word ''',Word,''' here.')
352 'h' :begin write(Word);RL(392)end
355 if flag<>'g' then begin Attack:=False;Line:='';Skip:=False end
358 {***************************** END OF ADPARSER ******************************}