Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_stream.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2008-2009 Katholieke Universiteit Leuven
3
 *
4
 * Use of this software is governed by the MIT license
5
 *
6
 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7
 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8
 */
9
10
#include <ctype.h>
11
#include <string.h>
12
#include <isl/ctx.h>
13
#include <isl_stream_private.h>
14
#include <isl/map.h>
15
#include <isl/aff.h>
16
#include <isl_val_private.h>
17
18
struct isl_keyword {
19
  char      *name;
20
  enum isl_token_type type;
21
};
22
23
static int same_name(const void *entry, const void *val)
24
0
{
25
0
  const struct isl_keyword *keyword = (const struct isl_keyword *)entry;
26
0
27
0
  return !strcmp(keyword->name, val);
28
0
}
29
30
enum isl_token_type isl_stream_register_keyword(__isl_keep isl_stream *s,
31
  const char *name)
32
0
{
33
0
  struct isl_hash_table_entry *entry;
34
0
  struct isl_keyword *keyword;
35
0
  uint32_t name_hash;
36
0
37
0
  if (
!s->keywords0
) {
38
0
    s->keywords = isl_hash_table_alloc(s->ctx, 10);
39
0
    if (!s->keywords)
40
0
      return ISL_TOKEN_ERROR;
41
0
    s->next_type = ISL_TOKEN_LAST;
42
0
  }
43
0
44
0
  
name_hash = isl_hash_string(0
isl_hash_init0
(), name);
45
0
46
0
  entry = isl_hash_table_find(s->ctx, s->keywords, name_hash,
47
0
          same_name, name, 1);
48
0
  if (!entry)
49
0
    return ISL_TOKEN_ERROR;
50
0
  
if (0
entry->data0
) {
51
0
    keyword = entry->data;
52
0
    return keyword->type;
53
0
  }
54
0
55
0
  
keyword = 0
isl_calloc_type0
(s->ctx, struct isl_keyword);
56
0
  if (!keyword)
57
0
    return ISL_TOKEN_ERROR;
58
0
  keyword->type = s->next_type++;
59
0
  keyword->name = strdup(name);
60
0
  if (
!keyword->name0
) {
61
0
    free(keyword);
62
0
    return ISL_TOKEN_ERROR;
63
0
  }
64
0
  entry->data = keyword;
65
0
66
0
  return keyword->type;
67
0
}
68
69
struct isl_token *isl_token_new(isl_ctx *ctx,
70
  int line, int col, unsigned on_new_line)
71
60.8k
{
72
60.8k
  struct isl_token *tok = isl_alloc_type(ctx, struct isl_token);
73
60.8k
  if (!tok)
74
0
    return NULL;
75
60.8k
  tok->line = line;
76
60.8k
  tok->col = col;
77
60.8k
  tok->on_new_line = on_new_line;
78
60.8k
  tok->is_keyword = 0;
79
60.8k
  tok->u.s = NULL;
80
60.8k
  return tok;
81
60.8k
}
82
83
/* Return the type of "tok".
84
 */
85
int isl_token_get_type(struct isl_token *tok)
86
0
{
87
0
  return tok ? 
tok->type0
:
ISL_TOKEN_ERROR0
;
88
0
}
89
90
/* Given a token of type ISL_TOKEN_VALUE, return the value it represents.
91
 */
92
__isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok)
93
0
{
94
0
  if (!tok)
95
0
    return NULL;
96
0
  
if (0
tok->type != ISL_TOKEN_VALUE0
)
97
0
    isl_die(ctx, isl_error_invalid, "not a value token",
98
0
      return NULL);
99
0
100
0
  return isl_val_int_from_isl_int(ctx, tok->u.v);
101
0
}
102
103
/* Given a token with a string representation, return a copy of this string.
104
 */
105
__isl_give char *isl_token_get_str(isl_ctx *ctx, struct isl_token *tok)
106
768
{
107
768
  if (!tok)
108
0
    return NULL;
109
768
  
if (768
!tok->u.s768
)
110
0
    isl_die(ctx, isl_error_invalid,
111
768
      "token does not have a string representation",
112
768
      return NULL);
113
768
114
768
  return strdup(tok->u.s);
115
768
}
116
117
void isl_token_free(struct isl_token *tok)
118
68.1k
{
119
68.1k
  if (!tok)
120
7.25k
    return;
121
60.8k
  
if (60.8k
tok->type == ISL_TOKEN_VALUE60.8k
)
122
9.97k
    isl_int_clear(tok->u.v);
123
50.9k
  else 
if (50.9k
tok->type == ISL_TOKEN_MAP50.9k
)
124
163
    isl_map_free(tok->u.map);
125
50.7k
  else 
if (50.7k
tok->type == ISL_TOKEN_AFF50.7k
)
126
179
    isl_pw_aff_free(tok->u.pwaff);
127
50.7k
  else
128
50.5k
    free(tok->u.s);
129
68.1k
  free(tok);
130
68.1k
}
131
132
void isl_stream_error(__isl_keep isl_stream *s, struct isl_token *tok,
133
  char *msg)
