tokens.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Tokens used by the compiler
  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 tokens;
  19. interface
  20. uses
  21. globtype;
  22. const
  23. tokenidlen=14;
  24. type
  25. ttoken=(NOTOKEN,
  26. { operators, which can also be overloaded }
  27. PLUS,
  28. MINUS,
  29. STAR,
  30. SLASH,
  31. EQUAL,
  32. GT,
  33. LT,
  34. GTE,
  35. LTE,
  36. SYMDIF,
  37. STARSTAR,
  38. OP_IS,
  39. OP_AS,
  40. OP_IN,
  41. ASSIGNMENT,
  42. { special chars }
  43. CARET,
  44. UNEQUAL,
  45. LECKKLAMMER,
  46. RECKKLAMMER,
  47. POINT,
  48. COMMA,
  49. LKLAMMER,
  50. RKLAMMER,
  51. COLON,
  52. SEMICOLON,
  53. KLAMMERAFFE,
  54. POINTPOINT,
  55. DOUBLEADDR,
  56. _EOF,
  57. ID,
  58. NOID,
  59. REALNUMBER,
  60. INTCONST,
  61. CSTRING,
  62. CCHAR,
  63. { C like operators }
  64. _PLUSASN,
  65. _MINUSASN,
  66. _ANDASN,
  67. _ORASN,
  68. _STARASN,
  69. _SLASHASN,
  70. _MODASN,
  71. _DIVASN,
  72. _NOTASN,
  73. _XORASN,
  74. { Normal words }
  75. _AS,
  76. _AT,
  77. _DO,
  78. _IF,
  79. _IN,
  80. _IS,
  81. _OF,
  82. _ON,
  83. _OR,
  84. _TO,
  85. _AND,
  86. _ASM,
  87. _DIV,
  88. _END,
  89. _FAR,
  90. _FOR,
  91. _MOD,
  92. _NEW,
  93. _NIL,
  94. _NOT,
  95. _SET,
  96. _SHL,
  97. _SHR,
  98. _TRY,
  99. _VAR,
  100. _XOR,
  101. _CASE,
  102. _CVAR,
  103. _ELSE,
  104. _EXIT,
  105. _FAIL,
  106. _FILE,
  107. _GOTO,
  108. _NAME,
  109. _NEAR,
  110. _READ,
  111. _SELF,
  112. _THEN,
  113. _TRUE,
  114. _TYPE,
  115. _UNIT,
  116. _USES,
  117. _WITH,
  118. _ALIAS,
  119. _ARRAY,
  120. _BEGIN,
  121. _BREAK,
  122. _CDECL,
  123. _CLASS,
  124. _CONST,
  125. _FALSE,
  126. _INDEX,
  127. _LABEL,
  128. _RAISE,
  129. _UNTIL,
  130. _WHILE,
  131. _WRITE,
  132. _DOWNTO,
  133. _EXCEPT,
  134. _EXPORT,
  135. _INLINE,
  136. _OBJECT,
  137. _PACKED,
  138. _PASCAL,
  139. _PUBLIC,
  140. _RECORD,
  141. _REPEAT,
  142. _RESULT,
  143. _STATIC,
  144. _STORED,
  145. _STRING,
  146. _SYSTEM,
  147. _ASMNAME,
  148. _DEFAULT,
  149. _DISPOSE,
  150. _DYNAMIC,
  151. _EXPORTS,
  152. _FINALLY,
  153. _FORWARD,
  154. _IOCHECK,
  155. _LIBRARY,
  156. _MESSAGE,
  157. _PRIVATE,
  158. _PROGRAM,
  159. _STDCALL,
  160. _SYSCALL,
  161. _VIRTUAL,
  162. _ABSOLUTE,
  163. _ABSTRACT,
  164. _CONTINUE,
  165. _EXTERNAL,
  166. _FUNCTION,
  167. _OPERATOR,
  168. _OVERRIDE,
  169. _POPSTACK,
  170. _PROPERTY,
  171. _REGISTER,
  172. _RESIDENT,
  173. _SAFECALL,
  174. _ASSEMBLER,
  175. _INHERITED,
  176. _INTERFACE,
  177. _INTERRUPT,
  178. _NODEFAULT,
  179. _OTHERWISE,
  180. _PROCEDURE,
  181. _PROTECTED,
  182. _PUBLISHED,
  183. _THREADVAR,
  184. _DESTRUCTOR,
  185. _INTERNPROC,
  186. _OPENSTRING,
  187. _CONSTRUCTOR,
  188. _INTERNCONST,
  189. _SHORTSTRING,
  190. _FINALIZATION,
  191. _SAVEREGISTERS,
  192. _IMPLEMENTATION,
  193. _INITIALIZATION,
  194. _RESOURCESTRING
  195. );
  196. tokenrec=record
  197. str : string[tokenidlen];
  198. special : boolean;
  199. keyword : tmodeswitch;
  200. encoded : longint;
  201. end;
  202. const
  203. tokeninfo:array[ttoken] of tokenrec=(
  204. (str:'' ;special:true ;keyword:m_none),
  205. { Operators which can be overloaded }
  206. (str:'+' ;special:true ;keyword:m_none),
  207. (str:'-' ;special:true ;keyword:m_none),
  208. (str:'*' ;special:true ;keyword:m_none),
  209. (str:'/' ;special:true ;keyword:m_none),
  210. (str:'=' ;special:true ;keyword:m_none),
  211. (str:'>' ;special:true ;keyword:m_none),
  212. (str:'<' ;special:true ;keyword:m_none),
  213. (str:'>=' ;special:true ;keyword:m_none),
  214. (str:'<=' ;special:true ;keyword:m_none),
  215. (str:'><' ;special:true ;keyword:m_none),
  216. (str:'**' ;special:true ;keyword:m_none),
  217. (str:'is' ;special:true ;keyword:m_none),
  218. (str:'as' ;special:true ;keyword:m_none),
  219. (str:'in' ;special:true ;keyword:m_none),
  220. (str:':=' ;special:true ;keyword:m_none),
  221. { Special chars }
  222. (str:'^' ;special:true ;keyword:m_none),
  223. (str:'<>' ;special:true ;keyword:m_none),
  224. (str:'[' ;special:true ;keyword:m_none),
  225. (str:']' ;special:true ;keyword:m_none),
  226. (str:'.' ;special:true ;keyword:m_none),
  227. (str:',' ;special:true ;keyword:m_none),
  228. (str:'(' ;special:true ;keyword:m_none),
  229. (str:')' ;special:true ;keyword:m_none),
  230. (str:':' ;special:true ;keyword:m_none),
  231. (str:';' ;special:true ;keyword:m_none),
  232. (str:'@' ;special:true ;keyword:m_none),
  233. (str:'..' ;special:true ;keyword:m_none),
  234. (str:'@@' ;special:true ;keyword:m_none),
  235. (str:'end of file' ;special:true ;keyword:m_none),
  236. (str:'identifier' ;special:true ;keyword:m_none),
  237. (str:'non identifier';special:true ;keyword:m_none),
  238. (str:'const real' ;special:true ;keyword:m_none),
  239. (str:'ordinal const' ;special:true ;keyword:m_none),
  240. (str:'const string' ;special:true ;keyword:m_none),
  241. (str:'const char' ;special:true ;keyword:m_none),
  242. { C like operators }
  243. (str:'+=' ;special:true ;keyword:m_none),
  244. (str:'-=' ;special:true ;keyword:m_none),
  245. (str:'&=' ;special:true ;keyword:m_none),
  246. (str:'|=' ;special:true ;keyword:m_none),
  247. (str:'*=' ;special:true ;keyword:m_none),
  248. (str:'/=' ;special:true ;keyword:m_none),
  249. (str:'' ;special:true ;keyword:m_none),
  250. (str:'' ;special:true ;keyword:m_none),
  251. (str:'' ;special:true ;keyword:m_none),
  252. (str:'' ;special:true ;keyword:m_none),
  253. { Normal words }
  254. (str:'AS' ;special:false;keyword:m_class),
  255. (str:'AT' ;special:false;keyword:m_none),
  256. (str:'DO' ;special:false;keyword:m_all),
  257. (str:'IF' ;special:false;keyword:m_all),
  258. (str:'IN' ;special:false;keyword:m_all),
  259. (str:'IS' ;special:false;keyword:m_class),
  260. (str:'OF' ;special:false;keyword:m_all),
  261. (str:'ON' ;special:false;keyword:m_class),
  262. (str:'OR' ;special:false;keyword:m_all),
  263. (str:'TO' ;special:false;keyword:m_all),
  264. (str:'AND' ;special:false;keyword:m_all),
  265. (str:'ASM' ;special:false;keyword:m_all),
  266. (str:'DIV' ;special:false;keyword:m_all),
  267. (str:'END' ;special:false;keyword:m_all),
  268. (str:'FAR' ;special:false;keyword:m_none),
  269. (str:'FOR' ;special:false;keyword:m_all),
  270. (str:'MOD' ;special:false;keyword:m_all),
  271. (str:'NEW' ;special:false;keyword:m_all),
  272. (str:'NIL' ;special:false;keyword:m_all),
  273. (str:'NOT' ;special:false;keyword:m_all),
  274. (str:'SET' ;special:false;keyword:m_all),
  275. (str:'SHL' ;special:false;keyword:m_all),
  276. (str:'SHR' ;special:false;keyword:m_all),
  277. (str:'TRY' ;special:false;keyword:m_class),
  278. (str:'VAR' ;special:false;keyword:m_all),
  279. (str:'XOR' ;special:false;keyword:m_all),
  280. (str:'CASE' ;special:false;keyword:m_all),
  281. (str:'CVAR' ;special:false;keyword:m_none),
  282. (str:'ELSE' ;special:false;keyword:m_all),
  283. (str:'EXIT' ;special:false;keyword:m_all),
  284. (str:'FAIL' ;special:false;keyword:m_none), { only set within constructors PM }
  285. (str:'FILE' ;special:false;keyword:m_all),
  286. (str:'GOTO' ;special:false;keyword:m_all),
  287. (str:'NAME' ;special:false;keyword:m_none),
  288. (str:'NEAR' ;special:false;keyword:m_none),
  289. (str:'READ' ;special:false;keyword:m_none),
  290. (str:'SELF' ;special:false;keyword:m_none), {set inside methods only PM }
  291. (str:'THEN' ;special:false;keyword:m_all),
  292. (str:'TRUE' ;special:false;keyword:m_all),
  293. (str:'TYPE' ;special:false;keyword:m_all),
  294. (str:'UNIT' ;special:false;keyword:m_all),
  295. (str:'USES' ;special:false;keyword:m_all),
  296. (str:'WITH' ;special:false;keyword:m_all),
  297. (str:'ALIAS' ;special:false;keyword:m_none),
  298. (str:'ARRAY' ;special:false;keyword:m_all),
  299. (str:'BEGIN' ;special:false;keyword:m_all),
  300. (str:'BREAK' ;special:false;keyword:m_none),
  301. (str:'CDECL' ;special:false;keyword:m_none),
  302. (str:'CLASS' ;special:false;keyword:m_class),
  303. (str:'CONST' ;special:false;keyword:m_all),
  304. (str:'FALSE' ;special:false;keyword:m_all),
  305. (str:'INDEX' ;special:false;keyword:m_none),
  306. (str:'LABEL' ;special:false;keyword:m_all),
  307. (str:'RAISE' ;special:false;keyword:m_class),
  308. (str:'UNTIL' ;special:false;keyword:m_all),
  309. (str:'WHILE' ;special:false;keyword:m_all),
  310. (str:'WRITE' ;special:false;keyword:m_none),
  311. (str:'DOWNTO' ;special:false;keyword:m_all),
  312. (str:'EXCEPT' ;special:false;keyword:m_class),
  313. (str:'EXPORT' ;special:false;keyword:m_none),
  314. (str:'INLINE' ;special:false;keyword:m_none),
  315. (str:'OBJECT' ;special:false;keyword:m_all),
  316. (str:'PACKED' ;special:false;keyword:m_all),
  317. (str:'PASCAL' ;special:false;keyword:m_none),
  318. (str:'PUBLIC' ;special:false;keyword:m_none),
  319. (str:'RECORD' ;special:false;keyword:m_all),
  320. (str:'REPEAT' ;special:false;keyword:m_all),
  321. (str:'RESULT' ;special:false;keyword:m_none),
  322. (str:'STATIC' ;special:false;keyword:m_none),
  323. (str:'STORED' ;special:false;keyword:m_none),
  324. (str:'STRING' ;special:false;keyword:m_all),
  325. (str:'SYSTEM' ;special:false;keyword:m_none),
  326. (str:'ASMNAME' ;special:false;keyword:m_none),
  327. (str:'DEFAULT' ;special:false;keyword:m_none),
  328. (str:'DISPOSE' ;special:false;keyword:m_all),
  329. (str:'DYNAMIC' ;special:false;keyword:m_none),
  330. (str:'EXPORTS' ;special:false;keyword:m_all),
  331. (str:'FINALLY' ;special:false;keyword:m_class),
  332. (str:'FORWARD' ;special:false;keyword:m_none),
  333. (str:'IOCHECK' ;special:false;keyword:m_none),
  334. (str:'LIBRARY' ;special:false;keyword:m_all),
  335. (str:'MESSAGE' ;special:false;keyword:m_none),
  336. (str:'PRIVATE' ;special:false;keyword:m_none),
  337. (str:'PROGRAM' ;special:false;keyword:m_all),
  338. (str:'STDCALL' ;special:false;keyword:m_none),
  339. (str:'SYSCALL' ;special:false;keyword:m_none),
  340. (str:'VIRTUAL' ;special:false;keyword:m_none),
  341. (str:'ABSOLUTE' ;special:false;keyword:m_none),
  342. (str:'ABSTRACT' ;special:false;keyword:m_none),
  343. (str:'CONTINUE' ;special:false;keyword:m_none),
  344. (str:'EXTERNAL' ;special:false;keyword:m_none),
  345. (str:'FUNCTION' ;special:false;keyword:m_all),
  346. (str:'OPERATOR' ;special:false;keyword:m_fpc),
  347. (str:'OVERRIDE' ;special:false;keyword:m_none),
  348. (str:'POPSTACK' ;special:false;keyword:m_none),
  349. (str:'PROPERTY' ;special:false;keyword:m_class),
  350. (str:'REGISTER' ;special:false;keyword:m_none),
  351. (str:'RESIDENT' ;special:false;keyword:m_none),
  352. (str:'SAFECALL' ;special:false;keyword:m_none),
  353. (str:'ASSEMBLER' ;special:false;keyword:m_none),
  354. (str:'INHERITED' ;special:false;keyword:m_all),
  355. (str:'INTERFACE' ;special:false;keyword:m_all),
  356. (str:'INTERRUPT' ;special:false;keyword:m_none),
  357. (str:'NODEFAULT' ;special:false;keyword:m_none),
  358. (str:'OTHERWISE' ;special:false;keyword:m_all),
  359. (str:'PROCEDURE' ;special:false;keyword:m_all),
  360. (str:'PROTECTED' ;special:false;keyword:m_none),
  361. (str:'PUBLISHED' ;special:false;keyword:m_none),
  362. (str:'THREADVAR' ;special:false;keyword:m_class),
  363. (str:'DESTRUCTOR' ;special:false;keyword:m_all),
  364. (str:'INTERNPROC' ;special:false;keyword:m_none),
  365. (str:'OPENSTRING' ;special:false;keyword:m_none),
  366. (str:'CONSTRUCTOR' ;special:false;keyword:m_all),
  367. (str:'INTERNCONST' ;special:false;keyword:m_none),
  368. (str:'SHORTSTRING' ;special:false;keyword:m_none),
  369. (str:'FINALIZATION' ;special:false;keyword:m_initfinal),
  370. (str:'SAVEREGISTERS' ;special:false;keyword:m_none),
  371. (str:'IMPLEMENTATION';special:false;keyword:m_all),
  372. (str:'INITIALIZATION';special:false;keyword:m_initfinal),
  373. (str:'RESOURCESTRING';special:false;keyword:m_class)
  374. );
  375. implementation
  376. end.
  377. {
  378. $Log$
  379. Revision 1.10 1999-08-03 22:03:39 peter
  380. * moved bitmask constants to sets
  381. * some other type/const renamings
  382. Revision 1.9 1999/07/22 09:38:01 florian
  383. + resourcestring implemented
  384. + start of longstring support
  385. Revision 1.8 1999/07/10 10:26:21 peter
  386. * merged
  387. Revision 1.7.2.1 1999/07/10 10:03:18 peter
  388. * fixed initialization/finalization in fpc mode
  389. * allow $TARGET also in search paths
  390. Revision 1.7 1999/05/24 08:55:30 florian
  391. * non working safecall directiv implemented, I don't know if we
  392. need it
  393. Revision 1.6 1999/04/28 06:02:19 florian
  394. * changes of Bruessel:
  395. + message handler can now take an explicit self
  396. * typinfo fixed: sometimes the type names weren't written
  397. * the type checking for pointer comparisations and subtraction
  398. and are now more strict (was also buggy)
  399. * small bug fix to link.pas to support compiling on another
  400. drive
  401. * probable bug in popt386 fixed: call/jmp => push/jmp
  402. transformation didn't count correctly the jmp references
  403. + threadvar support
  404. * warning if ln/sqrt gets an invalid constant argument
  405. Revision 1.5 1999/04/06 11:22:01 peter
  406. * more use of ttoken
  407. Revision 1.4 1999/04/01 22:07:53 peter
  408. * universal string names (ansistr instead of stransi) for val/str
  409. Revision 1.3 1999/02/22 20:13:41 florian
  410. + first implementation of message keyword
  411. Revision 1.2 1999/02/05 12:51:21 florian
  412. + openstring id is now supported
  413. Revision 1.1 1998/12/11 00:04:02 peter
  414. + globtype,tokens,version unit splitted from globals
  415. }