ruby-next-parser 3.1.0.0 → 3.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parser/ruby-next/lexer.rb +11345 -11023
- data/lib/parser/ruby-next/lexer.rl +41 -6
- data/lib/parser/ruby-next/version.rb +1 -1
- data/lib/parser/rubynext.rb +2456 -2438
- data/lib/parser/rubynext.y +21 -14
- metadata +4 -4
@@ -938,7 +938,11 @@ class Next
|
|
938
938
|
# b"
|
939
939
|
# must be parsed as "ab"
|
940
940
|
current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
|
941
|
-
elsif current_literal.regexp? && @version
|
941
|
+
elsif current_literal.regexp? && @version >= 31 && %w[c C m M].include?(escaped_char)
|
942
|
+
# Ruby >= 3.1 escapes \c- and \m chars, that's the only escape sequence
|
943
|
+
# supported by regexes so far, so it needs a separate branch.
|
944
|
+
current_literal.extend_string(@escape, @ts, @te)
|
945
|
+
elsif current_literal.regexp?
|
942
946
|
# Regular expressions should include escape sequences in their
|
943
947
|
# escaped form. On the other hand, escaped newlines are removed (in cases like "\\C-\\\n\\M-x")
|
944
948
|
current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
|
@@ -1439,6 +1443,18 @@ class Next
|
|
1439
1443
|
=> { emit(:tLABEL, tok(@ts, @te - 2), @ts, @te - 1)
|
1440
1444
|
fhold; fnext expr_labelarg; fbreak; };
|
1441
1445
|
|
1446
|
+
'...' c_nl
|
1447
|
+
=> {
|
1448
|
+
if @version >= 31
|
1449
|
+
emit(:tBDOT3, '...'.freeze, @ts, @te - 1)
|
1450
|
+
emit(:tNL, "\n".freeze, @te - 1, @te)
|
1451
|
+
fnext expr_end; fbreak;
|
1452
|
+
else
|
1453
|
+
p -= 4;
|
1454
|
+
fhold; fgoto expr_end;
|
1455
|
+
end
|
1456
|
+
};
|
1457
|
+
|
1442
1458
|
w_space_comment;
|
1443
1459
|
|
1444
1460
|
c_any
|
@@ -2043,19 +2059,38 @@ class Next
|
|
2043
2059
|
fnext expr_beg; fbreak;
|
2044
2060
|
};
|
2045
2061
|
|
2046
|
-
'...'
|
2062
|
+
'...' c_nl?
|
2047
2063
|
=> {
|
2064
|
+
# Here we scan and conditionally emit "\n":
|
2065
|
+
# + if it's there
|
2066
|
+
# + and emitted we do nothing
|
2067
|
+
# + and not emitted we return `p` to "\n" to process it on the next scan
|
2068
|
+
# + if it's not there we do nothing
|
2069
|
+
followed_by_nl = @te - 1 == @newline_s
|
2070
|
+
nl_emitted = false
|
2071
|
+
dots_te = followed_by_nl ? @te - 1 : @te
|
2072
|
+
|
2048
2073
|
if @version >= 30
|
2049
2074
|
if @lambda_stack.any? && @lambda_stack.last + 1 == @paren_nest
|
2050
2075
|
# To reject `->(...)` like `->...`
|
2051
|
-
emit(:tDOT3)
|
2076
|
+
emit(:tDOT3, '...'.freeze, @ts, dots_te)
|
2052
2077
|
else
|
2053
|
-
emit(:tBDOT3)
|
2078
|
+
emit(:tBDOT3, '...'.freeze, @ts, dots_te)
|
2079
|
+
|
2080
|
+
if @version >= 31 && followed_by_nl && @context.in_def_open_args?
|
2081
|
+
emit(:tNL, @te - 1, @te)
|
2082
|
+
nl_emitted = true
|
2083
|
+
end
|
2054
2084
|
end
|
2055
2085
|
elsif @version >= 27
|
2056
|
-
emit(:tBDOT3)
|
2086
|
+
emit(:tBDOT3, '...'.freeze, @ts, dots_te)
|
2057
2087
|
else
|
2058
|
-
emit(:tDOT3)
|
2088
|
+
emit(:tDOT3, '...'.freeze, @ts, dots_te)
|
2089
|
+
end
|
2090
|
+
|
2091
|
+
if followed_by_nl && !nl_emitted
|
2092
|
+
# return "\n" to process it on the next scan
|
2093
|
+
fhold;
|
2059
2094
|
end
|
2060
2095
|
|
2061
2096
|
fnext expr_beg; fbreak;
|