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

Method parseKeyword

components/compiler/lineparser.cpp:215–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 }
214
215 bool LineParser::parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner)
216 {
217 if (mState == MessageState)
218 {
219 if (const Extensions* extensions = getContext().getExtensions())
220 {
221 std::string argumentType; // ignored
222 bool hasExplicit = false; // ignored
223 if (extensions->isInstruction(keyword, argumentType, hasExplicit))
224 {
225 // pretend this is not a keyword
226 std::string name = loc.mLiteral;
227 if (name.size() >= 2 && name[0] == '"' && name[name.size() - 1] == '"')
228 name = name.substr(1, name.size() - 2);
229 return parseName(name, loc, scanner);
230 }
231 }
232 }
233
234 if (mState == SetMemberVarState)
235 {
236 mMemberName = loc.mLiteral;
237 std::pair<char, bool> type = getContext().getMemberType(mMemberName, ESM::RefId::stringRefId(mName));
238
239 if (type.first != ' ')
240 {
241 mState = SetMemberVarState2;
242 mType = type.first;
243 mReferenceMember = type.second;
244 return true;
245 }
246 }
247
248 if (mState == SetPotentialMemberVarState && keyword == Scanner::K_to)
249 {
250 getErrorHandler().warning("Unknown variable", loc);
251 SkipParser skip(getErrorHandler(), getContext());
252 scanner.scan(skip);
253 return false;
254 }
255
256 if (mState == SetState || mState == MessageButtonState)
257 {
258 // Allow keywords to be used as variable names and as buttons.
259 return parseName(loc.mLiteral, loc, scanner);
260 }
261
262 if (mState == BeginState || mState == ExplicitState)
263 {
264 // check for custom extensions
265 if (const Extensions* extensions = getContext().getExtensions())
266 {
267 std::string argumentType;
268
269 bool hasExplicit = mState == ExplicitState;
270 if (extensions->isInstruction(keyword, argumentType, hasExplicit))
271 {
272 if (!hasExplicit && mState == ExplicitState)

Callers

nothing calls this directly

Calls 15

exitFunction · 0.85
assignToLocalFunction · 0.85
assignToGlobalFunction · 0.85
assignToMemberFunction · 0.85
getExtensionsMethod · 0.80
isInstructionMethod · 0.80
warningMethod · 0.80
scanMethod · 0.80
parseArgumentsMethod · 0.80
isFunctionMethod · 0.80
putbackKeywordMethod · 0.80

Tested by

no test coverage detected