add isl_map_neg
[platform/upstream/isl.git] / isl_stream.h
1 #ifndef ISL_STREAM_H
2 #define ISL_STREAM_H
3
4 #include <stdio.h>
5
6 #if defined(__cplusplus)
7 extern "C" {
8 #endif
9
10 enum isl_token_type { ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
11                         ISL_TOKEN_IDENT, ISL_TOKEN_GE,
12                         ISL_TOKEN_LE, ISL_TOKEN_TO, ISL_TOKEN_AND,
13                         ISL_TOKEN_EXISTS };
14
15 struct isl_token {
16         enum isl_token_type  type;
17
18         unsigned int on_new_line : 1;
19         int line;
20         int col;
21
22         union {
23                 isl_int v;
24                 char    *s;
25         } u;
26 };
27
28 struct isl_stream {
29         struct isl_ctx  *ctx;
30         FILE            *file;
31         const char      *str;
32         int             line;
33         int             col;
34         int             eof;
35
36         char            *buffer;
37         size_t          size;
38         size_t          len;
39         int             c;
40
41         struct isl_token        *tokens[5];
42         int             n_token;
43 };
44
45 struct isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file);
46 struct isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str);
47 void isl_stream_free(struct isl_stream *s);
48
49 struct isl_token *isl_stream_next_token(struct isl_stream *s);
50 void isl_stream_push_token(struct isl_stream *s, struct isl_token *tok);
51 int isl_stream_eat(struct isl_stream *s, int type);
52
53 #if defined(__cplusplus)
54 }
55 #endif
56
57 #endif