52 keyword = entry->
data;
59 keyword->
type = s->next_type++;
65 entry->
data = keyword;
121 "token does not have a string representation",
124 return strdup(tok->
u.
s);
146 int col = tok ? tok->
col :
s->col;
153 fprintf(stderr,
"syntax error (%d, %d): %s\n",
line,
col, msg);
156 fprintf(stderr,
"got '%c'\n", tok->
type);
158 fprintf(stderr,
"got ident '%s'\n", tok->
u.
s);
160 fprintf(stderr,
"got keyword '%s'\n", tok->
u.
s);
162 fprintf(stderr,
"got value '");
164 fprintf(stderr,
"'\n");
167 fprintf(stderr,
"got map '");
171 fprintf(stderr,
"'\n");
174 fprintf(stderr,
"got affine expression '");
178 fprintf(stderr,
"'\n");
180 fprintf(stderr,
"got token '%s'\n", tok->
u.
s);
182 fprintf(stderr,
"got token type %d\n", tok->
type);
205 for (i = 0; i < 5; ++i)
249 return s->c =
s->un[--
s->n_un];
259 else if (c ==
'\n') {
271 s->un[
s->n_un++] = c;
284 s->start_line =
s->line;
285 s->start_col =
s->col;
299 if (
s->len >=
s->size) {
301 s->size = (3*
s->size)/2;
307 s->buffer[
s->len++] = c;
314 s->tokens[
s->n_token++] = tok;
323 if (!strcasecmp(s->buffer,
"exists"))
325 if (!strcasecmp(s->buffer,
"and"))
327 if (!strcasecmp(s->buffer,
"or"))
329 if (!strcasecmp(s->buffer,
"implies"))
331 if (!strcasecmp(s->buffer,
"not"))
333 if (!strcasecmp(s->buffer,
"infty"))
335 if (!strcasecmp(s->buffer,
"infinity"))
337 if (!strcasecmp(s->buffer,
"NaN"))
339 if (!strcasecmp(s->buffer,
"min"))
341 if (!strcasecmp(s->buffer,
"max"))
343 if (!strcasecmp(s->buffer,
"rat"))
345 if (!strcasecmp(s->buffer,
"true"))
347 if (!strcasecmp(s->buffer,
"false"))
349 if (!strcasecmp(s->buffer,
"ceild"))
351 if (!strcasecmp(s->buffer,
"floord"))
353 if (!strcasecmp(s->buffer,
"mod"))
355 if (!strcasecmp(s->buffer,
"ceil"))
357 if (!strcasecmp(s->buffer,
"floor"))
369 keyword = entry->
data;
370 return keyword->
type;
384 return c == -1 ? -1 : 0;
392 int old_line =
s->last_line;
395 if (same_line &&
s->tokens[
s->n_token - 1]->on_new_line)
397 return s->tokens[--
s->n_token];
400 if (same_line &&
s->c ==
'\n')
413 }
else if (!isspace(c) || (same_line && c ==
'\n'))
417 line =
s->start_line;
420 if (c == -1 || (same_line && c ==
'\n'))
452 tok->
u.
s = strdup(
"->");
465 int minus = c ==
'-';
491 if (isalpha(c) || c ==
'_') {
497 (isalnum(c) || c ==
'_'))
509 tok->
u.
s = strdup(
s->buffer);
527 tok->
u.
s = strdup(
s->buffer);
536 tok->
u.
s = strdup(
"==");
551 tok->
u.
s = strdup(
":=");
566 tok->
u.
s = strdup(
">=");
569 }
else if (c ==
'>') {
571 tok->
u.
s = strdup(
">>=");
575 tok->
u.
s = strdup(
">>");
578 tok->
u.
s = strdup(
">");
591 tok->
u.
s = strdup(
"<=");
594 }
else if (c ==
'<') {
596 tok->
u.
s = strdup(
"<<=");
600 tok->
u.
s = strdup(
"<<");
603 tok->
u.
s = strdup(
"<");
616 tok->
u.
s = strdup(
"&");
619 tok->
u.
s = strdup(
"&&");
628 tok->
u.
s = strdup(
"|");
631 tok->
u.
s = strdup(
"||");
639 tok->
u.
s = strdup(
"/\\");
642 }
else if (c ==
'/') {
643 tok->
u.
s = strdup(
"//");
661 tok->
u.
s = strdup(
"\\/");
671 tok->
u.
s = strdup(
"!=");
676 tok->
u.
s = strdup(
"!");
739 char *ident = strdup(tok->
u.
s);
795 for (i = 0; i < s->n_token; ++i)
802 return s ? s->ctx : NULL;
810 if (s->n_token != 0) {
820 free(
s->yaml_indent);
831 if (
s->yaml_size <
s->yaml_depth + 1) {
839 s->yaml_state = state;
842 int,
s->yaml_depth + 1);
845 s->yaml_indent = indent;
847 s->yaml_size =
s->yaml_depth + 1;
850 s->yaml_state[
s->yaml_depth] = state;
863 if (
s->yaml_depth < 1)
879 if (
s->yaml_depth < 1)
881 "not in YAML construct",
return -1);
883 s->yaml_state[
s->yaml_depth - 1] = state;
895 if (
s->yaml_depth < 1)
897 return s->yaml_state[
s->yaml_depth - 1];
906 if (
s->yaml_depth < 1)
910 s->yaml_indent[
s->yaml_depth - 1] = indent;
920 if (
s->yaml_depth < 1)
922 "not in YAML element",
return -1);
924 return s->yaml_indent[
s->yaml_depth - 1];
991 if (tok->
type ==
':') {
1011 indent = tok->
col - 1;
1032 if (tok->
type ==
'-') {
1047 indent = tok->
col - 1;
1088 indent = tok->
col - 1;
1117 indent = tok->
col - 1;
1157 indent = tok->
col - 1;
1188 indent = tok->
col - 1;
1189 dash = tok->
type ==
'-';
__isl_null isl_pw_aff * isl_pw_aff_free(__isl_take isl_pw_aff *pwaff)
__isl_give isl_printer * isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff)
#define isl_calloc_type(ctx, type)
#define isl_die(ctx, errno, msg, code)
void isl_ctx_deref(struct isl_ctx *ctx)
#define isl_assert(ctx, test, code)
isl_bool isl_bool_ok(int b)
#define isl_alloc_array(ctx, type, n)
#define isl_alloc_type(ctx, type)
#define isl_realloc_array(ctx, ptr, type, n)
void isl_ctx_ref(struct isl_ctx *ctx)
struct isl_hash_table_entry * isl_hash_table_entry_none
uint32_t isl_hash_string(uint32_t hash, const char *s)
void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table)
isl_stat isl_hash_table_foreach(isl_ctx *ctx, struct isl_hash_table *table, isl_stat(*fn)(void **entry, void *user), void *user)
struct isl_hash_table_entry * isl_hash_table_find(struct isl_ctx *ctx, struct isl_hash_table *table, uint32_t key_hash, isl_bool(*eq)(const void *entry, const void *val), const void *val, int reserve)
struct isl_hash_table * isl_hash_table_alloc(struct isl_ctx *ctx, int min_size)
__isl_export __isl_give ISL_HMAP __isl_take ISL_KEY __isl_take ISL_VAL * val
isl_stat isl_stat(*) void user)
void isl_ctx_set_full_error(isl_ctx *ctx, enum isl_error error, const char *msg, const char *file, int line)
#define isl_int_is_zero(i)
#define isl_int_print(out, i, width)
#define isl_int_read(r, s)
static isl_stat free_keyword(void **p, void *user)
static int isl_stream_getc(__isl_keep isl_stream *s)
void isl_stream_error(__isl_keep isl_stream *s, struct isl_token *tok, char *msg)
isl_stat isl_stream_yaml_read_start_sequence(__isl_keep isl_stream *s)
void isl_token_free(struct isl_token *tok)
__isl_give isl_stream * isl_stream_new_str(struct isl_ctx *ctx, const char *str)
int isl_stream_skip_line(__isl_keep isl_stream *s)
isl_bool isl_stream_yaml_next(__isl_keep isl_stream *s)
static int stream_getc(__isl_keep isl_stream *s)
static struct isl_token * next_token(__isl_keep isl_stream *s, int same_line)
static void isl_stream_ungetc(__isl_keep isl_stream *s, int c)
static int isl_stream_push_char(__isl_keep isl_stream *s, int c)
static isl_stat set_yaml_indent(__isl_keep isl_stream *s, int indent)
char * isl_stream_read_ident_if_available(__isl_keep isl_stream *s)
void isl_stream_push_token(__isl_keep isl_stream *s, struct isl_token *tok)
static enum isl_token_type check_keywords(__isl_keep isl_stream *s)
int isl_stream_is_empty(__isl_keep isl_stream *s)
enum isl_token_type isl_stream_register_keyword(__isl_keep isl_stream *s, const char *name)
static int update_state(__isl_keep isl_stream *s, enum isl_yaml_state state)
void isl_stream_flush_tokens(__isl_keep isl_stream *s)
__isl_give isl_stream * isl_stream_new_file(struct isl_ctx *ctx, FILE *file)
isl_ctx * isl_stream_get_ctx(__isl_keep isl_stream *s)
isl_stat isl_stream_yaml_read_start_mapping(__isl_keep isl_stream *s)
int isl_stream_eat(__isl_keep isl_stream *s, int type)
struct isl_token * isl_stream_next_token(__isl_keep isl_stream *s)
isl_stat isl_stream_yaml_read_end_mapping(__isl_keep isl_stream *s)
struct isl_token * isl_stream_next_token_on_same_line(__isl_keep isl_stream *s)
static enum isl_yaml_state current_state(__isl_keep isl_stream *s)
static isl_stat pop_state(__isl_keep isl_stream *s)
int isl_stream_next_token_is(__isl_keep isl_stream *s, int type)
__isl_give char * isl_token_get_str(isl_ctx *ctx, struct isl_token *tok)
void isl_stream_free(__isl_take isl_stream *s)
static int get_yaml_indent(__isl_keep isl_stream *s)
isl_stat isl_stream_yaml_read_end_sequence(__isl_keep isl_stream *s)
__isl_give isl_val * isl_token_get_val(isl_ctx *ctx, struct isl_token *tok)
isl_bool isl_token_has_str(struct isl_token *tok)
static __isl_give isl_stream * isl_stream_new(struct isl_ctx *ctx)
struct isl_token * isl_token_new(isl_ctx *ctx, int line, int col, unsigned on_new_line)
int isl_token_get_type(struct isl_token *tok)
static isl_bool same_name(const void *entry, const void *val)
static int push_state(__isl_keep isl_stream *s, enum isl_yaml_state state)
int isl_stream_eat_if_available(__isl_keep isl_stream *s, int type)
__isl_give isl_val * isl_val_int_from_isl_int(isl_ctx *ctx, isl_int n)
#define ISL_YAML_INDENT_FLOW
@ isl_yaml_sequence_start
@ isl_yaml_mapping_key_start
__isl_give isl_printer * isl_printer_print_map(__isl_take isl_printer *printer, __isl_keep isl_map *map)
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
#define ISL_ON_ERROR_ABORT
#define ISL_ON_ERROR_CONTINUE
__isl_null isl_printer * isl_printer_free(__isl_take isl_printer *printer)
__isl_give isl_printer * isl_printer_to_file(isl_ctx *ctx, FILE *file)