134
6
{
135
6
  int line = tok ? 
tok->line6
:
s->line0
;
136
6
  int col = tok ? 
tok->col6
:
s->col0
;
137
6
  fprintf(stderr, "syntax error (%d, %d): %s\n", line, col, msg);
138
6
  if (
tok6
) {
139
6
    if (tok->type < 256)
140
2
      fprintf(stderr, "got '%c'\n", tok->type);
141
4
    else 
if (4
tok->type == ISL_TOKEN_IDENT4
)
142
0
      fprintf(stderr, "got ident '%s'\n", tok->u.s);
143
4
    else 
if (4
tok->is_keyword4
)
144
0
      fprintf(stderr, "got keyword '%s'\n", tok->u.s);
145
4
    else 
if (4
tok->type == ISL_TOKEN_VALUE4
) {
146
0
      fprintf(stderr, "got value '");
147
0
      isl_int_print(stderr, tok->u.v, 0);
148
0
      fprintf(stderr, "'\n");
149
4
    } else 
if (4
tok->type == ISL_TOKEN_MAP4
) {
150
0
      isl_printer *p;
151
0
      fprintf(stderr, "got map '");
152
0
      p = isl_printer_to_file(s->ctx, stderr);
153
0
      p = isl_printer_print_map(p, tok->u.map);
154
0
      isl_printer_free(p);
155
0
      fprintf(stderr, "'\n");
156
4
    } else 
if (4
tok->type == ISL_TOKEN_AFF4
) {
157
0
      isl_printer *p;
158
0
      fprintf(stderr, "got affine expression '");
159
0
      p = isl_printer_to_file(s->ctx, stderr);
160
0
      p = isl_printer_print_pw_aff(p, tok->u.pwaff);
161
0
      isl_printer_free(p);
162
0
      fprintf(stderr, "'\n");
163
4
    } else 
if (4
tok->u.s4
)
164
4
      fprintf(stderr, "got token '%s'\n", tok->u.s);
165
4
    else
166
0
      fprintf(stderr, "got token type %d\n", tok->type);
167
6
  }
168
6
}
169
170
static __isl_give isl_stream* isl_stream_new(struct isl_ctx *ctx)
171
2.86k
{
172
2.86k
  int i;
173
2.86k
  isl_stream *s = isl_calloc_type(ctx, struct isl_stream);
174
2.86k
  if (!s)
175
0
    return NULL;
176
2.86k
  s->ctx = ctx;
177
2.86k
  isl_ctx_ref(s->ctx);
178
2.86k
  s->file = NULL;
179
2.86k
  s->str = NULL;
180
2.86k
  s->len = 0;
181
2.86k
  s->line = 1;
182
2.86k
  s->col = 1;
183
2.86k
  s->eof = 0;
184
2.86k
  s->last_line = 0;
185
2.86k
  s->c = -1;
186
2.86k
  s->n_un = 0;
187
17.1k
  for (i = 0; 
i < 517.1k
;
++i14.3k
)
188
14.3k
    s->tokens[i] = NULL;
189
2.86k
  s->n_token = 0;
190
2.86k
  s->keywords = NULL;
191
2.86k
  s->size = 256;
192
2.86k
  s->buffer = isl_alloc_array(ctx, char, s->size);
193
2.86k
  if (!s->buffer)
194
0
    goto error;
195
2.86k
  return s;
196
0
error:
197
0
  isl_stream_free(s);
198
0
  return NULL;
199
2.86k
}
200
201
__isl_give isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file)
202
112
{
203
112
  isl_stream *s = isl_stream_new(ctx);
204
112
  if (!s)
205
0
    return NULL;
206
112
  s->file = file;
207
112
  return s;
208
112
}
209
210
__isl_give isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str)
211
2.75k
{
212
2.75k
  isl_stream *s;
213
2.75k
  if (!str)
214
0
    return NULL;
215
2.75k
  s = isl_stream_new(ctx);
216
2.75k
  if (!s)
217
0
    return NULL;
218
2.75k
  s->str = str;
219
2.75k
  return s;
220
2.75k
}
221
222
/* Read a character from the stream and advance s->line and s->col
223
 * to point to the next character.
224
 */
225
static int stream_getc(__isl_keep isl_stream *s)
226
181k
{
227
181k
  int c;
228
181k
  if (s->eof)
229
471
    return -1;
230
181k
  
if (181k
s->n_un181k
)
231
49.8k
    return s->c = s->un[--s->n_un];
232
131k
  
if (131k
s->file131k
)
233
10.6k
    c = fgetc(s->file);
234
120k
  else {
235
120k
    c = *s->str++;
236
120k
    if (c == '\0')
237
340
      c = -1;
238
120k
  }
239
131k
  if (c == -1)
240
340
    s->eof = 1;
241
131k
  else 
if (131k
c == '\n'131k
) {
242
613
    s->line++;
243
613
    s->col = 1;
244
613
  } else
245
130k
    s->col++;
246
181k
  s->c = c;
247
181k
  return c;
248
181k
}
249
250
static void isl_stream_ungetc(__isl_keep isl_stream *s, int c)
251
49.8k
{
252
49.8k
  isl_assert(s->ctx, s->n_un < 5, return);
253
49.8k
  s->un[s->n_un++] = c;
254
49.8k
  s->c = -1;
255
49.8k
}
256
257
/* Read a character from the stream, skipping pairs of '\\' and '\n'.
258
 * Set s->start_line and s->start_col to the line and column
259
 * of the returned character.
260
 */
261
static int isl_stream_getc(__isl_keep isl_stream *s)
262
181k
{
263
181k
  int c;
264
181k
265
181k
  do {
266
181k
    s->start_line = s->line;
267
181k
    s->start_col = s->col;
268
181k
    c = stream_getc(s);
269
181k
    if (c != '\\')
270
181k
      return c;
271
0
    c = stream_getc(s);
272
181k
  } while (c == '\n');
273
181k
274
0
  isl_stream_ungetc(s, c);
275
0
276
0
  return '\\';
277
181k
}
278
279
static int isl_stream_push_char(__isl_keep isl_stream *s, int c)
280
79.9k
{
281
79.9k
  if (
s->len >= s->size79.9k
) {
282
0
    char *buffer;
283
0
    s->size = (3*s->size)/2;
284
0
    buffer = isl_realloc_array(s->ctx, s->buffer, char, s->size);
285
0
    if (!buffer)
286
0
      return -1;
287
0
    s->buffer = buffer;
288
0
  }
289
79.9k
  s->buffer[s->len++] = c;
290
79.9k
  return 0;
291
79.9k
}
292
293
void isl_stream_push_token(__isl_keep isl_stream *s, struct isl_token *tok)
294
193k
{
295
193k
  isl_assert(s->ctx, s->n_token < 5, return);
296
193k
  s->tokens[s->n_token++] = tok;
297
193k
}
298
299
static enum isl_token_type check_keywords(__isl_keep isl_stream *s)
300
17.6k
{
301
17.6k
  struct isl_hash_table_entry *entry;
302
17.6k
  struct isl_keyword *keyword;
303
17.6k
  uint32_t name_hash;
304
17.6k
305
17.6k
  if (!strcasecmp(s->buffer, "exists"))
306
131
    return ISL_TOKEN_EXISTS;
307
17.5k
  
if (17.5k
!strcasecmp(s->buffer, "and")17.5k
)
308
1.96k
    return ISL_TOKEN_AND;
309
15.5k
  
if (15.5k
!strcasecmp(s->buffer, "or")15.5k
)
310
151
    return ISL_TOKEN_OR;
311
15.4k
  
if (15.4k
!strcasecmp(s->buffer, "implies")15.4k
)
312
1
    return ISL_TOKEN_IMPLIES;
313
15.4k
  
if (15.4k
!strcasecmp(s->buffer, "not")15.4k
)
314
1
    return ISL_TOKEN_NOT;
315
15.4k
  
if (15.4k
!strcasecmp(s->buffer, "infty")15.4k
)
316
83
    return ISL_TOKEN_INFTY;
317
15.3k
  
if (15.3k
!strcasecmp(s->buffer, "infinity")15.3k
)
318
0
    return ISL_TOKEN_INFTY;
319
15.3k
  
if (15.3k
!strcasecmp(s->buffer, "NaN")15.3k
)
320
78
    return ISL_TOKEN_NAN;
321
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "min")15.2k
)
322
5
    return ISL_TOKEN_MIN;
