]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Cleaups and README
authorDale Weiler <killfieldengine@gmail.com>
Tue, 10 Apr 2012 00:18:49 +0000 (20:18 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Tue, 10 Apr 2012 00:18:49 +0000 (20:18 -0400)
Makefile
README
cpp.c [deleted file]
gmqcc.h
lex.c
parse.c
typedef.c

index 7690c66aa399738c3c834196a12a7417101d67c5..500245268f5133760fa04355c258ab4a089c68cf 100644 (file)
--- 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 5ba37c2ea9268bae65fbeb43f7b49ae11f36ee27..4ecb4db06f5fd6bb23d7dd4925f5c81718f05222 100644 (file)
--- 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 (file)
index 62a9819..0000000
--- a/cpp.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <limits.h>
-#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 0aecd5c489f872973033e69efe2617e5d7be4807..d8dafe2d337184721d6767387df8dd3600500450 100644 (file)
--- 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 48d01c49db4adee40308f55d5a11172e166e7436..9296158fd196cd5390e47fb60d7e1d096a936e7f 100644 (file)
--- 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 4ec25695aebc4de1cd703d489365123698c62eda..1ae0a8c1f315e39a80006f0134ce8d1151220183 100644 (file)
--- a/parse.c
+++ b/parse.c
 #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
index 6acfa85758c353ab0da07a97706677ca151fce19..5e72cf8785f01c7400e49dbd9d636ba70f8cf88b 100644 (file)
--- 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);
 }
-       
-               
-