/[m4]/m4/m4/input.c
ViewVC logotype

Diff of /m4/m4/input.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by gary, Thu Sep 20 03:48:05 2001 UTC revision 1.12 by gary, Sun Sep 30 14:43:38 2001 UTC
# Line 142  static int   file_peek                 (void); Line 142  static int   file_peek                 (void);
142  static  int   file_read                 (void);  static  int   file_read                 (void);
143  static  void  file_unget                (int ch);  static  void  file_unget                (int ch);
144  static  void  file_clean                (void);  static  void  file_clean                (void);
145  static  void  init_macro_token          (m4_symbol *symbol);  static  void  init_macro_token          (m4_token_data *td);
146  static  int   macro_peek                (void);  static  int   macro_peek                (void);
147  static  int   macro_read                (void);  static  int   macro_read                (void);
148  static  int   match_input               (const unsigned char *s);  static  int   match_input               (const unsigned char *s);
# Line 594  m4_pop_wrapup (void) Line 594  m4_pop_wrapup (void)
594  /* When a MACRO token is seen, next_token () uses init_macro_token  /* When a MACRO token is seen, next_token () uses init_macro_token
595     to retrieve the value of the function pointer.  */     to retrieve the value of the function pointer.  */
596  static void  static void
597  init_macro_token (m4_symbol *symbol)  init_macro_token (m4_token_data *td)
598  {  {
599    if (isp->funcs->read_func != macro_read)    if (isp->funcs->read_func != macro_read)
600      {      {
# Line 603  init_macro_token (m4_symbol *symbol) Line 603  init_macro_token (m4_symbol *symbol)
603        abort ();        abort ();
604      }      }
605    
606    M4_SYMBOL_TYPE (symbol)   = M4_TOKEN_FUNC;    M4_TOKEN_DATA_TYPE (td) = M4_TOKEN_FUNC;
607    M4_SYMBOL_FUNC (symbol)   = isp->u.u_m.func;    M4_TOKEN_DATA_FUNC (td) = isp->u.u_m.func;
608    M4_SYMBOL_HANDLE (symbol) = isp->u.u_m.handle;    M4_TOKEN_DATA_HANDLE (td) = isp->u.u_m.handle;
609    M4_SYMBOL_TRACED (symbol) = isp->u.u_m.traced;    M4_TOKEN_TRACED (td) = isp->u.u_m.traced;
610  }  }
611    
612    
# Line 794  m4_input_init (void) Line 794  m4_input_init (void)
794  }  }
795    
796  void  void
 m4_input_exit (void)  
 {  
   XFREE (lquote.string);  
   XFREE (rquote.string);  
   XFREE (bcomm.string);  
   XFREE (ecomm.string);  
   obstack_free (&wrapup_stack, NULL);  
   obstack_free (&input_stack, NULL);  
   obstack_free (&token_stack, NULL);  
 }  
   
 void  
797  m4_syntax_init (void)  m4_syntax_init (void)
798  {  {
799    int ch;    int ch;
# Line 1009  m4_set_syntax (char key, const unsigned Line 997  m4_set_syntax (char key, const unsigned
997     The storage pointed to by the fields in TD is therefore subject to     The storage pointed to by the fields in TD is therefore subject to
998     change the next time next_token () is called.         */     change the next time next_token () is called.         */
999  m4_token_t  m4_token_t
1000  m4_next_token (m4_symbol *symbol)  m4_next_token (m4_token_data *td)
1001  {  {
1002    int ch;    int ch;
1003    int quote_level;    int quote_level;
# Line 1031  m4_next_token (m4_symbol *symbol) Line 1019  m4_next_token (m4_symbol *symbol)
1019    
1020      if (ch == CHAR_MACRO)               /* MACRO TOKEN */      if (ch == CHAR_MACRO)               /* MACRO TOKEN */
1021        {        {
1022          init_macro_token (symbol);          init_macro_token (td);
1023          (void) next_char ();          (void) next_char ();
1024  #ifdef DEBUG_INPUT  #ifdef DEBUG_INPUT
1025          print_token("next_token", M4_TOKEN_MACDEF, symbol);          print_token("next_token", M4_TOKEN_MACDEF, td);
1026  #endif  #endif
1027          return M4_TOKEN_MACDEF;          return M4_TOKEN_MACDEF;
1028        }        }
# Line 1200  m4_next_token (m4_symbol *symbol) Line 1188  m4_next_token (m4_symbol *symbol)
1188    
1189    obstack_1grow (&token_stack, '\0');    obstack_1grow (&token_stack, '\0');
1190    
1191    M4_SYMBOL_TYPE (symbol) = M4_TOKEN_TEXT;    M4_TOKEN_DATA_TYPE (td) = M4_TOKEN_TEXT;
1192    M4_SYMBOL_TEXT (symbol) = obstack_finish (&token_stack);    M4_TOKEN_DATA_TEXT (td) = obstack_finish (&token_stack);
1193    
1194  #ifdef DEBUG_INPUT  #ifdef DEBUG_INPUT
1195    print_token("next_token", type, td);    print_token("next_token", type, td);
# Line 1216  m4_next_token (m4_symbol *symbol) Line 1204  m4_next_token (m4_symbol *symbol)
1204  static  void  lex_debug (void);  static  void  lex_debug (void);
1205    
1206  int  int
1207  m4_print_token (const char *s, m4_token_t t, m4_symbol *symbol)  m4_print_token (const char *s, m4_token_t t, m4_token_data *td)
1208  {  {
1209    fprintf (stderr, "%s: ", s);    fprintf (stderr, "%s: ", s);
1210    switch (t)    switch (t)
1211      {                           /* TOKSW */      {                           /* TOKSW */
1212      case M4_TOKEN_SIMPLE:      case M4_TOKEN_SIMPLE:
1213        fprintf (stderr, "char\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));        fprintf (stderr, "char\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
1214        break;        break;
1215    
1216      case M4_TOKEN_WORD:      case M4_TOKEN_WORD:
1217        fprintf (stderr, "word\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));        fprintf (stderr, "word\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
1218        break;        break;
1219    
1220      case M4_TOKEN_STRING:      case M4_TOKEN_STRING:
1221        fprintf (stderr, "string\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));        fprintf (stderr, "string\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
1222        break;        break;
1223    
1224      case M4_TOKEN_SPACE:      case M4_TOKEN_SPACE:
1225        fprintf (stderr, "space\t\"%s\"\n", M4_SYMBOL_TEXT (symbol));        fprintf (stderr, "space\t\"%s\"\n", M4_TOKEN_DATA_TEXT (td));
1226        break;        break;
1227    
1228      case M4_TOKEN_MACDEF:      case M4_TOKEN_MACDEF:
1229        fprintf (stderr, "macro 0x%x\n", (int)M4_SYMBOL_FUNC (symbol));        fprintf (stderr, "macro 0x%x\n", (int)M4_TOKEN_DATA_FUNC (td));
1230        break;        break;
1231    
1232      case M4_TOKEN_EOF:      case M4_TOKEN_EOF:
# Line 1256  static void Line 1244  static void
1244  lex_debug (void)  lex_debug (void)
1245  {  {
1246    m4_token_t t;    m4_token_t t;
1247    m4_symbol symbol;    m4_token_data td;
1248    
1249    while ((t = next_token (&symbol)) != NULL)    while ((t = next_token (&td)) != NULL)
1250      print_token ("lex", t, &symbol);      print_token ("lex", t, &td);
1251  }  }
1252  #endif  #endif

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26