323
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "max")15.2k
)
324
1
    return ISL_TOKEN_MAX;
325
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "rat")15.2k
)
326
22
    return ISL_TOKEN_RAT;
327
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "true")15.2k
)
328
1
    return ISL_TOKEN_TRUE;
329
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "false")15.2k
)
330
7
    return ISL_TOKEN_FALSE;
331
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "ceild")15.2k
)
332
0
    return ISL_TOKEN_CEILD;
333
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "floord")15.2k
)
334
1
    return ISL_TOKEN_FLOORD;
335
15.2k
  
if (15.2k
!strcasecmp(s->buffer, "mod")15.2k
)
336
58
    return ISL_TOKEN_MOD;
337
15.1k
  
if (15.1k
!strcasecmp(s->buffer, "ceil")15.1k
)
338
0
    return ISL_TOKEN_CEIL;
339
15.1k
  
if (15.1k
!strcasecmp(s->buffer, "floor")15.1k
)
340
142
    return ISL_TOKEN_FLOOR;
341
15.0k
342
15.0k
  
if (15.0k
!s->keywords15.0k
)
343
15.0k
    return ISL_TOKEN_IDENT;
344
0
345
0
  
name_hash = isl_hash_string(0
isl_hash_init0
(), s->buffer);
346
0
  entry = isl_hash_table_find(s->ctx, s->keywords, name_hash, same_name,
347
0
          s->buffer, 0);
348
0
  if (
entry0
) {
349
0
    keyword = entry->data;
350
0
    return keyword->type;
351
0
  }
352
0
353
0
  return ISL_TOKEN_IDENT;
