I'm trying to build a handy dsl-ish query ability into my javascript.
given:
var query = "lastName = 'smith' and firstName = 'jack' or city = 'vancouver'";
what's the most elegant way of parsing this sql-esque string into usable objects such as:
[
{
field:'lastName',
operator:'=',
value:'smith',
join:'and'
},
{
field:'firstName',
operator:'=',
value:'jack',
join:'or'
},
{
field:'city',
operator:'=',
value:'vancouver'
}
]
Before I start hopelessly looping I figured there would be some regex master that had a one-liner.