home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 5.ddi / PARSER.ZIP / DEFINE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-25  |  1.7 KB  |  70 lines

  1. /*****************************************************
  2. File: DEFINE.CPP     Copyright 1989 by John M. Dlugosz
  3.    deal with definitions once they are parsed
  4. *****************************************************/
  5.  
  6. #include "usual.hpp"
  7. #include <stream.hpp>
  8. #include "atom.hpp"
  9. #include "node.hpp"
  10. #include "define.hpp"
  11.  
  12. bool local_level= FALSE;
  13.  
  14. def_node_list global_stuff;
  15. struct p_list_struct {
  16.    def_node_list* l;
  17.    p_list_struct* next;
  18.    };
  19. static p_list_struct *p_list;
  20. def_node_list* completed_def_list;
  21.  
  22. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  23.  
  24. void store_thing (type_node* t, atom name, int storage_class, int param)
  25. {
  26. /* 'param' is passed through from the grammar.  If 1, this is a declaration
  27.    for a local or global object.  If 2, this is part of a parameter list */
  28. def_node* n= new def_node (name, storage_class, t);
  29.  
  30. // file it away somewhere
  31. switch (param) {
  32.    case 1:
  33.       if (name == -1) {
  34.          // >> I need to get a standard error reporter
  35.          cout << "abstract declarator ignored\n";
  36.          }
  37.       global_stuff.add (n);
  38.       break;
  39.    case 2:
  40.       // >> check it over
  41.       p_list->l->add(n);
  42.       break;
  43.    }
  44. }
  45.  
  46. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  47.  
  48. void parameter_list (int x)
  49. {
  50. p_list_struct* p;
  51. if (x) {
  52.    p= new p_list_struct;
  53.    p->next= p_list;
  54.    p->l= new def_node_list;
  55.    p_list= p;
  56.    }
  57. else {
  58.    p= p_list;
  59.    p_list= p_list->next;
  60.    completed_def_list= p->l;
  61.    delete p;
  62.    }
  63. }
  64.  
  65. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  66. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  67. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  68. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  69. /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
  70.