354
0
}
355
356
int isl_stream_skip_line(__isl_keep isl_stream *s)
357
14
{
358
14
  int c;
359
14
360
478
  while (
(c = isl_stream_getc(s)) != -1 && 478
c != '\n'478
)
361
14
    /* nothing */
362
464
    ;
363
14
364
14
  return c == -1 ? 
-10
:
014
;
365
14
}
366
367
static struct isl_token *next_token(__isl_keep isl_stream *s, int same_line)
368
255k
{
369
255k
  int c;
370
255k
  struct isl_token *tok = NULL;
371
255k
  int line, col;
372
255k
  int old_line = s->last_line;
373
255k
374
255k
  if (
s->n_token255k
) {
375
193k
    if (
same_line && 193k
s->tokens[s->n_token - 1]->on_new_line105
)
376
0
      return NULL;
377
193k
    return s->tokens[--s->n_token];
378
193k
  }
379
61.2k
380
61.2k
  
if (61.2k
same_line && 61.2k
s->c == '\n'210
)
381
0
    return NULL;
382
61.2k
383
61.2k
  s->len = 0;
384
61.2k
385
61.2k
  /* skip spaces and comment lines */
386
100k
  while (
(c = isl_stream_getc(s)) != -1100k
) {
387
99.8k
    if (
c == '#'99.8k
) {
388
14
      if (isl_stream_skip_line(s) < 0)
389
0
        break;
390
14
      c = '\n';
391
14
      if (same_line)
392
0
        break;
393
99.8k
    } else 
if (99.8k
!isspace(c) || 99.8k
(same_line && 39.1k
c == '\n'212
))
394
60.9k
      break;
395
99.8k
  }
396
61.2k
397
61.2k
  line = s->start_line;
398
61.2k
  col = s->start_col;
399
61.2k
400
61.2k
  if (
c == -1 || 61.2k
(same_line && 60.9k
c == '\n'210
))
401
568
    return NULL;
402
60.7k
  s->last_line = line;
403
60.7k
404
60.7k
  if (c == '(' ||
405
60.0k
      c == ')' ||
406
59.3k
      c == '+' ||
407
57.9k
      c == '*' ||
408
57.7k
      c == '%' ||
409
57.7k
      c == '?' ||
410
57.7k
      c == '^' ||
411
57.7k
      c == '@' ||
412
57.7k
      c == '$' ||
413
57.7k
      c == ',' ||
414
54.7k
      c == '.' ||
415
54.7k
      c == ';' ||
416
54.0k
      c == '[' ||
417
48.2k
      c == ']' ||
418
42.3k
      c == '{' ||
419
60.7k
      
c == '}'39.9k
) {
420
23.2k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
421
23.2k
    if (!tok)
422
0
      return NULL;
423
23.2k
    tok->type = (enum isl_token_type)c;
424
23.2k
    return tok;
425
23.2k
  }
426
37.4k
  
if (37.4k
c == '-'37.4k
) {
427
4.62k
    int c;
428
4.62k
    if (
(c = isl_stream_getc(s)) == '>'4.62k
) {
429
2.67k
      tok = isl_token_new(s->ctx, line, col, old_line != line);
430
2.67k
      if (!tok)
431
0
        return NULL;
432
2.67k
      tok->u.s = strdup("->");
433
2.67k
      tok->type = ISL_TOKEN_TO;
434
2.67k
      return tok;
435
2.67k
    }
436
1.94k
    
if (1.94k
c != -11.94k
)
437
1.94k
      isl_stream_ungetc(s, c);
438
1.94k
    if (
!isdigit(c)1.94k
) {
439
669
      tok = isl_token_new(s->ctx, line, col, old_line != line);
440
669
      if (!tok)
441
0
        return NULL;
442
669
      tok->type = (enum isl_token_type) '-';
443
669
      return tok;
444
669
    }
445
4.62k
  }
446
34.1k
  
if (34.1k
c == '-' || 34.1k
isdigit(c)32.8k
) {
447
9.97k
    int minus = c == '-';
448
9.97k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
449
9.97k
    if (!tok)
450
0
      return NULL;
451
9.97k
    tok->type = ISL_TOKEN_VALUE;
452
9.97k
    isl_int_init(tok->u.v);
453
9.97k
    if (isl_stream_push_char(s, c))
454
0
      goto error;
455
14.5k
    
while (9.97k
(c = isl_stream_getc(s)) != -1 && 14.5k
isdigit(c)14.3k
)
456
4.62k
      
if (4.62k
isl_stream_push_char(s, c)4.62k
)
457
0
        goto error;
458
9.97k
    
if (9.97k
c != -19.97k
)
459
9.77k
      isl_stream_ungetc(s, c);
460
9.97k
    isl_stream_push_char(s, '\0');
461
9.97k
    isl_int_read(tok->u.v, s->buffer);
462
9.97k
    if (
minus && 9.97k
isl_int_is_zero1.27k
(tok->u.v)) {
463
1
      tok->col++;
464
1
      tok->on_new_line = 0;
465
1
      isl_stream_push_token(s, tok);
466
1
      tok = isl_token_new(s->ctx, line, col, old_line != line);
467
1
      if (!tok)
468
0
        return NULL;
469
1
      tok->type = (enum isl_token_type) '-';
470
1
    }
471
9.97k
    return tok;
472
24.1k
  }
473
24.1k
  
if (24.1k
isalpha(c) || 24.1k
c == '_'6.49k
) {
474
17.6k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
475
17.6k
    if (!tok)
476
0
      return NULL;
477
17.6k
    isl_stream_push_char(s, c);
478
37.5k
    while ((c = isl_stream_getc(s)) != -1 &&
479
37.5k
        
(isalnum(c) || 37.4k
c == '_'18.7k
))
480
19.9k
      isl_stream_push_char(s, c);
481
17.6k
    if (c != -1)
482
17.5k
      isl_stream_ungetc(s, c);
483
17.7k
    while (
(c = isl_stream_getc(s)) != -1 && 17.7k
c == '\''17.6k
)
484
94
      isl_stream_push_char(s, c);
485
17.6k
    if (c != -1)
486
17.5k
      isl_stream_ungetc(s, c);
487
17.6k
    isl_stream_push_char(s, '\0');
488
17.6k
    tok->type = check_keywords(s);
489
17.6k
    if (tok->type != ISL_TOKEN_IDENT)
490
2.64k
      tok->is_keyword = 1;
491
17.6k
    tok->u.s = strdup(s->buffer);
492
17.6k
    if (!tok->u.s)
493
0
      goto error;
494
17.6k
    return tok;
495
17.6k
  }
496
6.49k
  
if (6.49k
c == '"'6.49k
) {
497
0
    tok = isl_token_new(s->ctx, line, col, old_line != line);
498
0
    if (!tok)
499
0
      return NULL;
500
0
    tok->type = ISL_TOKEN_STRING;
501
0
    tok->u.s = NULL;
502
0
    while (
(c = isl_stream_getc(s)) != -1 && 0
c != '"'0
&&
c != '\n'0
)
503
0
      isl_stream_push_char(s, c);
504
0
    if (
c != '"'0
) {
505
0
      isl_stream_error(s, NULL, "unterminated string");
506
0
      goto error;
507
0
    }
508
0
    isl_stream_push_char(s, '\0');
509
0
    tok->u.s = strdup(s->buffer);
510
0
    return tok;
511
0
  }
512
6.49k
  
if (6.49k
c == '='6.49k
) {
513
632
    int c;
514
632
    tok = isl_token_new(s->ctx, line, col, old_line != line);
515
632
    if (!tok)
516
0
      return NULL;
517
632
    
if (632
(c = isl_stream_getc(s)) == '='632
) {
518
0
      tok->u.s = strdup("==");
519
0
      tok->type = ISL_TOKEN_EQ_EQ;
520
0
      return tok;
521
0
    }
522
632
    
if (632
c != -1632
)
523
632
      isl_stream_ungetc(s, c);
524
632
    tok->type = (enum isl_token_type) '=';
525
632
    return tok;
526
632
  }
527
5.86k
  
if (5.86k
c == ':'5.86k
) {
528
1.60k
    int c;
529
1.60k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
530
1.60k
    if (!tok)
531
0
      return NULL;
532
1.60k
    
if (1.60k
(c = isl_stream_getc(s)) == '='1.60k
) {
533
0
      tok->u.s = strdup(":=");
534
0
      tok->type = ISL_TOKEN_DEF;
535
0
      return tok;
536
0
    }
537
1.60k
    
if (1.60k
c != -11.60k
)
538
1.60k
      isl_stream_ungetc(s, c);
539
1.60k
    tok->type = (enum isl_token_type) ':';
540
1.60k
    return tok;
541
1.60k
  }
542
4.25k
  
if (4.25k
c == '>'4.25k
) {
543
1.18k
    int c;
544
1.18k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
545
1.18k
    if (!tok)
546
0
      return NULL;
547
1.18k
    
if (1.18k
(c = isl_stream_getc(s)) == '='1.18k
) {
548
1.13k
      tok->u.s = strdup(">=");
549
1.13k
      tok->type = ISL_TOKEN_GE;
550
1.13k
      return tok;
551
55
    } else 
if (55
c == '>'55
) {
552
2
      if (
(c = isl_stream_getc(s)) == '='2
) {
553
1
        tok->u.s = strdup(">>=");
554
1
        tok->type = ISL_TOKEN_LEX_GE;
555
1
        return tok;
556
1
      }
557
1
      tok->u.s = strdup(">>");
558
1
      tok->type = ISL_TOKEN_LEX_GT;
559
55
    } else {
560
53
      tok->u.s = strdup(">");
561
53
      tok->type = ISL_TOKEN_GT;
562
53
    }
563
54
    
if (54
c != -154
)
564
54
      isl_stream_ungetc(s, c);
565
54
    return tok;
566
3.07k
  }
567
3.07k
  
if (3.07k
c == '<'3.07k
) {
568
2.58k
    int c;
569
2.58k
    tok = isl_token_new(s->ctx, line, col, old_line != line);
570
2.58k
    if (!tok)
571
0
      return NULL;
572
2.58k
    
if (2.58k
(c = isl_stream_getc(s)) == '='2.58k
) {
573
2.22k
      tok->u.s = strdup("<=");
574
2.22k
      tok->type = ISL_TOKEN_LE;
575
2.22k
      return tok;
576
352
    } else 
if (352
c == '<'352
) {
577
2
      if (
(c = isl_stream_getc(s)) == '='2
) {
578
1
        tok->u.s = strdup("<<=");
579
1
        tok->type = ISL_TOKEN_LEX_LE;
580
1
        return tok;
581
1
      }
582
1
      tok->u.s = strdup("<<");
583
1
      tok->type = ISL_TOKEN_LEX_LT;
584
352
    } else {
585
350
      tok->u.s = strdup("<");
586
350
      tok->type = ISL_TOKEN_LT;
587
350
    }
588
351
    
if (351
c != -1351
)
589
351
      isl_stream_ungetc(s, c);
590
351
    return tok;
591
492
  }
592
492
  
if (492
c == '&'492
) {
593
104
    tok = isl_token_new(s->ctx, line, col, old_line != line);
594
104
    if (!tok)
595
0
      return NULL;
596
104
    tok->type = ISL_TOKEN_AND;
597
104
    if (
(c = isl_stream_getc(s)) != '&' && 104
c != -197
) {
598
97
      tok->u.s = strdup("&");
599
97
      isl_stream_ungetc(s, c);
600
97
    } else
601
7
      tok->u.s = strdup("&&");
602
104
    return tok;
603
104
  }
604
388
  
if (388
c == '|'388
) {
605
1
    tok = isl_token_new(s->ctx, line, col, old_line != line);
606
1
    if (!tok)
607
0
      return NULL;
608
1
    tok->type = ISL_TOKEN_OR;
609
1
    if (
(c = isl_stream_getc(s)) != '|' && 1
c != -10
) {
610
0
      tok->u.s = strdup("|");
611
0
      isl_stream_ungetc(s, c);
612
0
    } else
613
1
      tok->u.s = strdup("||");
614
1
    return tok;
615
1
  }
616
387
  
if (387
c == '/'387
) {
617
375
    tok = isl_token_new(s->ctx, line, col, old_line != line);
618
375
    if (!tok)
619
0
      return NULL;
620
375
    
if (375
(c = isl_stream_getc(s)) != '\\' && 375
c != -1375
) {
621
375
      tok->type = (enum isl_token_type) '/';
622
375
      isl_stream_ungetc(s, c);
623
375
    } else {
624
0
      tok->u.s = strdup("/\\");
625
0
      tok->type = ISL_TOKEN_AND;
626
0
    }
627
375
    return tok;
628
375
  }
629
12
  
if (12
c == '\\'12
) {
630
0
    tok = isl_token_new(s->ctx, line, col, old_line != line);
631
0
    if (!tok)
632
0
      return NULL;
633
0
    
if (0
(c = isl_stream_getc(s)) != '/' && 0
c != -10
) {
634
0
      tok->type = (enum isl_token_type) '\\';
635
0
      isl_stream_ungetc(s, c);
636
0
    } else {
637
0
      tok->u.s = strdup("\\/");
638
0
      tok->type = ISL_TOKEN_OR;
639
0
    }
640
0
    return tok;
641
0
  }
642
12
  
if (12
c == '!'12
) {
643
12
    tok = isl_token_new(s->ctx, line, col, old_line != line);
644
12
    if (!tok)
645
0
      return NULL;
646
12
    
if (12
(c = isl_stream_getc(s)) == '='12
) {
647
12
      tok->u.s = strdup("!=");
648
12
      tok->type = ISL_TOKEN_NE;
649
12
      return tok;
650
0
    } else {
651
0
      tok->type = ISL_TOKEN_NOT;
652
0
      tok->u.s = strdup("!");
653
0
    }
654
0
    
if (0
c != -10
)
655
0
      isl_stream_ungetc(s, c);
656
0
    return tok;
657
0
  }
658
0
659
0
  tok = isl_token_new(s->ctx, line, col, old_line != line);
660
0
  if (!tok)
661
0
    return NULL;
662
0
  tok->type = ISL_TOKEN_UNKNOWN;
663
0
  return tok;
664
0
error:
665
0
  isl_token_free(tok);
666
0
  return NULL;
667
255k
}
668
669
struct isl_token *isl_stream_next_token(__isl_keep isl_stream *s)
670
254k
{
671
254k
  return next_token(s, 0);
672
254k
}
673
674
struct isl_token *isl_stream_next_token_on_same_line(__isl_keep isl_stream *s)
675
315
{
676
315
  return next_token(s, 1);
677
315
}
678
679
int isl_stream_eat_if_available(__isl_keep isl_stream *s, int type)
680
87.1k
{
681
87.1k
  struct isl_token *tok;
682
87.1k
683
87.1k
  tok = isl_stream_next_token(s);
684
87.1k
  if (!tok)
685
343
    return 0;
686
86.7k
  
if (86.7k
tok->type == type86.7k
) {
687
3.45k
    isl_token_free(tok);
688
3.45k
    return 1;
689
3.45k
  }
690
83.3k
  isl_stream_push_token(s, tok);
691
83.3k
  return 0;
692
83.3k
}
693
694
int isl_stream_next_token_is(__isl_keep isl_stream *s, int type)
695
36.4k
{
696
36.4k
  struct isl_token *tok;
697
36.4k
  int r;
698
36.4k
699
36.4k
  tok = isl_stream_next_token(s);
700
36.4k
  if (!tok)
701
15
    return 0;
702
36.4k
  r = tok->type == type;
703
36.4k
  isl_stream_push_token(s, tok);
704
36.4k
  return r;
705
36.4k
}
706
707
char *isl_stream_read_ident_if_available(__isl_keep isl_stream *s)
708
0
{
709
0
  struct isl_token *tok;
710
0
711
0
  tok = isl_stream_next_token(s);
712
0
  if (!tok)
713
0
    return NULL;
714
0
  
if (0
tok->type == ISL_TOKEN_IDENT0
) {
715
0
    char *ident = strdup(tok->u.s);
716
0
    isl_token_free(tok);
717
0
    return ident;
718
0
  }
719
0
  isl_stream_push_token(s, tok);
720
0
  return NULL;
721
0
}
722
723
int isl_stream_eat(__isl_keep isl_stream *s, int type)
724
13.3k
{
725
13.3k
  struct isl_token *tok;
726
13.3k
727
13.3k
  tok = isl_stream_next_token(s);
728
13.3k
  if (!tok)
729
0
    return -1;
730
13.3k
  
if (13.3k
tok->type == type13.3k
) {
731
13.3k
    isl_token_free(tok);
732
13.3k
    return 0;
733
13.3k
  }
734
2
  isl_stream_error(s, tok, "expecting other token");
735
2
  isl_stream_push_token(s, tok);
736
2
  return -1;
737
2
}
738
739
int isl_stream_is_empty(__isl_keep isl_stream *s)
740
0
{
741
0
  struct isl_token *tok;
742
0
743
0
  tok = isl_stream_next_token(s);
744
0
745
0
  if (!tok)
746
0
    return 1;
747
0
748
0
  isl_stream_push_token(s, tok);
749
0
  return 0;
750
0
}
751
752
static isl_stat free_keyword(void **p, void *user)
753
0
{
754
0
  struct isl_keyword *keyword = *p;
755
0
756
0
  free(keyword->name);
757
0
  free(keyword);
758
0
759
0
  return isl_stat_ok;
760
0
}
761
762
void isl_stream_flush_tokens(__isl_keep isl_stream *s)
763
0
{
764
0
  int i;
765
0
766
0
  if (!s)
767
0
    return;
768
0
  
for (i = 0; 0
i < s->n_token0
;
++i0
)
769
0
    isl_token_free(s->tokens[i]);
770
0
  s->n_token = 0;
771
0
}
772
773
isl_ctx *isl_stream_get_ctx(__isl_keep isl_stream *s)
774
0
{
775
0
  return s ? s->ctx : NULL;
776
0
}
777
778
void isl_stream_free(__isl_take isl_stream *s)
779
2.86k
{
780
2.86k
  if (!s)
781
0
    return;
782
2.86k
  free(s->buffer);
783
2.86k
  if (
s->n_token != 02.86k
) {
784
3
    struct isl_token *tok = isl_stream_next_token(s);
785
3
    isl_stream_error(s, tok, "unexpected token");
786
3
    isl_token_free(tok);
787
3
  }
788
2.86k
  if (
s->keywords2.86k
) {
789
0
    isl_hash_table_foreach(s->ctx, s->keywords, &free_keyword, NULL);
790
0
    isl_hash_table_free(s->ctx, s->keywords);
791
0
  }
792
2.86k
  free(s->yaml_state);
793
2.86k
  free(s->yaml_indent);
794
2.86k
  isl_ctx_deref(s->ctx);
795
2.86k
  free(s);
796
2.86k
}
797
798
/* Push "state" onto the stack of currently active YAML elements.
799
 * The caller is responsible for setting the corresponding indentation.
800
 * Return 0 on success and -1 on failure.
801
 */
