scanner.pas 81 KB

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