MCPcopy Create free account
hub / github.com/Kitware/CMake / ParseFunction

Method ParseFunction

Source/cmListFileCache.cxx:208–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208bool cmListFileParser::ParseFunction(cm::string_view name, long line)
209{
210 // Ininitialize a new function call.
211 this->FunctionName.assign(name.data(), name.size());
212 this->FunctionLine = line;
213
214 // Command name has already been parsed. Read the left paren.
215 cmListFileLexer_Token* token;
216 while ((token = cmListFileLexer_Scan(this->Lexer.get())) &&
217 token->type == cmListFileLexer_Token_Space) {
218 }
219 if (!token) {
220 this->IssueError("Unexpected end of file.\n"
221 "Parse error. Function missing opening \"(\".");
222 return false;
223 }
224 if (token->type != cmListFileLexer_Token_ParenLeft) {
225 auto error = cmStrCat(
226 "Parse error. Expected \"(\", got ",
227 cmListFileLexer_GetTypeAsString(this->Lexer.get(), token->type),
228 " with text \"", cm::string_view(token->text, token->length), "\".");
229 this->IssueError(error);
230 return false;
231 }
232
233 // Arguments.
234 unsigned long parenDepth = 0;
235 this->Separation = SeparationOkay;
236 while ((token = cmListFileLexer_Scan(this->Lexer.get()))) {
237 if (token->type == cmListFileLexer_Token_Space ||
238 token->type == cmListFileLexer_Token_Newline) {
239 this->Separation = SeparationOkay;
240 continue;
241 }
242 if (token->type == cmListFileLexer_Token_ParenLeft) {
243 parenDepth++;
244 this->Separation = SeparationOkay;
245 if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
246 return false;
247 }
248 } else if (token->type == cmListFileLexer_Token_ParenRight) {
249 if (parenDepth == 0) {
250 this->FunctionLineEnd = token->line;
251 return true;
252 }
253 parenDepth--;
254 this->Separation = SeparationOkay;
255 if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
256 return false;
257 }
258 this->Separation = SeparationWarning;
259 } else if (token->type == cmListFileLexer_Token_Identifier ||
260 token->type == cmListFileLexer_Token_ArgumentUnquoted) {
261 if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
262 return false;
263 }
264 this->Separation = SeparationWarning;
265 } else if (token->type == cmListFileLexer_Token_ArgumentQuoted) {

Callers 1

ParseMethod · 0.95

Calls 11

IssueErrorMethod · 0.95
AddArgumentMethod · 0.95
cmListFileLexer_ScanFunction · 0.85
assignMethod · 0.80
PushMethod · 0.80
cmStrCatFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected