MCPcopy Create free account
hub / github.com/cselab/aphros / ParseCodeBlocks

Function ParseCodeBlocks

src/parse/codeblocks.cpp:110–138  ·  view source on GitHub ↗

Parses a stream and returns a list of code blocks.

Source from the content-addressed store, hash-verified

108
109// Parses a stream and returns a list of code blocks.
110std::vector<CodeBlock> ParseCodeBlocks(std::istream& f) {
111 std::vector<CodeBlock> blocks;
112 std::string error;
113 while (true) {
114 auto res = ParseCodeBlock(f);
115 if (!res.error.empty()) {
116 error = res.error;
117 break;
118 }
119 if (!res.found) {
120 break;
121 }
122 blocks.push_back(res.block);
123 }
124
125 if (!error.empty()) {
126 std::string o;
127 o += __func__;
128 o += ": error after parsing " + std::to_string(blocks.size()) + " blocks\n";
129 o += error;
130 if (blocks.size()) {
131 o += "\nlast successful block:\n";
132 o += "name='" + Strip(blocks.back().name) + "' ";
133 o += "content='" + Strip(blocks.back().content) + "'";
134 }
135 fassert(false, o);
136 }
137 return blocks;
138}

Callers 2

ParseGroupsMethod · 0.85
TestFunction · 0.85

Calls 4

ParseCodeBlockFunction · 0.85
emptyMethod · 0.80
StripFunction · 0.70
sizeMethod · 0.45

Tested by 1

TestFunction · 0.68