Changeset View
Changeset View
Standalone View
Standalone View
src/lib/definition.cpp
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Line(s) | 248 | { | |||
---|---|---|---|---|---|
251 | // init worklist and result used as guard with this definition | 251 | // init worklist and result used as guard with this definition | ||
252 | QVector<Definition> queue{*this}; | 252 | QVector<Definition> queue{*this}; | ||
253 | QVector<Definition> definitions{*this}; | 253 | QVector<Definition> definitions{*this}; | ||
254 | while (!queue.isEmpty()) { | 254 | while (!queue.isEmpty()) { | ||
255 | // Iterate all context rules to find associated Definitions. This will | 255 | // Iterate all context rules to find associated Definitions. This will | ||
256 | // automatically catch other Definitions referenced with IncludeRuldes or ContextSwitch. | 256 | // automatically catch other Definitions referenced with IncludeRuldes or ContextSwitch. | ||
257 | const auto definition = queue.takeLast(); | 257 | const auto definition = queue.takeLast(); | ||
258 | for (const auto & context : definition.d->contexts) { | 258 | for (const auto & context : definition.d->contexts) { | ||
259 | // handle context switch attributes of this context itself | ||||
260 | for (const auto switchContext : {context->lineEndContext().context(), context->lineEmptyContext().context(), context->fallthroughContext().context()}) { | ||||
261 | if (switchContext) { | ||||
262 | if (!definitions.contains(switchContext->definition())) { | ||||
263 | queue.push_back(switchContext->definition()); | ||||
264 | definitions.push_back(switchContext->definition()); | ||||
265 | } | ||||
266 | } | ||||
267 | } | ||||
268 | | ||||
269 | // handle the embedded rules | ||||
259 | for (const auto &rule : context->rules()) { | 270 | for (const auto &rule : context->rules()) { | ||
260 | // handle include rules like inclusion | 271 | // handle include rules like inclusion | ||
261 | if (!definitions.contains(rule->definition())) { | 272 | if (!definitions.contains(rule->definition())) { | ||
262 | queue.push_back(rule->definition()); | 273 | queue.push_back(rule->definition()); | ||
263 | definitions.push_back(rule->definition()); | 274 | definitions.push_back(rule->definition()); | ||
264 | } | 275 | } | ||
265 | 276 | | |||
266 | // handle context switch context inclusion | 277 | // handle context switch context inclusion | ||
▲ Show 20 Lines • Show All 508 Lines • Show Last 20 Lines |