Polly 19.0.0git
cat.c
Go to the documentation of this file.
1#include <assert.h>
2#include <isl/obj.h>
3#include <isl/printer.h>
4#include <isl/stream.h>
5#include <isl/options.h>
6
8 {"isl", ISL_FORMAT_ISL},
9 {"omega", ISL_FORMAT_OMEGA},
10 {"polylib", ISL_FORMAT_POLYLIB},
11 {"ext-polylib", ISL_FORMAT_EXT_POLYLIB},
12 {"latex", ISL_FORMAT_LATEX},
13 {"C", ISL_FORMAT_C},
14 {0}
15};
16
18 { "block", ISL_YAML_STYLE_BLOCK },
19 { "flow", ISL_YAML_STYLE_FLOW },
20 { 0 }
21};
22
25 unsigned format;
26 unsigned yaml_style;
27};
28
29ISL_ARGS_START(struct cat_options, cat_options_args)
30ISL_ARG_CHILD(struct cat_options, isl, "isl", &isl_options_args, "isl options")
31ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \
32 cat_format, ISL_FORMAT_ISL, "output format")
33ISL_ARG_CHOICE(struct cat_options, yaml_style, 0, "yaml-style", \
34 cat_yaml_style, ISL_YAML_STYLE_BLOCK, "output YAML style")
36
37ISL_ARG_DEF(cat_options, struct cat_options, cat_options_args)
38
39int main(int argc, char **argv)
40{
41 struct isl_ctx *ctx;
42 isl_stream *s;
43 struct isl_obj obj;
44 struct cat_options *options;
46
47 options = cat_options_new_with_defaults();
49 argc = cat_options_parse(options, argc, argv, ISL_ARG_ALL);
50
51 ctx = isl_ctx_alloc_with_options(&cat_options_args, options);
52
53 s = isl_stream_new_file(ctx, stdin);
56
57 p = isl_printer_to_file(ctx, stdout);
59 p = isl_printer_set_yaml_style(p, options->yaml_style);
60 p = obj.type->print(p, obj.v);
63
64 obj.type->free(obj.v);
65
66 isl_ctx_free(ctx);
67
68 return 0;
69}
#define ISL_ARG_DEF(prefix, st, args)
Definition: arg.h:302
#define ISL_ARG_CHOICE(st, f, s, l, c, d, h)
Definition: arg.h:134
#define ISL_ARG_CHILD(st, f, l, c, h)
Definition: arg.h:264
#define ISL_ARG_ALL
Definition: arg.h:288
#define ISL_ARGS_START(s, name)
Definition: arg.h:113
#define ISL_ARGS_END
Definition: arg.h:117
struct isl_arg_choice cat_yaml_style[]
Definition: cat.c:17
struct isl_arg_choice cat_format[]
Definition: cat.c:7
isl_ctx * isl_ctx_alloc_with_options(struct isl_args *args, __isl_take void *opt)
void isl_ctx_free(isl_ctx *ctx)
Definition: isl_ctx.c:288
const char * p
Definition: isl_test.c:8643
const char * obj
Definition: isl_test.c:3316
#define assert(exp)
These are automatically generated checked C++ bindings for isl.
Definition: ISLTools.h:45
#define ISL_FORMAT_POLYLIB
Definition: printer.h:28
#define ISL_YAML_STYLE_FLOW
Definition: printer.h:39
__isl_null isl_printer * isl_printer_free(__isl_take isl_printer *printer)
Definition: isl_printer.c:269
#define ISL_FORMAT_C
Definition: printer.h:31
#define ISL_FORMAT_LATEX
Definition: printer.h:32
__isl_give isl_printer * isl_printer_to_file(isl_ctx *ctx, FILE *file)
Definition: isl_printer.c:217
#define ISL_YAML_STYLE_BLOCK
Definition: printer.h:38
#define ISL_FORMAT_ISL
Definition: printer.h:27
__isl_give isl_printer * isl_printer_set_yaml_style(__isl_take isl_printer *p, int yaml_style)
Definition: isl_printer.c:464
__isl_give isl_printer * isl_printer_end_line(__isl_take isl_printer *p)
Definition: isl_printer.c:667
__isl_give isl_printer * isl_printer_set_output_format(__isl_take isl_printer *p, int output_format)
Definition: isl_printer.c:373
#define ISL_FORMAT_OMEGA
Definition: printer.h:30
#define ISL_FORMAT_EXT_POLYLIB
Definition: printer.h:33
struct isl_obj isl_stream_read_obj(__isl_keep isl_stream *s)
Definition: isl_input.c:3135
__isl_give isl_stream * isl_stream_new_file(isl_ctx *ctx, FILE *file)
Definition: isl_stream.c:219
void isl_stream_free(__isl_take isl_stream *s)
Definition: isl_stream.c:805
unsigned yaml_style
Definition: cat.c:26
unsigned format
Definition: cat.c:25
struct isl_options * isl
Definition: cat.c:24
Definition: obj.h:48
unsigned format
Definition: pip.c:44