/*
* This is a hack, and has to be kept in sync with tokens.h
*/
-char const *fr_tokens[T_TOKEN_LAST + 1] = {
+char const *fr_tokens[T_TOKEN_LAST] = {
[T_INVALID] = "?",
[T_EOL] = "EOL",
[T_SINGLE_QUOTED_STRING] = "<'STRING'>",
[T_BACK_QUOTED_STRING] = "<`STRING`>",
[T_SOLIDUS_QUOTED_STRING] = "</STRING/>",
-
- [T_TOKEN_LAST] = "<invalid>",
};
*
* Non-string types convert to '?' to screw ups can be identified easily
*/
-const char fr_token_quote[T_TOKEN_LAST + 1] = {
+const char fr_token_quote[T_TOKEN_LAST] = {
[ 0 ... T_HASH ] = '?', /* GCC extension for range initialization, also allowed by clang */
[T_BARE_WORD] = '\0',
[T_SINGLE_QUOTED_STRING] = '\'',
[T_BACK_QUOTED_STRING] = '`',
[T_SOLIDUS_QUOTED_STRING] = '/',
-
- [T_TOKEN_LAST] = '?',
};
#define T(_x) [T_OP_ ## _x] = true
-const bool fr_assignment_op[T_TOKEN_LAST + 1] = {
+const bool fr_assignment_op[T_TOKEN_LAST] = {
T(INCRM),
T(ADD_EQ),
T(SUB_EQ),
T(PREPEND),
};
-const bool fr_equality_op[T_TOKEN_LAST + 1] = {
+const bool fr_equality_op[T_TOKEN_LAST] = {
T(NE),
T(GE),
T(GT),
#undef T
#define T(_x) [T_## _x] = true
-const bool fr_str_tok[T_TOKEN_LAST + 1] = {
+const bool fr_str_tok[T_TOKEN_LAST] = {
T(BARE_WORD),
T(DOUBLE_QUOTED_STRING),
T(SINGLE_QUOTED_STRING),
T_SINGLE_QUOTED_STRING, /* 'foo' */
T_BACK_QUOTED_STRING, /* `foo` */
T_SOLIDUS_QUOTED_STRING, /* /foo/ */
- T_TOKEN_LAST
} fr_token_t;
+/*
+ * This must be manually updated, and is never part of the ENUM.
+ */
+#define T_TOKEN_LAST (T_SOLIDUS_QUOTED_STRING + 1)
#define T_EQSTART T_OP_ADD_EQ
#define T_EQEND (T_HASH)
extern size_t fr_tokens_table_len;
extern fr_table_num_sorted_t const fr_token_quotes_table[];
extern size_t fr_token_quotes_table_len;
-extern const char *fr_tokens[T_TOKEN_LAST + 1];
-extern const char fr_token_quote[T_TOKEN_LAST + 1];
-extern const bool fr_assignment_op[T_TOKEN_LAST + 1];
-extern const bool fr_equality_op[T_TOKEN_LAST + 1];
-extern const bool fr_str_tok[T_TOKEN_LAST + 1];
+extern const char *fr_tokens[T_TOKEN_LAST];
+extern const char fr_token_quote[T_TOKEN_LAST];
+extern const bool fr_assignment_op[T_TOKEN_LAST];
+extern const bool fr_equality_op[T_TOKEN_LAST];
+extern const bool fr_str_tok[T_TOKEN_LAST];
int getword (char const **ptr, char *buf, int buflen, bool unescape);
fr_token_t gettoken(char const **ptr, char *buf, int buflen, bool unescape);