search - Flex and Bison Associativity difficulty -


Using Flex and Bison, I have a grammatical description for the Boolean query language, which supports logical "and", "or", "

, and" Using "nested subpictures (") "along with the operation.

All were good till I saw that queries like" A and B or C and D " Want to parse "(a and b). (C & D) "is actually interpreted as" A & B (C & D) ", I'm almost certain that this is a collaborative issue but no suitable explanation or example can be found anywhere This or I am missing something important.

Relevant information from boolpars.y:

token token% token OPEN_PARENCLOSE_PAREN% not right% left and % Left OR %% Query: Expression {...}; Expression: Expression and Expression {...} | Expression The expression {...} | expression not {...} | OPEN_PAREN expressionCLOSE_PAREN {...} | token {...};

Can anybody find fault ? I can not see why the bison is not giving "or" the appropriate priority.

from the bison docs :

The priority of the operator is determined by the orderly order of announcements; the higher the line number of the declaration (less on the page or screen), the priority is higher.

Then change the order for your case or on screen and is a high priority

 % left or% left and  

Although I have not tested it)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -