add isl_map_has_equal_dim
[isl.git] / include / isl_stream.h
blobc63b67e83220ad3c2ab58fbfcdfc8bdd22d7907f
1 /*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
10 #ifndef ISL_STREAM_H
11 #define ISL_STREAM_H
13 #include <stdio.h>
14 #include <isl_hash.h>
15 #include <isl_obj.h>
17 #if defined(__cplusplus)
18 extern "C" {
19 #endif
21 enum isl_token_type { ISL_TOKEN_ERROR = -1,
22 ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
23 ISL_TOKEN_IDENT, ISL_TOKEN_GE,
24 ISL_TOKEN_LE, ISL_TOKEN_GT, ISL_TOKEN_LT,
25 ISL_TOKEN_LEX_GE, ISL_TOKEN_LEX_LE,
26 ISL_TOKEN_LEX_GT, ISL_TOKEN_LEX_LT,
27 ISL_TOKEN_TO, ISL_TOKEN_AND,
28 ISL_TOKEN_OR, ISL_TOKEN_EXISTS,
29 ISL_TOKEN_DEF, ISL_TOKEN_INFTY, ISL_TOKEN_NAN,
30 ISL_TOKEN_STRING,
31 ISL_TOKEN_LAST };
33 struct isl_token {
34 enum isl_token_type type;
36 unsigned int on_new_line : 1;
37 int line;
38 int col;
40 union {
41 isl_int v;
42 char *s;
43 } u;
46 void isl_token_free(struct isl_token *tok);
48 struct isl_stream {
49 struct isl_ctx *ctx;
50 FILE *file;
51 const char *str;
52 int line;
53 int col;
54 int eof;
56 char *buffer;
57 size_t size;
58 size_t len;
59 int c;
61 struct isl_token *tokens[5];
62 int n_token;
64 struct isl_hash_table *keywords;
65 enum isl_token_type next_type;
68 struct isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file);
69 struct isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str);
70 void isl_stream_free(struct isl_stream *s);
72 void isl_stream_error(struct isl_stream *s, struct isl_token *tok, char *msg);
74 struct isl_token *isl_stream_next_token(struct isl_stream *s);
75 struct isl_token *isl_stream_next_token_on_same_line(struct isl_stream *s);
76 int isl_stream_next_token_is(struct isl_stream *s, int type);
77 void isl_stream_push_token(struct isl_stream *s, struct isl_token *tok);
78 void isl_stream_flush_tokens(struct isl_stream *s);
79 int isl_stream_eat_if_available(struct isl_stream *s, int type);
80 char *isl_stream_read_ident_if_available(struct isl_stream *s);
81 int isl_stream_eat(struct isl_stream *s, int type);
82 int isl_stream_is_empty(struct isl_stream *s);
83 int isl_stream_skip_line(struct isl_stream *s);
85 enum isl_token_type isl_stream_register_keyword(struct isl_stream *s,
86 const char *name);
88 struct isl_obj isl_stream_read_obj(struct isl_stream *s);
89 __isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam);
90 __isl_give isl_set *isl_stream_read_set(struct isl_stream *s, int nparam);
91 __isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(
92 struct isl_stream *s);
94 #if defined(__cplusplus)
96 #endif
98 #endif