Front-end to the Bison/Flex parser. More...
|Parser (const std::string &s)|
|void||parse (const std::string &s)|
|Parse the given command string after clearing the action stack. |
|Kernel &||kernel (void)|
|Return a ref to the compiled (hopefully) Kernel. |
Front-end to the Bison/Flex parser.
Creates a compiled Kernel that can then be executed to select atoms. The grammar accepted is relatively simple and patterned after C/PERL expressions. Relational operators are allowed, as are basic logical operators (and, or, and not). Pre-defined keywords are: name, id, resname, resid, segid. These evaluate to the current atom's appropriate property. Case IS significant both for keywords and for strings. Integer numbers are allowed. Strings are delimited by either single quotes (') or double quotes ("). Also, strings inequalities are handled lexically as C++ strings are, i.e. string1 > string2 is true is it would be in regular C++ code.
Regular expressions (in PERL format) are supported via Boost. The regular expression matching operator, '=~' is slightly special in that it will only permit you to match a keyword that would evaluate to a string. In other words, you may match against a name, resname, and segname (segname is an alias for segid), but NOT an id nor a resid.
String equality matches the entire string. If you want to match a subset, you should use the '=~' operator. In other words,
"CA" == "C" -> false "C" == "C" -> true "CA" =~ "C" -> true
Finally, the standard precedence and associativity that apply in C++ apply here. Expressions are evaluated left to right and parenthesis may be used to alter precedence/evaluation order. Unlike C/C++ however, the logical operators do not short-circuit.
If there is a syntax error in the selection string, then a runtime_error() is thrown.