Split lines with many copyright years
[gromacs.git] / src / gromacs / selection / scanner.h
blob32ad4286446947c425744021537df1139fde0543
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2009,2010,2011,2012,2014 by the GROMACS development team.
5 * Copyright (c) 2015,2019,2020, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
36 /*! \internal \file
37 * \brief
38 * Parser/scanner interaction functions.
40 * This is an implementation header: there should be no need to use it outside
41 * this directory.
43 * \author Teemu Murtola <teemu.murtola@gmail.com>
44 * \ingroup module_selection
46 #ifndef SELECTION_SCANNER_H
47 #define SELECTION_SCANNER_H
49 #include <exception>
50 #include <string>
52 #include "parser.h"
54 namespace gmx
56 class TextWriter;
59 struct gmx_ana_indexgrps_t;
60 struct gmx_ana_selcollection_t;
62 #ifndef YY_TYPEDEF_YY_SCANNER_T
63 # define YY_TYPEDEF_YY_SCANNER_T
64 typedef void* yyscan_t;
65 #endif
67 /** Initializes the selection scanner. */
68 void _gmx_sel_init_lexer(yyscan_t* scannerp,
69 struct gmx_ana_selcollection_t* sc,
70 gmx::TextWriter* statusWriter,
71 int maxnr,
72 bool bGroups,
73 struct gmx_ana_indexgrps_t* grps);
74 /** Frees memory allocated for the selection scanner. */
75 void _gmx_sel_free_lexer(yyscan_t scanner);
76 /** Stores an exception that is caught during parsing. */
77 void _gmx_sel_lexer_set_exception(yyscan_t scanner, const std::exception_ptr& ex);
78 /** Rethrows and clears the stored exception if one is present. */
79 // TODO: The semantics is a bit confusing, need to be thought more,
80 // but easier to do as part of larger refactoring of the parsing.
81 void _gmx_sel_lexer_rethrow_exception_if_occurred(yyscan_t scanner);
83 /** Returns writer for status output (if not NULL, the scanner is interactive). */
84 gmx::TextWriter* _gmx_sel_lexer_get_status_writer(yyscan_t scanner);
85 /** Returns the selection collection for the scanner. */
86 struct gmx_ana_selcollection_t* _gmx_sel_lexer_selcollection(yyscan_t scanner);
87 /** Returns true if the external index groups for the scanner are set. */
88 bool _gmx_sel_lexer_has_groups_set(yyscan_t scanner);
89 /** Returns the external index groups for the scanner. */
90 struct gmx_ana_indexgrps_t* _gmx_sel_lexer_indexgrps(yyscan_t scanner);
91 /** Returns the number of selections after which the parser should stop. */
92 int _gmx_sel_lexer_exp_selcount(yyscan_t scanner);
94 /** Returns a pretty string of the current selection. */
95 const char* _gmx_sel_lexer_pselstr(yyscan_t scanner);
96 /*! \brief
97 * Sets the current parser context location.
99 * This location is set while Bison reductions are being processed, and
100 * identifies the location of the current rule/reduction.
102 void _gmx_sel_lexer_set_current_location(yyscan_t scanner, const gmx::SelectionLocation& location);
103 /*! \brief
104 * Returns the current parser context location.
106 * This returns the location last set with
107 * _gmx_sel_lexer_set_current_location().
109 const gmx::SelectionLocation& _gmx_sel_lexer_get_current_location(yyscan_t scanner);
110 /*! \brief
111 * Returns the selection text for the current parser context.
113 * This returns the selection text that corresponds to the position set last
114 * with _gmx_sel_lexer_set_current_location().
116 std::string _gmx_sel_lexer_get_current_text(yyscan_t scanner);
117 /*! \brief
118 * Returns the selection text at the given location.
120 std::string _gmx_sel_lexer_get_text(yyscan_t scanner, const gmx::SelectionLocation& location);
121 /** Clears the current selection string. */
122 void _gmx_sel_lexer_clear_pselstr(yyscan_t scanner);
123 /** Clears the method stack in the scanner in error situations. */
124 void _gmx_sel_lexer_clear_method_stack(yyscan_t scanner);
125 /** Notifies the scanner that a complete method expression has been parsed. */
126 void _gmx_sel_finish_method(yyscan_t scanner);
127 /** Initializes the scanner to scan a file. */
128 void _gmx_sel_set_lex_input_file(yyscan_t scanner, FILE* fp);
129 /** Initializes the scanner to scan a string. */
130 void _gmx_sel_set_lex_input_str(yyscan_t scanner, const char* str);
132 /** The scanning function generated by Flex. */
133 #define YY_DECL int _gmx_sel_yylex(YYSTYPE* yylval, YYLTYPE* yylloc, yyscan_t yyscanner)
134 YY_DECL;
136 #endif