802
static int push_state(__isl_keep isl_stream *s, enum isl_yaml_state state)
803
0
{
804
0
  if (
s->yaml_size < s->yaml_depth + 10
) {
805
0
    int *indent;
806
0
    enum isl_yaml_state *state;
807
0
808
0
    state = isl_realloc_array(s->ctx, s->yaml_state,
809
0
          enum isl_yaml_state, s->yaml_depth + 1);
810
0
    if (!state)
811
0
      return -1;
812
0
    s->yaml_state = state;
813
0
814
0
    indent = isl_realloc_array(s->ctx, s->yaml_indent,
815
0
          int, s->yaml_depth + 1);
816
0
    if (!indent)
817
0
      return -1;
818
0
    s->yaml_indent = indent;
819
0
820
0
    s->yaml_size = s->yaml_depth + 1;
821
0
  }
822
0
823
0
  s->yaml_state[s->yaml_depth] = state;
824
0
  s->yaml_depth++;
825
0
826
0
  return 0;
827
0
}
828
829
/* Remove the innermost active YAML element from the stack.
830
 * Return 0 on success and -1 on failure.
831
 */
832
static int pop_state(__isl_keep isl_stream *s)
833
0
{
834
0
  if (!s)
835
0
    return -1;
836
0
  
if (0
s->yaml_depth < 10
)
837
0
    isl_die(isl_stream_get_ctx(s), isl_error_invalid,
838
0
      "not in YAML construct", return -1);
839
0
840
0
  s->yaml_depth--;
841
0
842
0
  return 0;
843
0
}
844
845
/* Set the state of the innermost active YAML element to "state".
846
 * Return 0 on success and -1 on failure.
847
 */
