hide isl_token internals
[isl.git] / include / isl / stream.h
blob427349967802a62aca08950306e6df20430585c1
1 /*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the MIT 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/aff_type.h>
16 #include <isl/obj.h>
17 #include <isl/val.h>
19 #if defined(__cplusplus)
20 extern "C" {
21 #endif
23 enum isl_token_type { ISL_TOKEN_ERROR = -1,
24 ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
25 ISL_TOKEN_IDENT, ISL_TOKEN_GE,
26 ISL_TOKEN_LE, ISL_TOKEN_GT, ISL_TOKEN_LT,
27 ISL_TOKEN_NE, ISL_TOKEN_EQ_EQ,
28 ISL_TOKEN_LEX_GE, ISL_TOKEN_LEX_LE,
29 ISL_TOKEN_LEX_GT, ISL_TOKEN_LEX_LT,
30 ISL_TOKEN_TO, ISL_TOKEN_AND,
31 ISL_TOKEN_OR, ISL_TOKEN_EXISTS, ISL_TOKEN_NOT,
32 ISL_TOKEN_DEF, ISL_TOKEN_INFTY, ISL_TOKEN_NAN,
33 ISL_TOKEN_MIN, ISL_TOKEN_MAX, ISL_TOKEN_RAT,
34 ISL_TOKEN_TRUE, ISL_TOKEN_FALSE,
35 ISL_TOKEN_CEILD, ISL_TOKEN_FLOORD, ISL_TOKEN_MOD,
36 ISL_TOKEN_STRING,
37 ISL_TOKEN_MAP, ISL_TOKEN_AFF,
38 ISL_TOKEN_CEIL, ISL_TOKEN_FLOOR,
39 ISL_TOKEN_IMPLIES,
40 ISL_TOKEN_LAST };
42 struct isl_token;
44 __isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok);
45 __isl_give char *isl_token_get_str(isl_ctx *ctx, struct isl_token *tok);
46 int isl_token_get_type(struct isl_token *tok);
47 void isl_token_free(struct isl_token *tok);
49 struct isl_stream {
50 struct isl_ctx *ctx;
51 FILE *file;
52 const char *str;
53 int line;
54 int col;
55 int eof;
57 char *buffer;
58 size_t size;
59 size_t len;
60 int c;
61 int un[5];
62 int n_un;
64 struct isl_token *tokens[5];
65 int n_token;
67 struct isl_hash_table *keywords;
68 enum isl_token_type next_type;
71 struct isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file);
72 struct isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str);
73 void isl_stream_free(struct isl_stream *s);
75 void isl_stream_error(struct isl_stream *s, struct isl_token *tok, char *msg);
77 struct isl_token *isl_stream_next_token(struct isl_stream *s);
78 struct isl_token *isl_stream_next_token_on_same_line(struct isl_stream *s);
79 int isl_stream_next_token_is(struct isl_stream *s, int type);
80 void isl_stream_push_token(struct isl_stream *s, struct isl_token *tok);
81 void isl_stream_flush_tokens(struct isl_stream *s);
82 int isl_stream_eat_if_available(struct isl_stream *s, int type);
83 char *isl_stream_read_ident_if_available(struct isl_stream *s);
84 int isl_stream_eat(struct isl_stream *s, int type);
85 int isl_stream_is_empty(struct isl_stream *s);
86 int isl_stream_skip_line(struct isl_stream *s);
88 enum isl_token_type isl_stream_register_keyword(struct isl_stream *s,
89 const char *name);
91 struct isl_obj isl_stream_read_obj(struct isl_stream *s);
92 __isl_give isl_multi_aff *isl_stream_read_multi_aff(struct isl_stream *s);
93 __isl_give isl_map *isl_stream_read_map(struct isl_stream *s);
94 __isl_give isl_set *isl_stream_read_set(struct isl_stream *s);
95 __isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(
96 struct isl_stream *s);
97 __isl_give isl_union_map *isl_stream_read_union_map(struct isl_stream *s);
99 #if defined(__cplusplus)
101 #endif
103 #endif