]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
Merging master and adopting its main.c
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index ebbe1880c01f330ecb24fdf0ec81827f00000c55..3f1aa76c0f5c312273a1d17a8c33fe06996e8627 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -464,8 +464,6 @@ int lex_do(lex_file *lex)
                case '[':
                case ']':
 
-               case ',':
-
                case '#':
 
                        return (lex->tok->ttype = ch);
@@ -491,12 +489,22 @@ int lex_do(lex_file *lex)
                        case '|':
                        case '^':
                        case '~':
+                       case ',':
                                return ch;
                        default:
                                break;
                }
        }
 
+       if (ch == ',') {
+           if (!lex_tokench(lex, ch) ||
+               !lex_endtoken(lex))
+           {
+               return (lex->tok->ttype = TOKEN_FATAL);
+           }
+           return (lex->tok->ttype = TOKEN_OPERATOR);
+       }
+
        if (ch == '+' || ch == '-' || /* ++, --, +=, -=  and -> as well! */
            ch == '>' || ch == '<' || /* <<, >>, <=, >= */
            ch == '=' ||              /* == */
@@ -579,10 +587,11 @@ int lex_do(lex_file *lex)
                } else if (!strcmp(v, "vector")) {
                        lex->tok->ttype = TOKEN_TYPENAME;
                    lex->tok->constval.t = TYPE_VECTOR;
-               } else if (!strcmp(v, "for") ||
-                        !strcmp(v, "while") ||
-                        !strcmp(v, "do")    ||
-                        !strcmp(v, "var")   ||
+               } else if (!strcmp(v, "for")  ||
+                        !strcmp(v, "while")  ||
+                        !strcmp(v, "do")     ||
+                        !strcmp(v, "var")    ||
+                        !strcmp(v, "return") ||
                         !strcmp(v, "const"))
                        lex->tok->ttype = TOKEN_KEYWORD;