My understanding is that in Lex/Bison, the lexical analysis is done by lex, the syntaxical by the rules of Bison, and the semantic one by the actions of Bison.
Is it then possible to go back from the semantic analysis, i.e. the actions, to the syntaxical one ?
One exemple would be that : suppose I want to be able to detect pseudo-C as "i++", "i=i+1","i=i+2". But I want that "i=i+1" to be reduce as "i++", and "i=i+2" to be a second rule. Is it the possible to do something like that :
identifier_plusplus: IDENTIFIER '+' '+'
add: IDENTIFIER '=' IDENTIFIER '+' NUMBER {if($1 == $3 && $5 == 1) REDUCE_IN(identifier_plusplus);}
Here, it is not very usefull, but in a case where I use identifier_plusplus in another rule, it could be very powerfull.
EDIT : An example where it can be usefull would be if I have another rule that catch For loops which increment one by one. I would like to type something as :
for_one: FOR '(' IDENTIFIER '=' '0' ';' IDENTIFIER '<' CONST ';' IDENTIFIER PLUSPLUS ')' exprs
With no care if I wrote i++ or i=i+1.
Is it more clear now ? (please excuse my english...)
Thank you in advance.