LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Member Functions | List of all members
loos::Parser Class Reference

Front-end to the Bison/Flex parser. More...

#include <Parser.hpp>

Public Member Functions

 Parser (const std::string &s)
 
void parse (const std::string &s)
 Parse the given command string after clearing the action stack.
 
Kernelkernel (void)
 Return a ref to the compiled (hopefully) Kernel.
 

Detailed Description

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, @verbatim "CA" == "C" -> false "C" == "C" -> true "CA" =~ "C" -> true \endverbatim 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. Examples: @code string selection_string = "resid >= 10 && resid <= 100 && name == 'CA'"; Parser parsed(selection_string); KernelSelector parsed_selector(parsed.kernel()); AtomicGroup parsed_selection = molecule.select(parsed_selector)

Parser objects are intended to be a parse-once object. If you want to parse multiple selection strings, then you should instantiate a Parser object for each selection string.


The documentation for this class was generated from the following file: