Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,11 @@ flags:
- name: IGNORE_VISIBILITY
comment: "a call that ignores method visibility"
comment: Flags for call nodes.
- name: EmbeddedStatementsNodeFlags
values:
- name: LITERAL_CONTENT
comment: "the interpolation contributes literal string content to the enclosing literal"
comment: Flags for embedded statements nodes.
- name: EncodingFlags
values:
- name: FORCED_UTF8_ENCODING
Expand Down Expand Up @@ -2935,6 +2940,7 @@ nodes:
if a then b else c end
^^^^^^^^^^
- name: EmbeddedStatementsNode
flags: EmbeddedStatementsNodeFlags
fields:
- name: opening_loc
type: location
Expand All @@ -2948,6 +2954,10 @@ nodes:

"foo #{bar}"
^^^^^^

The `literal_content?` flag is set on `#{begin "a" end}`, which folds
into the enclosing literal. A leading semicolon in `#{; "a"}` keeps
the interpolation as a runtime expression.
- name: EmbeddedVariableNode
fields:
- name: operator_loc
Expand Down
3 changes: 3 additions & 0 deletions include/prism/internal/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ enum {
PM_STRING_CONCAT_ENCODING_UTF8 | PM_STRING_CONCAT_ENCODING_BINARY
};

/* The string supplies literal text when it is itself interpolated. */
static const pm_node_flags_t PM_INTERPOLATED_STRING_NODE_FLAGS_LITERAL_CONTENT = ((PM_INTERPOLATED_STRING_NODE_FLAGS_LAST - 1) << 7);