848
static int update_state(__isl_keep isl_stream *s, enum isl_yaml_state state)
849
0
{
850
0
  if (!s)
851
0
    return -1;
852
0
  
if (0
s->yaml_depth < 10
)
853
0
    isl_die(isl_stream_get_ctx(s), isl_error_invalid,
854
0
      "not in YAML construct", return -1);
855
0
856
0
  s->yaml_state[s->yaml_depth - 1] = state;
857
0
858
0
  return 0;
859
0
}
860
861
/* Return the state of the innermost active YAML element.
862
 * Return isl_yaml_none if we are not inside any YAML element.
863
 */
864
static enum isl_yaml_state current_state(__isl_keep isl_stream *s)
865
0
{
866
0
  if (!s)
867
0
    return isl_yaml_none;
868
0
  
if (0
s->yaml_depth < 10
)
869
0
    return isl_yaml_none;
870
0
  return s->yaml_state[s->yaml_depth - 1];
871
0
}
872
873
/* Set the indentation of the innermost active YAML element to "indent".
874
 * If "indent" is equal to ISL_YAML_INDENT_FLOW, then this means
875
 * that the current elemient is in flow format.
876
 */
877
static int set_yaml_indent(__isl_keep isl_stream *s, int indent)
878
0
{
879
0
  if (s->yaml_depth < 1)
880
0
    isl_die(s->ctx, isl_error_internal,
881
0
      "not in YAML element", return -1);
882
0
883
0
  s->yaml_indent[s->yaml_depth - 1] = indent;
884
0
885
0
  return 0;
886
0
}
887
888
/* Return the indentation of the innermost active YAML element
889
 * of -1 on error.
890
 */
