I want to parse a search string similar to the one provided by Gmail using Perl. An example input would be "tag: thing by: {user1 user2} {-tag: a by: user3}". I want to put it in a tree structure like
{and => [
"tag:thing",
{or => [
"by:user1",
"by:user2",
]},
{or => [
{not => "tag:a"},
"by:user3",
]},
}
General rules:
- Tokens separated by default space with an AND operator.
- Tokens in braces are alternatives (OR). Brackets can go before or after the field specifier. that is, "by: {user1 user2}" and "{by: user1 by: user2}" are equivalent.
- Tokens with a hyphen prefix are excluded.
These elements can also be combined and nested: for example. "{by: user5 - {tag: k by: user3}}, etc."
- , . ? ( ?)
- ?
( DBIx:: Class.)