MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / scan_comment

Method scan_comment

examples/server/json.hpp:8145–8210  ·  view source on GitHub ↗

! * @brief scan a comment * @return whether comment could be scanned successfully */

Source from the content-addressed store, hash-verified

8143 * @return whether comment could be scanned successfully
8144 */
8145 bool scan_comment()
8146 {
8147 switch (get())
8148 {
8149 // single-line comments skip input until a newline or EOF is read
8150 case '/':
8151 {
8152 while (true)
8153 {
8154 switch (get())
8155 {
8156 case '\n':
8157 case '\r':
8158 case std::char_traits<char_type>::eof():
8159 case '\0':
8160 return true;
8161
8162 default:
8163 break;
8164 }
8165 }
8166 }
8167
8168 // multi-line comments skip input until */ is read
8169 case '*':
8170 {
8171 while (true)
8172 {
8173 switch (get())
8174 {
8175 case std::char_traits<char_type>::eof():
8176 case '\0':
8177 {
8178 error_message = "invalid comment; missing closing '*/'";
8179 return false;
8180 }
8181
8182 case '*':
8183 {
8184 switch (get())
8185 {
8186 case '/':
8187 return true;
8188
8189 default:
8190 {
8191 unget();
8192 continue;
8193 }
8194 }
8195 }
8196
8197 default:
8198 continue;
8199 }
8200 }
8201 }
8202

Callers

nothing calls this directly

Calls 2

ungetFunction · 0.85
getFunction · 0.70

Tested by

no test coverage detected