From eee61ddbba165f772a0e720825dcf6810eaa2648 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 1 Aug 2018 23:25:46 +1200 Subject: Rename lexer and parser, fix compilation warnings --- Makefile | 2 +- common.c | 2 +- common.h | 1 - lex.c | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lex.h | 35 +++++++++ lexer.c | 250 ------------------------------------------------------------ lexer.h | 35 --------- parse.c | 155 +++++++++++++++++++++++++++++++++++++ parse.h | 3 + parser.c | 153 ------------------------------------- parser.h | 3 - simulator.c | 6 +- 12 files changed, 448 insertions(+), 447 deletions(-) create mode 100644 lex.c create mode 100644 lex.h delete mode 100644 lexer.c delete mode 100644 lexer.h create mode 100644 parse.c create mode 100644 parse.h delete mode 100644 parser.c delete mode 100644 parser.h diff --git a/Makefile b/Makefile index 5ba9cc6..3c48b8b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CFLAGS += -std=c99 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -Wall -Wextra all: simulator -simulator: simulator.o common.o gate.o logic.o lexer.o parser.o +simulator: simulator.o common.o gate.o logic.o lex.o parse.o .PHONY: test test: all diff --git a/common.c b/common.c index c0e0af4..fbc9ae2 100644 --- a/common.c +++ b/common.c @@ -7,7 +7,7 @@ indicate_file_area(FILE* fd, size_t line, size_t column, size_t span) { char margin[] = " "; /* FIXME use proper line counting, not this hack */ char buf[1024]; - char *line_start = &buf; + char *line_start = buf; rewind(fd); for (; line; line--) { diff --git a/common.h b/common.h index 5a6977d..069bc81 100644 --- a/common.h +++ b/common.h @@ -5,6 +5,5 @@ #include void indicate_file_area(FILE *fd, size_t line, size_t column, size_t span); -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif diff --git a/lex.c b/lex.c new file mode 100644 index 0000000..dc4a56e --- /dev/null +++ b/lex.c @@ -0,0 +1,250 @@ +#include +#include +#include +#include + +#include "common.h" +#include "lex.h" + +#ifdef emit_error +#warn "Remember to remove the global emit_error +#undef emit_error +#endif /* ifdef emit_error */ + +#define emit_error(...) fprintf(stderr, "Error (%zd,%zd): ", line_number, 1 + column_number);\ + fprintf(stderr, __VA_ARGS__) + +#define BUFFER_SIZE 1024 + +struct keyword { + char *s; /* human-readable name of the token, as written by a user */ + enum TOKEN_TYPE t; +}; + + +/** Static defs **************************************************************/ + +static struct keyword keywords[] = { + {.s = "module", .t = TOK_MODULE }, + {.s = "input" , .t = TOK_INPUT }, + {.s = "expr" , .t = TOK_EXPR }, + {.s = "or" , .t = TOK_OR }, + {.s = "and" , .t = TOK_AND }, + {.s = "xor" , .t = TOK_XOR }, + {.s = "not" , .t = TOK_NOT }, + {.s = NULL } +}; + +static struct keyword token_descriptors[] = { + {.s = "module declaration" , .t = TOK_MODULE }, + {.s = "input declaration" , .t = TOK_INPUT }, + {.s = "expression start" , .t = TOK_EXPR }, + {.s = "colon" , .t = TOK_COLON }, + {.s = "end of line" , .t = TOK_EOL }, + {.s = "binary OR expression" , .t = TOK_OR }, + {.s = "binary AND expression", .t = TOK_AND }, + {.s = "binary XOR expression", .t = TOK_XOR }, + {.s = "unary NOT expression" , .t = TOK_NOT }, + {.s = "identifier" , .t = TOK_IDENT }, + {.s = NULL } +}; + +static char buf[BUFFER_SIZE]; +static FILE* fd; +static size_t line_number = 0; +static size_t column_number = 0; +static ssize_t leading_whitespace_len = 0; +static struct token *tok_start = NULL; +static struct token *tok_cursor = NULL; + + +/** Helpers ******************************************************************/ + +static struct location +get_current_loc(void) { + struct location l; + l.line = line_number; + l.column = column_number + 1; + l.leading_whitespace_len = leading_whitespace_len == -1 ? 0 : leading_whitespace_len; + return l; +} + +static int +expect(const char c) { + if (buf[column_number] != c) { + emit_error("Expected '%c', got '%c'\n", c, buf[column_number]); + return 1; + } + column_number++; + return 0; +} + +static void +eat_whitespace(void) { + while (column_number < BUFFER_SIZE && ( + buf[column_number] == ' ' || + buf[column_number] == '\t')) { + column_number++; + } +} + +static void +add_token(struct token t) { + struct token *last = tok_cursor; + + if (leading_whitespace_len == -1) { + leading_whitespace_len = 0; + } + + tok_cursor = malloc(sizeof(*tok_cursor)); + if (tok_cursor == NULL) { + emit_error("Internal error: malloc failed:"); + perror("malloc"); + /* FIXME return falsey and propagate error up */ + return; + } + + *tok_cursor = t; + + /* tok_start is NULL on first token only */ + if (tok_start == NULL) { + tok_start = tok_cursor; + } else { + last->next = tok_cursor; + } +} + +const char * +get_token_description(enum TOKEN_TYPE t) { + size_t i = 0; + + for (i = 0; i < sizeof(token_descriptors) / sizeof(token_descriptors[0]) && token_descriptors[i].s; i++) { + if (t == token_descriptors[i].t) { + return token_descriptors[i].s; + } + } + + return "(internal error: unknown token)"; +} + +/** Beans ********************************************************************/ + +static struct token +lex_alphanum(void) { + struct token t; + size_t i = 0; + + t.loc = get_current_loc(); + + i = 0; + while (i < MAX_IDENT_LENGTH - 1 && isalnum(buf[column_number + i])) { + t.value[i] = buf[column_number + i]; + i++; + } + t.value[i] = '\0'; + + column_number += i; + t.span = i; + + if (i == 0) { + emit_error("Expected alphanumeric, got '%c'\n", buf[i]); + } + + /* default to identifier, see below for keyword */ + t.type = TOK_IDENT; + + /* figure out if it's a keyword or not */ + for (i = 0; i < sizeof(keywords) / sizeof(struct keyword) && keywords[i].s; i++) { + if (strcmp(t.value, keywords[i].s) == 0) { + t.type = keywords[i].t; + break; + } + } + + return t; +} + +static struct token +lex_eol(void) { + struct token t; + + t.type = TOK_EOL; + t.loc = get_current_loc(); + t.span = 1; + + expect('\n'); + + return t; +} + +static struct token +lex_colon(void) { + struct token t; + + t.type = TOK_COLON; + t.loc = get_current_loc(); + t.span = 1; + + expect(':'); + + return t; +} + +static int +lex_line(void) { + size_t length = strlen(buf); + leading_whitespace_len = -1; + + while (column_number < length && column_number < strlen(buf)) { + switch (buf[column_number]) { + case ':': + add_token(lex_colon()); + break; + case ' ': + case '\t': + eat_whitespace(); + if (leading_whitespace_len == -1) { + leading_whitespace_len = column_number; + } + break; + case '\r': + case '\n': + add_token(lex_eol()); + break; + default: + /* perform more broad checks */ + if (isalnum(buf[column_number])) { + add_token(lex_alphanum()); + } else { + /* nope, still no dice */ + emit_error("Unexpected '%c'\n", buf[column_number]); + return 1; + } + break; + } + } + return 0; +} + +struct token * +lex_file(FILE *fd_local) { + fd = fd_local; + + line_number = 1; + tok_cursor = tok_start = NULL; + + while (NULL != fgets(buf, sizeof(buf), fd)) { + column_number = 0; + if (lex_line()) { + return NULL; + } + line_number++; + } + + /* Terminate linked list */ + if (tok_cursor) { + tok_cursor->next = NULL; + } + + return tok_start; +} diff --git a/lex.h b/lex.h new file mode 100644 index 0000000..3ce15f4 --- /dev/null +++ b/lex.h @@ -0,0 +1,35 @@ +#define MAX_IDENT_LENGTH 128 + +enum TOKEN_TYPE { + /* Keywords */ + TOK_MODULE, + TOK_INPUT, + TOK_EXPR, + TOK_COLON, + TOK_EOL, + TOK_OR, + TOK_AND, + TOK_XOR, + TOK_NOT, + + /* Etc */ + TOK_IDENT +}; + +struct location { + size_t line; + size_t column; + size_t leading_whitespace_len; +}; + +struct token { + enum TOKEN_TYPE type; + struct location loc; + char value[MAX_IDENT_LENGTH]; + size_t span; + struct token *next; +}; + +struct token* lex_file(FILE*); +const char *get_token_description(enum TOKEN_TYPE); + diff --git a/lexer.c b/lexer.c deleted file mode 100644 index 53c64e7..0000000 --- a/lexer.c +++ /dev/null @@ -1,250 +0,0 @@ -#include -#include -#include -#include - -#include "common.h" -#include "lexer.h" - -#ifdef emit_error -#warn "Remember to remove the global emit_error -#undef emit_error -#endif /* ifdef emit_error */ - -#define emit_error(...) fprintf(stderr, "Error (%zd,%zd): ", line_number, 1 + column_number);\ - fprintf(stderr, __VA_ARGS__) - -#define BUFFER_SIZE 1024 - -struct keyword { - char *s; /* human-readable name of the token, as written by a user */ - enum TOKEN_TYPE t; -}; - - -/** Static defs **************************************************************/ - -static struct keyword keywords[] = { - {.s = "module", .t = TOK_MODULE }, - {.s = "input" , .t = TOK_INPUT }, - {.s = "expr" , .t = TOK_EXPR }, - {.s = "or" , .t = TOK_OR }, - {.s = "and" , .t = TOK_AND }, - {.s = "xor" , .t = TOK_XOR }, - {.s = "not" , .t = TOK_NOT }, - {.s = NULL } -}; - -static struct keyword token_descriptors[] = { - {.s = "module declaration" , .t = TOK_MODULE }, - {.s = "input declaration" , .t = TOK_INPUT }, - {.s = "expression start" , .t = TOK_EXPR }, - {.s = "colon" , .t = TOK_COLON }, - {.s = "end of line" , .t = TOK_EOL }, - {.s = "binary OR expression" , .t = TOK_OR }, - {.s = "binary AND expression", .t = TOK_AND }, - {.s = "binary XOR expression", .t = TOK_XOR }, - {.s = "unary NOT expression" , .t = TOK_NOT }, - {.s = "identifier" , .t = TOK_IDENT }, - {.s = NULL } -}; - -static char buf[BUFFER_SIZE]; -static FILE* fd; -static size_t line_number = 0; -static size_t column_number = 0; -static size_t leading_whitespace_len = 0; -static struct token *tok_start = NULL; -static struct token *tok_cursor = NULL; - - -/** Helpers ******************************************************************/ - -static struct location -get_current_loc(void) { - struct location l; - l.line = line_number; - l.column = column_number + 1; - l.leading_whitespace_len = leading_whitespace_len == -1 ? 0 : leading_whitespace_len; - return l; -} - -static int -expect(const char c) { - if (buf[column_number] != c) { - emit_error("Expected '%c', got '%c'\n", c, buf[column_number]); - return 1; - } - column_number++; - return 0; -} - -static void -eat_whitespace(void) { - while (column_number < BUFFER_SIZE && ( - buf[column_number] == ' ' || - buf[column_number] == '\t')) { - column_number++; - } -} - -static void -add_token(struct token t) { - struct token *last = tok_cursor; - - if (leading_whitespace_len == -1) { - leading_whitespace_len = 0; - } - - tok_cursor = malloc(sizeof(*tok_cursor)); - if (tok_cursor == NULL) { - emit_error("Internal error: malloc failed:"); - perror("malloc"); - /* FIXME return falsey and propagate error up */ - return; - } - - *tok_cursor = t; - - /* tok_start is NULL on first token only */ - if (tok_start == NULL) { - tok_start = tok_cursor; - } else { - last->next = tok_cursor; - } -} - -const char * -get_token_description(enum TOKEN_TYPE t) { - size_t i = 0; - - for (i = 0; i < sizeof(token_descriptors) / sizeof(token_descriptors[0]) && token_descriptors[i].s; i++) { - if (t == token_descriptors[i].t) { - return token_descriptors[i].s; - } - } - - return "(internal error: unknown token)"; -} - -/** Beans ********************************************************************/ - -static struct token -lex_alphanum(void) { - struct token t; - size_t i = 0; - - t.loc = get_current_loc(); - - i = 0; - while (i < MAX_IDENT_LENGTH - 1 && isalnum(buf[column_number + i])) { - t.value[i] = buf[column_number + i]; - i++; - } - t.value[i] = '\0'; - - column_number += i; - t.span = i; - - if (i == 0) { - emit_error("Expected alphanumeric, got '%c'\n", buf[i]); - } - - /* default to identifier, see below for keyword */ - t.type = TOK_IDENT; - - /* figure out if it's a keyword or not */ - for (i = 0; i < sizeof(keywords) / sizeof(struct keyword) && keywords[i].s; i++) { - if (strcmp(t.value, keywords[i].s) == 0) { - t.type = keywords[i].t; - break; - } - } - - return t; -} - -static struct token -lex_eol(void) { - struct token t; - - t.type = TOK_EOL; - t.loc = get_current_loc(); - t.span = 1; - - expect('\n'); - - return t; -} - -static struct token -lex_colon(void) { - struct token t; - - t.type = TOK_COLON; - t.loc = get_current_loc(); - t.span = 1; - - expect(':'); - - return t; -} - -static int -lex_line(void) { - size_t length = strlen(buf); - leading_whitespace_len = -1; - - while (column_number < length && column_number < strlen(buf)) { - switch (buf[column_number]) { - case ':': - add_token(lex_colon()); - break; - case ' ': - case '\t': - eat_whitespace(); - if (leading_whitespace_len == -1) { - leading_whitespace_len = column_number; - } - break; - case '\r': - case '\n': - add_token(lex_eol()); - break; - default: - /* perform more broad checks */ - if (isalnum(buf[column_number])) { - add_token(lex_alphanum()); - } else { - /* nope, still no dice */ - emit_error("Unexpected '%c'\n", buf[column_number]); - return 1; - } - break; - } - } - return 0; -} - -struct token * -lex_file(FILE *fd_local) { - fd = fd_local; - - line_number = 1; - tok_cursor = tok_start = NULL; - - while (NULL != fgets(buf, sizeof(buf), fd)) { - column_number = 0; - if (lex_line()) { - return NULL; - } - line_number++; - } - - /* Terminate linked list */ - if (tok_cursor) { - tok_cursor->next = NULL; - } - - return tok_start; -} diff --git a/lexer.h b/lexer.h deleted file mode 100644 index 3ce15f4..0000000 --- a/lexer.h +++ /dev/null @@ -1,35 +0,0 @@ -#define MAX_IDENT_LENGTH 128 - -enum TOKEN_TYPE { - /* Keywords */ - TOK_MODULE, - TOK_INPUT, - TOK_EXPR, - TOK_COLON, - TOK_EOL, - TOK_OR, - TOK_AND, - TOK_XOR, - TOK_NOT, - - /* Etc */ - TOK_IDENT -}; - -struct location { - size_t line; - size_t column; - size_t leading_whitespace_len; -}; - -struct token { - enum TOKEN_TYPE type; - struct location loc; - char value[MAX_IDENT_LENGTH]; - size_t span; - struct token *next; -}; - -struct token* lex_file(FILE*); -const char *get_token_description(enum TOKEN_TYPE); - diff --git a/parse.c b/parse.c new file mode 100644 index 0000000..668a700 --- /dev/null +++ b/parse.c @@ -0,0 +1,155 @@ +#include +#include +#include +#include + +#include "lex.h" +#include "common.h" +#include "error.h" +#include "logic.h" +#include "gate.h" + + +static FILE* fd; +static struct token *cursor; +static const char *filename; + +#define EXPECT_AND_DISCARD_CRITICAL(type)\ + do { \ + EXPECT_CRITICAL(type) \ + kerchunk(); \ + } while (0); + +#define EXPECT_CRITICAL(type)\ + do { \ + if (expect(type)) { \ + return 1; \ + } \ + } while (0); + +/* FIXME change to varadic fuction */ +#define emit(...) \ + if (cursor) { \ + fprintf(stderr, "%s at (%zd,%zd): ", filename, cursor->loc.line, cursor->loc.column); \ + fprintf(stderr, __VA_ARGS__); \ + indicate_file_area(fd, cursor->loc.line, cursor->loc.column - cursor->loc.leading_whitespace_len, cursor->span); \ + } else { \ + fprintf(stderr, "%s: ", filename); \ + fprintf(stderr, __VA_ARGS__); \ + } + + +//static struct op_lookup uop_handlers[] = { +// {.str = "not", .handler = logic_nand}, +//}; +// +//static struct op_lookup bop_handlers[] = { +// {.str = "and", .handler = logic_and}, +// {.str = "or", .handler = logic_or}, +// {.str = "nand", .handler = logic_nand}, +// {.str = "nor", .handler = logic_nor}, +// {.str = "xor", .handler = logic_xor} +//}; +// +//static struct tok_lookup tok_handlers[] = { +// {.str = "input", .handler = parse_input}, +// {.str = "module", .handler = parse_module}, +// {.str = "expr", .handler = parse_expr} +//}; + +static int +expect(enum TOKEN_TYPE e) { + const char *expected_desc = "(internal error)"; + const char *observed_desc = "(internal error)"; + + if (!cursor || cursor->type != e) { + expected_desc = get_token_description(e); + if (cursor) { + observed_desc = get_token_description(cursor->type); + } else { + observed_desc = "end of file"; + } + emit("Error: Expected %s, got %s\n", expected_desc, observed_desc); + return 1; + } + + return 0; +} + +static void +kerchunk() { + if (cursor) { + cursor = cursor->next; + } +} + +int +parse_expr(void) { + /* FIXME write wrapper to exit on fail */ + EXPECT_AND_DISCARD_CRITICAL(TOK_EXPR); + EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME do something, don't discard */ + EXPECT_AND_DISCARD_CRITICAL(TOK_COLON); + + switch(cursor->type) { + /* FIXME do some things */ + case TOK_OR : /* fallthrough */ + case TOK_AND: /* fallthrough */ + case TOK_XOR: + kerchunk(); + EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ + EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ + break; + case TOK_NOT: + kerchunk(); + EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ + break; + default: + emit("Error: Unexpected %s\n", get_token_description(cursor->type)); + return 1; + } + return 0; +} + + +int +parse(const char *fname, FILE *f, struct token *t) { + fd = f; + filename = fname; + cursor = t; + + /* Eat leading EOL tokens */ + while (cursor && cursor->type == TOK_EOL) { + kerchunk(); + } + + EXPECT_AND_DISCARD_CRITICAL(TOK_MODULE); + + EXPECT_CRITICAL(TOK_IDENT); + emit("Debug: module is named %s\n", cursor->value); + /* FIXME do something */ + kerchunk(); + + EXPECT_AND_DISCARD_CRITICAL(TOK_EOL); + + while (cursor) { + switch(cursor->type) { + case TOK_EOL: + kerchunk(); + break; + case TOK_INPUT: + kerchunk(); + expect(TOK_IDENT); + emit("Debug: input is named %s\n", cursor->value); + /* FIXME do something */ + kerchunk(); + break; + case TOK_EXPR: + parse_expr(); + break; + default: + emit("Error: Unexpected %s\n", get_token_description(cursor->type)); + return 1; + } + } + return 0; +} diff --git a/parse.h b/parse.h new file mode 100644 index 0000000..95a1fa8 --- /dev/null +++ b/parse.h @@ -0,0 +1,3 @@ +#include + +int parse(const char*, FILE*, struct token *); diff --git a/parser.c b/parser.c deleted file mode 100644 index 88e7a1e..0000000 --- a/parser.c +++ /dev/null @@ -1,153 +0,0 @@ -#include -#include -#include -#include - -#include "lexer.h" -#include "common.h" -#include "error.h" -#include "logic.h" -#include "gate.h" - - -static FILE* fd; -static struct token *cursor; -static const char *filename; - -#define EXPECT_AND_DISCARD_CRITICAL(type)\ - do { \ - EXPECT_CRITICAL(type) \ - kerchunk(); \ - } while (0); - -#define EXPECT_CRITICAL(type)\ - do { \ - if (expect(type)) { \ - return 1; \ - } \ - } while (0); - -/* FIXME change to varadic fuction */ -#define emit(...) \ - if (cursor) { \ - fprintf(stderr, "%s at (%zd,%zd): ", filename, cursor->loc.line, cursor->loc.column); \ - fprintf(stderr, __VA_ARGS__); \ - indicate_file_area(fd, cursor->loc.line, cursor->loc.column - cursor->loc.leading_whitespace_len, cursor->span); \ - } else { \ - fprintf(stderr, "%s: ", filename); \ - fprintf(stderr, __VA_ARGS__); \ - } - - -//static struct op_lookup uop_handlers[] = { -// {.str = "not", .handler = logic_nand}, -//}; -// -//static struct op_lookup bop_handlers[] = { -// {.str = "and", .handler = logic_and}, -// {.str = "or", .handler = logic_or}, -// {.str = "nand", .handler = logic_nand}, -// {.str = "nor", .handler = logic_nor}, -// {.str = "xor", .handler = logic_xor} -//}; -// -//static struct tok_lookup tok_handlers[] = { -// {.str = "input", .handler = parse_input}, -// {.str = "module", .handler = parse_module}, -// {.str = "expr", .handler = parse_expr} -//}; - -static int -expect(enum TOKEN_TYPE e) { - char *expected_desc = "(internal error)"; - char *observed_desc = "(internal error)"; - - if (!cursor || cursor->type != e) { - expected_desc = get_token_description(e); - if (cursor) { - observed_desc = get_token_description(cursor->type); - } else { - observed_desc = "end of file"; - } - emit("Error: Expected %s, got %s\n", expected_desc, observed_desc); - return 1; - } - - return 0; -} - -static void -kerchunk() { - if (cursor) { - cursor = cursor->next; - } -} - -int -parse_expr(void) { - /* FIXME write wrapper to exit on fail */ - EXPECT_AND_DISCARD_CRITICAL(TOK_EXPR); - EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME do something, don't discard */ - EXPECT_AND_DISCARD_CRITICAL(TOK_COLON); - - switch(cursor->type) { - /* FIXME do some things */ - case TOK_OR : /* fallthrough */ - case TOK_AND: /* fallthrough */ - case TOK_XOR: - kerchunk(); - EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ - EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ - break; - case TOK_NOT: - kerchunk(); - EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */ - break; - default: - emit("Error: Unexpected %s\n", get_token_description(cursor->type)); - } -} - - -int -parse(const char *fname, FILE *f, struct token *t) { - fd = f; - filename = fname; - cursor = t; - - /* Eat leading EOL tokens */ - while (cursor && cursor->type == TOK_EOL) { - kerchunk(); - } - - EXPECT_AND_DISCARD_CRITICAL(TOK_MODULE); - - EXPECT_CRITICAL(TOK_IDENT); - emit("Debug: module is named %s\n", cursor->value); - /* FIXME do something */ - kerchunk(); - - EXPECT_AND_DISCARD_CRITICAL(TOK_EOL); - - while (cursor) { - switch(cursor->type) { - case TOK_EOL: - kerchunk(); - break; - case TOK_INPUT: - kerchunk(); - expect(TOK_IDENT); - emit("Debug: input is named %s\n", cursor->value); - /* FIXME do something */ - kerchunk(); - break; - case TOK_EXPR: - parse_expr(); - break; - default: - emit("Error: Unexpected %s\n", get_token_description(cursor->type)); - return 1; - } - } - return 0; -} diff --git a/parser.h b/parser.h deleted file mode 100644 index 95a1fa8..0000000 --- a/parser.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -int parse(const char*, FILE*, struct token *); diff --git a/simulator.c b/simulator.c index 1b33aec..b9f69bd 100644 --- a/simulator.c +++ b/simulator.c @@ -3,8 +3,8 @@ //#include "gate.h" //#include "logic.h" -#include "lexer.h" -#include "parser.h" +#include "lex.h" +#include "parse.h" int main(int argc, char **argv) { FILE *fd = NULL; @@ -31,5 +31,5 @@ int main(int argc, char **argv) { // gate_update(); // gate_dump(); - return 0; + return p; } -- cgit v1.1