Missing value-handling
[pspp-builds.git] / src / lex-def.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
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.
9
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.
14
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
18    02110-1301, USA. */
19
20 #if !lex_def_h
21 #define lex_def_h 1
22
23 #include <ctype.h>
24 #include <stdbool.h>
25 #include <sys/types.h>
26
27 /* Returns nonzero if character CH may be the first character in an
28    identifier. */
29 #define CHAR_IS_ID1(CH)                         \
30         (isalpha ((unsigned char) (CH))         \
31          || (CH) == '@'                         \
32          || (CH) == '#'                         \
33          || (CH) == '$')
34
35 /* Returns nonzero if character CH may be a character in an
36    identifier other than the first. */
37 #define CHAR_IS_IDN(CH)                         \
38         (CHAR_IS_ID1 (CH)                       \
39          || isdigit ((unsigned char) (CH))      \
40          || (CH) == '.'                         \
41          || (CH) == '_')
42
43 /* Token types. */
44 /* The order of the enumerals below is important.  Do not change it. */
45 enum
46   {
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. */
52
53     T_AND,      /* AND */
54     T_OR,       /* OR */
55     T_NOT,      /* NOT */
56
57     T_EQ,       /* EQ */
58     T_GE,       /* GE or >= */
59     T_GT,       /* GT or > */
60     T_LE,       /* LE or <= */
61     T_LT,       /* LT or < */
62     T_NE,       /* NE or ~= */
63
64     T_ALL,      /* ALL */
65     T_BY,       /* BY */
66     T_TO,       /* TO */
67     T_WITH,     /* WITH */
68
69     T_EXP,      /* ** */
70
71     T_FIRST_KEYWORD = T_AND,
72     T_LAST_KEYWORD = T_WITH,
73     T_N_KEYWORDS = T_LAST_KEYWORD - T_FIRST_KEYWORD + 1
74   };
75
76
77 /* Comparing identifiers. */
78 int lex_id_match_len (const char *keyword_string, size_t keyword_len,
79                       const char *token_string, size_t token_len);
80 int lex_id_match (const char *keyword_string, const char *token_string);
81 int lex_id_to_token (const char *id, size_t len);
82
83 #endif /* !lex_def_h */