views:

61

answers:

1

Hi,

I am building a query in a textarea with different conditions selected from the html controls. Also users are open to do modification to it.

Client side: For the below list of condition:

a(1, 3) > 20
b(4, 5) < 90
c(3, 0) = 80

I form a query:

a(1, 3) > 20 and b(4, 5) < 90 or c(3, 0) = 80

On the server side this has to be parsed, lookup and call each function with arguments. (a, b and c are the functions)

I want to check for the query syntax (not sure at the client side or the server side) before processing it. For example if the user enters incorrect function / arguments or they use incorrect operators.

Appreciate your suggestions and feedback.

PS: Using python

+4  A: 

PLY has a simple expression example that will get you most of the way there.

Ned Batchelder
+1, I would advise PLY, if only for being able to grow the syntax without redoing regexp.
Aiden Bell