]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.h
Some side-effect propagation for better warnings, so that comma-operators with assign...
[xonotic/gmqcc.git] / lexer.h
diff --git a/lexer.h b/lexer.h
index eaddb03c8044de35588d6f85698e98ef71c9850f..49c7762081454933216aac4e3d902dfa956f6e59 100644 (file)
--- a/lexer.h
+++ b/lexer.h
@@ -1,5 +1,27 @@
-#ifndef GMQCC_LEXER_HDR_
-#define GMQCC_LEXER_HDR_
+/*
+ * Copyright (C) 2012
+ *     Wolfgang Bumiller
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef GMQCC_LEXER_HDR
+#define GMQCC_LEXER_HDR
 
 typedef struct token_s token;
 
@@ -139,9 +161,8 @@ typedef struct {
 static const oper_info c_operators[] = {
     { "(",   0, opid1('('),         ASSOC_LEFT,  99, OP_PREFIX}, /* paren expression - non function call */
 
-    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  16, OP_SUFFIX},
-    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  16, OP_SUFFIX},
-
+    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  15, OP_SUFFIX},
+    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  15, OP_SUFFIX},
     { ".",   2, opid1('.'),         ASSOC_LEFT,  15, 0 },
     { "(",   0, opid1('('),         ASSOC_LEFT,  15, 0 }, /* function call */
     { "[",   2, opid1('['),         ASSOC_LEFT,  15, 0 }, /* array subscript */
@@ -204,9 +225,8 @@ static const size_t c_operator_count = (sizeof(c_operators) / sizeof(c_operators
 static const oper_info fte_operators[] = {
     { "(",   0, opid1('('),         ASSOC_LEFT,  99, OP_PREFIX}, /* paren expression - non function call */
 
-    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  16, OP_SUFFIX},
-    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  16, OP_SUFFIX},
-
+    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  15, OP_SUFFIX},
+    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  15, OP_SUFFIX},
     { ".",   2, opid1('.'),         ASSOC_LEFT,  15, 0 },
     { "(",   0, opid1('('),         ASSOC_LEFT,  15, 0 }, /* function call */
     { "[",   2, opid1('['),         ASSOC_LEFT,  15, 0 }, /* array subscript */
@@ -232,6 +252,9 @@ static const oper_info fte_operators[] = {
     { "==",  2, opid2('=','='),     ASSOC_LEFT,  10,  0 },
     { "!=",  2, opid2('!','='),     ASSOC_LEFT,  10,  0 },
 
+    { "?",   3, opid2('?',':'),     ASSOC_RIGHT, 9,  0 },
+    { ":",   3, opid2(':','?'),     ASSOC_RIGHT, 9,  0 },
+
     { "=",   2, opid1('='),         ASSOC_RIGHT, 8,  0 },
     { "+=",  2, opid2('+','='),     ASSOC_RIGHT, 8,  0 },
     { "-=",  2, opid2('-','='),     ASSOC_RIGHT, 8,  0 },
@@ -240,14 +263,12 @@ static const oper_info fte_operators[] = {
     { "%=",  2, opid2('%','='),     ASSOC_RIGHT, 8,  0 },
     { "&=",  2, opid2('&','='),     ASSOC_RIGHT, 8,  0 },
     { "|=",  2, opid2('|','='),     ASSOC_RIGHT, 8,  0 },
+    { "&~=", 2, opid3('&','~','='), ASSOC_RIGHT, 8,  0 },
 
     { "&&",  2, opid2('&','&'),     ASSOC_LEFT,  5,  0 },
     { "||",  2, opid2('|','|'),     ASSOC_LEFT,  5,  0 },
 
-    { ",",   2, opid1(','),         ASSOC_LEFT,  2,  0 },
-
-    { "?",   3, opid2('?',':'),     ASSOC_RIGHT, 1,  0 },
-    { ":",   3, opid2(':','?'),     ASSOC_RIGHT, 1,  0 }
+    { ",",   2, opid1(','),         ASSOC_LEFT,  2,  0 }
 };
 static const size_t fte_operator_count = (sizeof(fte_operators) / sizeof(fte_operators[0]));