pexports.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Florian Klaempfl
  4. This unit handles the exports parsing
  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 pexports;
  19. interface
  20. { reads an exports statement in a library }
  21. procedure read_exports;
  22. implementation
  23. uses
  24. cobjects,globals,scanner,symtable,pbase,verbose;
  25. const
  26. { export options }
  27. eo_resident = $1;
  28. type
  29. pexportsitem = ^texportsitem;
  30. texportsitem = object(tlinkedlist_item)
  31. sym : psym;
  32. index : longint;
  33. name : pstring;
  34. options : word;
  35. constructor init;
  36. end;
  37. var
  38. exportslist : tlinkedlist;
  39. constructor texportsitem.init;
  40. begin
  41. sym:=nil;
  42. index:=-1;
  43. name:=nil;
  44. options:=0;
  45. end;
  46. procedure read_exports;
  47. var
  48. hp : pexportsitem;
  49. code : word;
  50. begin
  51. hp:=new(pexportsitem,init);
  52. consume(_EXPORTS);
  53. while true do
  54. begin
  55. if token=ID then
  56. begin
  57. getsym(pattern,true);
  58. if srsym^.typ=unitsym then
  59. begin
  60. consume(ID);
  61. consume(POINT);
  62. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  63. end;
  64. consume(ID);
  65. if assigned(srsym) then
  66. begin
  67. hp^.sym:=srsym;
  68. if (srsym^.typ<>procsym) or
  69. ((pprocdef(pprocsym(srsym)^.definition)^.options and poexports)=0) then
  70. Message(parser_e_illegal_symbol_exported);
  71. if (idtoken=_INDEX) then
  72. begin
  73. consume(_INDEX);
  74. val(pattern,hp^.index,code);
  75. consume(INTCONST);
  76. end;
  77. if (idtoken=_NAME) then
  78. begin
  79. consume(_NAME);
  80. hp^.name:=stringdup(pattern);
  81. consume(ID);
  82. end;
  83. if (idtoken=_RESIDENT) then
  84. begin
  85. consume(_RESIDENT);
  86. hp^.options:=hp^.options or eo_resident;
  87. end;
  88. end;
  89. end
  90. else
  91. consume(ID);
  92. if token=COMMA then
  93. consume(COMMA)
  94. else
  95. break;
  96. end;
  97. consume(SEMICOLON);
  98. end;
  99. begin
  100. { a library is a root of sources, e.g. it can't be used
  101. twice in one compiler run }
  102. exportslist.init;
  103. end.
  104. {
  105. $Log$
  106. Revision 1.2 1998-09-26 17:45:35 peter
  107. + idtoken and only one token table
  108. }