Skip to content

Commit

Permalink
DataFilter parser - remove warnings and avoid crash on syntax error
Browse files Browse the repository at this point in the history
- Crash on syntax error happened on <leaf> destructor and the cause
  was tokens declared as <leaf> but not creating a leaf, to avoid
  this a new <string> type without destructor was added for them.
- Warnings indicated semantic value not set for some rules due to
  the lack of $$ = $1, likely bening, but lets avoid it.
  • Loading branch information
amtriathlon committed Oct 28, 2022
1 parent 5a77180 commit fa8eb0b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Core/DataFilter.y
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ extern Leaf *DataFilterroot; // root node for parsed statement

%}

// Symbol can be meta or metric name
%token <leaf> SYMBOL PYTHON
// Symbol can be meta, metric, variable or function name
%token <string> SYMBOL PYTHON

// Constants can be a string or a number
%token <leaf> DF_STRING DF_INTEGER DF_FLOAT
%token <string> DF_STRING DF_INTEGER DF_FLOAT
%token <function> BEST TIZ CONFIG CONST_

// comparative operators
Expand All @@ -68,6 +68,7 @@ extern Leaf *DataFilterroot; // root node for parsed statement
QList<Leaf*> *comp;
int op;
char function[32];
char* string;
}

%destructor { $$->clear($$); delete $$; } <leaf>
Expand Down Expand Up @@ -140,7 +141,7 @@ block:
statements:

statement { $$ = new QList<Leaf*>(); $$->append($1); }
| statements statement { $$->append($2); }
| statements statement { $1->append($2); $$ = $1; }
;

/*
Expand Down Expand Up @@ -253,7 +254,9 @@ parms:
$$->fparms << $1;
}
| parms ',' parameter { $1->fparms << $3;
$1->leng = @3.last_column; }
$1->leng = @3.last_column;
$$ = $1;
}
;

/*
Expand Down Expand Up @@ -464,6 +467,7 @@ expr:
delete $1->lvalue.n; // not used anymore
$1->lvalue.l = NULL; // avoid double deletion
$1->fparms.clear(); // no parameters!
$$ = $1;
}
| '(' expr ')' { $$ = new Leaf(@2.first_column, @2.last_column);
$$->type = Leaf::Logical;
Expand Down

0 comments on commit fa8eb0b

Please sign in to comment.