source: ThirdParty/mpqc_open/src/lib/util/keyval/ipv2_parse.yy@ 860145

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 860145 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 7.1 KB
RevLine 
[0b990d]1/*
2 * ipv2_parse.yy
3 *
4 * Copyright (C) 1996 Limit Point Systems, Inc.
5 *
6 * Author: Curtis Janssen <cljanss@ca.sandia.gov>
7 * Maintainer: LPS
8 *
9 * This file is part of the SC Toolkit.
10 *
11 * The SC Toolkit is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Library General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * The SC Toolkit is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * The U.S. Government is granted a limited license as per AL 91-7.
26 */
27%{
28#ifdef DEC
29#include <math.h>
30#else
31#include <stdlib.h>
32#endif
33#include <string.h>
34#ifdef BISON
35#define YYDEBUG 0
36#if YYDEBUG != 0
37int yydebug =1;
38#endif /* YYDEBUG != 0 */
39#endif /* BISON */
40#if defined(SABER)
41#define xmalloc malloc
42#endif
43#if defined(SGI)
44#include <alloca.h>
45#endif
46#include <util/keyval/ipv2.h>
47#define yyerror sc::IPV2::yerror
48#define yyparse sc::IPV2::yparse
49#define yylex sc::IPV2::ylex
50#define yywrap sc::IPV2::ywrap
51%}
52
53%union {
54 char *str;
55 sc::ip_string_list_t *sl;
56 double dbl;
57 }
58
59%token T_KEYWORD_LEFT T_ARRAY_LEFT T_TABLE_LEFT
60%token T_KEYWORD_RIGHT T_ARRAY_RIGHT T_TABLE_RIGHT
61%token T_CONCAT
62%token <str> T_STRING T_QUOTED_STRING
63%type <str> string quoted_string var_key var_sub table_key polymorph
64%type <sl> stringlist parentlist commalist
65%type <str> expression
66%type <dbl> subexpression expvalue
67
68%start input
69%%
70
71input: group_defs
72 ;
73
74group_defs: group_defs group_def
75 |
76 ;
77
78group_def: keyword ':' T_KEYWORD_LEFT group_defs T_KEYWORD_RIGHT
79 { ip_pop_keyword(); }
80 | keyword ':' karray_defs
81 { ip_pop_keyword(); }
82 | keyword ':' group_def
83 { ip_pop_keyword(); }
84 | keyword '=' value
85 { ip_pop_keyword(); }
86 | T_TABLE_LEFT stringlist T_TABLE_RIGHT
87 { ip_begin_table($2); }
88 '='
89 T_TABLE_LEFT tablevalues T_TABLE_RIGHT
90 { ip_done_table(); }
91 | implicit_keyword ':' T_KEYWORD_LEFT group_defs T_KEYWORD_RIGHT
92 | implicit_keyword ':' karray_defs
93 | implicit_keyword ':' group_def
94 | implicit_keyword '=' value
95 ;
96/* old table construction stuff
97 | T_TABLE_LEFT stringlist T_TABLE_RIGHT
98 '='
99 T_TABLE_LEFT stringlist T_TABLE_RIGHT
100 { ip_construct_table($2,$6); }
101 ;
102 */
103
104/* One or more strings in a stringlist.
105 * This is needed to distinguish array construction from table contruction
106 * (with no columns-which is silly anyway). If we allow zero or more,
107 * then YACC complains about the reduce/reduce conflict. */
108stringlist: stringlist table_key
109 { $$ = ip_add_string_list($1,$2); }
110 | table_key
111 { $$ = ip_string_to_string_list($1); }
112 ;
113
114
115table_key: table_key ':' string { $$ = ip_append_keystrings($1,$3); }
116 | string { $$ = $1; }
117 ;
118
119tablevalues: tablevalues value
120 |
121 ;
122
123karray_defs: array_left karray_elems array_right
124 ;
125
126karray_elems: karray_elems { ip_incr_karray(); } karray_elem
127 | { ip_init_karray(); }
128 ;
129
130karray_elem: karray_defs
131 | T_KEYWORD_LEFT group_defs T_KEYWORD_RIGHT
132 | group_def
133 ;
134
135array_left: T_ARRAY_LEFT { ip_start_karray(); }
136 ;
137
138array_right: T_ARRAY_RIGHT { ip_pop_karray(); }
139 ;
140
141/*
142keyword: T_STRING
143 { ip_push_keyword($1); }
144 | T_STRING '<' T_STRING '>' { ip_push_keyclass($1,$3); }
145 ;
146*/
147
148keyword: string { ip_push_keyword($1); }
149 | string polymorph { ip_push_keyclass($1,$2,0); }
150 | string parentlist { ip_push_keyclass($1,0,$2); }
151 | string parentlist polymorph { ip_push_keyclass($1,$3,$2); }
152 | string polymorph parentlist { ip_push_keyclass($1,$2,$3); }
153 ;
154implicit_keyword:
155 polymorph { ip_push_keyclass(0,$1,0); }
156 ;
157
158polymorph: '<' string '>' { $$ = $2; }
159 ;
160
161parentlist: '<' '<' commalist '>' '>' { $$ = $3; }
162 ;
163
164commalist: commalist ',' string { $$ = ip_add_string_list($1,$3); }
165 | string { $$ = ip_string_to_string_list($1); }
166 ;
167
168value: array
169 | string
170 { ip_assign_value($1); }
171 | var_sub { ip_assign_variable($1); }
172 | expression { ip_assign_value($1); }
173 ;
174
175expression: T_KEYWORD_LEFT subexpression T_KEYWORD_RIGHT
176 { $$ = ip_double_to_string($2); }
177 ;
178
179subexpression: expvalue '*' expvalue { $$ = $1 * $3; }
180 | expvalue '-' expvalue { $$ = $1 - $3; }
181 | expvalue '+' expvalue { $$ = $1 + $3; }
182 | expvalue '/' expvalue { $$ = $1 / $3; }
183 ;
184
185
186expvalue: var_sub { $$ = ip_get_variable_double($1); }
187 | string { $$ = atof($1); free($1); }
188 ;
189
190var_sub: '$' var_key { $$ = $2; }
191 ;
192
193
194var_key: var_key ':' string { $$ = ip_append_keystrings($1,$3); }
195 | ':' string { $$ = ip_append_keystrings(NULL,$2); }
196 | string { $$ = $1; }
197 ;
198
199array: array_left values array_right
200 ;
201
202values: values { ip_incr_karray(); } value
203 |
204 { ip_init_karray(); }
205 ;
206
207quoted_string: quoted_string T_CONCAT T_QUOTED_STRING
208 { $$ = (char*) malloc(strlen($1)+strlen($3)+1);
209 strcpy($$, $1);
210 strcat($$, $3);
211 free($1);
212 free($3);
213 }
214 | T_QUOTED_STRING
215 { $$ = $1; }
216 ;
217
218string: T_STRING { $$ = $1; }
219 | quoted_string { $$ = $1; }
220 ;
221
222%%
Note: See TracBrowser for help on using the repository browser.