891
static int get_yaml_indent(__isl_keep isl_stream *s)
892
0
{
893
0
  if (s->yaml_depth < 1)
894
0
    isl_die(s->ctx, isl_error_internal,
895
0
      "not in YAML element", return -1);
896
0
897
0
  return s->yaml_indent[s->yaml_depth - 1];
898
0
}
899
900
/* Move to the next state at the innermost level.
901
 * Return 1 if successful.
902
 * Return 0 if we are at the end of the innermost level.
903
 * Return -1 on error.
904
 *
905
 * If we are in state isl_yaml_mapping_key_start, then we have just
906
 * started a mapping and we are expecting a key.  If the mapping started
907
 * with a '{', then we check if the next token is a '}'.  If so,
908
 * then the mapping is empty and there is no next state at this level.
909
 * Otherwise, we assume that there is at least one key (the one from
910
 * which we derived the indentation in isl_stream_yaml_read_start_mapping.
911
 *
912
 * If we are in state isl_yaml_mapping_key, then the we expect a colon
913
 * followed by a value, so there is always a next state unless
914
 * some error occurs.
915
 *
916
 * If we are in state isl_yaml_mapping_val, then there may or may
917
 * not be a subsequent key in the same mapping.
918
 * In flow format, the next key is preceded by a comma.
919
 * In block format, the next key has the same indentation as the first key.
920
 * If the first token has a smaller indentation, then we have reached
921
 * the end of the current mapping.
922
 *
923
 * If we are in state isl_yaml_sequence_start, then we have just
924
 * started a sequence.  If the sequence started with a '[',
925
 * then we check if the next token is a ']'.  If so, then the sequence
926
 * is empty and there is no next state at this level.
927
 * Otherwise, we assume that there is at least one element in the sequence
928
 * (the one from which we derived the indentation in
929
 * isl_stream_yaml_read_start_sequence.
930
 *
931
 * If we are in state isl_yaml_sequence, then there may or may
932
 * not be a subsequent element in the same sequence.
933
 * In flow format, the next element is preceded by a comma.
934
 * In block format, the next element is introduced by a dash with
935
 * the same indentation as that of the first element.
936
 * If the first token is not a dash or if it has a smaller indentation,
937
 * then we have reached the end of the current sequence.
938
 */
939
int isl_stream_yaml_next(__isl_keep isl_stream *s)
940
0
{
941
0
  struct isl_token *tok;
942
0
  enum isl_yaml_state state;
943
0
  int indent;
944
0
945
0
  state = current_state(s);
946
0
  if (state == isl_yaml_none)
947
0
    isl_die(s->ctx, isl_error_invalid,
948
0
      "not in YAML element", return -1);
949
0
  switch (state) {
950
0
  case isl_yaml_mapping_key_start:
951
0
    if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
&&
952
0
        isl_stream_next_token_is(s, '}'))
953
0
      return 0;
954
0
    
if (0
update_state(s, isl_yaml_mapping_key) < 00
)
955
0
      return -1;
956
0
    return 1;
957
0
  case isl_yaml_mapping_key:
958
0
    tok = isl_stream_next_token(s);
959
0
    if (
!tok0
) {
960
0
      if (s->eof)
961
0
        isl_stream_error(s, NULL, "unexpected EOF");
962
0
      return -1;
963
0
    }
964
0
    
if (0
tok->type == ':'0
) {
965
0
      isl_token_free(tok);
966
0
      if (update_state(s, isl_yaml_mapping_val) < 0)
967
0
        return -1;
968
0
      return 1;
969
0
    }
970
0
    isl_stream_error(s, tok, "expecting ':'");
971
0
    isl_stream_push_token(s, tok);
972
0
    return -1;
973
0
  case isl_yaml_mapping_val:
974
0
    if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
) {
975
0
      if (!isl_stream_eat_if_available(s, ','))
976
0
        return 0;
977
0
      
if (0
update_state(s, isl_yaml_mapping_key) < 00
)
978
0
        return -1;
979
0
      return 1;
980
0
    }
981
0
    tok = isl_stream_next_token(s);
982
0
    if (!tok)
983
0
      return 0;
984
0
    indent = tok->col - 1;
985
0
    isl_stream_push_token(s, tok);
986
0
    if (indent < get_yaml_indent(s))
987
0
      return 0;
988
0
    
if (0
update_state(s, isl_yaml_mapping_key) < 00
)
989
0
      return -1;
990
0
    return 1;
991
0
  case isl_yaml_sequence_start:
992
0
    if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
) {
993
0
      if (isl_stream_next_token_is(s, ']'))
994
0
        return 0;
995
0
      
if (0
update_state(s, isl_yaml_sequence) < 00
)
996
0
        return -1;
997
0
      return 1;
998
0
    }
999
0
    tok = isl_stream_next_token(s);
1000
0
    if (
!tok0
) {
1001
0
      if (s->eof)
1002
0
        isl_stream_error(s, NULL, "unexpected EOF");
1003
0
      return -1;
1004
0
    }
1005
0
    
if (0
tok->type == '-'0
) {
1006
0
      isl_token_free(tok);
1007
0
      if (update_state(s, isl_yaml_sequence) < 0)
1008
0
        return -1;
1009
0
      return 1;
1010
0
    }
1011
0
    isl_stream_error(s, tok, "expecting '-'");
1012
0
    isl_stream_push_token(s, tok);
1013
0
    return 0;
1014
0
  case isl_yaml_sequence:
1015
0
    if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
)
1016
0
      return isl_stream_eat_if_available(s, ',');
1017
0
    tok = isl_stream_next_token(s);
1018
0
    if (!tok)
