/[pspp]/pspp/src/lexer.c
ViewVC logotype

Diff of /pspp/src/lexer.c

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

revision 1.13 by blp, Mon Mar 7 03:04:50 2005 UTC revision 1.14 by blp, Sat Mar 12 01:08:33 2005 UTC
# Line 81  static struct string put_tokstr; Line 81  static struct string put_tokstr;
81  static double put_tokval;  static double put_tokval;
82    
83  static void unexpected_eof (void);  static void unexpected_eof (void);
 static inline int check_id (const char *id, size_t len);  
84  static void convert_numeric_string_to_char_string (int type);  static void convert_numeric_string_to_char_string (int type);
85  static int parse_string (int type);  static int parse_string (int type);
86    
# Line 363  lex_get (void) Line 362  lex_get (void)
362            strncpy (tokid, ds_c_str (&tokstr), 8);            strncpy (tokid, ds_c_str (&tokstr), 8);
363            tokid[8] = 0;            tokid[8] = 0;
364    
365            token = check_id (ds_c_str (&tokstr), ds_length (&tokstr));            token = lex_id_to_token (ds_c_str (&tokstr), ds_length (&tokstr));
366            break;            break;
367    
368          default:          default:
# Line 636  lex_id_match (const char *kw, const char Line 635  lex_id_match (const char *kw, const char
635  {  {
636    return lex_id_match_len (kw, strlen (kw), tok, strlen (tok));    return lex_id_match_len (kw, strlen (kw), tok, strlen (tok));
637  }  }
638    
639    /* Returns the proper token type, either T_ID or a reserved keyword
640       enum, for ID[], which must contain LEN characters. */
641    int
642    lex_id_to_token (const char *id, size_t len)
643    {
644      const char **kwp;
645    
646      if (len < 2 || len > 4)
647        return T_ID;
648      
649      for (kwp = keywords; *kwp; kwp++)
650        if (!strcasecmp (*kwp, id))
651          return T_FIRST_KEYWORD + (kwp - keywords);
652    
653      return T_ID;
654    }
655    
656  /* Weird token functions. */  /* Weird token functions. */
657    
# Line 1002  unexpected_eof (void) Line 1018  unexpected_eof (void)
1018    msg (FE, _("Unexpected end of file."));    msg (FE, _("Unexpected end of file."));
1019  }  }
1020    
 /* Returns the proper token type, either T_ID or a reserved keyword  
    enum, for ID[], which must contain LEN characters. */  
 static inline int  
 check_id (const char *id, size_t len)  
 {  
   const char **kwp;  
   
   if (len < 2 || len > 4)  
     return T_ID;  
     
   for (kwp = keywords; *kwp; kwp++)  
     if (!strcmp (*kwp, id))  
       return T_FIRST_KEYWORD + (kwp - keywords);  
   
   return T_ID;  
 }  
   
1021  /* When invoked, tokstr contains a string of binary, octal, or hex  /* When invoked, tokstr contains a string of binary, octal, or hex
1022     digits, for values of TYPE of 0, 1, or 2, respectively.  The string     digits, for values of TYPE of 0, 1, or 2, respectively.  The string
1023     is converted to characters having the specified values. */     is converted to characters having the specified values. */

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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