hlc

High level language for lli
Log | Files | Refs

commit a33a3c4f16a03b5eceefa005fc56491e43488a97
parent 9cca5ce74afac3b0967f04dbff6acdfa07d3af4b
Author: thing1 <l.standen@posteo.com>
Date:   Sun, 12 Oct 2025 14:20:44 +0100

updated error messages and cleaned up makefile

Diffstat:
MMakefile | 7++++---
Mlex.h | 4+++-
Mlex_names.c | 7++++---
3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,6 +1,7 @@ CC=c89 -CFLAGS=-ggdb -pedantic -fsanitize=address -Wall -Wextra -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112L -#CFLAGS=-ggdb -pedantic -Wall -Wextra +CFLAGS=-ggdb -pedantic -fsanitize=address -Wall -Wextra +CPPFLAGS=-D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112L + SRC = lex.c lex_names.c main.c OBJ = ${SRC:.c=.o} @@ -10,7 +11,7 @@ all: hlc spec: spec.md smu spec.md > spec.html .c.o: - ${CC} -c ${CFLAGS} $< + ${CC} -c ${CFLAGS} ${CPPFLAGS} $< hlc: ${OBJ} ${CC} -o $@ ${OBJ} ${CFLAGS} diff --git a/lex.h b/lex.h @@ -40,12 +40,14 @@ typedef struct lex_val { extern char *input, *startpos, *endpos; extern lex_val *(*nextfn)(void); +lex_val *lex_type(void); +lex_val *lex_number(void); +lex_val *lex_assign(void); lex_val *lex_name(void); lex_val *lex_value(void); lex_val *lex_sym(void); lex_val *lex_comma(void); lex_val *lex_semi(void); -lex_val *lex_type(void); int get_err_len(void); int get_line_num(char *); diff --git a/lex_names.c b/lex_names.c @@ -5,11 +5,12 @@ #define is(f) if (func == f) char *get_name(lex_val *(*func)(void)) { - is(lex_name) return "name"; is(lex_type) return "type"; - is(lex_value) return "value"; + is(lex_comma) return "comma"; is(lex_semi) return ";"; + is(lex_assign) return "="; is(lex_sym) return "symbol"; - is(lex_comma) return "comma"; + is(lex_number) return "[0-9]+"; + is(lex_name) return "name"; return NULL; }