mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
Some new types, and lexer changes
This commit is contained in:
parent
fe6e142f85
commit
c436c3a6c6
4 changed files with 31 additions and 14 deletions
BIN
gmqcc
BIN
gmqcc
Binary file not shown.
33
gmqcc.h
33
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 *);
|
||||
|
|
11
lex.c
11
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) {
|
||||
|
|
1
parse.c
1
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) {
|
||||
|
|
Loading…
Reference in a new issue