38 namespace functionEntries
56 void Foam::functionEntries::ifeqEntry::readToken(token& t, Istream& is)
61 if (is.read(t).bad() || is.eof() || !t.good())
70 Foam::token Foam::functionEntries::ifeqEntry::expandToken
72 const dictionary&
dict,
73 const string& keyword,
77 if (keyword[0] ==
'$')
79 const word varName(keyword.substr(1));
85 return token(ePtr->stream());
90 string expanded(keyword);
94 return token(expanded, t.lineNumber());
97 else if (!t.isString())
100 return token(keyword, t.lineNumber());
107 Foam::token Foam::functionEntries::ifeqEntry::expandToken
109 const dictionary&
dict,
115 return expandToken(
dict, t.wordToken(), t);
117 else if (t.isVariable())
119 return expandToken(
dict, t.stringToken(), t);
121 else if (t.isString())
123 return expandToken(
dict, t.stringToken(), t);
130 bool Foam::functionEntries::ifeqEntry::equalToken
136 const bool eqType = (t1.type() == t2.type());
144 return (eqType && t1.boolToken() == t2.boolToken());
147 return (eqType && t1.flagToken() == t2.flagToken());
150 return (eqType && t1.pToken() == t2.pToken());
156 return t1.wordToken() == t2.wordToken();
158 else if (t2.isString())
161 return w2.match(t1.wordToken());
170 return w1.match(
w2) ||
w2.match(
w1);
172 else if (t2.isWord())
175 return w1.match(t2.wordToken());
181 if (t2.isStringType())
183 return t1.stringToken() == t2.stringToken();
190 return t1.labelToken() == t2.labelToken();
192 else if (t2.isScalar())
194 return t1.labelToken() == t2.scalarToken();
201 return equal(t1.floatToken(), t2.floatToken());
203 else if (t2.isLabel())
205 return t1.floatToken() == t2.labelToken();
207 else if (t2.isScalar())
209 return t1.scalarToken() == t2.scalarToken();
216 return equal(t1.doubleToken(), t2.doubleToken());
218 else if (t2.isLabel())
220 return t1.doubleToken() == t2.labelToken();
222 else if (t2.isScalar())
224 return t1.scalarToken() == t2.scalarToken();
242 void Foam::functionEntries::ifeqEntry::skipUntil
244 DynamicList<filePos>& stack,
245 const dictionary& parentDict,
246 const word& endDirective,
255 if (!t.isDirective())
259 else if (t.wordToken() ==
"#if" || t.wordToken() ==
"#ifeq")
261 stack.append(filePos(is.name(), is.lineNumber()));
262 skipUntil(stack, parentDict,
"#endif", is);
265 else if (t.wordToken() == endDirective)
272 <<
"Did not find matching " << endDirective <<
nl
291 bool pending =
false;
298 execute(stack, parentDict, is);
303 ifEntry::execute(stack, parentDict, is);
312 skipUntil(stack, parentDict,
"#endif", is);
355 evaluate(
true, stack, parentDict, is);
374 skipUntil(stack, parentDict,
"#endif", is);
392 if (ifEntry::isTrue(
e.stream()))
409 evaluate(
false, stack, parentDict, is);
414 evaluate(
true, stack, parentDict, is);
428 const label nNested = stack.size();
434 cond1 = expandToken(parentDict, cond1);
438 cond2 = expandToken(parentDict, cond2);
440 const bool equal = equalToken(cond1, cond2);
449 if (stack.size() != nNested)
452 <<
"Did not find matching #endif for condition starting"
453 <<
" at line " << stack.last().second()
470 return execute(stack, parentDict, is);