]> granicus.if.org Git - yasm/commitdiff
Support all unary operators in directive expressions.
authorPeter Johnson <peter@tortall.net>
Sun, 16 May 2010 03:14:09 +0000 (03:14 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 16 May 2010 03:14:09 +0000 (03:14 -0000)
svn path=/trunk/yasm/; revision=2322

modules/parsers/nasm/nasm-parse.c

index 0c4820ff2c37e73db942e4000108d9b4348ec307..792091e124cd8cf09a807ae2697009f8e400f41e 100644 (file)
@@ -1321,47 +1321,7 @@ parse_expr6(yasm_parser_nasm *parser_nasm, expr_type type)
     yasm_expr *e;
     yasm_symrec *sym;
 
-    /* directives allow very little and handle IDs specially */
-    if (type == DIR_EXPR) {
-        switch (curtok) {
-        case '~':
-            get_next_token();
-            e = parse_expr6(parser_nasm, type);
-            if (!e) {
-                yasm_error_set(YASM_ERROR_SYNTAX,
-                               N_("expected expression after %s"), "`~'");
-                return NULL;
-            }
-            return p_expr_new_branch(YASM_EXPR_NOT, e);
-        case '(':
-            get_next_token();
-            e = parse_expr(parser_nasm, type);
-            if (!e) {
-                yasm_error_set(YASM_ERROR_SYNTAX,
-                               N_("expected expression after %s"), "`('");
-                return NULL;
-            }
-            if (!expect(')')) {
-                yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis"));
-                return NULL;
-            }
-            get_next_token();
-            return e;
-        case INTNUM:
-            e = p_expr_new_ident(yasm_expr_int(INTNUM_val));
-            break;
-        case REG:
-            e = p_expr_new_ident(yasm_expr_reg(REG_val));
-            break;
-        case ID:
-            sym = yasm_symtab_use(p_symtab, ID_val, cur_line);
-            e = p_expr_new_ident(yasm_expr_sym(sym));
-            yasm_xfree(ID_val);
-            break;
-        default:
-            return NULL;
-        }
-    } else switch (curtok) {
+    switch (curtok) {
         case '+':
             get_next_token();
             e = parse_expr6(parser_nasm, type);
@@ -1437,10 +1397,8 @@ parse_expr6(yasm_parser_nasm *parser_nasm, expr_type type)
             return e;
         case INTNUM:
             e = p_expr_new_ident(yasm_expr_int(INTNUM_val));
-            break;
-        case FLTNUM:
-            e = p_expr_new_ident(yasm_expr_float(FLTNUM_val));
-            break;
+            get_next_token();
+            return e;
         case REG:
             if (type == DV_EXPR) {
                 yasm_error_set(YASM_ERROR_SYNTAX,
@@ -1448,6 +1406,24 @@ parse_expr6(yasm_parser_nasm *parser_nasm, expr_type type)
                 return NULL;
             }
             e = p_expr_new_ident(yasm_expr_reg(REG_val));
+            get_next_token();
+            return e;
+    }
+
+    /* directives allow very little and handle IDs specially */
+    if (type == DIR_EXPR) {
+        switch (curtok) {
+        case ID:
+            sym = yasm_symtab_use(p_symtab, ID_val, cur_line);
+            e = p_expr_new_ident(yasm_expr_sym(sym));
+            yasm_xfree(ID_val);
+            break;
+        default:
+            return NULL;
+        }
+    } else switch (curtok) {
+        case FLTNUM:
+            e = p_expr_new_ident(yasm_expr_float(FLTNUM_val));
             break;
         case STRING:
         {
@@ -1498,6 +1474,7 @@ parse_expr6(yasm_parser_nasm *parser_nasm, expr_type type)
         default:
             return NULL;
     }
+
     get_next_token();
     return e;
 }