MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ast1

Method ast1

test/testtokenlist.cpp:168–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 }
167
168 void ast1() const {
169 const char code[] = "('Release|x64' == 'Release|x64');";
170
171 TokenList tokenlist(settingsDefault, Standards::Language::C);
172 ASSERT(tokenlist.createTokensFromString(code));
173 // TODO: put this logic in TokenList
174 // generate links
175 {
176 std::stack<Token*> lpar;
177 for (Token* tok2 = tokenlist.front(); tok2; tok2 = tok2->next()) {
178 if (tok2->str() == "(")
179 lpar.push(tok2);
180 else if (tok2->str() == ")") {
181 if (lpar.empty())
182 break;
183 Token::createMutualLinks(lpar.top(), tok2);
184 lpar.pop();
185 }
186 }
187 }
188 tokenlist.createAst(); // do not crash
189 }
190};
191
192REGISTER_TEST(TestTokenList)

Callers

nothing calls this directly

Calls 6

frontMethod · 0.80
nextMethod · 0.80
createAstMethod · 0.80
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected