Skip to content

Commit 0a7ba1e

Browse files
committed
Adding C++ parser.
1 parent 11a3e57 commit 0a7ba1e

1 file changed

Lines changed: 0 additions & 34 deletions

File tree

parser_cpp/logica_parse.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -414,40 +414,6 @@ static SpanString SpanFromJson(const Json& j) {
414414
return SpanString(SpanTextFromJson(j));
415415
}
416416

417-
static void ConvertSpanOffsetsToChar(Json& node) {
418-
if (!g_heritage_pool) return;
419-
if (node.is_array()) {
420-
auto& a = node.as_array();
421-
// Span encoding: ["__hs", idx, start, stop]
422-
if (a.size() == 4 && a[0].is_string() && a[0].as_string() == "__hs") {
423-
const int64_t idx = a[1].as_int();
424-
const int64_t start_b = a[2].as_int();
425-
const int64_t stop_b = a[3].as_int();
426-
a[2] = Json(g_heritage_pool->ByteOffsetToCharOffset(idx, start_b));
427-
a[3] = Json(g_heritage_pool->ByteOffsetToCharOffset(idx, stop_b));
428-
return;
429-
}
430-
for (auto& v : a) ConvertSpanOffsetsToChar(v);
431-
return;
432-
}
433-
if (!node.is_object()) return;
434-
auto& o = node.as_object();
435-
const bool is_span = o.count("__hs") && o.count("start") && o.count("stop") && o.size() <= 3;
436-
if (is_span) {
437-
const int64_t idx = o.at("__hs").as_int();
438-
const int64_t start_b = o.at("start").as_int();
439-
const int64_t stop_b = o.at("stop").as_int();
440-
const int64_t start_c = g_heritage_pool->ByteOffsetToCharOffset(idx, start_b);
441-
const int64_t stop_c = g_heritage_pool->ByteOffsetToCharOffset(idx, stop_b);
442-
o["start"] = Json(start_c);
443-
o["stop"] = Json(stop_c);
444-
return;
445-
}
446-
for (auto& kv : o) {
447-
ConvertSpanOffsetsToChar(kv.second);
448-
}
449-
}
450-
451417
// ------------------------------
452418
// Parsing exception.
453419
// ------------------------------

0 commit comments

Comments
 (0)