scanner.pas 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420
  1. {
  2. $Id$
  3. Copyright (c) 1993,97 by Florian Klaempfl
  4. This unit implements the scanner part and handling of the switches
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit scanner;
  19. interface
  20. uses
  21. strings,dos,cobjects,globals,symtable,systems,files,verbose,link;
  22. const
  23. id_len = 14;
  24. type
  25. ident = string[id_len];
  26. const
  27. {$ifdef L_C}
  28. anz_keywords = 32;
  29. keyword : array[1..anz_keywords] of ident = (
  30. 'auto','break','case','char','const','continue','default','do',
  31. 'double','else','enum','extern','float','for','goto','if',
  32. 'int','long','register','return','short','signed','sizeof','static',
  33. 'struct','switch','typedef','union','unsigned','void','volatile',
  34. 'while');
  35. {$else}
  36. max_keywords = 71;
  37. anz_keywords : longint = max_keywords;
  38. keyword : array[1..max_keywords] of ident = (
  39. { 'ABSOLUTE',}
  40. 'AND',
  41. 'ARRAY','AS','ASM',
  42. { 'ASSEMBLER',}
  43. 'BEGIN',
  44. 'BREAK','CASE','CLASS',
  45. 'CONST','CONSTRUCTOR','CONTINUE',
  46. 'DESTRUCTOR','DISPOSE','DIV','DO','DOWNTO','ELSE','END',
  47. 'EXCEPT',
  48. 'EXIT',
  49. { 'EXPORT',}
  50. 'EXPORTS',
  51. { 'EXTERNAL',}
  52. 'FAIL','FALSE',
  53. { 'FAR',}
  54. 'FILE','FINALLY','FOR',
  55. { 'FORWARD',}
  56. 'FUNCTION','GOTO','IF','IMPLEMENTATION','IN',
  57. 'INHERITED','INITIALIZATION',
  58. { 'INLINE',} {INLINE is a reserved word in TP. Why?}
  59. 'INTERFACE',
  60. { 'INTERRUPT',}
  61. 'IS',
  62. 'LABEL','LIBRARY','MOD',
  63. { 'NEAR',}
  64. 'NEW','NIL','NOT','OBJECT',
  65. 'OF','ON','OPERATOR','OR','OTHERWISE','PACKED',
  66. 'PROCEDURE','PROGRAM','PROPERTY',
  67. 'RAISE','RECORD','REPEAT','SELF',
  68. 'SET','SHL','SHR','STRING','THEN','TO',
  69. 'TRUE','TRY','TYPE','UNIT','UNTIL',
  70. 'USES','VAR',
  71. { 'VIRTUAL',}
  72. 'WHILE','WITH','XOR');
  73. {***}
  74. keyword_token : array[1..max_keywords] of ttoken = (
  75. { _ABSOLUTE,}
  76. _AND,
  77. _ARRAY,_AS,_ASM,
  78. { _ASSEMBLER,}
  79. _BEGIN,
  80. _BREAK,_CASE,_CLASS,
  81. _CONST,_CONSTRUCTOR,_CONTINUE,
  82. _DESTRUCTOR,_DISPOSE,_DIV,_DO,_DOWNTO,
  83. _ELSE,_END,_EXCEPT,
  84. _EXIT,
  85. { _EXPORT,}
  86. _EXPORTS,
  87. { _EXTERNAL,}
  88. _FAIL,_FALSE,
  89. { _FAR,}
  90. _FILE,_FINALLY,_FOR,
  91. { _FORWARD,}
  92. _FUNCTION,_GOTO,_IF,_IMPLEMENTATION,_IN,
  93. _INHERITED,_INITIALIZATION,
  94. { _INLINE,}
  95. _INTERFACE,
  96. { _INTERRUPT,}
  97. _IS,
  98. _LABEL,_LIBRARY,_MOD,
  99. { _NEAR,}
  100. _NEW,_NIL,_NOT,_OBJECT,
  101. _OF,_ON,_OPERATOR,_OR,_OTHERWISE,_PACKED,
  102. _PROCEDURE,_PROGRAM,_PROPERTY,
  103. _RAISE,_RECORD,_REPEAT,_SELF,
  104. _SET,_SHL,_SHR,_STRING,_THEN,_TO,
  105. _TRUE,_TRY,_TYPE,_UNIT,_UNTIL,
  106. _USES,_VAR,
  107. { _VIRTUAL,}
  108. _WHILE,_WITH,_XOR);
  109. {$endif}
  110. function yylex : ttoken;
  111. procedure initscanner(const fn: string);
  112. procedure donescanner(compiled_at_higher_level : boolean);
  113. { the asm parser use this function getting the input }
  114. function asmgetchar : char;
  115. { this procedure is called at the end of each line }
  116. { and the function does the statistics }
  117. procedure write_line;
  118. { this procedure must be called before starting another scanner }
  119. procedure update_line;
  120. type
  121. tpreproctoken = (PP_IFDEF,PP_IFNDEF,PP_ELSE,PP_ENDIF,PP_IFOPT);
  122. ppreprocstack = ^tpreprocstack;
  123. tpreprocstack = object
  124. t : tpreproctoken;
  125. accept : boolean;
  126. next : ppreprocstack;
  127. name : string;
  128. line_nb : longint;
  129. constructor init(_t : tpreproctoken;a : boolean;n : ppreprocstack);
  130. destructor done;
  131. end;
  132. var
  133. pattern,orgpattern : string;
  134. { macros }
  135. const
  136. {$ifdef TP}
  137. maxmacrolen = 1024;
  138. {$else}
  139. maxmacrolen = 16*1024;
  140. {$endif}
  141. type
  142. tmacrobuffer = array[0..maxmacrolen-1] of char;
  143. var
  144. macropos : longint;
  145. macrobuffer : ^tmacrobuffer;
  146. preprocstack : ppreprocstack;
  147. inputbuffer : pchar;
  148. inputpointer : word;
  149. s_point : boolean;
  150. c : char;
  151. comment_level : word;
  152. {this is usefull to get the write filename
  153. for the last instruction of an include file !}
  154. Const FileHasChanged : Boolean = False;
  155. implementation
  156. uses
  157. pbase;
  158. procedure remove_keyword(const s : string);
  159. var
  160. i,j : longint;
  161. begin
  162. for i:=1 to anz_keywords do
  163. begin
  164. if keyword[i]=s then
  165. begin
  166. for j:=i to anz_keywords-1 do
  167. begin
  168. keyword[j]:=keyword[j+1];
  169. keyword_token[j]:=keyword_token[j+1];
  170. end;
  171. dec(anz_keywords);
  172. break;
  173. end;
  174. end;
  175. end;
  176. const
  177. newline = #10;
  178. { const
  179. line_count : longint = 0; stored in tinputfile }
  180. { used to get better line info }
  181. procedure update_line;
  182. begin
  183. inc(current_module^.current_inputfile^.line_no,
  184. current_module^.current_inputfile^.line_count);
  185. current_module^.current_inputfile^.line_count:=0;
  186. end;
  187. procedure reload;
  188. var
  189. readsize : word;
  190. i,saveline,count : longint;
  191. begin
  192. if filehaschanged then
  193. begin
  194. {$ifdef EXTDEBUG}
  195. writeln ('Note: Finished reading ',current_module^.current_inputfile^.name^);
  196. write (' Coming back to ');
  197. current_module^.current_inputfile^.next^.write_file_line(output);
  198. writeln;
  199. {$endif EXTDEBUG}
  200. current_module^.current_inputfile:=current_module^.current_inputfile^.next;
  201. { this was missing !}
  202. c:=inputbuffer[inputpointer];
  203. inc(inputpointer);
  204. {$ifdef EXTDEBUG}
  205. write('Next 16 char "');
  206. for i:=-1 to 14 do
  207. write(inputbuffer[inputpointer+i]);
  208. writeln('"');
  209. {$endif EXTDEBUG}
  210. filehaschanged:=false;
  211. exit;
  212. end;
  213. if current_module^.current_inputfile=nil then
  214. internalerror(14);
  215. if current_module^.current_inputfile^.filenotatend then
  216. begin
  217. { load the next piece of source }
  218. blockread(current_module^.current_inputfile^.f,inputbuffer^,
  219. current_module^.current_inputfile^.bufsize-1,readsize);
  220. { check if non-empty file }
  221. { this is an aweful hack FK }
  222. if readsize > 0 then
  223. begin
  224. { check if null character before readsize }
  225. { this mixed up the scanner.. }
  226. { force proper line counting }
  227. saveline:=current_module^.current_inputfile^.line_no;
  228. i:=0;
  229. while i<readsize do
  230. begin
  231. if inputbuffer[i] in [#10,#13] then
  232. begin
  233. if (byte(inputbuffer[i+1])+byte(inputbuffer[i])=23) then
  234. inc(i);
  235. inc(current_module^.current_inputfile^.line_no);
  236. end;
  237. if inputbuffer[i] = #0 then
  238. Message(scan_f_illegal_char);
  239. inc(i);
  240. end;
  241. current_module^.current_inputfile^.line_no:=saveline;
  242. end;
  243. inputbuffer[readsize]:=#0;
  244. c:=inputbuffer[0];
  245. { inputpointer points always to the _next_ character to read }
  246. inputpointer:=1;
  247. if eof(current_module^.current_inputfile^.f) then
  248. begin
  249. current_module^.current_inputfile^.filenotatend:=false;
  250. { if this is the main source file then EOF }
  251. if current_module^.current_inputfile^.next=nil then
  252. inputbuffer[readsize]:=#26;
  253. end;
  254. end
  255. else
  256. begin
  257. current_module^.current_inputfile^.close;
  258. inputbuffer:=current_module^.current_inputfile^.next^.buf;
  259. inputpointer:=current_module^.current_inputfile^.next^.bufpos;
  260. if assigned(current_module^.current_inputfile^.next) then
  261. begin
  262. c:=inputbuffer[inputpointer];
  263. filehaschanged:=True;
  264. {$ifdef EXTDEBUG}
  265. write('Next 16 char "');
  266. for i := 0 to 15 do write(inputbuffer[inputpointer+i]);
  267. writeln('"');
  268. {$endif}
  269. inputbuffer[inputpointer] := #0;
  270. { if c=newline writeline is called but increment the old
  271. inputstack instead of the new one }
  272. if c=newline then
  273. begin
  274. inc(current_module^.current_inputfile^.next^.line_no);
  275. dec(current_module^.current_inputfile^.line_no);
  276. end;
  277. end;
  278. end;
  279. end;
  280. procedure write_line;
  281. var
  282. status : tcompilestatus;
  283. begin
  284. {$ifdef ver0_6}
  285. status.totalcompiledlines:=abslines;
  286. status.currentline:=current_module^.current_inputfile^.line_no
  287. +current_module^.current_inputfile^.line_count;
  288. status.currentsource:=current_module^.current_inputfile^.name^+current_module^.current_inputfile^.ext^;
  289. status.totallines:=0;
  290. {$else}
  291. with status do
  292. begin
  293. totalcompiledlines:=abslines;
  294. currentline:=current_module^.current_inputfile^.line_no
  295. +current_module^.current_inputfile^.line_count;
  296. currentsource:=current_module^.current_inputfile^.name^+current_module^.current_inputfile^.ext^;
  297. totallines:=0;
  298. end;
  299. {$endif}
  300. if compilestatusproc(status) then
  301. stop;
  302. inc(current_module^.current_inputfile^.line_count);
  303. lastlinepointer:=inputpointer;
  304. inc(abslines);
  305. end;
  306. procedure src_comment;forward;
  307. var prevc : char;
  308. procedure nextchar;
  309. begin
  310. c:=inputbuffer[inputpointer];
  311. inc(inputpointer);
  312. if c=#0 then
  313. reload;
  314. if c in [#10,#13] then
  315. begin
  316. { here there was a problem if the inputbuffer
  317. stopped at #13 and the next at #10
  318. because two newlines where counted !! }
  319. write_line;
  320. if (byte(inputbuffer[inputpointer])+byte(c)=23) then
  321. inc(inputpointer);
  322. if (inputbuffer[inputpointer]=#0) and
  323. current_module^.current_inputfile^.filenotatend then
  324. begin
  325. prevc:=c;
  326. reload;
  327. if (byte(c)+byte(prevc)<>23) then
  328. dec(inputpointer);
  329. end;
  330. c:=newline;
  331. end;
  332. end;
  333. procedure skipspace;
  334. var
  335. lastc : byte;
  336. begin
  337. lastc:=0;
  338. while c in [' ',#9,#10,#12,#13] do
  339. begin
  340. nextchar;
  341. if c='{' then
  342. src_comment;
  343. end;
  344. end;
  345. function is_keyword(var token : ttoken) : boolean;
  346. var
  347. m,n,k : integer;
  348. begin
  349. { there are no keywords with a length less than 2 }
  350. if length(pattern)<=1 then
  351. begin
  352. is_keyword:=false;
  353. exit;
  354. end;
  355. m:=1;
  356. n:=anz_keywords;
  357. while m<=n do
  358. begin
  359. k:=m+(n-m) shr 1;
  360. if pattern=keyword[k] then
  361. begin
  362. token:=keyword_token[k];
  363. is_keyword:=true;
  364. exit;
  365. end
  366. else if pattern>keyword[k] then m:=k+1 else n:=k-1;
  367. end;
  368. is_keyword:=false;
  369. end;
  370. {*****************************************************************************
  371. Preprocessor
  372. *****************************************************************************}
  373. function readmessage:string;
  374. var
  375. i : longint;
  376. begin
  377. i:=0;
  378. repeat
  379. case c of
  380. '}' : break;
  381. #26 : Message(scan_f_end_of_file);
  382. else
  383. begin
  384. if (i<255) then
  385. begin
  386. inc(i);
  387. readmessage[i]:=c;
  388. end;
  389. end;
  390. end;
  391. nextchar;
  392. until false;
  393. readmessage[0]:=chr(i);
  394. end;
  395. constructor tpreprocstack.init(_t : tpreproctoken;a : boolean;n : ppreprocstack);
  396. begin
  397. t:=_t;
  398. accept:=a;
  399. next:=n;
  400. end;
  401. destructor tpreprocstack.done;
  402. begin
  403. end;
  404. procedure dec_comment_level;
  405. begin
  406. if cs_tp_compatible in aktswitches then
  407. comment_level:=0
  408. else
  409. dec(comment_level);
  410. end;
  411. procedure handle_switches;
  412. function read_original_string : string;
  413. var
  414. hs : string;
  415. begin
  416. hs:='';
  417. while c in ['A'..'Z','a'..'z','_','0'..'9'] do
  418. begin
  419. hs:=hs+c;
  420. nextchar;
  421. end;
  422. read_original_string:=hs;
  423. end;
  424. function read_string : string;
  425. begin
  426. read_string:=upper(read_original_string);
  427. end;
  428. function read_number : longint;
  429. var
  430. hs : string;
  431. l : longint;
  432. w : word;
  433. begin
  434. read_number:=0;
  435. hs:='';
  436. while c in ['0'..'9'] do
  437. begin
  438. hs:=hs+c;
  439. nextchar;
  440. end;
  441. valint(hs,l,w);
  442. read_number:=l;
  443. end;
  444. var
  445. preprocpat : string;
  446. preproc_token : ttoken;
  447. function read_preproc : ttoken;
  448. { var
  449. y : ttoken;
  450. code : word;
  451. l : longint;
  452. hs : string;
  453. hp : pinputfile;
  454. hp2 : pchar;}
  455. label
  456. preproc_exit;
  457. begin
  458. while c in [' ',#9,#13,#12,#10] do
  459. begin
  460. { if c=#10 then write_line;}
  461. nextchar;
  462. end;
  463. case c of
  464. 'A'..'Z','a'..'z','_','0'..'9' :
  465. begin
  466. preprocpat:=c;
  467. nextchar;
  468. while c in ['A'..'Z','a'..'z','0'..'9','_'] do
  469. begin
  470. preprocpat:=preprocpat+c;
  471. nextchar;
  472. end;
  473. uppervar(preprocpat);
  474. read_preproc:=ID;
  475. goto preproc_exit;
  476. end;
  477. '(' : begin
  478. nextchar;
  479. read_preproc:=LKLAMMER;
  480. goto preproc_exit;
  481. end;
  482. ')' : begin
  483. nextchar;
  484. read_preproc:=RKLAMMER;
  485. goto preproc_exit;
  486. end;
  487. '+' : begin
  488. nextchar;
  489. read_preproc:=PLUS;
  490. goto preproc_exit;
  491. end;
  492. '-' : begin
  493. nextchar;
  494. read_preproc:=MINUS;
  495. goto preproc_exit;
  496. end;
  497. '*' : begin
  498. nextchar;
  499. read_preproc:=STAR;
  500. goto preproc_exit;
  501. end;
  502. '/' : begin
  503. nextchar;
  504. read_preproc:=SLASH;
  505. goto preproc_exit;
  506. end;
  507. '=' : begin
  508. nextchar;
  509. read_preproc:=EQUAL;
  510. goto preproc_exit;
  511. end;
  512. '>' : begin
  513. nextchar;
  514. if c='=' then
  515. begin
  516. nextchar;
  517. read_preproc:=GTE;
  518. goto preproc_exit;
  519. end
  520. else
  521. begin
  522. read_preproc:=GT;
  523. goto preproc_exit;
  524. end;
  525. end;
  526. '<' : begin
  527. nextchar;
  528. if c='>' then
  529. begin
  530. nextchar;
  531. read_preproc:=UNEQUAL;
  532. goto preproc_exit;
  533. end
  534. else if c='=' then
  535. begin
  536. nextchar;
  537. read_preproc:=LTE;
  538. goto preproc_exit;
  539. end
  540. else
  541. begin
  542. read_preproc:=LT;
  543. goto preproc_exit;
  544. end;
  545. end;
  546. #26:
  547. begin
  548. update_line;
  549. Message(scan_f_end_of_file);
  550. end
  551. else
  552. begin
  553. read_preproc:=_EOF;
  554. end;
  555. end;
  556. preproc_exit :
  557. update_line;
  558. end;
  559. procedure preproc_consume(t : ttoken);
  560. begin
  561. if t<>preproc_token then
  562. Message(scan_e_preproc_syntax_error);
  563. preproc_token:=read_preproc;
  564. end;
  565. function read_expr : string;forward;
  566. function read_factor : string;
  567. var
  568. hs : string;
  569. mac : pmacrosym;
  570. len : byte;
  571. begin
  572. if preproc_token=ID then
  573. begin
  574. if preprocpat='NOT' then
  575. begin
  576. preproc_consume(ID);
  577. hs:=read_expr;
  578. if hs='0' then
  579. read_factor:='1'
  580. else
  581. read_factor:='0';
  582. end
  583. else
  584. begin
  585. mac:=pmacrosym(macros^.search(hs));
  586. hs:=preprocpat;
  587. preproc_consume(ID);
  588. if assigned(mac) then
  589. begin
  590. if mac^.defined and assigned(mac^.buftext) then
  591. begin
  592. if mac^.buflen>255 then
  593. begin
  594. len:=255;
  595. Message(scan_w_marco_cut_after_255_chars);
  596. end
  597. else
  598. len:=mac^.buflen;
  599. hs[0]:=char(len);
  600. move(mac^.buftext^,hs[1],len);
  601. end
  602. else
  603. read_factor:='';
  604. end
  605. else
  606. read_factor:=hs;
  607. end
  608. end
  609. else if preproc_token=LKLAMMER then
  610. begin
  611. preproc_consume(LKLAMMER);
  612. read_factor:=read_expr;
  613. preproc_consume(RKLAMMER);
  614. end
  615. else
  616. Message(scan_e_error_in_preproc_expr);
  617. end;
  618. function read_term : string;
  619. var
  620. hs1,hs2 : string;
  621. begin
  622. hs1:=read_factor;
  623. while true do
  624. begin
  625. if (preproc_token=ID) then
  626. begin
  627. if preprocpat='AND' then
  628. begin
  629. preproc_consume(ID);
  630. hs2:=read_factor;
  631. if (hs1<>'0') and (hs2<>'0') then
  632. hs1:='1';
  633. end
  634. else
  635. break;
  636. end
  637. else
  638. break;
  639. end;
  640. read_term:=hs1;
  641. end;
  642. function read_simple_expr : string;
  643. var
  644. hs1,hs2 : string;
  645. begin
  646. hs1:=read_term;
  647. while true do
  648. begin
  649. if (preproc_token=ID) then
  650. begin
  651. if preprocpat='OR' then
  652. begin
  653. preproc_consume(ID);
  654. hs2:=read_term;
  655. if (hs1<>'0') or (hs2<>'0') then
  656. hs1:='1';
  657. end
  658. else
  659. break;
  660. end
  661. else
  662. break;
  663. end;
  664. read_simple_expr:=hs1;
  665. end;
  666. function read_expr : string;
  667. var
  668. hs1,hs2 : string;
  669. b : boolean;
  670. t : ttoken;
  671. w : word;
  672. l1,l2 : longint;
  673. begin
  674. hs1:=read_simple_expr;
  675. t:=preproc_token;
  676. if not(t in [EQUAL,UNEQUAL,LT,GT,LTE,GTE]) then
  677. begin
  678. read_expr:=hs1;
  679. exit;
  680. end;
  681. preproc_consume(t);
  682. hs2:=read_simple_expr;
  683. if is_number(hs1) and is_number(hs2) then
  684. begin
  685. valint(hs1,l1,w);
  686. valint(hs2,l2,w);
  687. case t of
  688. EQUAL:
  689. b:=l1=l2;
  690. UNEQUAL:
  691. b:=l1<>l2;
  692. LT:
  693. b:=l1<l2;
  694. GT:
  695. b:=l1>l2;
  696. GTE:
  697. b:=l1>=l2;
  698. LTE:
  699. b:=l1<=l2;
  700. end;
  701. end
  702. else
  703. begin
  704. case t of
  705. EQUAL:
  706. b:=hs1=hs2;
  707. UNEQUAL:
  708. b:=hs1<>hs2;
  709. LT:
  710. b:=hs1<hs2;
  711. GT:
  712. b:=hs1>hs2;
  713. GTE:
  714. b:=hs1>=hs2;
  715. LTE:
  716. b:=hs1<=hs2;
  717. end;
  718. end;
  719. if b then
  720. read_expr:='1'
  721. else
  722. read_expr:='0';
  723. end;
  724. procedure skip_until_pragma;
  725. var
  726. found : longint;
  727. begin
  728. found:=0;
  729. repeat
  730. case c of
  731. #26 : Message(scan_f_end_of_file);
  732. { newline : begin
  733. write_line;
  734. found:=0;
  735. end; }
  736. '{' : begin
  737. if comment_level=0 then
  738. found:=1;
  739. inc(comment_level);
  740. end;
  741. '}' : begin
  742. dec_comment_level;
  743. found:=0;
  744. end;
  745. '$' : begin
  746. if found=1 then
  747. found:=2;
  748. end;
  749. else
  750. found:=0;
  751. end;
  752. nextchar;
  753. until (found=2);
  754. update_line;
  755. end;
  756. function Is_conditional(const hs:string):boolean;
  757. begin
  758. Is_Conditional:=((hs='ELSE') or (hs='IFDEF') or (hs='IFNDEF') or
  759. (hs='IFOPT') or (hs='ENDIF') or (hs='ELSE') or (hs='IF'));
  760. end;
  761. var
  762. path,hs : string;
  763. hp : pinputfile;
  764. mac : pmacrosym;
  765. found : boolean;
  766. ht : ttoken;
  767. procedure popstack;
  768. var
  769. hp : ppreprocstack;
  770. begin
  771. hp:=preprocstack^.next;
  772. dispose(preprocstack,done);
  773. preprocstack:=hp;
  774. end;
  775. var
  776. _d : dirstr;
  777. _n : namestr;
  778. _e : extstr;
  779. hs2,
  780. msg : string;
  781. begin
  782. nextchar;
  783. hs:=read_string;
  784. update_line;
  785. Message1(scan_d_handling_switch,hs);
  786. if hs='I' then
  787. begin
  788. skipspace;
  789. hs:=c;
  790. nextchar;
  791. while not(c in [' ','}','*',#13,newline]) do
  792. begin
  793. hs:=hs+c;
  794. nextchar;
  795. if c=#26 then Message(scan_f_end_of_file);
  796. end;
  797. { if c=newline then write_line;}
  798. { read until end of comment }
  799. while c<>'}' do
  800. begin
  801. nextchar;
  802. if c=#26 then Message(scan_f_end_of_file);
  803. { if c=newline then write_line;}
  804. end;
  805. {
  806. dec(comment_level);
  807. }
  808. { Initialization }
  809. if (hs[1]='-') then
  810. {exclude(aktswitches,cs_iocheck) Not yet supported.}
  811. aktswitches:=aktswitches-[cs_iocheck]
  812. else if (hs[1]='+') then
  813. {include(aktswitches,cs_iocheck) Not supported yet.}
  814. aktswitches:=aktswitches+[cs_iocheck]
  815. else
  816. begin
  817. fsplit(hs,_d,_n,_e);
  818. update_line;
  819. { directory where the current file is first inspected }
  820. path:=search(hs,current_module^.current_inputfile^.path^,found);
  821. if found then
  822. hp:=new(pinputfile,init(path+_d,_n,_e))
  823. else
  824. begin
  825. path:=search(hs,includesearchpath,found);
  826. hp:=new(pinputfile,init(path+_d,_n,_e));
  827. end;
  828. hp^.reset;
  829. if ioresult=0 then
  830. begin
  831. current_module^.current_inputfile^.bufpos:=inputpointer;
  832. hp^.next:=current_module^.current_inputfile;
  833. current_module^.current_inputfile:=hp;
  834. current_module^.sourcefiles.register_file(hp);
  835. inputbuffer:=current_module^.current_inputfile^.buf;
  836. Message1(scan_u_start_include_file,current_module^.current_inputfile^.name^);
  837. reload;
  838. { we have read the }
  839. { comment end }
  840. dec_comment_level;
  841. { only warn for over one => incompatible with BP }
  842. if (comment_level>1) then
  843. Message1(scan_w_comment_level,tostr(comment_level));
  844. end
  845. else
  846. Message1(scan_f_cannot_open_includefile,_d+_n+_e);
  847. end;
  848. end
  849. { conditional compiling ? }
  850. else if Is_Conditional(hs) then
  851. begin
  852. while true do
  853. begin
  854. if hs='ENDIF' then
  855. begin
  856. { we can always accept an ELSE }
  857. if assigned(preprocstack) then
  858. begin
  859. Message1(scan_c_endif_found,preprocstack^.name);
  860. if preprocstack^.t=PP_ELSE then
  861. popstack;
  862. end
  863. else
  864. Message(scan_e_endif_without_if);
  865. { now pop the condition }
  866. if assigned(preprocstack) then
  867. begin
  868. { we only use $ifdef in the stack }
  869. if (preprocstack^.t=PP_IFDEF) then
  870. popstack
  871. else
  872. Message(scan_e_too_much_endifs);
  873. end
  874. else
  875. Message(scan_e_endif_without_if);
  876. end
  877. else if hs='IFDEF' then
  878. begin
  879. skipspace;
  880. hs:=read_string;
  881. mac:=pmacrosym(macros^.search(hs));
  882. preprocstack:=new(ppreprocstack,init(PP_IFDEF,
  883. { the block before must be accepted }
  884. { the symbole must be exist and be defined }
  885. (
  886. (preprocstack=nil) or
  887. preprocstack^.accept
  888. ) and
  889. assigned(mac) and
  890. mac^.defined,
  891. preprocstack));
  892. preprocstack^.name:=hs;
  893. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  894. if preprocstack^.accept then
  895. Message2(scan_c_ifdef_found,preprocstack^.name,'accepted')
  896. else
  897. Message2(scan_c_ifdef_found,preprocstack^.name,'rejected');
  898. end
  899. else if hs='IFOPT' then
  900. begin
  901. skipspace;
  902. hs:=read_string;
  903. { !!!! read switch state }
  904. { PP_IFDEF is correct, we doesn't distinguish between }
  905. { ifopt and ifdef }
  906. preprocstack:=new(ppreprocstack,init(PP_IFDEF,
  907. { the block before must be accepted }
  908. (
  909. (preprocstack=nil) or
  910. preprocstack^.accept
  911. ) and
  912. { !!!! subject to change: }
  913. false,
  914. preprocstack));
  915. preprocstack^.name:=hs;
  916. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  917. if preprocstack^.accept then
  918. Message2(scan_c_ifopt_found,preprocstack^.name,'accepted')
  919. else
  920. Message2(scan_c_ifopt_found,preprocstack^.name,'rejected');
  921. end
  922. else if hs='IF' then
  923. begin
  924. skipspace;
  925. { start preproc expression scanner }
  926. preproc_token:=read_preproc;
  927. hs:=read_expr;
  928. { PP_IFDEF is correct, we doesn't distinguish between }
  929. { if, ifopt and ifdef }
  930. preprocstack:=new(ppreprocstack,init(PP_IFDEF,
  931. { the block before must be accepted }
  932. (
  933. (preprocstack=nil) or
  934. preprocstack^.accept
  935. ) and
  936. (hs<>'0'),
  937. preprocstack));
  938. preprocstack^.name:=hs;
  939. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  940. if preprocstack^.accept then
  941. Message2(scan_c_if_found,preprocstack^.name,'accepted')
  942. else
  943. Message2(scan_c_if_found,preprocstack^.name,'rejected');
  944. end
  945. else if hs='IFNDEF' then
  946. begin
  947. skipspace;
  948. hs:=read_string;
  949. mac:=pmacrosym(macros^.search(hs));
  950. preprocstack:=new(ppreprocstack,init(PP_IFDEF,
  951. { the block before must be accepted }
  952. (
  953. (preprocstack=nil) or
  954. preprocstack^.accept
  955. ) and
  956. not(assigned(mac) and
  957. mac^.defined),
  958. preprocstack));
  959. preprocstack^.name:=hs;
  960. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  961. if preprocstack^.accept then
  962. Message2(scan_c_ifndef_found,preprocstack^.name,'accepted')
  963. else
  964. Message2(scan_c_ifndef_found,preprocstack^.name,'rejected');
  965. end
  966. else if hs='ELSE' then
  967. begin
  968. if assigned(preprocstack) then
  969. begin
  970. preprocstack:=new(ppreprocstack,init(PP_ELSE,
  971. { invert }
  972. not(preprocstack^.accept) and
  973. { but only true, if only the ifdef block is }
  974. { not accepted }
  975. (
  976. (preprocstack^.next=nil) or
  977. (preprocstack^.next^.accept)
  978. ),
  979. preprocstack));
  980. preprocstack^.line_nb := current_module^.current_inputfile^.line_no;
  981. preprocstack^.name := preprocstack^.next^.name;
  982. if preprocstack^.accept then
  983. Message2(scan_c_else_found,preprocstack^.name,'accepted')
  984. else
  985. Message2(scan_c_else_found,preprocstack^.name,'rejected');
  986. end
  987. else
  988. Message(scan_e_endif_without_if);
  989. end
  990. else if hs='IFOPT' then
  991. begin
  992. skipspace;
  993. hs:=read_string;
  994. preprocstack:=new(ppreprocstack,init(PP_IFDEF,
  995. false,
  996. preprocstack));
  997. end;
  998. { accept the text ? }
  999. if (preprocstack=nil) or preprocstack^.accept then
  1000. break
  1001. else
  1002. begin
  1003. Message(scan_c_skipping_until);
  1004. repeat
  1005. skip_until_pragma;
  1006. hs:=read_string;
  1007. until Is_Conditional(hs);
  1008. end;
  1009. end;
  1010. end
  1011. else if (hs='WAIT') then
  1012. begin
  1013. Message(scan_i_press_enter);
  1014. readln;
  1015. end
  1016. else if (hs='INFO') or (hs='MESSAGE') then
  1017. begin
  1018. skipspace;
  1019. Message1(scan_i_user_defined,readmessage);
  1020. end
  1021. else if hs='NOTE' then
  1022. begin
  1023. skipspace;
  1024. Message1(scan_n_user_defined,readmessage);
  1025. end
  1026. else if hs='WARNING' then
  1027. begin
  1028. skipspace;
  1029. Message1(scan_w_user_defined,readmessage);
  1030. end
  1031. else if hs='ERROR' then
  1032. begin
  1033. skipspace;
  1034. Message1(scan_e_user_defined,readmessage);
  1035. end
  1036. else if (hs='FATALERROR') or (hs='STOP') then
  1037. begin
  1038. skipspace;
  1039. Message1(scan_f_user_defined,readmessage);
  1040. end
  1041. else if (hs='L') and (c in [' ',#9]) then
  1042. begin
  1043. skipspace;
  1044. hs:='';
  1045. while not(c in [' ','}',#9,newline,#13]) do
  1046. begin
  1047. hs:=hs+c;
  1048. nextchar;
  1049. if c=#26 then Message(scan_f_end_of_file);
  1050. end;
  1051. hs:=FixFileName(hs);
  1052. if not path_absolute(hs) and (current_module^.current_inputfile^.path<>nil) then
  1053. path:=search(hs,current_module^.current_inputfile^.path^+';'+objectsearchpath,found);
  1054. Linker.AddObjectFile(path+hs);
  1055. current_module^.linkofiles.insert(hs);
  1056. end
  1057. else if hs='D' then
  1058. begin
  1059. if current_module^.in_main then
  1060. Message(scan_w_switch_is_global)
  1061. else
  1062. begin
  1063. if c='-' then
  1064. aktswitches:=aktswitches-[cs_debuginfo]
  1065. else
  1066. aktswitches:=aktswitches+[cs_debuginfo];
  1067. end;
  1068. end
  1069. else if hs='R' then
  1070. begin
  1071. if c='-' then
  1072. {exclude(aktswitches,cs_rangechecking) Not yet supported.}
  1073. aktswitches:=aktswitches-[cs_rangechecking]
  1074. else
  1075. {include(aktswitches,cs_rangechecking); Not yet supported.}
  1076. aktswitches:=aktswitches+[cs_rangechecking];
  1077. end
  1078. else if hs='Q' then
  1079. begin
  1080. if c='-' then
  1081. {include(aktswitches,cs_check_overflow) Not yet supported.}
  1082. aktswitches:=aktswitches-[cs_check_overflow]
  1083. else
  1084. {include(aktswitches,cs_check_overflow); Not yet supported.}
  1085. aktswitches:=aktswitches+[cs_check_overflow]
  1086. end
  1087. else if hs='T' then
  1088. begin
  1089. if c='-' then
  1090. aktswitches:=aktswitches-[cs_typed_addresses]
  1091. else
  1092. aktswitches:=aktswitches+[cs_typed_addresses]
  1093. end
  1094. else if hs='V' then
  1095. begin
  1096. if c='-' then
  1097. aktswitches:=aktswitches-[cs_strict_var_strings]
  1098. else
  1099. aktswitches:=aktswitches+[cs_strict_var_strings]
  1100. end
  1101. else if hs='F' then
  1102. begin
  1103. Message(scan_n_far_directive_ignored);
  1104. end
  1105. else if hs='S' then
  1106. begin
  1107. if target_info.target<>target_linux then
  1108. begin
  1109. case c of
  1110. '-' : aktswitches:=aktswitches-[cs_check_stack];
  1111. '+' : aktswitches:=aktswitches+[cs_check_stack];
  1112. else
  1113. Message(scan_w_illegal_switch);
  1114. end;
  1115. end
  1116. else
  1117. begin
  1118. if c in ['+','-'] then
  1119. Message(scan_n_stack_check_global_under_linux)
  1120. else
  1121. Message(scan_w_illegal_switch);
  1122. end;
  1123. end
  1124. else if hs='E' then
  1125. begin
  1126. { This is a global switch which affects all units }
  1127. if ((current_module = main_module) and (main_module^.in_main = false)) then
  1128. begin
  1129. case c of
  1130. '-' : aktswitches:=aktswitches-[cs_fp_emulation];
  1131. '+' : aktswitches:=aktswitches+[cs_fp_emulation];
  1132. else
  1133. Message(scan_w_illegal_switch);
  1134. end;
  1135. end
  1136. else
  1137. Message(scan_w_switch_is_global);
  1138. end
  1139. else if hs='X' then
  1140. begin
  1141. { This is a global switch which only affects the unit/program }
  1142. { being compiled }
  1143. if not (current_module^.in_main) then
  1144. begin
  1145. case c of
  1146. '-' : aktswitches:=aktswitches-[cs_extsyntax];
  1147. '+' : aktswitches:=aktswitches+[cs_extsyntax];
  1148. else
  1149. Message(scan_w_illegal_switch);
  1150. end;
  1151. end
  1152. else
  1153. Message(scan_w_switch_is_global);
  1154. end
  1155. else if hs='LINKLIB' then
  1156. begin
  1157. skipspace;
  1158. hs:=read_original_string;
  1159. Linker.AddLibraryFile(hs);
  1160. current_module^.linklibfiles.insert(hs);
  1161. end
  1162. {$ifdef i386}
  1163. else if hs='OUTPUT_FORMAT' then
  1164. begin
  1165. { this is a global switch }
  1166. if current_module^.in_main then
  1167. Message(scan_w_switch_is_global)
  1168. else
  1169. begin
  1170. skipspace;
  1171. hs:=upper(read_string);
  1172. if hs='NASM' then
  1173. current_module^.output_format:=of_nasm
  1174. else if hs='MASM' then
  1175. current_module^.output_format:=of_masm
  1176. else if hs='O' then
  1177. current_module^.output_format:=of_o
  1178. else if hs='OBJ' then
  1179. current_module^.output_format:=of_obj
  1180. else
  1181. Message(scan_w_illegal_switch);
  1182. end;
  1183. { for use in globals }
  1184. output_format:=current_module^.output_format;
  1185. end
  1186. {$endif}
  1187. {$ifdef SUPPORT_MMX}
  1188. else if hs='MMX' then
  1189. begin
  1190. if c='-' then
  1191. aktswitches:=aktswitches-[cs_mmx]
  1192. else
  1193. aktswitches:=aktswitches+[cs_mmx];
  1194. end
  1195. else if hs='SATURATION' then
  1196. begin
  1197. if c='-' then
  1198. aktswitches:=aktswitches-[cs_mmx_saturation]
  1199. else
  1200. aktswitches:=aktswitches+[cs_mmx_saturation];
  1201. end
  1202. {$endif SUPPORT_MMX}
  1203. else if hs='DEFINE' then
  1204. begin
  1205. skipspace;
  1206. hs:=read_string;
  1207. mac:=pmacrosym(macros^.search(hs));
  1208. if not assigned(mac) then
  1209. begin
  1210. mac:=new(pmacrosym,init(hs));
  1211. mac^.defined:=true;
  1212. Message1(parser_m_macro_defined,mac^.name);
  1213. macros^.insert(mac);
  1214. end
  1215. else
  1216. begin
  1217. Message1(parser_m_macro_defined,mac^.name);
  1218. mac^.defined:=true;
  1219. { delete old definition }
  1220. if assigned(mac^.buftext) then
  1221. begin
  1222. freemem(mac^.buftext,mac^.buflen);
  1223. mac^.buftext:=nil;
  1224. end;
  1225. end;
  1226. if support_macros then
  1227. begin
  1228. { key words are never substituted }
  1229. hs2:=pattern;
  1230. pattern:=hs;
  1231. if is_keyword(ht) then
  1232. Message(scan_e_keyword_cant_be_a_macro);
  1233. pattern:=hs2;
  1234. skipspace;
  1235. { !!!!!! handle macro params, need we this? }
  1236. { may be a macro? }
  1237. if c=':' then
  1238. begin
  1239. nextchar;
  1240. if c='=' then
  1241. begin
  1242. { first char }
  1243. nextchar;
  1244. macropos:=0;
  1245. while (c<>'}') do
  1246. begin
  1247. macrobuffer^[macropos]:=c;
  1248. { if c=newline then write_line;}
  1249. nextchar;
  1250. if c=#26 then Message(scan_f_end_of_file);
  1251. inc(macropos);
  1252. if macropos>maxmacrolen then
  1253. Message(scan_f_macro_buffer_overflow);
  1254. end;
  1255. { free buffer of macro ?}
  1256. if assigned(mac^.buftext) then
  1257. freemem(mac^.buftext,mac^.buflen);
  1258. { get new mem }
  1259. getmem(mac^.buftext,macropos);
  1260. mac^.buflen:=macropos;
  1261. { copy the text }
  1262. move(macrobuffer^,mac^.buftext^,macropos);
  1263. end;
  1264. end;
  1265. end;
  1266. end
  1267. else if hs='UNDEF' then
  1268. begin
  1269. skipspace;
  1270. hs:=read_string;
  1271. mac:=pmacrosym(macros^.search(hs));
  1272. if not assigned(mac) then
  1273. begin
  1274. mac:=new(pmacrosym,init(hs));
  1275. Message1(parser_m_macro_undefined,mac^.name);
  1276. mac^.defined:=false;
  1277. macros^.insert(mac);
  1278. end
  1279. else
  1280. begin
  1281. Message1(parser_m_macro_undefined,mac^.name);
  1282. mac^.defined:=false;
  1283. { delete old definition }
  1284. if assigned(mac^.buftext) then
  1285. begin
  1286. freemem(mac^.buftext,mac^.buflen);
  1287. mac^.buftext:=nil;
  1288. end;
  1289. end;
  1290. end
  1291. else if hs='PACKRECORDS' then
  1292. begin
  1293. skipspace;
  1294. if upcase(c)='N' then
  1295. begin
  1296. hs:=read_string;
  1297. if hs='NORMAL' then
  1298. aktpackrecords:=2
  1299. else
  1300. Message(scan_w_only_pack_records);
  1301. end
  1302. else
  1303. case read_number of
  1304. 1 : aktpackrecords:=1;
  1305. 2 : aktpackrecords:=2;
  1306. 4 : aktpackrecords:=4;
  1307. else Message(scan_w_only_pack_records);
  1308. end;
  1309. end
  1310. {$ifdef i386}
  1311. else if hs='I386_INTEL' then
  1312. aktasmmode:=I386_INTEL
  1313. else if hs='I386_DIRECT' then
  1314. aktasmmode:=I386_DIRECT
  1315. else if hs='I386_ATT' then
  1316. aktasmmode:=I386_ATT
  1317. {$endif}
  1318. else
  1319. begin
  1320. Message(scan_w_illegal_switch);
  1321. end;
  1322. end;
  1323. procedure src_comment;
  1324. begin
  1325. inc(comment_level);
  1326. { only warn for over one => incompatible with BP }
  1327. if (comment_level>1) then
  1328. Message1(scan_w_comment_level,tostr(comment_level));
  1329. nextchar;
  1330. while true do
  1331. begin
  1332. { handle compiler switches }
  1333. if (comment_level=1) and (c='$') then
  1334. handle_switches;
  1335. { handle_switches can dec comment_level, }
  1336. { if there is an include file }
  1337. while (c<>'}') and (comment_level>0) do
  1338. begin
  1339. if c='{' then
  1340. src_comment
  1341. else
  1342. begin
  1343. if c=#26 then Message(scan_f_end_of_file);
  1344. { if c=newline then write_line;}
  1345. nextchar;
  1346. end;
  1347. end;
  1348. { this is needed for the include files }
  1349. { if there is a end of comment then read it }
  1350. if c='}' then
  1351. begin
  1352. nextchar;
  1353. dec_comment_level;
  1354. { only warn for over one => incompatible with BP }
  1355. if (comment_level>1) then
  1356. Message1(scan_w_comment_level,tostr(comment_level));
  1357. end;
  1358. { checks }{ }
  1359. if c='{' then
  1360. begin
  1361. inc(comment_level);
  1362. { only warn for over one => incompatible with BP }
  1363. if (comment_level>1) then
  1364. Message1(scan_w_comment_level,tostr(comment_level));
  1365. nextchar;
  1366. end
  1367. else
  1368. break;
  1369. end;
  1370. end;
  1371. procedure delphi_comment;
  1372. begin
  1373. { C++/Delphi styled comment }
  1374. inc(comment_level);
  1375. nextchar;
  1376. { this is currently not supported }
  1377. if c='$' then
  1378. Message(scan_e_wrong_styled_switch);
  1379. while c<>newline do
  1380. begin
  1381. if c=#26 then Message(scan_f_end_of_file);
  1382. nextchar;
  1383. end;
  1384. dec(comment_level);
  1385. end;
  1386. const
  1387. yylexcount : longint = 0;
  1388. function yylex : ttoken;
  1389. var
  1390. y : ttoken;
  1391. code : word;
  1392. l : longint;
  1393. hs : string;
  1394. mac : pmacrosym;
  1395. hp : pinputfile;
  1396. hp2 : pchar;
  1397. label
  1398. yylex_exit;
  1399. begin
  1400. { was the last character a point ? }
  1401. { this code is needed because the scanner if there is a 1. found if }
  1402. { this is a floating point number or range like 1..3 }
  1403. if s_point then
  1404. begin
  1405. s_point:=false;
  1406. if c='.' then
  1407. begin
  1408. nextchar;
  1409. yylex:=POINTPOINT;
  1410. goto yylex_exit;
  1411. end;
  1412. yylex:=POINT;
  1413. goto yylex_exit;
  1414. end;
  1415. if c='{' then src_comment;
  1416. skipspace;
  1417. lasttokenpos:=inputpointer-1;
  1418. case c of
  1419. 'A'..'Z','a'..'z','_' :
  1420. begin
  1421. orgpattern:=c;
  1422. nextchar;
  1423. while c in ['A'..'Z','a'..'z','0'..'9','_'] do
  1424. begin
  1425. orgpattern:=orgpattern+c;
  1426. nextchar;
  1427. end;
  1428. pattern:=orgpattern;
  1429. uppervar(pattern);
  1430. if is_keyword(y) then
  1431. yylex:=y
  1432. else
  1433. begin
  1434. { this takes some time ... }
  1435. if support_macros then
  1436. begin
  1437. mac:=pmacrosym(macros^.search(pattern));
  1438. if assigned(mac) and (assigned(mac^.buftext)) then
  1439. begin
  1440. { don't forget the last char }
  1441. dec(inputpointer);
  1442. current_module^.current_inputfile^.bufpos:=inputpointer;
  1443. { this isn't a proper way, but ... }
  1444. hp:=new(pinputfile,init('','Macro '+pattern,''));
  1445. hp^.next:=current_module^.current_inputfile;
  1446. current_module^.current_inputfile:=hp;
  1447. current_module^.sourcefiles.register_file(hp);
  1448. { set an own buffer }
  1449. getmem(hp2,mac^.buflen+1);
  1450. current_module^.current_inputfile^.setbuf(hp2,mac^.buflen+1);
  1451. inputbuffer:=current_module^.current_inputfile^.buf;
  1452. { copy text }
  1453. move(mac^.buftext^,inputbuffer^,mac^.buflen);
  1454. { put end sign }
  1455. inputbuffer[mac^.buflen+1]:=#0;
  1456. { load c }
  1457. c:=inputbuffer[0];
  1458. { point to the next char }
  1459. inputpointer:=1;
  1460. { handle empty macros }
  1461. if c=#0 then reload;
  1462. { play it again ... }
  1463. inc(yylexcount);
  1464. if yylexcount>16 then
  1465. Message(scan_w_macro_deep_ten);
  1466. {$ifdef TP}
  1467. yylex:=yylex;
  1468. {$else}
  1469. yylex:=yylex();
  1470. {$endif}
  1471. { that's all folks }
  1472. dec(yylexcount);
  1473. goto yylex_exit;
  1474. end;
  1475. end;
  1476. yylex:=ID;
  1477. end;
  1478. goto yylex_exit;
  1479. end;
  1480. '$' : begin
  1481. pattern:=c;
  1482. nextchar;
  1483. while ((ord(c)>=ord('0')) and (ord(c)<=ord('9'))) or
  1484. (ord(upcase(c))>=ord('A')) and (ord(upcase(c))<=ord('F')) do
  1485. begin
  1486. pattern:=pattern+c;
  1487. nextchar;
  1488. end;
  1489. yylex:=INTCONST;
  1490. goto yylex_exit;
  1491. end;
  1492. {why ?ifdef FPC}
  1493. { because the tp val doesn't recognize this, }
  1494. { so it's useless in TP versions }
  1495. { it's solved with valint }
  1496. '%' : begin
  1497. pattern:=c;
  1498. nextchar;
  1499. while c in ['0','1'] do
  1500. begin
  1501. pattern:=pattern+c;
  1502. nextchar;
  1503. end;
  1504. yylex:=INTCONST;
  1505. goto yylex_exit;
  1506. end;
  1507. {cond removed endif}
  1508. '0'..'9' : begin
  1509. pattern:=c;
  1510. nextchar;
  1511. while c in ['0'..'9'] do
  1512. begin
  1513. pattern:=pattern+c;
  1514. nextchar;
  1515. end;
  1516. if c in ['.','e','E'] then
  1517. begin
  1518. if c='.' then
  1519. begin
  1520. nextchar;
  1521. if not(c in ['0'..'9']) then
  1522. begin
  1523. s_point:=true;
  1524. yylex:=INTCONST;
  1525. goto yylex_exit;
  1526. end;
  1527. pattern:=pattern+'.';
  1528. while c in ['0'..'9'] do
  1529. begin
  1530. pattern:=pattern+c;
  1531. nextchar;
  1532. end;
  1533. end;
  1534. if upcase(c)='E' then
  1535. begin
  1536. pattern:=pattern+'E';
  1537. nextchar;
  1538. if c in ['-','+'] then
  1539. begin
  1540. pattern:=pattern+c;
  1541. nextchar;
  1542. end;
  1543. if not(c in ['0'..'9']) then
  1544. Message(scan_f_illegal_char);
  1545. while c in ['0'..'9'] do
  1546. begin
  1547. pattern:=pattern+c;
  1548. nextchar;
  1549. end;
  1550. end;
  1551. yylex:=REALNUMBER;
  1552. goto yylex_exit;
  1553. end;
  1554. yylex:=INTCONST;
  1555. goto yylex_exit;
  1556. end;
  1557. ';' : begin
  1558. nextchar;
  1559. yylex:=SEMICOLON;
  1560. exit;
  1561. end;
  1562. '[' : begin
  1563. nextchar;
  1564. yylex:=LECKKLAMMER;
  1565. goto yylex_exit;
  1566. end;
  1567. ']' : begin
  1568. nextchar;
  1569. yylex:=RECKKLAMMER;
  1570. goto yylex_exit;
  1571. end;
  1572. '(' : begin
  1573. nextchar;
  1574. if c='*' then
  1575. begin
  1576. inc(comment_level);
  1577. nextchar;
  1578. while true do
  1579. begin
  1580. { this is currently not supported }
  1581. if c='$' then
  1582. Message(scan_e_wrong_styled_switch);
  1583. repeat
  1584. while c<>'*' do
  1585. begin
  1586. if c=#26 then Message(scan_f_end_of_file);
  1587. { if c=newline then write_line;}
  1588. nextchar;
  1589. end;
  1590. if c=#26 then Message(scan_f_end_of_file);
  1591. {if c=newline then write_line;}
  1592. nextchar;
  1593. until c=')';
  1594. dec(comment_level);
  1595. nextchar;
  1596. { check for *)(* }
  1597. if c='(' then
  1598. begin
  1599. nextchar;
  1600. if c<>'*' then
  1601. begin
  1602. yylex:=LKLAMMER;
  1603. goto yylex_exit;
  1604. end;
  1605. inc(comment_level);
  1606. nextchar;
  1607. end
  1608. else
  1609. begin
  1610. {$ifndef TP}
  1611. yylex:=yylex();
  1612. {$else TP}
  1613. yylex:=yylex;
  1614. {$endif TP}
  1615. goto yylex_exit;
  1616. end;
  1617. end;
  1618. end;
  1619. yylex:=LKLAMMER;
  1620. goto yylex_exit;
  1621. end;
  1622. ')' : begin
  1623. nextchar;
  1624. yylex:=RKLAMMER;
  1625. goto yylex_exit;
  1626. end;
  1627. '+' : begin
  1628. nextchar;
  1629. if (c='=') and c_like_operators then
  1630. begin
  1631. nextchar;
  1632. yylex:=_PLUSASN;
  1633. goto yylex_exit;
  1634. end
  1635. else
  1636. begin
  1637. yylex:=PLUS;
  1638. goto yylex_exit;
  1639. end;
  1640. end;
  1641. '-' : begin
  1642. nextchar;
  1643. if (c='=') and c_like_operators then
  1644. begin
  1645. nextchar;
  1646. yylex:=_MINUSASN;
  1647. goto yylex_exit;
  1648. end
  1649. else
  1650. begin
  1651. yylex:=MINUS;
  1652. goto yylex_exit;
  1653. end;
  1654. end;
  1655. ':' : begin
  1656. nextchar;
  1657. if c='=' then
  1658. begin
  1659. nextchar;
  1660. yylex:=ASSIGNMENT;
  1661. goto yylex_exit;
  1662. end
  1663. else
  1664. begin
  1665. yylex:=COLON;
  1666. goto yylex_exit;
  1667. end;
  1668. end;
  1669. '*' : begin
  1670. nextchar;
  1671. if (c='=') and c_like_operators then
  1672. begin
  1673. nextchar;
  1674. yylex:=_STARASN;
  1675. goto yylex_exit;
  1676. end
  1677. else
  1678. begin
  1679. yylex:=STAR;
  1680. goto yylex_exit;
  1681. end;
  1682. end;
  1683. '/' : begin
  1684. nextchar;
  1685. if (c='=') and c_like_operators then
  1686. begin
  1687. nextchar;
  1688. yylex:=_SLASHASN;
  1689. goto yylex_exit;
  1690. end
  1691. else if (c='/') then
  1692. begin
  1693. delphi_comment;
  1694. {$ifndef TP}
  1695. yylex:=yylex();
  1696. {$else TP}
  1697. yylex:=yylex;
  1698. {$endif TP}
  1699. goto yylex_exit;
  1700. end
  1701. else
  1702. begin
  1703. yylex:=SLASH;
  1704. goto yylex_exit;
  1705. end;
  1706. end;
  1707. '=' : begin
  1708. nextchar;
  1709. yylex:=EQUAL;
  1710. goto yylex_exit;
  1711. end;
  1712. '.' : begin
  1713. nextchar;
  1714. if c='.' then
  1715. begin
  1716. nextchar;
  1717. yylex:=POINTPOINT;
  1718. goto yylex_exit;
  1719. end
  1720. else
  1721. yylex:=POINT;
  1722. goto yylex_exit;
  1723. end;
  1724. '@' : begin
  1725. nextchar;
  1726. if c='@' then
  1727. begin
  1728. nextchar;
  1729. yylex:=DOUBLEADDR;
  1730. end
  1731. else
  1732. yylex:=KLAMMERAFFE;
  1733. goto yylex_exit;
  1734. end;
  1735. ',' : begin
  1736. nextchar;
  1737. yylex:=COMMA;
  1738. exit;
  1739. end;
  1740. '''','#','^' :
  1741. begin
  1742. if c='^' then
  1743. begin
  1744. nextchar;
  1745. c:=upcase(c);
  1746. if not(block_type=bt_type) and (c in ['A'..'Z']) then
  1747. begin
  1748. pattern:=chr(ord(c)-64);
  1749. nextchar;
  1750. end
  1751. else
  1752. begin
  1753. yylex:=CARET;
  1754. goto yylex_exit;
  1755. end;
  1756. end
  1757. else pattern:='';
  1758. while true do
  1759. case c of
  1760. '#' :
  1761. begin
  1762. hs:='';
  1763. nextchar;
  1764. if c='$' then
  1765. begin
  1766. hs:='$';
  1767. nextchar;
  1768. while c in (['0'..'9','a'..'f','A'..'F']) do
  1769. begin
  1770. hs:=hs+upcase(c);
  1771. nextchar;
  1772. end;
  1773. end
  1774. else
  1775. { FPC supports binary constants }
  1776. { %10101 evalutes to 37 }
  1777. if c='%' then
  1778. begin
  1779. nextchar;
  1780. while c in ['0','1'] do
  1781. begin
  1782. hs:=hs+upcase(c);
  1783. nextchar;
  1784. end;
  1785. end
  1786. else
  1787. begin
  1788. while (ord(c)>=ord('0')) and (ord(c)<=ord('9')) do
  1789. begin
  1790. hs:=hs+c;
  1791. nextchar;
  1792. end;
  1793. end;
  1794. valint(hs,l,code);
  1795. if (code<>0) or (l<0) or (l>255) then
  1796. Message(scan_e_illegal_char_const);
  1797. pattern:=pattern+chr(l);
  1798. end;
  1799. '''' :
  1800. begin
  1801. repeat
  1802. nextchar;
  1803. case c of
  1804. #26 : begin
  1805. Message(scan_f_end_of_file);
  1806. break;
  1807. end;
  1808. #13,
  1809. newline : begin
  1810. Message(scan_f_string_exceeds_line);
  1811. break;
  1812. end;
  1813. '''' : begin
  1814. nextchar;
  1815. if c<>'''' then
  1816. break;
  1817. end;
  1818. end;
  1819. pattern:=pattern+c;
  1820. until false;
  1821. end;
  1822. '^' : begin
  1823. nextchar;
  1824. c:=upcase(c);
  1825. if ord(c)<64 then
  1826. pattern:=pattern+chr(ord(c)+64)
  1827. else
  1828. pattern:=pattern+chr(ord(c)-64);
  1829. nextchar;
  1830. end;
  1831. else break;
  1832. end;
  1833. { strings with length 1 become const chars }
  1834. if length(pattern)=1 then
  1835. yylex:=CCHAR
  1836. else yylex:=CSTRING;
  1837. goto yylex_exit;
  1838. end;
  1839. '>' : begin
  1840. nextchar;
  1841. if c='=' then
  1842. begin
  1843. nextchar;
  1844. yylex:=GTE;
  1845. goto yylex_exit;
  1846. end
  1847. else if c='>' then
  1848. begin
  1849. nextchar;
  1850. yylex:=_SHR;
  1851. goto yylex_exit;
  1852. end
  1853. else if c='<' then
  1854. begin
  1855. nextchar;
  1856. { >< is for a symetric diff for sets }
  1857. yylex:=SYMDIF;
  1858. goto yylex_exit;
  1859. end
  1860. else
  1861. begin
  1862. yylex:=GT;
  1863. goto yylex_exit;
  1864. end;
  1865. end;
  1866. '<' : begin
  1867. nextchar;
  1868. if c='>' then
  1869. begin
  1870. nextchar;
  1871. yylex:=UNEQUAL;
  1872. goto yylex_exit;
  1873. end
  1874. else if c='=' then
  1875. begin
  1876. nextchar;
  1877. yylex:=LTE;
  1878. goto yylex_exit;
  1879. end
  1880. else if c='<' then
  1881. begin
  1882. nextchar;
  1883. yylex:=_SHL;
  1884. goto yylex_exit;
  1885. end
  1886. else
  1887. begin
  1888. yylex:=LT;
  1889. goto yylex_exit;
  1890. end;
  1891. end;
  1892. #26 : begin
  1893. yylex:=_EOF;
  1894. goto yylex_exit;
  1895. end;
  1896. else
  1897. begin
  1898. update_line;
  1899. Message(scan_f_illegal_char);
  1900. end;
  1901. end;
  1902. yylex_exit :
  1903. update_line;
  1904. end;
  1905. const last_asmgetchar_was_a_comment : boolean = false;
  1906. function asmgetchar : char;
  1907. begin
  1908. if c='{' then
  1909. begin
  1910. src_comment;
  1911. { a comment is a seperator }
  1912. asmgetchar:=';';
  1913. last_asmgetchar_was_a_comment:=true;
  1914. end
  1915. else
  1916. begin
  1917. update_line;
  1918. if last_asmgetchar_was_a_comment then
  1919. begin
  1920. last_asmgetchar_was_a_comment:=false;
  1921. asmgetchar:=c;
  1922. exit;
  1923. end;
  1924. nextchar;
  1925. asmgetchar:=c;
  1926. if c='/' then
  1927. begin
  1928. nextchar;
  1929. if c='/' then
  1930. begin
  1931. delphi_comment;
  1932. asmgetchar:=c;
  1933. end
  1934. else
  1935. begin
  1936. last_asmgetchar_was_a_comment:=true;
  1937. asmgetchar:='/';
  1938. end;
  1939. end;
  1940. end;
  1941. end;
  1942. procedure initscanner(const fn: string);
  1943. var
  1944. d:dirstr;
  1945. n:namestr;
  1946. e:extstr;
  1947. begin
  1948. fsplit(fn,d,n,e);
  1949. current_module^.current_inputfile:=new(pinputfile,init(d,n,e));
  1950. current_module^.current_inputfile^.reset;
  1951. current_module^.sourcefiles.register_file(current_module^.current_inputfile);
  1952. if ioresult<>0 then
  1953. Message(scan_f_cannot_open_input);
  1954. inputbuffer:=current_module^.current_inputfile^.buf;
  1955. preprocstack:=nil;
  1956. reload;
  1957. comment_level:=0;
  1958. lasttokenpos:=0;
  1959. lastlinepointer:=0;
  1960. s_point:=false;
  1961. end;
  1962. procedure donescanner(compiled_at_higher_level : boolean);
  1963. var
  1964. st : string;
  1965. begin
  1966. if not (compiled_at_higher_level) and assigned(preprocstack) then
  1967. begin
  1968. if preprocstack^.t=PP_IFDEF then
  1969. st:='$IF(N)(DEF)'
  1970. else
  1971. st:='$ELSE';
  1972. Message3(scan_e_endif_expected,st,preprocstack^.name,tostr(preprocstack^.line_nb));
  1973. end;
  1974. end;
  1975. end.
  1976. {
  1977. $Log$
  1978. Revision 1.10 1998-04-22 21:06:50 florian
  1979. * last fixes before the release:
  1980. - veryyyy slow firstcall fixed
  1981. Revision 1.9 1998/04/16 12:14:58 peter
  1982. * quick hack for ^[ in strings
  1983. Revision 1.8 1998/04/16 12:07:55 peter
  1984. * quick $L+ hack
  1985. Revision 1.7 1998/04/10 15:39:48 florian
  1986. * more fixes to get classes.pas compiled
  1987. Revision 1.6 1998/04/09 09:33:15 pierre
  1988. * bugfix of newline in BP was wrong !!
  1989. (ate a character !!)
  1990. Revision 1.5 1998/04/07 22:45:05 florian
  1991. * bug0092, bug0115 and bug0121 fixed
  1992. + packed object/class/array
  1993. Revision 1.4 1998/04/07 13:19:49 pierre
  1994. * bugfixes for reset_gdb_info
  1995. in MEM parsing for go32v2
  1996. better external symbol creation
  1997. support for rhgdb.exe (lowercase file names)
  1998. Revision 1.3 1998/03/29 17:27:59 florian
  1999. * aopt386 compiles with TP
  2000. * correct line number is displayed, if a #0 is in the input
  2001. Revision 1.2 1998/03/28 23:09:57 florian
  2002. * secondin bugfix (m68k and i386)
  2003. * overflow checking bugfix (m68k and i386) -- pretty useless in
  2004. secondadd, since everything is done using 32-bit
  2005. * loading pointer to routines hopefully fixed (m68k)
  2006. * flags problem with calls to RTL internal routines fixed (still strcmp
  2007. to fix) (m68k)
  2008. * #ELSE was still incorrect (didn't take care of the previous level)
  2009. * problem with filenames in the command line solved
  2010. * problem with mangledname solved
  2011. * linking name problem solved (was case insensitive)
  2012. * double id problem and potential crash solved
  2013. * stop after first error
  2014. * and=>test problem removed
  2015. * correct read for all float types
  2016. * 2 sigsegv fixes and a cosmetic fix for Internal Error
  2017. * push/pop is now correct optimized (=> mov (%esp),reg)
  2018. Revision 1.1.1.1 1998/03/25 11:18:15 root
  2019. * Restored version
  2020. Revision 1.43 1998/03/24 21:48:34 florian
  2021. * just a couple of fixes applied:
  2022. - problem with fixed16 solved
  2023. - internalerror 10005 problem fixed
  2024. - patch for assembler reading
  2025. - small optimizer fix
  2026. - mem is now supported
  2027. Revision 1.42 1998/03/10 17:19:29 peter
  2028. * fixed bug0108
  2029. * better linebreak scanning (concentrated in nextchar(), it supports
  2030. #10, #13, #10#13, #13#10
  2031. Revision 1.41 1998/03/10 16:27:45 pierre
  2032. * better line info in stabs debug
  2033. * symtabletype and lexlevel separated into two fields of tsymtable
  2034. + ifdef MAKELIB for direct library output, not complete
  2035. + ifdef CHAINPROCSYMS for overloaded seach across units, not fully
  2036. working
  2037. + ifdef TESTFUNCRET for setting func result in underfunction, not
  2038. working
  2039. Revision 1.40 1998/03/10 01:17:27 peter
  2040. * all files have the same header
  2041. * messages are fully implemented, EXTDEBUG uses Comment()
  2042. + AG... files for the Assembler generation
  2043. Revision 1.39 1998/03/09 12:58:14 peter
  2044. * FWait warning is only showed for Go32V2 and $E+
  2045. * opcode tables moved to i386.pas/m68k.pas to reduce circular uses (and
  2046. for m68k the same tables are removed)
  2047. + $E for i386
  2048. Revision 1.38 1998/03/06 00:52:52 peter
  2049. * replaced all old messages from errore.msg, only ExtDebug and some
  2050. Comment() calls are left
  2051. * fixed options.pas
  2052. Revision 1.37 1998/03/04 17:34:06 michael
  2053. + Changed ifdef FPK to ifdef FPC
  2054. Revision 1.36 1998/03/03 22:38:34 peter
  2055. * the last 3 files
  2056. Revision 1.35 1998/03/02 01:49:26 peter
  2057. * renamed target_DOS to target_GO32V1
  2058. + new verbose system, merged old errors and verbose units into one new
  2059. verbose.pas, so errors.pas is obsolete
  2060. Revision 1.34 1998/02/26 11:57:16 daniel
  2061. * New assembler optimizations commented out, because of bugs.
  2062. * Use of dir-/name- and extstr.
  2063. Revision 1.33 1998/02/22 23:03:32 peter
  2064. * renamed msource->mainsource and name->unitname
  2065. * optimized filename handling, filename is not seperate anymore with
  2066. path+name+ext, this saves stackspace and a lot of fsplit()'s
  2067. * recompiling of some units in libraries fixed
  2068. * shared libraries are working again
  2069. + $LINKLIB <lib> to support automatic linking to libraries
  2070. + libraries are saved/read from the ppufile, also allows more libraries
  2071. per ppufile
  2072. Revision 1.32 1998/02/17 21:20:59 peter
  2073. + Script unit
  2074. + __EXIT is called again to exit a program
  2075. - target_info.link/assembler calls
  2076. * linking works again for dos
  2077. * optimized a few filehandling functions
  2078. * fixed stabs generation for procedures
  2079. Revision 1.31 1998/02/16 12:51:44 michael
  2080. + Implemented linker object
  2081. Revision 1.30 1998/02/13 10:35:45 daniel
  2082. * Made Motorola version compilable.
  2083. * Fixed optimizer
  2084. Revision 1.29 1998/02/12 17:19:25 florian
  2085. * fixed to get remake3 work, but needs additional fixes (output, I don't like
  2086. also that aktswitches isn't a pointer)
  2087. Revision 1.28 1998/02/12 11:50:44 daniel
  2088. Yes! Finally! After three retries, my patch!
  2089. Changes:
  2090. Complete rewrite of psub.pas.
  2091. Added support for DLL's.
  2092. Compiler requires less memory.
  2093. Platform units for each platform.
  2094. Revision 1.27 1998/02/07 09:39:27 florian
  2095. * correct handling of in_main
  2096. + $D,$T,$X,$V like tp
  2097. Revision 1.26 1998/02/05 22:27:06 florian
  2098. * small problems fixed: remake3 should now work
  2099. Revision 1.25 1998/02/03 22:13:35 florian
  2100. * clean up
  2101. Revision 1.24 1998/02/02 23:42:38 florian
  2102. * data is now dword aligned per default else the stack ajustements are useless
  2103. + $wait directive: stops compiling til return is presseed (a message is
  2104. also written, useful to give the user a change to notice a message
  2105. Revision 1.23 1998/02/02 13:13:28 pierre
  2106. * line_count transfered to tinputfile, to avoid crosscounting
  2107. Revision 1.22 1998/01/30 17:30:10 pierre
  2108. + better line counting mechanism
  2109. line count updated only when important tokens are read
  2110. (not for comment , ; )
  2111. Revision 1.21 1998/01/26 19:09:52 peter
  2112. * fixed EOF in open string constant reading
  2113. Revision 1.20 1998/01/22 08:56:55 peter
  2114. * Fixed string exceeds end of line problem (#13 is not a linux
  2115. linebreak)
  2116. Revision 1.19 1998/01/20 18:18:46 peter
  2117. * fixed skip_until_pragma, bug0044 and the compiler recompile good
  2118. Revision 1.18 1998/01/20 16:30:17 pierre
  2119. * bug with braces in log from Peter removed
  2120. Revision 1.17 1998/01/20 15:14:33 peter
  2121. * fixes bug 44 with multiple $'s between skipped $IFDEF and $ENDIF
  2122. Revision 1.16 1998/01/13 16:16:06 pierre
  2123. * bug in interdependent units handling
  2124. - primary unit was not in loaded_units list
  2125. - current_module^.symtable was assigned too early
  2126. - donescanner must not call error if the compilation
  2127. of the unit was done at a higher level.
  2128. Revision 1.15 1998/01/09 23:08:34 florian
  2129. + C++/Delphi styled //-comments
  2130. * some bugs in Delphi object model fixed
  2131. + override directive
  2132. Revision 1.14 1998/01/09 18:01:17 florian
  2133. * VIRTUAL isn't anymore a common keyword
  2134. + DYNAMIC is equal to VIRTUAL
  2135. Revision 1.13 1998/01/09 13:39:57 florian
  2136. * public, protected and private aren't anymore key words
  2137. + published is equal to public
  2138. Revision 1.12 1997/12/12 13:28:41 florian
  2139. + version 0.99.0
  2140. * all WASM options changed into MASM
  2141. + -O2 for Pentium II optimizations
  2142. Revision 1.11 1997/12/10 23:07:30 florian
  2143. * bugs fixed: 12,38 (also m68k),39,40,41
  2144. + warning if a system unit is without -Us compiled
  2145. + warning if a method is virtual and private (was an error)
  2146. * some indentions changed
  2147. + factor does a better error recovering (omit some crashes)
  2148. + problem with @type(x) removed (crashed the compiler)
  2149. Revision 1.10 1997/12/09 14:09:15 carl
  2150. * bugfix of Runerror 216 when reading a null character (such as trying to
  2151. compile a binary file)
  2152. Revision 1.9 1997/12/08 11:51:12 pierre
  2153. * corrected some buggy code in hexadecimal number reading
  2154. Revision 1.8 1997/12/05 14:22:20 daniel
  2155. * Did some source code beutification.
  2156. Revision 1.7 1997/12/03 13:43:14 carl
  2157. + OUTPUT_FORMAT switch is processor specific to i386.
  2158. Revision 1.6 1997/12/02 16:00:55 carl
  2159. * bugfix of include files - now gives out a fatalerror if not found,
  2160. otherwise would create invalid pointer operations everywhere.
  2161. * bugfix of $i+xyz now the $i+/- switch is correctly recognized as io
  2162. checking and ont an include directive.
  2163. Revision 1.5 1997/11/28 18:14:48 pierre
  2164. working version with several bug fixes
  2165. Revision 1.4 1997/11/28 14:26:26 florian
  2166. Fixed some bugs
  2167. Revision 1.3 1997/11/27 17:47:14 carl
  2168. * fixed bug with assem switches and m68k.
  2169. Revision 1.2 1997/11/27 17:40:48 carl
  2170. + assem type scanning switches for intel targets.
  2171. Revision 1.1.1.1 1997/11/27 08:33:01 michael
  2172. FPC Compiler CVS start
  2173. Pre-CVS log:
  2174. CEC Carl-Eric Codere
  2175. FK Florian Klaempfl
  2176. PM Pierre Muller
  2177. + feature added
  2178. - removed
  2179. * bug fixed or changed
  2180. History:
  2181. 6th september 1997:
  2182. + added support for global switches (i.e $X and $E (for m68k)) (CEC)
  2183. 1st october 1997:
  2184. + added $ifopt as dummy which is always rejected (FK)
  2185. 13th october 1997:
  2186. * user defined message are now written via the errors unit
  2187. and exterror (FK)
  2188. + compiler switch $INFO added, does the same like $MESSAGE,
  2189. the text is written via comment(v_info,...) (FK)
  2190. + $STOP and $FATALERROR added: they are equivalent, the
  2191. following message is written and the compiler stops (FK)
  2192. - write_c, no more necessary (FK)
  2193. 14th october 1997:
  2194. + wrong line counting corrected: <comment start> $I test
  2195. <comment end>
  2196. (FK)
  2197. 17th october 1997:
  2198. + support of $if expr (FK)
  2199. * $define a=1234 to a:=1234 (FK)
  2200. + -So allows now <comment start> <comment start> <comment end>
  2201. as comment (preocedure dec_comment_level) (FK)
  2202. 22th october 1997:
  2203. + $NOTE (FK)
  2204. 9th november 1997:
  2205. + added updating of line_no in asmgetchar. (CEC)
  2206. 14th november 1997:
  2207. * fixed problem with asm line counting. (CEC)
  2208. 17th november 1997:
  2209. + kommentar renamed src_comment and kommentarebene renamed comment_level (PM)
  2210. }