2 * Copyright 2013 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
12 /* Extract a mapping key from the token "tok".
13 * Return KEY_ERROR on error, i.e., if "tok" does not
14 * correspond to any known key.
16 static KEY
extract_key(__isl_keep isl_stream
*s
, struct isl_token
*tok
)
25 type
= isl_token_get_type(tok
);
26 if (type
!= ISL_TOKEN_IDENT
&& type
!= ISL_TOKEN_STRING
) {
27 isl_stream_error(s
, tok
, "expecting key");
31 ctx
= isl_stream_get_ctx(s
);
32 name
= isl_token_get_str(ctx
, tok
);
36 for (key
= 0; key
< KEY_END
; ++key
) {
37 if (!strcmp(name
, key_str
[key
]))
43 isl_die(ctx
, isl_error_invalid
, "unknown key",
48 /* Read a key from "s" and return the corresponding enum.
49 * Return KEY_ERROR on error, i.e., if the first token
50 * on the stream does not correspond to any known key.
52 static KEY
get_key(__isl_keep isl_stream
*s
)
54 struct isl_token
*tok
;
57 tok
= isl_stream_next_token(s
);
58 key
= extract_key(s
, tok
);