diff options
author | David Phillips <david@sighup.nz> | 2018-08-01 23:25:46 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-08-01 23:25:46 +1200 |
commit | eee61ddbba165f772a0e720825dcf6810eaa2648 (patch) | |
tree | c9b238e386dfcf19f0c3244998efa8d2dc6d0a82 | |
parent | e22abc4eaf4f1446c6ac31e4b709cb5206d4fe3b (diff) | |
download | hence-eee61ddbba165f772a0e720825dcf6810eaa2648.tar.xz |
Rename lexer and parser, fix compilation warnings
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | common.c | 2 | ||||
-rw-r--r-- | common.h | 1 | ||||
-rw-r--r-- | lex.c (renamed from lexer.c) | 4 | ||||
-rw-r--r-- | lex.h (renamed from lexer.h) | 0 | ||||
-rw-r--r-- | parse.c (renamed from parser.c) | 8 | ||||
-rw-r--r-- | parse.h (renamed from parser.h) | 0 | ||||
-rw-r--r-- | simulator.c | 6 |
8 files changed, 12 insertions, 11 deletions
@@ -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 @@ -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--) { @@ -5,6 +5,5 @@ #include <stddef.h> void indicate_file_area(FILE *fd, size_t line, size_t column, size_t span); -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif @@ -4,7 +4,7 @@ #include <string.h> #include "common.h" -#include "lexer.h" +#include "lex.h" #ifdef emit_error #warn "Remember to remove the global emit_error @@ -53,7 +53,7 @@ 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 ssize_t leading_whitespace_len = 0; static struct token *tok_start = NULL; static struct token *tok_cursor = NULL; @@ -3,7 +3,7 @@ #include <stdlib.h> #include <string.h> -#include "lexer.h" +#include "lex.h" #include "common.h" #include "error.h" #include "logic.h" @@ -59,8 +59,8 @@ static const char *filename; static int expect(enum TOKEN_TYPE e) { - char *expected_desc = "(internal error)"; - char *observed_desc = "(internal error)"; + const char *expected_desc = "(internal error)"; + const char *observed_desc = "(internal error)"; if (!cursor || cursor->type != e) { expected_desc = get_token_description(e); @@ -105,7 +105,9 @@ parse_expr(void) { break; default: emit("Error: Unexpected %s\n", get_token_description(cursor->type)); + return 1; } + return 0; } 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; } |