add copyright statements
[platform/upstream/isl.git] / isl_stream.h
1 /*
2  * Copyright 2008-2009 Katholieke Universiteit Leuven
3  *
4  * Use of this software is governed by the GNU LGPLv2.1 license
5  *
6  * Written by Sven Verdoolaege, K.U.Leuven, Departement
7  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8  */
9
10 #ifndef ISL_STREAM_H
11 #define ISL_STREAM_H
12
13 #include <stdio.h>
14
15 #if defined(__cplusplus)
16 extern "C" {
17 #endif
18
19 enum isl_token_type { ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
20                         ISL_TOKEN_IDENT, ISL_TOKEN_GE,
21                         ISL_TOKEN_LE, ISL_TOKEN_TO, ISL_TOKEN_AND,
22                         ISL_TOKEN_EXISTS };
23
24 struct isl_token {
25         enum isl_token_type  type;
26
27         unsigned int on_new_line : 1;
28         int line;
29         int col;
30
31         union {
32                 isl_int v;
33                 char    *s;
34         } u;
35 };
36
37 void isl_token_free(struct isl_token *tok);
38
39 struct isl_stream {
40         struct isl_ctx  *ctx;
41         FILE            *file;
42         const char      *str;
43         int             line;
44         int             col;
45         int             eof;
46
47         char            *buffer;
48         size_t          size;
49         size_t          len;
50         int             c;
51
52         struct isl_token        *tokens[5];
53         int             n_token;
54 };
55
56 struct isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file);
57 struct isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str);
58 void isl_stream_free(struct isl_stream *s);
59
60 void isl_stream_error(struct isl_stream *s, struct isl_token *tok, char *msg);
61
62 struct isl_token *isl_stream_next_token(struct isl_stream *s);
63 void isl_stream_push_token(struct isl_stream *s, struct isl_token *tok);
64 int isl_stream_eat(struct isl_stream *s, int type);
65
66 #if defined(__cplusplus)
67 }
68 #endif
69
70 #endif