I have to do Lexing and Parsing using PLY. I have gone through http://www.dabeaz.com/ply/ply.html this documentation to learn about PLY and looked at the calculator example. I'm new to all this. So, the step-1 to proceed towards this process is to figure out the grammar rules according to the input expressions.
Some of the sample input expressions for my application will look like are:
1.) [foo, bar, baz] UNION/U ([foo,bar] INTERSECT [bar])
2.) [foo, bar] MINUS/- [bar]
3.) [foo, bar, baz, cat] INTERSECT/∩ [baz, cat]
4.) [a,b,c,d] UNION/U [d,e,f]
[] (square bracket indicates array/list)
UNION/U, INTESERCT/∩, MINUS/- represent the set operations.
How do i write grammar rules for this kind of expressions involving list and SET operators, so that they will be properly identified as list and set operators when they are sent to lexer of PLY to get converted into tokens?
Please help. I have seen many examples of PLY but everywhere they have normal arithmetic expressions. I really want to understand how do i write them in the way i need.