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

Method ParseDef

libs/wgtcc/cpp.cc:725–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723
724
725 void Preprocessor::ParseDef(TokenSequence ls) {
726 ls.Next();
727 auto ident = ls.Expect(Token::IDENTIFIER);
728 if (ident->str_ == "defined") {
729 Error(ident, "'defined' cannot be used as a macro name");
730 }
731 auto tok = ls.Peek();
732 if (tok->tag_ == '(' && !tok->ws_) {
733 // There is no white space between ident and '('
734 // Hence, we are defining function-like macro
735
736 // Parse Identifier list
737 ls.Next(); // Skip '('
738 ParamList params;
739 auto variadic = ParseIdentList(params, ls);
740 const auto& macro = Macro(variadic, params, ls);
741 AddMacro(ident->str_, macro);
742 }
743 else {
744 AddMacro(ident->str_, Macro(ls));
745 }
746 }
747
748
749 bool Preprocessor::ParseIdentList(ParamList& params, TokenSequence& is) {

Callers

nothing calls this directly

Calls 5

ErrorFunction · 0.85
MacroClass · 0.85
ExpectMethod · 0.80
NextMethod · 0.45
PeekMethod · 0.45

Tested by

no test coverage detected