1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 /* Returns nonzero if character CH may be the first character in an
29 #define CHAR_IS_ID1(CH) \
30 (isalpha ((unsigned char) (CH)) \
35 /* Returns nonzero if character CH may be a character in an
36 identifier other than the first. */
37 #define CHAR_IS_IDN(CH) \
39 || isdigit ((unsigned char) (CH)) \
44 /* The order of the enumerals below is important. Do not change it. */
47 T_ID = 256, /* Identifier. */
48 T_POS_NUM, /* Positive number. */
49 T_NEG_NUM, /* Negative number. */
50 T_STRING, /* Quoted string. */
51 T_STOP, /* End of input. */
71 T_FIRST_KEYWORD = T_AND,
72 T_LAST_KEYWORD = T_WITH,
73 T_N_KEYWORDS = T_LAST_KEYWORD - T_FIRST_KEYWORD + 1
78 extern char tokid[LONG_NAME_LEN + 1];
79 extern struct string tokstr;
87 /* Common functions. */
89 void lex_error (const char *, ...);
90 int lex_end_of_command (void);
92 /* Token testing functions. */
93 bool lex_is_number (void);
94 double lex_number (void);
95 bool lex_is_integer (void);
96 long lex_integer (void);
98 /* Token matching functions. */
100 int lex_match_id (const char *);
101 int lex_match_int (int);
103 /* Forcible matching functions. */
104 int lex_force_match (int);
105 int lex_force_match_id (const char *);
106 int lex_force_int (void);
107 int lex_force_num (void);
108 int lex_force_id (void);
109 int lex_force_string (void);
111 /* Comparing identifiers. */
112 int lex_id_match_len (const char *keyword_string, size_t keyword_len,
113 const char *token_string, size_t token_len);
114 int lex_id_match (const char *keyword_string, const char *token_string);
115 int lex_id_to_token (const char *id, size_t len);
117 /* Weird token functions. */
118 int lex_look_ahead (void);
119 void lex_put_back (int);
120 void lex_put_back_id (const char *tokid);
122 /* Weird line processing functions. */
123 const char *lex_entire_line (void);
124 const char *lex_rest_of_line (int *end_dot);
125 void lex_discard_line (void);
126 void lex_set_prog (char *p);
128 /* Weird line reading functions. */
129 int lex_get_line (void);
130 void lex_preprocess_line (void);
133 const char *lex_token_name (int);
134 char *lex_token_representation (void);
136 /* Really weird functions. */
137 void lex_negative_to_dash (void);
138 void lex_reset_eof (void);
139 void lex_skip_comment (void);
141 #endif /* !lexer_h */