]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Some new types, and lexer changes
authorDale Weiler <killfieldengine@gmail.com>
Mon, 9 Apr 2012 11:45:20 +0000 (07:45 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Mon, 9 Apr 2012 11:45:20 +0000 (07:45 -0400)
gmqcc
gmqcc.h
lex.c
parse.c

diff --git a/gmqcc b/gmqcc
index 1c50928f3d25825755ac41cb5c218900a0f59668..f34c8a62d65e4d80880e4e4ec6ad0dde46d5cf60 100755 (executable)
Binary files a/gmqcc and b/gmqcc differ
diff --git a/gmqcc.h b/gmqcc.h
index 162eed48be74cc43a6d1ddaf7a58c49b6fadb5cd..091725b16807df9396c2f4a309f69b4b9fdeb580 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -20,8 +20,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#ifndef DPQCC_HDR
-#define DPQCC_HDR
+#ifndef GMQCC_HDR
+#define GMQCC_HDR
 #include <stdio.h>
 
 /* The types supported by the language */
@@ -155,23 +155,30 @@ struct lex_file {
 #define TOKEN_CONTINUE 5
 #define TOKEN_RETURN   6
 #define TOKEN_GOTO     7
-#define TOKEN_FOR      8
+#define TOKEN_FOR      8   // extension
+#define TOKEN_INT      9   // extension
+#define TOKEN_BOOL     10  // extension
+#define TOKEN_VOID     11
+#define TOKEN_STRING   12
+#define TOKEN_FLOAT    13
+#define TOKEN_VECTOR   14
+#define TOKEN_ENTITY   15
 
 /*
  * Lexer state constants, these are numbers for where exactly in
  * the lexing the lexer is at. Or where it decided to stop if a lexer
  * error occurs.
  */
-#define LEX_COMMENT  128 /* higher than ascii */
-#define LEX_CHRLIT   129
-#define LEX_STRLIT   130
-#define LEX_IDENT    131
-#define LEX_DO       132
-#define LEX_ELSE     133
-#define LEX_IF       134
-#define LEX_WHILE    135
-#define LEX_INCLUDE  136
-#define LEX_DEFINE   137
+#define LEX_COMMENT    128 /* higher than ascii */
+#define LEX_CHRLIT     129
+#define LEX_STRLIT     130
+#define LEX_IDENT      131
+#define LEX_DO         132
+#define LEX_ELSE       133
+#define LEX_IF         134
+#define LEX_WHILE      135
+#define LEX_INCLUDE    136
+#define LEX_DEFINE     137
 
 int              lex_token(struct lex_file *);
 void             lex_reset(struct lex_file *);
diff --git a/lex.c b/lex.c
index 1cb8d0c9cff314953b3978530ee35f5ebbdc578c..e94252de83f23803ac30b08edaea9d45d78d2d56 100644 (file)
--- a/lex.c
+++ b/lex.c
 static const char *const lex_keywords[] = {
        "do",    "else",     "if",     "while",
        "break", "continue", "return", "goto",
-       "for"
+       "for",
+       
+       /* types */
+       "int",
+       "bool",
+       "void",
+       "string",
+       "float",
+       "vector",
+       "entity"
 };
 
 struct lex_file *lex_open(const char *name) {
diff --git a/parse.c b/parse.c
index a43981f15a618facacd653c5200ca3b07be82f58..7743360fe6f23e68696fba1d2b8aa449a787c891 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -22,6 +22,7 @@
  */
 #include <limits.h>
 #include "gmqcc.h"
+
 int parse(struct lex_file *file) {
        int     token = 0;
        while ((token = lex_token(file)) != ERROR_LEX && file->length >= 0) {