1019
0
      return 0;
1020
0
    indent = tok->col - 1;
1021
0
    if (
indent < get_yaml_indent(s) || 0
tok->type != '-'0
) {
1022
0
      isl_stream_push_token(s, tok);
1023
0
      return 0;
1024
0
    }
1025
0
    isl_token_free(tok);
1026
0
    return 1;
1027
0
  default:
1028
0
    isl_die(s->ctx, isl_error_internal,
1029
0
      "unexpected state", return 0);
1030
0
  }
1031
0
}
1032
1033
/* Start reading a YAML mapping.
1034
 * Return 0 on success and -1 on error.
1035
 *
1036
 * If the first token on the stream is a '{' then we remove this token
1037
 * from the stream and keep track of the fact that the mapping
1038
 * is given in flow format.
1039
 * Otherwise, we assume the first token is the first key of the mapping and
1040
 * keep track of its indentation, but keep the token on the stream.
1041
 * In both cases, the next token we expect is the first key of the mapping.
1042
 */
1043
int isl_stream_yaml_read_start_mapping(__isl_keep isl_stream *s)
1044
0
{
1045
0
  struct isl_token *tok;
1046
0
  int indent;
1047
0
1048
0
  if (push_state(s, isl_yaml_mapping_key_start) < 0)
1049
0
    return -1;
1050
0
1051
0
  tok = isl_stream_next_token(s);
1052
0
  if (
!tok0
) {
1053
0
    if (s->eof)
1054
0
      isl_stream_error(s, NULL, "unexpected EOF");
1055
0
    return -1;
1056
0
  }
1057
0
  
if (0
isl_token_get_type(tok) == '{'0
) {
1058
0
    isl_token_free(tok);
1059
0
    return set_yaml_indent(s, ISL_YAML_INDENT_FLOW);
1060
0
  }
1061
0
  indent = tok->col - 1;
1062
0
  isl_stream_push_token(s, tok);
1063
0
1064
0
  return set_yaml_indent(s, indent);
1065
0
}
1066
1067
/* Finish reading a YAML mapping.
1068
 * Return 0 on success and -1 on error.
1069
 *
1070
 * If the mapping started with a '{', then we expect a '}' to close
1071
 * the mapping.
1072
 * Otherwise, we double-check that the next token (if any)
1073
 * has a smaller indentation than that of the current mapping.
1074
 */
1075
int isl_stream_yaml_read_end_mapping(__isl_keep isl_stream *s)
1076
0
{
1077
0
  struct isl_token *tok;
1078
0
  int indent;
1079
0
1080
0
  if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
) {
1081
0
    if (isl_stream_eat(s, '}') < 0)
1082
0
      return -1;
1083
0
    return pop_state(s);
1084
0
  }
1085
0
1086
0
  tok = isl_stream_next_token(s);
1087
0
  if (!tok)
1088
0
    return pop_state(s);
1089
0
1090
0
  indent = tok->col - 1;
1091
0
  isl_stream_push_token(s, tok);
1092
0
1093
0
  if (indent >= get_yaml_indent(s))
1094
0
    isl_die(isl_stream_get_ctx(s), isl_error_invalid,
1095
0
      "mapping not finished", return -1);
1096
0
1097
0
  return pop_state(s);
1098
0
}
1099
1100
/* Start reading a YAML sequence.
1101
 * Return 0 on success and -1 on error.
1102
 *
1103
 * If the first token on the stream is a '[' then we remove this token
1104
 * from the stream and keep track of the fact that the sequence
1105
 * is given in flow format.
1106
 * Otherwise, we assume the first token is the dash that introduces
1107
 * the first element of the sequence and keep track of its indentation,
1108
 * but keep the token on the stream.
1109
 * In both cases, the next token we expect is the first element
1110
 * of the sequence.
1111
 */
1112
int isl_stream_yaml_read_start_sequence(__isl_keep isl_stream *s)
1113
0
{
1114
0
  struct isl_token *tok;
1115
0
  int indent;
1116
0
1117
0
  if (push_state(s, isl_yaml_sequence_start) < 0)
1118
0
    return -1;
1119
0
1120
0
  tok = isl_stream_next_token(s);
1121
0
  if (
!tok0
) {
1122
0
    if (s->eof)
1123
0
      isl_stream_error(s, NULL, "unexpected EOF");
1124
0
    return -1;
1125
0
  }
1126
0
  
if (0
isl_token_get_type(tok) == '['0
) {
1127
0
    isl_token_free(tok);
1128
0
    return set_yaml_indent(s, ISL_YAML_INDENT_FLOW);
1129
0
  }
1130
0
  indent = tok->col - 1;
1131
0
  isl_stream_push_token(s, tok);
1132
0
1133
0
  return set_yaml_indent(s, indent);
1134
0
}
1135
1136
/* Finish reading a YAML sequence.
1137
 * Return 0 on success and -1 on error.
1138
 *
1139
 * If the sequence started with a '[', then we expect a ']' to close
1140
 * the sequence.
1141
 * Otherwise, we double-check that the next token (if any)
1142
 * is not a dash or that it has a smaller indentation than
1143
 * that of the current sequence.
1144
 */
1145
int isl_stream_yaml_read_end_sequence(__isl_keep isl_stream *s)
1146
0
{
1147
0
  struct isl_token *tok;
1148
0
  int indent;
1149
0
  int dash;
1150
0
1151
0
  if (
get_yaml_indent(s) == 0
ISL_YAML_INDENT_FLOW0
) {
1152
0
    if (isl_stream_eat(s, ']') < 0)
1153
0
      return -1;
1154
0
    return pop_state(s);
1155
0
  }
1156
0
1157
0
  tok = isl_stream_next_token(s);
1158
0
  if (!tok)
1159
0
    return pop_state(s);
1160
0
1161
0
  indent = tok->col - 1;
1162
0
  dash = tok->type == '-';
1163
0
  isl_stream_push_token(s, tok);
1164
0
1165
0
  if (
indent >= get_yaml_indent(s) && 0
dash0
)
1166
0
    isl_die(isl_stream_get_ctx(s), isl_error_invalid,
1167
0
      "sequence not finished", return -1);
1168
0
1169
0
  return pop_state(s);
1170
0
}