more work on filter.c
authorsiboud <siboud@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 7 Feb 2005 04:03:13 +0000 (04:03 +0000)
committersiboud <siboud@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 7 Feb 2005 04:03:13 +0000 (04:03 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@867 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/filter.c

index a25b99c4c8575f1c5e7fdda590d35686db37a09d..380cfe0639d3f29bba64361fd7feceafd044ecb7 100644 (file)
@@ -58,7 +58,6 @@ parse_simple_expression(GString* expression) {
        unsigned i;
 
        for(i=0;i<strlen(expression);i++) {
-               
 
        }
 }
@@ -79,8 +78,9 @@ lttv_filter_new(char *expression, LttvTrace *t) {
        
        gpointer tree;
                
-       GString *currentOption = g_string_new(""); 
-               
+       GString *current_option = g_string_new(""); 
+       lttv_simple_expression current_expression;
+       
        g_print("filter::lttv_filter_new()\n");         /* debug */
 
        /*
@@ -98,10 +98,19 @@ lttv_filter_new(char *expression, LttvTrace *t) {
        
        /*
         *      Parse entire expression and construct
-        *      the binary tree
+        *      the binary tree.  There are two steps 
+   *   in browsing that string
+   *     1. finding boolean ops ( &,|,^,! ) and parenthesis
+   *     2. finding simple expressions
+   *       - field path
+   *       - op ( >, <, =, >=, <=, !=)
+   *       - value
         */
        for(i=0;i<strlen(expression);i++) {
                switch(expression[i]) {
+      /*
+       *  boolean operators
+       */
                        case '&':               /* and */
                                parse_simple_expression(currentOption);
                                g_print("%s\n",&currentOption);
@@ -115,16 +124,40 @@ lttv_filter_new(char *expression, LttvTrace *t) {
                                g_print("%s\n",currentOption);
                                currentOption = g_string_new("");
                                break;
-                       case '!':               /* not */
-                               g_print("%s\n",currentOption);
-                               currentOption = g_string_new("");
-                               break;
+                       case '!':               /* not, or not equal (math op) */
+        if(expression[i+1] == '=') {  /* != */
+          current_expression.op = LTTV_FIELD_NE;
+          i++;
+        } else {  /* ! */
+                               g_print("%s\n",currentOption);
+                               currentOption = g_string_new("");
+        }
+        break;
                        case '(':               /* start of parenthesis */
                                p++;
                                break;
                        case ')':               /* end of parenthesis */
                                p--;
                                break;
+      /*
+       *  mathematic operators
+       */
+      case '<':   /* lower, lower or equal */
+        if(expression[i+1] == '=') { /* <= */
+          i++;
+          current_expression.op = LTTV_FIELD_LE;                  
+        } else current_expression.op = LTTV_FIELD_LT;
+        break;
+      case '>':   /* higher, higher or equal */
+        if(expression[i+1] == '=') { /* >= */
+          i++;
+          current_expression.op = LTTV_FIELD_GE;                  
+        } else current_expression.op = LTTV_FIELD_GT;
+        break;
+      case '=':   /* equal */
+        current_expression.op = LTTV_FIELD_EQ;
+        break;
+      case 
                        default:                /* concatening current string */
                                g_string_append_c(currentOption,expression[i]);                                 
                }
This page took 0.029411 seconds and 4 git commands to generate.