MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / ParseElse

Method ParseElse

libs/wgtcc/cpp.cc:611–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609
610
611 void Preprocessor::ParseElse(TokenSequence ls) {
612 auto directive = ls.Next();
613 if (!ls.Empty())
614 Error(ls.Peek(), "expect new line");
615
616 if (ppCondStack_.empty())
617 Error(directive, "unexpected 'else' directive");
618 auto top = ppCondStack_.top();
619 if (top.tag_ == Token::PP_ELSE)
620 Error(directive, "unexpected 'else' directive");
621
622 while (!ppCondStack_.empty()) {
623 top = ppCondStack_.top();
624 if (top.tag_ == Token::PP_IF ||
625 top.tag_ == Token::PP_IFDEF ||
626 top.tag_ == Token::PP_IFNDEF ||
627 top.cond_) {
628 break;
629 }
630 ppCondStack_.pop();
631 }
632 if (ppCondStack_.empty())
633 Error(directive, "unexpected 'else' directive");
634
635 auto cond = !top.cond_;
636 auto enabled = top.enabled_;
637 ppCondStack_.push({ Token::PP_ELSE, enabled, cond });
638 }
639
640
641 void Preprocessor::ParseEndif(TokenSequence ls) {

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.85
NextMethod · 0.45
EmptyMethod · 0.45
PeekMethod · 0.45

Tested by

no test coverage detected