/*
* A growable list of nodes for bookkeeping that never becomes part of the tree,
* such as the block exits and implicit parameters that are tracked while
Expand Down
2 changes: 1 addition & 1 deletion snapshots/encoding_binary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
│ ├── opening_loc: (7,0)-(7,1) = "/"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (7,1)-(7,10))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (7,1)-(7,3) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (7,3)-(7,9))
Expand Down
14 changes: 7 additions & 7 deletions snapshots/heredoc_percent_newline_delimiter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
│ │ ├── opening_loc: ∅
│ │ ├── parts: (length: 1)
│ │ │ └── @ EmbeddedStatementsNode (location: (2,0)-(2,6))
│ │ │ ├── flags: ∅
│ │ │ ├── flags: literal_content
│ │ │ ├── opening_loc: (2,0)-(2,2) = "\#{"
│ │ │ ├── statements:
│ │ │ │ @ StatementsNode (location: (2,2)-(2,5))
Expand All @@ -37,7 +37,7 @@
│ │ ├── opening_loc: ∅
│ │ ├── parts: (length: 1)
│ │ │ └── @ EmbeddedStatementsNode (location: (6,0)-(6,6))
│ │ │ ├── flags: ∅
│ │ │ ├── flags: literal_content
│ │ │ ├── opening_loc: (6,0)-(6,2) = "\#{"
│ │ │ ├── statements:
│ │ │ │ @ StatementsNode (location: (6,2)-(6,5))
Expand All @@ -58,7 +58,7 @@
│ ├── opening_loc: (9,0)-(10,0) = "%r\n"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (10,0)-(10,6))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (10,0)-(10,2) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (10,2)-(10,5))
Expand Down Expand Up @@ -86,7 +86,7 @@
│ │ │ │ ├── closing_loc: ∅
│ │ │ │ └── unescaped: "a"
│ │ │ ├── @ EmbeddedStatementsNode (location: (14,1)-(14,7))
│ │ │ │ ├── flags: ∅
│ │ │ │ ├── flags: literal_content
│ │ │ │ ├── opening_loc: (14,1)-(14,3) = "\#{"
│ │ │ │ ├── statements:
│ │ │ │ │ @ StatementsNode (location: (14,3)-(14,6))
Expand Down Expand Up @@ -122,7 +122,7 @@
│ │ │ │ ├── closing_loc: ∅
│ │ │ │ └── unescaped: "a"
│ │ │ ├── @ EmbeddedStatementsNode (location: (19,1)-(19,7))
│ │ │ │ ├── flags: ∅
│ │ │ │ ├── flags: literal_content
│ │ │ │ ├── opening_loc: (19,1)-(19,3) = "\#{"
│ │ │ │ ├── statements:
│ │ │ │ │ @ StatementsNode (location: (19,3)-(19,6))
Expand Down Expand Up @@ -155,7 +155,7 @@
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
│ │ ├── @ EmbeddedStatementsNode (location: (24,1)-(24,7))
│ │ │ ├── flags: ∅
│ │ │ ├── flags: literal_content
│ │ │ ├── opening_loc: (24,1)-(24,3) = "\#{"
│ │ │ ├── statements:
│ │ │ │ @ StatementsNode (location: (24,3)-(24,6))
Expand All @@ -180,7 +180,7 @@
├── opening_loc: (29,0)-(30,0) = "%r\n"
├── parts: (length: 1)
│ └── @ EmbeddedStatementsNode (location: (30,0)-(30,6))
│ ├── flags: ∅
│ ├── flags: literal_content
│ ├── opening_loc: (30,0)-(30,2) = "\#{"
│ ├── statements:
│ │ @ StatementsNode (location: (30,2)-(30,5))
Expand Down
10 changes: 5 additions & 5 deletions snapshots/heredoc_percent_q_newline_delimiter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
│ ├── opening_loc: (1,0)-(2,0) = "%Q\n"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (2,0)-(2,6))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (2,0)-(2,2) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (2,2)-(2,5))
Expand All @@ -29,7 +29,7 @@
│ ├── opening_loc: (5,0)-(6,0) = "%\n"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (6,0)-(6,6))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (6,0)-(6,2) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (6,2)-(6,5))
Expand All @@ -54,7 +54,7 @@
│ ├── opening_loc: (9,5)-(10,0) = "%Q\n"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (11,0)-(11,6))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (11,0)-(11,2) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (11,2)-(11,5))
Expand All @@ -79,7 +79,7 @@
│ ├── opening_loc: (14,5)-(15,0) = "%\n"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (16,0)-(16,6))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (16,0)-(16,2) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (16,2)-(16,5))
Expand All @@ -98,7 +98,7 @@
├── opening_loc: (20,0)-(21,0) = "%Q\r\n"
├── parts: (length: 1)
│ └── @ EmbeddedStatementsNode (location: (21,0)-(21,6))
│ ├── flags: ∅
│ ├── flags: literal_content
│ ├── opening_loc: (21,0)-(21,2) = "\#{"
│ ├── statements:
│ │ @ StatementsNode (location: (21,2)-(21,5))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/heredocs_nested.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "pre\n"
│ │ ├── @ EmbeddedStatementsNode (location: (3,0)-(7,1))
│ │ │ ├── flags: ∅
│ │ │ ├── flags: literal_content
│ │ │ ├── opening_loc: (3,0)-(3,2) = "\#{"
│ │ │ ├── statements:
│ │ │ │ @ StatementsNode (location: (4,0)-(4,6))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/dstr_evstr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
├── opening_loc: (1,0)-(1,1) = "\""
├── parts: (length: 2)
│ ├── @ EmbeddedStatementsNode (location: (1,1)-(1,7))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (1,1)-(1,3) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (1,3)-(1,6))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/dstr_str.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
├── opening_loc: (1,0)-(1,1) = "\""
├── parts: (length: 2)
│ ├── @ EmbeddedStatementsNode (location: (1,1)-(1,7))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (1,1)-(1,3) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (1,3)-(1,6))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/heredoc_nested.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
│ │ ├── opening_loc: (1,1)-(1,4) = "<<A"
│ │ ├── parts: (length: 3)
│ │ │ ├── @ EmbeddedStatementsNode (location: (2,0)-(2,6))
│ │ │ │ ├── flags: ∅
│ │ │ │ ├── flags: literal_content
│ │ │ │ ├── opening_loc: (2,0)-(2,2) = "\#{"
│ │ │ │ ├── statements:
│ │ │ │ │ @ StatementsNode (location: (2,2)-(2,5))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/pct_w_heredoc_interp_nested.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
│ │ ├── opening_loc: ∅
│ │ ├── parts: (length: 1)
│ │ │ └── @ EmbeddedStatementsNode (location: (1,6)-(1,12))
│ │ │ ├── flags: ∅
│ │ │ ├── flags: literal_content
│ │ │ ├── opening_loc: (1,6)-(1,8) = "\#{"
│ │ │ ├── statements:
│ │ │ │ @ StatementsNode (location: (1,8)-(1,11))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/str_str.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "a "
│ └── @ EmbeddedStatementsNode (location: (1,3)-(1,9))
│ ├── flags: ∅
│ ├── flags: literal_content
│ ├── opening_loc: (1,3)-(1,5) = "\#{"
│ ├── statements:
│ │ @ StatementsNode (location: (1,5)-(1,8))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/seattlerb/str_str_str.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "a "
│ ├── @ EmbeddedStatementsNode (location: (1,3)-(1,9))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (1,3)-(1,5) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (1,5)-(1,8))
Expand Down
4 changes: 2 additions & 2 deletions snapshots/unparser/corpus/literal/literal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@
│ ├── opening_loc: (53,0)-(53,1) = "/"
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (53,1)-(53,12))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (53,1)-(53,3) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (53,3)-(53,11))
Expand Down Expand Up @@ -763,7 +763,7 @@
│ ├── opening_loc: (59,0)-(59,2) = ":\""
│ ├── parts: (length: 1)
│ │ └── @ EmbeddedStatementsNode (location: (59,2)-(59,10))
│ │ ├── flags: ∅
│ │ ├── flags: literal_content
│ │ ├── opening_loc: (59,2)-(59,4) = "\#{"
│ │ ├── statements:
│ │ │ @ StatementsNode (location: (59,4)-(59,9))
Expand Down
2 changes: 1 addition & 1 deletion snapshots/whitequark/dedenting_heredoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
│ │ │ │ ├── closing_loc: ∅
│ │ │ │ └── unescaped: " x\n"
│ │ │ ├── @ EmbeddedStatementsNode (location: (3,2)-(3,10))
│ │ │ │ ├── flags: ∅
│ │ │ │ ├── flags: literal_content
│ │ │ │ ├── opening_loc: (3,2)-(3,4) = "\#{"
│ │ │ │ ├── statements:
│ │ │ │ │ @ StatementsNode (location: (3,4)-(3,9))
Expand Down
Loading
Loading