hi guys,

despite the help, i'm still having problems in adding a propability to every condition in my conditional structures in the code.

to eliminate amibiguities, we defined that every conditional in the grammar  has an obligatory associated probability.
so, the conditional would be like:
x > 5 prob 70
s < 30 prob 65
a == b prob 55
c == func (b) prob 20
c != 4 prob 98
so, every conditional expression in a condicional structure [while, if...] would take the form:
while (x > 5 prob 70 && s < 30 prob 65)
the evaluation of the sentence is the same as in standard C, but i have to pass the probability value to AST, in a way to put it in the generated Assembly code.
Sentences like
while (x > 5)
lead us to error; the correct sentence must have a associated probability, like shown before.

we performed a change to the SDCC.lex file to recognize the prob token
"prob"         { count(); return(PROB); }

or it would be

"prob"         { count(); TKEYWORDSDCC(PROB); }???

in the SDCC.y we defined a new non-terminal named propab
Probab  :
PROB CONSTANT {\$\$ = (int) floatFromVal(\$2); }
;

and rewrite the relations and equalities expressions to:
relational_expr
: shift_expr
| relational_expr '<' shift_expr Probab{
\$\$ = (port->lt_nge ?
newNode('!',newNode(GE_OP,\$1,\$3),NULL) :
newNode('<', \$1,\$3));
}
| relational_expr '>' shift_expr Probab{
\$\$ = (port->gt_nle ?
newNode('!',newNode(LE_OP,\$1,\$3),NULL) :
newNode('>',\$1,\$3));
}
| relational_expr LE_OP shift_expr Probab{
\$\$ = (port->le_ngt ?
newNode('!', newNode('>', \$1 , \$3 ), NULL) :
newNode(LE_OP,\$1,\$3));
}
| relational_expr GE_OP shift_expr Probab{
\$\$ = (port->ge_nlt ?
newNode('!', newNode('<', \$1 , \$3 ), NULL) :
newNode(GE_OP,\$1,\$3));
}
;

equality_expr
: relational_expr
| equality_expr EQ_OP relational_expr Probab{
\$\$ = (port->eq_nne ?
newNode('!',newNode(NE_OP,\$1,\$3),NULL) :
newNode(EQ_OP,\$1,\$3));
}
| equality_expr NE_OP relational_expr Probab{
\$\$ = (port->ne_neq ?
newNode('!', newNode(EQ_OP,\$1,\$3), NULL) :
newNode(NE_OP,\$1,\$3));
}
;

But unfortunately our changes lead us to errors and we wonder ourselves if we are changing the files in a right way and/or changing the right files.

What is the best way to keep the probabilities values in the AST? Will it be necessary to add a node to every sentence or just to the ones that needs to preserve that value?

Great Thanks
Emanuel Pessoa