MCPcopy Create free account
hub / github.com/OpenMW/openmw / parseKeyword

Method parseKeyword

components/compiler/exprparser.cpp:356–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354 }
355
356 bool ExprParser::parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner)
357 {
358 if (const Extensions* extensions = getContext().getExtensions())
359 {
360 char returnType; // ignored
361 std::string argumentType; // ignored
362 bool hasExplicit = false; // ignored
363 bool isInstruction = extensions->isInstruction(keyword, argumentType, hasExplicit);
364
365 if (isInstruction
366 || (mExplicit.empty() && extensions->isFunction(keyword, returnType, argumentType, hasExplicit)))
367 {
368 std::string name = loc.mLiteral;
369 if (name.size() >= 2 && name[0] == '"' && name[name.size() - 1] == '"')
370 name = name.substr(1, name.size() - 2);
371 if (isInstruction || mLocals.getType(Misc::StringUtils::lowerCase(name)) != ' ')
372 {
373 // pretend this is not a keyword
374 return parseName(name, loc, scanner);
375 }
376 }
377 }
378
379 if (keyword == Scanner::K_end || keyword == Scanner::K_begin || keyword == Scanner::K_short
380 || keyword == Scanner::K_long || keyword == Scanner::K_float || keyword == Scanner::K_if
381 || keyword == Scanner::K_endif || keyword == Scanner::K_else || keyword == Scanner::K_elseif
382 || keyword == Scanner::K_while || keyword == Scanner::K_endwhile || keyword == Scanner::K_return
383 || keyword == Scanner::K_messagebox || keyword == Scanner::K_set || keyword == Scanner::K_to)
384 {
385 return parseName(loc.mLiteral, loc, scanner);
386 }
387
388 mFirst = false;
389
390 if (!mExplicit.empty())
391 {
392 if (mRefOp && mNextOperand)
393 {
394
395 // check for custom extensions
396 if (const Extensions* extensions = getContext().getExtensions())
397 {
398 char returnType;
399 std::string argumentType;
400
401 bool hasExplicit = true;
402 if (extensions->isFunction(keyword, returnType, argumentType, hasExplicit))
403 {
404 if (!hasExplicit)
405 {
406 getErrorHandler().warning("Stray explicit reference", loc);
407 mExplicit.clear();
408 }
409
410 start();
411
412 mTokenLoc = loc;
413 int optionals = parseArguments(argumentType, scanner);

Callers

nothing calls this directly

Calls 11

lowerCaseFunction · 0.85
getExtensionsMethod · 0.80
isInstructionMethod · 0.80
isFunctionMethod · 0.80
warningMethod · 0.80
generateFunctionCodeMethod · 0.80
putbackKeywordMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
getTypeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected