parser: use CHAR_MAX to define non-ASCII token id values

The first token id is given the value 256.  This ensures it is
outside the range of any valid character.

But we don't allow non-ASCII characters on input, so we can use 128
as the first non-character token id value.  Represent this as
(CHAR_MAX + 1), to make explicit the reason this value is chosen.

Give the enumerated type representing token ids a name.

Signed-off-by: Alex Elder <elder@linaro.org>
Message-Id: <20211001232338.769309-12-elder@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Alex Elder 2021-10-01 18:23:15 -05:00 committed by Bjorn Andersson
parent b246e6d86f
commit fad43b91d2

View File

@ -3,6 +3,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@ -19,8 +20,9 @@ struct list_head qmi_consts = LIST_INIT(qmi_consts);
struct list_head qmi_messages = LIST_INIT(qmi_messages);
struct list_head qmi_structs = LIST_INIT(qmi_structs);
enum {
TOK_CONST = 256,
enum token_id {
/* Also any non-NUL (7-bit) ASCII character */
TOK_CONST = CHAR_MAX + 1,
TOK_ID,
TOK_MESSAGE,
TOK_NUM,