From: Dale Weiler Date: Tue, 10 Apr 2012 00:18:49 +0000 (-0400) Subject: Cleaups and README X-Git-Tag: 0.1-rc1~705 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a440c1410bad2a06b6a9385094a3dae0142f9395;p=xonotic%2Fgmqcc.git Cleaups and README --- diff --git a/Makefile b/Makefile index 7690c66..5002452 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc CFLAGS = -O3 -Wall -OBJ = main.o lex.o error.o parse.o cpp.o typedef.o +OBJ = main.o lex.o error.o parse.o typedef.o %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) diff --git a/README b/README index 5ba37c2..4ecb4db 100644 --- a/README +++ b/README @@ -25,6 +25,11 @@ parse.c This is the parser which goes over all tokens and generates a parse tree (not currently, but will) and check for syntax correctness. +typedef.c + This is the typedef system, this is a seperate file because it's a lot more + complicated than it sounds. This handles all typedefs, and even recrusive + typedefs. + README This is the file you're currently reading diff --git a/cpp.c b/cpp.c deleted file mode 100644 index 62a9819..0000000 --- a/cpp.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "gmqcc.h" - -/* - * Returns the next token back to the caller - * which is what we parse for the preprocessor here. - */ -int cpp(struct lex_file *file) { - /* no return */ -} diff --git a/gmqcc.h b/gmqcc.h index 0aecd5c..d8dafe2 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -196,9 +196,6 @@ struct parsenode { int type; /* some token */ }; -/* cpp.c */ -int cpp (struct lex_file *); - /* typedef.c */ typedef struct typedef_node_t { char *name; /* name of actual type */ diff --git a/lex.c b/lex.c index 48d01c4..9296158 100644 --- a/lex.c +++ b/lex.c @@ -249,7 +249,7 @@ static int lex_skipcmt(struct lex_file *file) { lex_addch(ch, file); while ((ch = lex_getch(file)) != '*') { if (ch == EOF) - return error(ERROR_LEX, "malformatted comment", " "); + return error(ERROR_LEX, "malformatted comment at line %d", file->line); else lex_addch(ch, file); } diff --git a/parse.c b/parse.c index 4ec2569..1ae0a8c 100644 --- a/parse.c +++ b/parse.c @@ -39,39 +39,37 @@ #define PARSE_TYPE_RETURN 6 #define PARSE_TYPE_GOTO 7 #define PARSE_TYPE_FOR 8 // extension -#define PARSE_TYPE_INT 9 // extension -#define PARSE_TYPE_BOOL 10 // extension -#define PARSE_TYPE_VOID 11 -#define PARSE_TYPE_STRING 12 -#define PARSE_TYPE_FLOAT 13 -#define PARSE_TYPE_VECTOR 14 -#define PARSE_TYPE_ENTITY 15 -#define PARSE_TYPE_LAND 16 -#define PARSE_TYPE_LOR 17 -#define PARSE_TYPE_LTEQ 18 -#define PARSE_TYPE_GTEQ 19 -#define PARSE_TYPE_EQEQ 20 -#define PARSE_TYPE_LNEQ 21 -#define PARSE_TYPE_COMMA 22 -#define PARSE_TYPE_LNOT 23 -#define PARSE_TYPE_STAR 24 -#define PARSE_TYPE_DIVIDE 25 -#define PARSE_TYPE_LPARTH 26 -#define PARSE_TYPE_RPARTH 27 -#define PARSE_TYPE_MINUS 28 -#define PARSE_TYPE_ADD 29 -#define PARSE_TYPE_EQUAL 30 -#define PARSE_TYPE_LSS 31 // left subscript -#define PARSE_TYPE_RSS 32 -#define PARSE_TYPE_LBS 33 // left bracket scope -#define PARSE_TYPE_RBS 34 // right bracket scope -#define PARSE_TYPE_ELIP 35 // ... -#define PARSE_TYPE_DOT 36 -#define PARSE_TYPE_LT 37 -#define PARSE_TYPE_GT 38 -#define PARSE_TYPE_BAND 39 -#define PARSE_TYPE_BOR 40 -#define PARSE_TYPE_DONE 41 // finished statement +#define PARSE_TYPE_VOID 9 +#define PARSE_TYPE_STRING 10 +#define PARSE_TYPE_FLOAT 11 +#define PARSE_TYPE_VECTOR 12 +#define PARSE_TYPE_ENTITY 13 +#define PARSE_TYPE_LAND 14 +#define PARSE_TYPE_LOR 15 +#define PARSE_TYPE_LTEQ 16 +#define PARSE_TYPE_GTEQ 17 +#define PARSE_TYPE_EQEQ 18 +#define PARSE_TYPE_LNEQ 19 +#define PARSE_TYPE_COMMA 20 +#define PARSE_TYPE_LNOT 21 +#define PARSE_TYPE_STAR 22 +#define PARSE_TYPE_DIVIDE 23 +#define PARSE_TYPE_LPARTH 24 +#define PARSE_TYPE_RPARTH 25 +#define PARSE_TYPE_MINUS 26 +#define PARSE_TYPE_ADD 27 +#define PARSE_TYPE_EQUAL 28 +#define PARSE_TYPE_LSS 29 // left subscript +#define PARSE_TYPE_RSS 30 +#define PARSE_TYPE_LBS 31 // left bracket scope +#define PARSE_TYPE_RBS 32 // right bracket scope +#define PARSE_TYPE_ELIP 33 // ... +#define PARSE_TYPE_DOT 34 +#define PARSE_TYPE_LT 35 +#define PARSE_TYPE_GT 36 +#define PARSE_TYPE_BAND 37 +#define PARSE_TYPE_BOR 38 +#define PARSE_TYPE_DONE 39 // finished statement /* * Adds a parse type to the parse tree, this is where all the hard @@ -119,9 +117,7 @@ void parse_debug(struct parsenode *tree) { case PARSE_TYPE_ELIP: STORE("DECLTYPE: VALIST\n"); case PARSE_TYPE_ENTITY: STORE("DECLTYPE: ENTITY\n"); - case PARSE_TYPE_INT: STORE("DECLTYPE: INT\n"); case PARSE_TYPE_FLOAT: STORE("DECLTYPE: FLOAT\n"); - case PARSE_TYPE_BOOL: STORE("DECLTYPE: BOOL\n"); case PARSE_TYPE_GT: STORE("TEST: GREATER THAN\n"); case PARSE_TYPE_LT: STORE("TEST: LESS THAN\n"); @@ -237,22 +233,11 @@ int parse(struct lex_file *file) { case TOKEN_CONTINUE: PARSE_TODO(PARSE_TYPE_CONTINUE); case TOKEN_RETURN: PARSE_TODO(PARSE_TYPE_RETURN); case TOKEN_GOTO: PARSE_TODO(PARSE_TYPE_GOTO); - case TOKEN_INT: PARSE_TODO(PARSE_TYPE_INT); case TOKEN_VOID: PARSE_TODO(PARSE_TYPE_VOID); case TOKEN_STRING: PARSE_TODO(PARSE_TYPE_STRING); case TOKEN_FLOAT: PARSE_TODO(PARSE_TYPE_FLOAT); case TOKEN_VECTOR: PARSE_TODO(PARSE_TYPE_VECTOR); case TOKEN_ENTITY: PARSE_TODO(PARSE_TYPE_ENTITY); - - /* TODO: Preprocessor */ - case '#': - token = lex_token(file); - token = lex_token(file); - token = lex_token(file); - token = lex_token(file); - token = lex_token(file); - token = lex_token(file); - break; /* * From here down is all language punctuation: There is no diff --git a/typedef.c b/typedef.c index 6acfa85..5e72cf8 100644 --- a/typedef.c +++ b/typedef.c @@ -187,6 +187,3 @@ int typedef_add(const char *from, const char *to) { } return error(ERROR_PARSE, "cannot typedef %s (not a type)\n", from); } - - -