Skip to content

Commit

Permalink
Implement rational parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
egiurleo committed Jun 5, 2024
1 parent 289dd78 commit f78e402
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main/pipeline/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ unique_ptr<parser::Node> 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<const char *>(start), end - start);

return make_unique<parser::Rational>(locOffset(loc, parser), value);

break;
}
case PM_STATEMENTS_NODE: {
pm_node_list body = ((pm_statements_node *)node)->body;
pm_node *first = body.nodes[0];
Expand Down Expand Up @@ -311,7 +324,6 @@ unique_ptr<parser::Node> 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:
Expand Down

0 comments on commit f78e402

Please sign in to comment.