PC_graph/main.c
2024-11-12 11:38:26 +01:00

40 lines
768 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 lexer *lex;
struct expr_node *node;
if (argc < 2) {
printf("Usage: %s <expression>\n", argv[0]);
return 1;
}
lex = lex_create(argv[1]);
node = parse_expression(lex);
lex_free(lex);
if (node) {
FILE *file;
struct graph_range graph;
graph.xmin = -20.0;
graph.xmax = 20.0;
graph.ymin = -20.0;
graph.ymax = 20.0;
graph.step = 0.01;
file = fopen("out.ps", "w");
ps_export_graph(file, node, &graph);
fclose(file);
}
node_free(node);
return 0;
}