Gromacs
2016.6
|
#include <exception>
#include <memory>
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/stringutil.h"
#include "parsetree.h"
#include "scanner.h"
#include "selelem.h"
Helper functions for the selection parser.
This header is includes only from parser.cpp (generated from parser.y), and it includes functions and macros used internally by the parser. They are in a separate file to make then easier to edit (no need to regenerate the parser), and to keep parser.y as simple as possible.
Macros | |
#define | GMX_YYFORCE_C_STACK_EXTENSION 1 |
Custom macro to influence Bison behavior. More... | |
#define | CHECK_SEL(sel) |
Checks that a valid tree was set. More... | |
Exception handling macros for actions | |
These macros should be used at the beginning and end of each semantic action that may throw an exception. For robustness, it's best to wrap all actions that call functions declared outside parser.y should be wrapped. These macros take care to catch any exceptions, store the exception (or handle it and allow the parser to continue), and terminate the parser cleanly if necessary. The code calling the parser should use _gmx_sel_lexer_rethrow_exception_if_occurred() to rethrow any exceptions. | |
#define | BEGIN_ACTION try { |
Starts an action that may throw exceptions. | |
#define | END_ACTION |
Finishes an action that may throw exceptions. More... | |
#define | END_ACTION_TOPLEVEL |
Finishes an action that may throw exceptions and does not support resuming. More... | |
Functions | |
template<typename ValueType > | |
static ValueType | get (ValueType *src) |
Retrieves a semantic value. More... | |
template<typename ValueType > | |
static void | set (ValueType *&dest, ValueType value) |
Sets a semantic value. More... | |
template<typename ValueType > | |
static void | set_empty (ValueType *&dest) |
Sets an empty semantic value. More... | |
#define CHECK_SEL | ( | sel | ) |
#define END_ACTION |
Finishes an action that may throw exceptions.
#define END_ACTION_TOPLEVEL |
Finishes an action that may throw exceptions and does not support resuming.
#define GMX_YYFORCE_C_STACK_EXTENSION 1 |
Custom macro to influence Bison behavior.
This macro added to parser.cpp through our patch to force Bison to use C-style logic for stack reallocation even though we have provided YYLTYPE and are compiling the code in C++ (our YYLTYPE can safely be copied this way). An alternative would be to provide the whole reallocation logic through an undocumented yyoverflow() macro, but that is probably also more trouble than it is worth.
|
static |
Retrieves a semantic value.
[in] | src | Semantic value to get the value from. |
unspecified | Any exception thrown by the move constructor of ValueType. |
There should be no statements that may throw exceptions in actions before this function has been called for all semantic values that have a C++ object stored. Together with set(), this function abstracts away exception safety issues that arise from the use of a plain pointer for storing the semantic values.
Does not throw for smart pointer types. If used with types that may throw, the order of operations should be such that it is exception-safe.
|
static |
Sets a semantic value.
ValueType | Type of value to set. |
[out] | dest | Semantic value to set (typically $$). |
[in] | value | Value to put into the semantic value. |
std::bad_alloc | if out of memory. |
unspecified | Any exception thrown by the move constructor of ValueType. |
This should be the last statement before END_ACTION, except for a possible CHECK_SEL.
|
static |
Sets an empty semantic value.
ValueType | Type of value to set (must be default constructible). |
[out] | dest | Semantic value to set (typically $$). |
std::bad_alloc | if out of memory. |
unspecified | Any exception thrown by the default constructor of ValueType. |
This should be the last statement before END_ACTION, except for a possible CHECK_SEL.