Skip to content

Commit

Permalink
Implement translation for __FILE__ keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Sep 3, 2024
1 parent eec159b commit 476b1e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parser/prism/Translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
case PM_SOURCE_FILE_NODE: { // The `__FILE__` keyword
return translateSimpleKeyword<pm_source_file_node, parser::FileLiteral>(node);
}
case PM_SOURCE_LINE_NODE: { // The `__LINE__` keyword
return translateSimpleKeyword<pm_source_line_node, parser::LineLiteral>(node);
}
case PM_SPLAT_NODE: {
auto splatNode = reinterpret_cast<pm_splat_node *>(node);
pm_location_t *loc = &splatNode->base.location;
Expand Down Expand Up @@ -758,7 +761,6 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
case PM_RESCUE_MODIFIER_NODE:
case PM_RESCUE_NODE:
case PM_SHAREABLE_CONSTANT_NODE:
case PM_SOURCE_LINE_NODE:
case PM_UNDEF_NODE:
case PM_X_STRING_NODE:
case PM_SCOPE_NODE:
Expand Down
2 changes: 2 additions & 0 deletions test/prism_regression/keyword_LINE.parse-tree.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LineLiteral {
}
3 changes: 3 additions & 0 deletions test/prism_regression/keyword_LINE.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

__LINE__

0 comments on commit 476b1e3

Please sign in to comment.