stage1_2/iec.flex
changeset 76 ec7799ec929b
parent 75 0e381bdb8888
child 80 d79c950fb9c3
equal deleted inserted replaced
75:0e381bdb8888 76:ec7799ec929b
   767 			  yy_pop_state();
   767 			  yy_pop_state();
   768 			  /* now process the new file... */
   768 			  /* now process the new file... */
   769 			}
   769 			}
   770 
   770 
   771 
   771 
   772 <<EOF>>			{
   772 <<EOF>>			{     /* NOTE: We must not change the value of include_stack_ptr
   773 			  if (--include_stack_ptr < 0) {
   773 			       *       just yet. We must only decrement it if we are NOT
       
   774 			       *       at the end of the main file.
       
   775 			       *       If we have finished parsing the main file, then we
       
   776 			       *       must leave include_stack_ptr at 0, in case the 
       
   777 			       *       parser is called once again with a new file.
       
   778 			       *       (In fact, we currently do just that!)
       
   779 			       */
       
   780 			  if (include_stack_ptr == 0) {
   774 			      /* yyterminate() terminates the scanner and returns a 0 to the 
   781 			      /* yyterminate() terminates the scanner and returns a 0 to the 
   775 			       * scanner's  caller, indicating "all done".
   782 			       * scanner's  caller, indicating "all done".
   776 			       *	
   783 			       *	
   777 			       * Our syntax parser (written with bison) has the token	
   784 			       * Our syntax parser (written with bison) has the token	
   778 			       * END_OF_INPUT associated to the value 0, so even though
   785 			       * END_OF_INPUT associated to the value 0, so even though
   780 			       * calling yyterminate() is equivalent to doing that. 
   787 			       * calling yyterminate() is equivalent to doing that. 
   781 			       */ 	
   788 			       */ 	
   782 			    yyterminate();
   789 			    yyterminate();
   783 			  }      
   790 			  }      
   784  else {
   791  else {
       
   792 			    --include_stack_ptr;	
   785 			    yy_delete_buffer(YY_CURRENT_BUFFER);
   793 			    yy_delete_buffer(YY_CURRENT_BUFFER);
   786 			    yy_switch_to_buffer((include_stack[include_stack_ptr]).buffer_state);
   794 			    yy_switch_to_buffer((include_stack[include_stack_ptr]).buffer_state);
   787 			    yylineno = include_stack[include_stack_ptr].lineno;
   795 			    yylineno = include_stack[include_stack_ptr].lineno;
   788 			      /* removing constness of char *. This is safe actually,
   796 			      /* removing constness of char *. This is safe actually,
   789 			       * since the only real const char * that is stored on the stack is
   797 			       * since the only real const char * that is stored on the stack is