Gromacs
2024.4
|
#include "gmxpre.h"
#include "scanner_internal.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "parser.h"
#include "parsetree.h"
#include "scanner.h"
#include "selectioncollection_impl.h"
#include "selelem.h"
#include "selmethod.h"
#include "symrec.h"
Helper functions for the selection tokenizer.
This file implements the functions in the headers scanner.h and scanner_internal.h.
Functions | |
static int | init_param_token (YYSTYPE *yylval, gmx_ana_selparam_t *param, bool bBoolNo) |
Handles initialization of method parameter token. | |
static int | init_method_token (YYSTYPE *yylval,::gmx::SelectionLocation *yylloc, const gmx::SelectionParserSymbol *symbol, bool bPosMod, gmx_sel_lexer_t *state) |
Processes a selection method token. | |
int | _gmx_sel_lexer_process_pending (YYSTYPE *yylval,::gmx::SelectionLocation *yylloc, gmx_sel_lexer_t *state) |
Internal function for cases where several tokens need to be returned. More... | |
int | _gmx_sel_lexer_process_identifier (YYSTYPE *yylval,::gmx::SelectionLocation *yylloc, char *yytext, size_t yyleng, gmx_sel_lexer_t *state) |
Internal function that processes identifier tokens. More... | |
void | _gmx_sel_lexer_add_token (::gmx::SelectionLocation *yylloc, const char *str, int len, gmx_sel_lexer_t *state) |
Internal function to add a token to the pretty-printed selection text. More... | |
void | _gmx_sel_init_lexer (yyscan_t *scannerp, struct gmx_ana_selcollection_t *sc, gmx::TextWriter *statusWriter, int maxnr, bool bGroups, struct gmx_ana_indexgrps_t *grps) |
Initializes the selection scanner. More... | |
void | _gmx_sel_free_lexer (yyscan_t scanner) |
Frees memory allocated for the selection scanner. More... | |
void | _gmx_sel_lexer_set_exception (yyscan_t scanner, const std::exception_ptr &ex) |
Stores an exception that is caught during parsing. More... | |
void | _gmx_sel_lexer_rethrow_exception_if_occurred (yyscan_t scanner) |
Rethrows and clears the stored exception if one is present. More... | |
gmx::TextWriter * | _gmx_sel_lexer_get_status_writer (yyscan_t scanner) |
Returns writer for status output (if not NULL, the scanner is interactive). More... | |
struct gmx_ana_selcollection_t * | _gmx_sel_lexer_selcollection (yyscan_t scanner) |
Returns the selection collection for the scanner. More... | |
bool | _gmx_sel_lexer_has_groups_set (yyscan_t scanner) |
Returns true if the external index groups for the scanner are set. More... | |
struct gmx_ana_indexgrps_t * | _gmx_sel_lexer_indexgrps (yyscan_t scanner) |
Returns the external index groups for the scanner. More... | |
int | _gmx_sel_lexer_exp_selcount (yyscan_t scanner) |
Returns the number of selections after which the parser should stop. More... | |
const char * | _gmx_sel_lexer_pselstr (yyscan_t scanner) |
Returns a pretty string of the current selection. More... | |
void | _gmx_sel_lexer_set_current_location (yyscan_t scanner, const gmx::SelectionLocation &location) |
Sets the current parser context location. More... | |
const gmx::SelectionLocation & | _gmx_sel_lexer_get_current_location (yyscan_t scanner) |
Returns the current parser context location. More... | |
std::string | _gmx_sel_lexer_get_current_text (yyscan_t scanner) |
Returns the selection text for the current parser context. More... | |
std::string | _gmx_sel_lexer_get_text (yyscan_t scanner, const gmx::SelectionLocation &location) |
Returns the selection text at the given location. | |
void | _gmx_sel_lexer_clear_pselstr (yyscan_t scanner) |
Clears the current selection string. More... | |
void | _gmx_sel_lexer_clear_method_stack (yyscan_t scanner) |
Clears the method stack in the scanner in error situations. More... | |
void | _gmx_sel_finish_method (yyscan_t scanner) |
Notifies the scanner that a complete method expression has been parsed. More... | |
void | _gmx_sel_set_lex_input_file (yyscan_t scanner, FILE *fp) |
Initializes the scanner to scan a file. More... | |
void | _gmx_sel_set_lex_input_str (yyscan_t scanner, const char *str) |
Initializes the scanner to scan a string. More... | |
void _gmx_sel_finish_method | ( | yyscan_t | scanner | ) |
Notifies the scanner that a complete method expression has been parsed.
void _gmx_sel_free_lexer | ( | yyscan_t | scanner | ) |
Frees memory allocated for the selection scanner.
void _gmx_sel_init_lexer | ( | yyscan_t * | scannerp, |
struct gmx_ana_selcollection_t * | sc, | ||
gmx::TextWriter * | statusWriter, | ||
int | maxnr, | ||
bool | bGroups, | ||
struct gmx_ana_indexgrps_t * | grps | ||
) |
Initializes the selection scanner.
void _gmx_sel_lexer_add_token | ( | ::gmx::SelectionLocation * | , |
const char * | str, | ||
int | len, | ||
gmx_sel_lexer_t * | state | ||
) |
Internal function to add a token to the pretty-printed selection text.
void _gmx_sel_lexer_clear_method_stack | ( | yyscan_t | scanner | ) |
Clears the method stack in the scanner in error situations.
void _gmx_sel_lexer_clear_pselstr | ( | yyscan_t | scanner | ) |
Clears the current selection string.
int _gmx_sel_lexer_exp_selcount | ( | yyscan_t | scanner | ) |
Returns the number of selections after which the parser should stop.
const gmx::SelectionLocation& _gmx_sel_lexer_get_current_location | ( | yyscan_t | scanner | ) |
Returns the current parser context location.
This returns the location last set with _gmx_sel_lexer_set_current_location().
std::string _gmx_sel_lexer_get_current_text | ( | yyscan_t | scanner | ) |
Returns the selection text for the current parser context.
This returns the selection text that corresponds to the position set last with _gmx_sel_lexer_set_current_location().
gmx::TextWriter* _gmx_sel_lexer_get_status_writer | ( | yyscan_t | scanner | ) |
Returns writer for status output (if not NULL, the scanner is interactive).
bool _gmx_sel_lexer_has_groups_set | ( | yyscan_t | scanner | ) |
Returns true if the external index groups for the scanner are set.
struct gmx_ana_indexgrps_t* _gmx_sel_lexer_indexgrps | ( | yyscan_t | scanner | ) |
Returns the external index groups for the scanner.
int _gmx_sel_lexer_process_identifier | ( | YYSTYPE * | , |
::gmx::SelectionLocation * | , | ||
char * | , | ||
size_t | , | ||
gmx_sel_lexer_t * | state | ||
) |
Internal function that processes identifier tokens.
int _gmx_sel_lexer_process_pending | ( | YYSTYPE * | , |
::gmx::SelectionLocation * | , | ||
gmx_sel_lexer_t * | state | ||
) |
Internal function for cases where several tokens need to be returned.
const char* _gmx_sel_lexer_pselstr | ( | yyscan_t | scanner | ) |
Returns a pretty string of the current selection.
void _gmx_sel_lexer_rethrow_exception_if_occurred | ( | yyscan_t | scanner | ) |
Rethrows and clears the stored exception if one is present.
struct gmx_ana_selcollection_t* _gmx_sel_lexer_selcollection | ( | yyscan_t | scanner | ) |
Returns the selection collection for the scanner.
void _gmx_sel_lexer_set_current_location | ( | yyscan_t | scanner, |
const gmx::SelectionLocation & | location | ||
) |
Sets the current parser context location.
This location is set while Bison reductions are being processed, and identifies the location of the current rule/reduction.
void _gmx_sel_lexer_set_exception | ( | yyscan_t | scanner, |
const std::exception_ptr & | ex | ||
) |
Stores an exception that is caught during parsing.
void _gmx_sel_set_lex_input_file | ( | yyscan_t | scanner, |
FILE * | fp | ||
) |
Initializes the scanner to scan a file.
void _gmx_sel_set_lex_input_str | ( | yyscan_t | scanner, |
const char * | str | ||
) |
Initializes the scanner to scan a string.