Fixing copyright issues and code contributors
[alexxy/gromacs.git] / src / gmxlib / selection / scanner_internal.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2009, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38 /*! \internal \file
39  * \brief Internal header file used by the selection tokenizer.
40  */
41 #ifndef SELECTION_SCANNER_INTERNAL_H
42 #define SELECTION_SCANNER_INTERNAL_H
43
44 #include "parser.h"
45
46 /** The scanning function generated by Flex. */
47 #define YY_DECL int _gmx_sel_yylex(YYSTYPE *yylval, yyscan_t yyscanner)
48 YY_DECL;
49
50 /* These need to be defined before including scanner_flex.h, because it
51  * uses YY_EXTRA_TYPE. But we also need to include it before defining
52  * gmx_sel_lexer_t; hence the forward declaration. */
53 struct gmx_sel_lexer_t;
54 #define YY_EXTRA_TYPE struct gmx_sel_lexer_t *
55
56 /* We cannot include scanner_flex.h from the scanner itself, because it
57  * seems to break everything. */
58 /* And we need to define YY_NO_UNISTD_H here as well, otherwise unistd.h
59  * gets included in other files than scanner.c... */
60 #ifndef FLEX_SCANNER
61 #define YY_NO_UNISTD_H
62 #include "scanner_flex.h"
63 #endif
64
65 /*! \brief
66  * Internal data structure for the selection tokenizer state.
67  */
68 typedef struct gmx_sel_lexer_t
69 {
70     struct gmx_ana_selcollection_t  *sc;
71     struct gmx_ana_indexgrps_t      *grps;
72     int                              nexpsel;
73
74     gmx_bool                             bInteractive;
75     char                            *inputstr;
76     int                              nalloc_input;
77
78     char                            *pselstr;
79     int                              pslen;
80     int                              nalloc_psel;
81
82     struct gmx_ana_selmethod_t     **mstack;
83     int                              msp;
84     int                              mstack_alloc;
85
86     int                              neom;
87     struct gmx_ana_selparam_t       *nextparam;
88     gmx_bool                             bBoolNo;
89     struct gmx_ana_selmethod_t      *nextmethod;
90     int                              prev_pos_kw;
91
92     gmx_bool                             bMatchOf;
93     gmx_bool                             bMatchBool;
94     gmx_bool                             bCmdStart;
95
96     gmx_bool                             bBuffer;
97     YY_BUFFER_STATE                  buffer;
98 } gmx_sel_lexer_t;
99
100 /* Because Flex defines yylval, yytext, and yyleng as macros,
101  * and this file is included from scanner.l,
102  * we cannot have them here as parameter names... */
103 /** Internal function for cases where several tokens need to be returned. */
104 int
105 _gmx_sel_lexer_process_pending(YYSTYPE *, gmx_sel_lexer_t *state);
106 /** Internal function that processes identifier tokens. */
107 int
108 _gmx_sel_lexer_process_identifier(YYSTYPE *, char *, size_t,
109                                   gmx_sel_lexer_t *state);
110 /** Internal function to add a token to the pretty-printed selection text. */
111 void
112 _gmx_sel_lexer_add_token(const char *str, int len, gmx_sel_lexer_t *state);
113
114 #endif