From f78e402590d54c674795836b29058cd9448c92d1 Mon Sep 17 00:00:00 2001 From: Emily Samp Date: Wed, 5 Jun 2024 16:03:58 -0500 Subject: [PATCH] Implement rational parsing --- main/pipeline/pipeline.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main/pipeline/pipeline.cc b/main/pipeline/pipeline.cc index a7f2e329dd7..92edc62ffea 100644 --- a/main/pipeline/pipeline.cc +++ b/main/pipeline/pipeline.cc @@ -174,6 +174,19 @@ unique_ptr convertPrismToSorbet(pm_node_t *node, pm_parser_t *pars break; } + case PM_RATIONAL_NODE: { + pm_rational_node *rationalNode = (pm_rational_node *)node; + pm_location_t *loc = &rationalNode->base.location; + + const uint8_t *start = rationalNode->numeric->location.start; + const uint8_t *end = rationalNode->numeric->location.end; + + std::string value = std::string(reinterpret_cast(start), end - start); + + return make_unique(locOffset(loc, parser), value); + + break; + } case PM_STATEMENTS_NODE: { pm_node_list body = ((pm_statements_node *)node)->body; pm_node *first = body.nodes[0]; @@ -311,7 +324,6 @@ unique_ptr convertPrismToSorbet(pm_node_t *node, pm_parser_t *pars case PM_POST_EXECUTION_NODE: case PM_PRE_EXECUTION_NODE: case PM_RANGE_NODE: - case PM_RATIONAL_NODE: case PM_REDO_NODE: case PM_REGULAR_EXPRESSION_NODE: case PM_REQUIRED_KEYWORD_PARAMETER_NODE: