35bool Foam::primitiveEntry::acceptToken
42 bool accept = tok.good();
44 if (tok.isDirective())
49 const word&
key = tok.wordToken();
55 || !expandFunction(
key.substr(1),
dict, is)
58 else if (tok.isExpression())
63 const string&
key = tok.stringToken();
79 else if (tok.isVariable())
85 const string&
key = tok.stringToken();
91 || !expandVariable(
key.substr(1),
dict)
99bool Foam::primitiveEntry::expandFunction
101 const word& functionName,
124 uint64_t balanced = 0u;
136 const char c = tok.
pToken();
141 if (depth >= 0 && depth < 61)
143 balanced &= ~(1u << depth);
151 if (depth >= 0 && depth < 61)
153 balanced |= (1u << depth);
167 "Too many closing ')' ... was a ';' forgotten?"
170 else if (depth < 61 && ((balanced >> depth) & 1u))
186 "Too many closing '}' ... was a ';' forgotten?"
189 else if (depth < 61 && !((balanced >> depth) & 1u))
192 reportReadWarning(is,
"Imbalanced '(' with '}'");
199 if (acceptToken(tok,
dict, is))
212 reportReadWarning(is,
"Imbalanced brackets");
222 const label keywordLineNumber = is.lineNumber();
237 std::ostringstream
os;
238 os <<
"ill defined primitiveEntry starting at keyword '"
240 <<
" on line " << keywordLineNumber
264 static_cast<IOstreamOption>(is),
284 os.writeKeyword(keyword());
290 bool started =
false;
291 for (
const token& tok : *
this)
329 const InfoProxy<primitiveEntry>& iproxy
332 const auto&
e = *iproxy;
336 const label nPrintTokens =
Foam::min(label(10), label(
e.size()));
338 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
340 for (label i = 0; i < nPrintTokens; ++i)
342 os <<
nl <<
" " <<
e[i].info();
A simple container for options an IOstream can normally have.
label lineNumber() const noexcept
Const access to the current stream line number.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
bool bad() const noexcept
True if stream is corrupted.
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ....
ITstream(const ITstream &is)
Copy construct.
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Istream & read(token &)=0
Return next token from stream.
void resize(const label len)
static const List< token > & null() noexcept
virtual Ostream & write(const char c) override
Write character.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry(const keyType &keyword)
Construct from keyword.
const keyType & keyword() const noexcept
Return keyword.
static void reportReadWarning(const IOstream &, const std::string &)
Report a read warning (on std::cerr).
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
A class for handling file names.
static bool execute(const dictionary &parentDict, primitiveEntry &thisEntry, Istream &is)
Execute in a primitiveEntry context, extracts token or line.
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.
A class for handling keywords in dictionaries.
primitiveEntry(const keyType &key)
Construct from keyword and no tokens.
virtual const fileName & name() const
Return the token stream name.
virtual void write(Ostream &os) const
Write.
virtual bool read(const dictionary &dict, Istream &is)
Read tokens from the given stream.
virtual const dictionary & dict() const
This entry is not a dictionary, calling this function generates a FatalError.
A token holds an item read from Istream.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
@ END_STATEMENT
End entry [isseparator].
@ NULL_TOKEN
Nul character.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
punctuationToken pToken() const
Return punctuation character.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
A class for handling words, derived from Foam::string.
#define SafeFatalIOErrorInFunction(ios, msg)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a).