]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
allow dots in frame names to compile hypnotic
authorDale Weiler <weilercdale@gmail.com>
Fri, 9 Jul 2021 16:17:02 +0000 (12:17 -0400)
committerDale Weiler <weilercdale@gmail.com>
Fri, 9 Jul 2021 16:17:02 +0000 (12:17 -0400)
lexer.cpp
parser.cpp

index 1007948958caf4103a108feb3b97633af2277af7..d63ff8ceceab54e2cf19ab2cae99128ce786b790 100644 (file)
--- a/lexer.cpp
+++ b/lexer.cpp
@@ -300,9 +300,9 @@ static bool isident_start(int ch)
     return util_isalpha(ch) || ch == '_';
 }
 
-static bool isident(int ch)
+static bool isident(int ch, bool allow_dot)
 {
-    return isident_start(ch) || util_isdigit(ch);
+    return isident_start(ch) || util_isdigit(ch) || (allow_dot && ch == '.');
 }
 
 /* isxdigit_only is used when we already know it's not a digit
@@ -579,12 +579,12 @@ static int lex_skipwhite(lex_file *lex, bool hadwhite)
 }
 
 /* Get a token */
-static bool GMQCC_WARN lex_finish_ident(lex_file *lex)
+static bool GMQCC_WARN lex_finish_ident(lex_file *lex, bool allow_dot)
 {
     int ch;
 
     ch = lex_getch(lex);
-    while (ch != EOF && isident(ch))
+    while (ch != EOF && isident(ch, allow_dot))
     {
         lex_tokench(lex, ch);
         ch = lex_getch(lex);
@@ -611,12 +611,12 @@ static int lex_parse_frame(lex_file *lex)
         return 1;
 
     if (!isident_start(ch)) {
-        lexerror(lex, "invalid framename, must start with one of a-z or _, got %c", ch);
+        lexerror(lex, "invalid framename, must start with one of a-z, or _, got %c", ch);
         return -1;
     }
 
     lex_tokench(lex, ch);
-    if (!lex_finish_ident(lex))
+    if (!lex_finish_ident(lex, true))
         return -1;
     lex_endtoken(lex);
     return 0;
@@ -901,7 +901,7 @@ static int GMQCC_WARN lex_finish_digit(lex_file *lex, int lastch)
         ch = lex_getch(lex);
 
     /* generally we don't want words to follow numbers: */
-    if (isident(ch)) {
+    if (isident(ch, false)) {
         lexerror(lex, "unexpected trailing characters after number");
         return (lex->tok.ttype = TOKEN_ERROR);
     }
@@ -972,7 +972,7 @@ int lex_do(lex_file *lex)
             return lex_do(lex);
         }
         lex_tokench(lex, ch);
-        if (!lex_finish_ident(lex))
+        if (!lex_finish_ident(lex, true))
             return (lex->tok.ttype = TOKEN_ERROR);
         lex_endtoken(lex);
         /* skip the known commands */
@@ -1306,7 +1306,7 @@ int lex_do(lex_file *lex)
         const char *v;
 
         lex_tokench(lex, ch);
-        if (!lex_finish_ident(lex)) {
+        if (!lex_finish_ident(lex, false)) {
             /* error? */
             return (lex->tok.ttype = TOKEN_ERROR);
         }
index 8aa49f77bc76f1d96219c2b77d59641775eb6008..a59191c235ef70f29332cfac427e7bd83be727c6 100644 (file)
@@ -3913,7 +3913,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
 
         framenum = parse_expression_leave(parser, true, false, false);
         if (!framenum) {
-            parseerror(parser, "expected a framenumber constant in[frame,think] notation");
+            parseerror(parser, "expected a framenumber constant in [frame,think] notation");
             return false;
         }
         if (!ast_istype(framenum, ast_value) || !( (ast_value*)framenum )->m_hasvalue) {