PC_graph/main.c
2024-12-23 12:27:13 +01:00

44 lines
897 B
C

#include <stdio.h>
#include <stdlib.h>
#include "lex.h"
#include "parser.h"
#include "ps_graph.h"
int main(int argc, char *argv[]) {
struct parser parser;
struct expr_node *node;
FILE *file;
struct graph_range graph;
if (argc < 2) {
printf("Usage: %s <expression>\n", argv[0]);
return 1;
}
node = parser_parse(&parser, argv[1], "x");
if (!node) {
fprintf(stderr, "%s", parser_get_error_text(&parser));
return parser_get_error(&parser);
}
graph.xmin = -10.0;
graph.xmax = 10.0;
graph.ymin = -10.0;
graph.ymax = 10.0;
graph.step = 0.01;
file = fopen("out.ps", "w");
ps_export_graph(file, node, &graph);
fclose(file);
file = fopen("graph.dot", "w");
node_debug_print_gv(node, file);
fclose(file);
node_free(node);
return 0;
}