From: Dale Weiler Date: Mon, 9 Apr 2012 11:45:20 +0000 (-0400) Subject: Some new types, and lexer changes X-Git-Tag: 0.1-rc1~713 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c436c3a6c66fa51ff52ac8740bcc82c58f4afa30;p=xonotic%2Fgmqcc.git Some new types, and lexer changes --- diff --git a/gmqcc b/gmqcc index 1c50928..f34c8a6 100755 Binary files a/gmqcc and b/gmqcc differ diff --git a/gmqcc.h b/gmqcc.h index 162eed4..091725b 100644 --- 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 /* 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 1cb8d0c..e94252d 100644 --- a/lex.c +++ b/lex.c @@ -30,7 +30,16 @@ 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 a43981f..7743360 100644 --- a/parse.c +++ b/parse.c @@ -22,6 +22,7 @@ */ #include #include "gmqcc.h" + int parse(struct lex_file *file) { int token = 0; while ((token = lex_token(file)) != ERROR_LEX && file->length >= 0) {