summaryrefslogtreecommitdiff
path: root/simulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'simulator.c')
-rw-r--r--simulator.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/simulator.c b/simulator.c
index 4f99c4f..bbea893 100644
--- a/simulator.c
+++ b/simulator.c
@@ -7,13 +7,24 @@
#include "parser.h"
int main(int argc, char **argv) {
- (void)argc;
- (void)argv;
+ FILE *fd = NULL;
+
+ if (argc != 2) {
+ fprintf(stderr, "Syntax: %s file.hence\n", argv[0]);
+ return 1;
+ }
// gate_init();
- struct token *tok = lex_file(stdin);
- int p = parse(tok);
+ fd = fopen(argv[1], "r");
+
+ if (!fd) {
+ perror("fopen");
+ return 1;
+ }
+
+ struct token *tok = lex_file(fd);
+ int p = parse(fd, tok);
// gate_set_input("a", LOGIC_LOW);
// gate_set_input("b", LOGIC_LOW);