prism 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -1
- data/Makefile +1 -1
- data/config.yml +429 -2
- data/docs/build_system.md +8 -11
- data/docs/releasing.md +1 -1
- data/docs/relocation.md +34 -0
- data/docs/ruby_api.md +1 -1
- data/ext/prism/api_node.c +1824 -1305
- data/ext/prism/extconf.rb +13 -36
- data/ext/prism/extension.c +298 -109
- data/ext/prism/extension.h +4 -4
- data/include/prism/ast.h +442 -2
- data/include/prism/defines.h +26 -8
- data/include/prism/options.h +47 -1
- data/include/prism/util/pm_buffer.h +10 -0
- data/include/prism/version.h +2 -2
- data/include/prism.h +51 -4
- data/lib/prism/dot_visitor.rb +26 -0
- data/lib/prism/dsl.rb +14 -6
- data/lib/prism/ffi.rb +93 -28
- data/lib/prism/inspect_visitor.rb +4 -1
- data/lib/prism/node.rb +1886 -105
- data/lib/prism/parse_result/errors.rb +1 -1
- data/lib/prism/parse_result/newlines.rb +1 -1
- data/lib/prism/parse_result.rb +54 -2
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/reflection.rb +4 -4
- data/lib/prism/relocation.rb +504 -0
- data/lib/prism/serialize.rb +1252 -765
- data/lib/prism/string_query.rb +30 -0
- data/lib/prism/translation/parser/builder.rb +61 -0
- data/lib/prism/translation/parser/compiler.rb +228 -162
- data/lib/prism/translation/parser/lexer.rb +435 -61
- data/lib/prism/translation/parser.rb +51 -3
- data/lib/prism/translation/parser35.rb +12 -0
- data/lib/prism/translation/ripper.rb +13 -3
- data/lib/prism/translation/ruby_parser.rb +17 -7
- data/lib/prism/translation.rb +1 -0
- data/lib/prism.rb +9 -7
- data/prism.gemspec +11 -1
- data/rbi/prism/dsl.rbi +10 -7
- data/rbi/prism/node.rbi +44 -17
- data/rbi/prism/parse_result.rbi +17 -0
- data/rbi/prism/string_query.rbi +12 -0
- data/rbi/prism/translation/parser35.rbi +6 -0
- data/rbi/prism.rbi +39 -36
- data/sig/prism/dsl.rbs +6 -4
- data/sig/prism/node.rbs +29 -15
- data/sig/prism/parse_result.rbs +10 -0
- data/sig/prism/relocation.rbs +185 -0
- data/sig/prism/serialize.rbs +4 -2
- data/sig/prism/string_query.rbs +11 -0
- data/sig/prism.rbs +22 -1
- data/src/diagnostic.c +2 -2
- data/src/node.c +39 -0
- data/src/options.c +31 -0
- data/src/prettyprint.c +62 -0
- data/src/prism.c +738 -199
- data/src/regexp.c +7 -3
- data/src/serialize.c +18 -0
- data/src/static_literals.c +1 -1
- data/src/util/pm_buffer.c +40 -0
- data/src/util/pm_char.c +1 -1
- data/src/util/pm_constant_pool.c +6 -2
- data/src/util/pm_string.c +1 -0
- data/src/util/pm_strncasecmp.c +13 -1
- metadata +13 -7
data/config.yml
CHANGED
@@ -719,6 +719,11 @@ flags:
|
|
719
719
|
- name: REPEATED_PARAMETER
|
720
720
|
comment: "a parameter name that has been repeated in the method signature"
|
721
721
|
comment: Flags for parameter nodes.
|
722
|
+
- name: ParenthesesNodeFlags
|
723
|
+
values:
|
724
|
+
- name: MULTIPLE_STATEMENTS
|
725
|
+
comment: "parentheses that contain multiple potentially void statements"
|
726
|
+
comment: Flags for parentheses nodes.
|
722
727
|
- name: RangeFlags
|
723
728
|
values:
|
724
729
|
- name: EXCLUDE_END
|
@@ -855,6 +860,11 @@ nodes:
|
|
855
860
|
^^^^^^^^^
|
856
861
|
- name: keyword_loc
|
857
862
|
type: location
|
863
|
+
comment: |
|
864
|
+
Represents the location of the `alias` keyword.
|
865
|
+
|
866
|
+
alias foo bar
|
867
|
+
^^^^^
|
858
868
|
comment: |
|
859
869
|
Represents the use of the `alias` keyword to alias a method.
|
860
870
|
|
@@ -932,6 +942,11 @@ nodes:
|
|
932
942
|
- name: arguments
|
933
943
|
type: node[]
|
934
944
|
kind: non-void expression
|
945
|
+
comment: |
|
946
|
+
The list of arguments, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
947
|
+
|
948
|
+
foo(bar, baz)
|
949
|
+
^^^^^^^^
|
935
950
|
comment: |
|
936
951
|
Represents a set of arguments to a method or a keyword.
|
937
952
|
|
@@ -977,16 +992,41 @@ nodes:
|
|
977
992
|
- name: requireds
|
978
993
|
type: node[]
|
979
994
|
kind: pattern expression
|
995
|
+
comment: |
|
996
|
+
Represents the required elements of the array pattern.
|
997
|
+
|
998
|
+
foo in [1, 2]
|
999
|
+
^ ^
|
980
1000
|
- name: rest
|
981
1001
|
type: node?
|
982
1002
|
kind: pattern expression
|
1003
|
+
comment: |
|
1004
|
+
Represents the rest element of the array pattern.
|
1005
|
+
|
1006
|
+
foo in *bar
|
1007
|
+
^^^^
|
983
1008
|
- name: posts
|
984
1009
|
type: node[]
|
985
1010
|
kind: pattern expression
|
1011
|
+
comment: |
|
1012
|
+
Represents the elements after the rest element of the array pattern.
|
1013
|
+
|
1014
|
+
foo in *bar, baz
|
1015
|
+
^^^
|
986
1016
|
- name: opening_loc
|
987
1017
|
type: location?
|
1018
|
+
comment: |
|
1019
|
+
Represents the opening location of the array pattern.
|
1020
|
+
|
1021
|
+
foo in [1, 2]
|
1022
|
+
^
|
988
1023
|
- name: closing_loc
|
989
1024
|
type: location?
|
1025
|
+
comment: |
|
1026
|
+
Represents the closing location of the array pattern.
|
1027
|
+
|
1028
|
+
foo in [1, 2]
|
1029
|
+
^
|
990
1030
|
comment: |
|
991
1031
|
Represents an array pattern in pattern matching.
|
992
1032
|
|
@@ -996,8 +1036,8 @@ nodes:
|
|
996
1036
|
foo in [1, 2]
|
997
1037
|
^^^^^^^^^^^^^
|
998
1038
|
|
999
|
-
foo in *
|
1000
|
-
|
1039
|
+
foo in *bar
|
1040
|
+
^^^^^^^^^^^
|
1001
1041
|
|
1002
1042
|
foo in Bar[]
|
1003
1043
|
^^^^^^^^^^^^
|
@@ -1084,20 +1124,50 @@ nodes:
|
|
1084
1124
|
fields:
|
1085
1125
|
- name: begin_keyword_loc
|
1086
1126
|
type: location?
|
1127
|
+
comment: |
|
1128
|
+
Represents the location of the `begin` keyword.
|
1129
|
+
|
1130
|
+
begin x end
|
1131
|
+
^^^^^
|
1087
1132
|
- name: statements
|
1088
1133
|
type: node?
|
1089
1134
|
kind: StatementsNode
|
1135
|
+
comment: |
|
1136
|
+
Represents the statements within the begin block.
|
1137
|
+
|
1138
|
+
begin x end
|
1139
|
+
^
|
1090
1140
|
- name: rescue_clause
|
1091
1141
|
type: node?
|
1092
1142
|
kind: RescueNode
|
1143
|
+
comment: |
|
1144
|
+
Represents the rescue clause within the begin block.
|
1145
|
+
|
1146
|
+
begin x; rescue y; end
|
1147
|
+
^^^^^^^^
|
1093
1148
|
- name: else_clause
|
1094
1149
|
type: node?
|
1095
1150
|
kind: ElseNode
|
1151
|
+
comment: |
|
1152
|
+
Represents the else clause within the begin block.
|
1153
|
+
|
1154
|
+
begin x; rescue y; else z; end
|
1155
|
+
^^^^^^
|
1096
1156
|
- name: ensure_clause
|
1097
1157
|
type: node?
|
1098
1158
|
kind: EnsureNode
|
1159
|
+
comment: |
|
1160
|
+
Represents the ensure clause within the begin block.
|
1161
|
+
|
1162
|
+
begin x; ensure y; end
|
1163
|
+
^^^^^^^^
|
1099
1164
|
- name: end_keyword_loc
|
1100
1165
|
type: location?
|
1166
|
+
comment: |
|
1167
|
+
Represents the location of the `end` keyword.
|
1168
|
+
|
1169
|
+
begin x end
|
1170
|
+
^^^
|
1101
1171
|
newline: false
|
1102
1172
|
comment: |
|
1103
1173
|
Represents a begin statement.
|
@@ -1111,8 +1181,18 @@ nodes:
|
|
1111
1181
|
- name: expression
|
1112
1182
|
type: node?
|
1113
1183
|
kind: non-void expression
|
1184
|
+
comment: |
|
1185
|
+
The expression that is being passed as a block argument. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1186
|
+
|
1187
|
+
foo(&args)
|
1188
|
+
^^^^^
|
1114
1189
|
- name: operator_loc
|
1115
1190
|
type: location
|
1191
|
+
comment: |
|
1192
|
+
Represents the location of the `&` operator.
|
1193
|
+
|
1194
|
+
foo(&args)
|
1195
|
+
^
|
1116
1196
|
comment: |
|
1117
1197
|
Represents a block argument using `&`.
|
1118
1198
|
|
@@ -1123,6 +1203,11 @@ nodes:
|
|
1123
1203
|
fields:
|
1124
1204
|
- name: name
|
1125
1205
|
type: constant
|
1206
|
+
comment: |
|
1207
|
+
The name of the block local variable.
|
1208
|
+
|
1209
|
+
a { |; b| } # name `:b`
|
1210
|
+
^
|
1126
1211
|
comment: |
|
1127
1212
|
Represents a block local variable.
|
1128
1213
|
|
@@ -1132,21 +1217,50 @@ nodes:
|
|
1132
1217
|
fields:
|
1133
1218
|
- name: locals
|
1134
1219
|
type: constant[]
|
1220
|
+
comment: |
|
1221
|
+
The local variables declared in the block.
|
1222
|
+
|
1223
|
+
[1, 2, 3].each { |i| puts x } # locals: [:i]
|
1224
|
+
^
|
1135
1225
|
- name: parameters
|
1136
1226
|
type: node?
|
1137
1227
|
kind:
|
1138
1228
|
- BlockParametersNode
|
1139
1229
|
- NumberedParametersNode
|
1140
1230
|
- ItParametersNode
|
1231
|
+
comment: |
|
1232
|
+
The parameters of the block.
|
1233
|
+
|
1234
|
+
[1, 2, 3].each { |i| puts x }
|
1235
|
+
^^^
|
1236
|
+
[1, 2, 3].each { puts _1 }
|
1237
|
+
^^^^^^^^^^^
|
1238
|
+
[1, 2, 3].each { puts it }
|
1239
|
+
^^^^^^^^^^^
|
1141
1240
|
- name: body
|
1142
1241
|
type: node?
|
1143
1242
|
kind:
|
1144
1243
|
- StatementsNode
|
1145
1244
|
- BeginNode
|
1245
|
+
comment: |
|
1246
|
+
The body of the block.
|
1247
|
+
|
1248
|
+
[1, 2, 3].each { |i| puts x }
|
1249
|
+
^^^^^^
|
1146
1250
|
- name: opening_loc
|
1147
1251
|
type: location
|
1252
|
+
comment: |
|
1253
|
+
Represents the location of the opening `|`.
|
1254
|
+
|
1255
|
+
[1, 2, 3].each { |i| puts x }
|
1256
|
+
^
|
1148
1257
|
- name: closing_loc
|
1149
1258
|
type: location
|
1259
|
+
comment: |
|
1260
|
+
Represents the location of the closing `|`.
|
1261
|
+
|
1262
|
+
[1, 2, 3].each { |i| puts x }
|
1263
|
+
^
|
1150
1264
|
comment: |
|
1151
1265
|
Represents a block of ruby code.
|
1152
1266
|
|
@@ -1157,10 +1271,27 @@ nodes:
|
|
1157
1271
|
fields:
|
1158
1272
|
- name: name
|
1159
1273
|
type: constant?
|
1274
|
+
comment: |
|
1275
|
+
The name of the block parameter.
|
1276
|
+
|
1277
|
+
def a(&b) # name `:b`
|
1278
|
+
^
|
1279
|
+
end
|
1160
1280
|
- name: name_loc
|
1161
1281
|
type: location?
|
1282
|
+
comment: |
|
1283
|
+
Represents the location of the block parameter name.
|
1284
|
+
|
1285
|
+
def a(&b)
|
1286
|
+
^
|
1162
1287
|
- name: operator_loc
|
1163
1288
|
type: location
|
1289
|
+
comment: |
|
1290
|
+
Represents the location of the `&` operator.
|
1291
|
+
|
1292
|
+
def a(&b)
|
1293
|
+
^
|
1294
|
+
end
|
1164
1295
|
comment: |
|
1165
1296
|
Represents a block parameter of a method, block, or lambda definition.
|
1166
1297
|
|
@@ -1172,13 +1303,49 @@ nodes:
|
|
1172
1303
|
- name: parameters
|
1173
1304
|
type: node?
|
1174
1305
|
kind: ParametersNode
|
1306
|
+
comment: |
|
1307
|
+
Represents the parameters of the block.
|
1308
|
+
|
1309
|
+
-> (a, b = 1; local) { }
|
1310
|
+
^^^^^^^^
|
1311
|
+
|
1312
|
+
foo do |a, b = 1; local|
|
1313
|
+
^^^^^^^^
|
1314
|
+
end
|
1175
1315
|
- name: locals
|
1176
1316
|
type: node[]
|
1177
1317
|
kind: BlockLocalVariableNode
|
1318
|
+
comment: |
|
1319
|
+
Represents the local variables of the block.
|
1320
|
+
|
1321
|
+
-> (a, b = 1; local) { }
|
1322
|
+
^^^^^
|
1323
|
+
|
1324
|
+
foo do |a, b = 1; local|
|
1325
|
+
^^^^^
|
1326
|
+
end
|
1178
1327
|
- name: opening_loc
|
1179
1328
|
type: location?
|
1329
|
+
comment: |
|
1330
|
+
Represents the opening location of the block parameters.
|
1331
|
+
|
1332
|
+
-> (a, b = 1; local) { }
|
1333
|
+
^
|
1334
|
+
|
1335
|
+
foo do |a, b = 1; local|
|
1336
|
+
^
|
1337
|
+
end
|
1180
1338
|
- name: closing_loc
|
1181
1339
|
type: location?
|
1340
|
+
comment: |
|
1341
|
+
Represents the closing location of the block parameters.
|
1342
|
+
|
1343
|
+
-> (a, b = 1; local) { }
|
1344
|
+
^
|
1345
|
+
|
1346
|
+
foo do |a, b = 1; local|
|
1347
|
+
^
|
1348
|
+
end
|
1182
1349
|
comment: |
|
1183
1350
|
Represents a block's parameters declaration.
|
1184
1351
|
|
@@ -1216,19 +1383,54 @@ nodes:
|
|
1216
1383
|
- name: receiver
|
1217
1384
|
type: node?
|
1218
1385
|
kind: non-void expression
|
1386
|
+
comment: |
|
1387
|
+
The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1388
|
+
|
1389
|
+
foo.bar &&= value
|
1390
|
+
^^^
|
1219
1391
|
- name: call_operator_loc
|
1220
1392
|
type: location?
|
1393
|
+
comment: |
|
1394
|
+
Represents the location of the call operator.
|
1395
|
+
|
1396
|
+
foo.bar &&= value
|
1397
|
+
^
|
1221
1398
|
- name: message_loc
|
1222
1399
|
type: location?
|
1400
|
+
comment: |
|
1401
|
+
Represents the location of the message.
|
1402
|
+
|
1403
|
+
foo.bar &&= value
|
1404
|
+
^^^
|
1223
1405
|
- name: read_name
|
1224
1406
|
type: constant
|
1407
|
+
comment: |
|
1408
|
+
Represents the name of the method being called.
|
1409
|
+
|
1410
|
+
foo.bar &&= value # read_name `:bar`
|
1411
|
+
^^^
|
1225
1412
|
- name: write_name
|
1226
1413
|
type: constant
|
1414
|
+
comment: |
|
1415
|
+
Represents the name of the method being written to.
|
1416
|
+
|
1417
|
+
foo.bar &&= value # write_name `:bar=`
|
1418
|
+
^^^
|
1227
1419
|
- name: operator_loc
|
1228
1420
|
type: location
|
1421
|
+
comment: |
|
1422
|
+
Represents the location of the operator.
|
1423
|
+
|
1424
|
+
foo.bar &&= value
|
1425
|
+
^^^
|
1229
1426
|
- name: value
|
1230
1427
|
type: node
|
1231
1428
|
kind: non-void expression
|
1429
|
+
comment: |
|
1430
|
+
Represents the value being assigned.
|
1431
|
+
|
1432
|
+
foo.bar &&= value
|
1433
|
+
^^^^^
|
1232
1434
|
comment: |
|
1233
1435
|
Represents the use of the `&&=` operator on a call.
|
1234
1436
|
|
@@ -1253,22 +1455,59 @@ nodes:
|
|
1253
1455
|
^^^
|
1254
1456
|
- name: call_operator_loc
|
1255
1457
|
type: location?
|
1458
|
+
comment: |
|
1459
|
+
Represents the location of the call operator.
|
1460
|
+
|
1461
|
+
foo.bar
|
1462
|
+
^
|
1463
|
+
|
1464
|
+
foo&.bar
|
1465
|
+
^^
|
1256
1466
|
- name: name
|
1257
1467
|
type: constant
|
1468
|
+
comment: |
|
1469
|
+
Represents the name of the method being called.
|
1470
|
+
|
1471
|
+
foo.bar # name `:foo`
|
1472
|
+
^^^
|
1258
1473
|
- name: message_loc
|
1259
1474
|
type: location?
|
1475
|
+
comment: |
|
1476
|
+
Represents the location of the message.
|
1477
|
+
|
1478
|
+
foo.bar
|
1479
|
+
^^^
|
1260
1480
|
- name: opening_loc
|
1261
1481
|
type: location?
|
1482
|
+
comment: |
|
1483
|
+
Represents the location of the left parenthesis.
|
1484
|
+
foo(bar)
|
1485
|
+
^
|
1262
1486
|
- name: arguments
|
1263
1487
|
type: node?
|
1264
1488
|
kind: ArgumentsNode
|
1489
|
+
comment: |
|
1490
|
+
Represents the arguments to the method call. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1491
|
+
|
1492
|
+
foo(bar)
|
1493
|
+
^^^
|
1265
1494
|
- name: closing_loc
|
1266
1495
|
type: location?
|
1496
|
+
comment: |
|
1497
|
+
Represents the location of the right parenthesis.
|
1498
|
+
|
1499
|
+
foo(bar)
|
1500
|
+
^
|
1267
1501
|
- name: block
|
1268
1502
|
type: node?
|
1269
1503
|
kind:
|
1270
1504
|
- BlockNode
|
1271
1505
|
- BlockArgumentNode
|
1506
|
+
comment: |
|
1507
|
+
Represents the block that is being passed to the method.
|
1508
|
+
|
1509
|
+
foo { |a| a }
|
1510
|
+
^^^^^^^^^
|
1272
1511
|
comment: |
|
1273
1512
|
Represents a method call, in all of the various forms that can take.
|
1274
1513
|
|
@@ -1295,21 +1534,61 @@ nodes:
|
|
1295
1534
|
- name: receiver
|
1296
1535
|
type: node?
|
1297
1536
|
kind: non-void expression
|
1537
|
+
comment: |
|
1538
|
+
The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1539
|
+
|
1540
|
+
foo.bar += value
|
1541
|
+
^^^
|
1298
1542
|
- name: call_operator_loc
|
1299
1543
|
type: location?
|
1544
|
+
comment: |
|
1545
|
+
Represents the location of the call operator.
|
1546
|
+
|
1547
|
+
foo.bar += value
|
1548
|
+
^
|
1300
1549
|
- name: message_loc
|
1301
1550
|
type: location?
|
1551
|
+
comment: |
|
1552
|
+
Represents the location of the message.
|
1553
|
+
|
1554
|
+
foo.bar += value
|
1555
|
+
^^^
|
1302
1556
|
- name: read_name
|
1303
1557
|
type: constant
|
1558
|
+
comment: |
|
1559
|
+
Represents the name of the method being called.
|
1560
|
+
|
1561
|
+
foo.bar += value # read_name `:bar`
|
1562
|
+
^^^
|
1304
1563
|
- name: write_name
|
1305
1564
|
type: constant
|
1565
|
+
comment: |
|
1566
|
+
Represents the name of the method being written to.
|
1567
|
+
|
1568
|
+
foo.bar += value # write_name `:bar=`
|
1569
|
+
^^^
|
1306
1570
|
- name: binary_operator
|
1307
1571
|
type: constant
|
1572
|
+
comment: |
|
1573
|
+
Represents the binary operator being used.
|
1574
|
+
|
1575
|
+
foo.bar += value # binary_operator `:+`
|
1576
|
+
^
|
1308
1577
|
- name: binary_operator_loc
|
1309
1578
|
type: location
|
1579
|
+
comment: |
|
1580
|
+
Represents the location of the binary operator.
|
1581
|
+
|
1582
|
+
foo.bar += value
|
1583
|
+
^^
|
1310
1584
|
- name: value
|
1311
1585
|
type: node
|
1312
1586
|
kind: non-void expression
|
1587
|
+
comment: |
|
1588
|
+
Represents the value being assigned.
|
1589
|
+
|
1590
|
+
foo.bar += value
|
1591
|
+
^^^^^
|
1313
1592
|
comment: |
|
1314
1593
|
Represents the use of an assignment operator on a call.
|
1315
1594
|
|
@@ -1321,19 +1600,54 @@ nodes:
|
|
1321
1600
|
- name: receiver
|
1322
1601
|
type: node?
|
1323
1602
|
kind: non-void expression
|
1603
|
+
comment: |
|
1604
|
+
The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1605
|
+
|
1606
|
+
foo.bar ||= value
|
1607
|
+
^^^
|
1324
1608
|
- name: call_operator_loc
|
1325
1609
|
type: location?
|
1610
|
+
comment: |
|
1611
|
+
Represents the location of the call operator.
|
1612
|
+
|
1613
|
+
foo.bar ||= value
|
1614
|
+
^
|
1326
1615
|
- name: message_loc
|
1327
1616
|
type: location?
|
1617
|
+
comment: |
|
1618
|
+
Represents the location of the message.
|
1619
|
+
|
1620
|
+
foo.bar ||= value
|
1621
|
+
^^^
|
1328
1622
|
- name: read_name
|
1329
1623
|
type: constant
|
1624
|
+
comment: |
|
1625
|
+
Represents the name of the method being called.
|
1626
|
+
|
1627
|
+
foo.bar ||= value # read_name `:bar`
|
1628
|
+
^^^
|
1330
1629
|
- name: write_name
|
1331
1630
|
type: constant
|
1631
|
+
comment: |
|
1632
|
+
Represents the name of the method being written to.
|
1633
|
+
|
1634
|
+
foo.bar ||= value # write_name `:bar=`
|
1635
|
+
^^^
|
1332
1636
|
- name: operator_loc
|
1333
1637
|
type: location
|
1638
|
+
comment: |
|
1639
|
+
Represents the location of the operator.
|
1640
|
+
|
1641
|
+
foo.bar ||= value
|
1642
|
+
^^^
|
1334
1643
|
- name: value
|
1335
1644
|
type: node
|
1336
1645
|
kind: non-void expression
|
1646
|
+
comment: |
|
1647
|
+
Represents the value being assigned.
|
1648
|
+
|
1649
|
+
foo.bar ||= value
|
1650
|
+
^^^^^
|
1337
1651
|
comment: |
|
1338
1652
|
Represents the use of the `||=` operator on a call.
|
1339
1653
|
|
@@ -1345,12 +1659,32 @@ nodes:
|
|
1345
1659
|
- name: receiver
|
1346
1660
|
type: node
|
1347
1661
|
kind: non-void expression
|
1662
|
+
comment: |
|
1663
|
+
The object that the method is being called on. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1664
|
+
|
1665
|
+
foo.bar = 1
|
1666
|
+
^^^
|
1348
1667
|
- name: call_operator_loc
|
1349
1668
|
type: location
|
1669
|
+
comment: |
|
1670
|
+
Represents the location of the call operator.
|
1671
|
+
|
1672
|
+
foo.bar = 1
|
1673
|
+
^
|
1350
1674
|
- name: name
|
1351
1675
|
type: constant
|
1676
|
+
comment: |
|
1677
|
+
Represents the name of the method being called.
|
1678
|
+
|
1679
|
+
foo.bar = 1 # name `:foo`
|
1680
|
+
^^^
|
1352
1681
|
- name: message_loc
|
1353
1682
|
type: location
|
1683
|
+
comment: |
|
1684
|
+
Represents the location of the message.
|
1685
|
+
|
1686
|
+
foo.bar = 1
|
1687
|
+
^^^
|
1354
1688
|
comment: |
|
1355
1689
|
Represents assigning to a method call.
|
1356
1690
|
|
@@ -1369,11 +1703,26 @@ nodes:
|
|
1369
1703
|
- name: value
|
1370
1704
|
type: node
|
1371
1705
|
kind: pattern expression
|
1706
|
+
comment: |
|
1707
|
+
Represents the value to capture.
|
1708
|
+
|
1709
|
+
foo => bar
|
1710
|
+
^^^
|
1372
1711
|
- name: target
|
1373
1712
|
type: node
|
1374
1713
|
kind: LocalVariableTargetNode
|
1714
|
+
comment: |
|
1715
|
+
Represents the target of the capture.
|
1716
|
+
|
1717
|
+
foo => bar
|
1718
|
+
^^^
|
1375
1719
|
- name: operator_loc
|
1376
1720
|
type: location
|
1721
|
+
comment: |
|
1722
|
+
Represents the location of the `=>` operator.
|
1723
|
+
|
1724
|
+
foo => bar
|
1725
|
+
^^
|
1377
1726
|
comment: |
|
1378
1727
|
Represents assigning to a local variable in pattern matching.
|
1379
1728
|
|
@@ -1384,16 +1733,41 @@ nodes:
|
|
1384
1733
|
- name: predicate
|
1385
1734
|
type: node?
|
1386
1735
|
kind: non-void expression
|
1736
|
+
comment: |
|
1737
|
+
Represents the predicate of the case match. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1738
|
+
|
1739
|
+
case true; in false; end
|
1740
|
+
^^^^
|
1387
1741
|
- name: conditions
|
1388
1742
|
type: node[]
|
1389
1743
|
kind: InNode
|
1744
|
+
comment: |
|
1745
|
+
Represents the conditions of the case match.
|
1746
|
+
|
1747
|
+
case true; in false; end
|
1748
|
+
^^^^^^^^
|
1390
1749
|
- name: else_clause
|
1391
1750
|
type: node?
|
1392
1751
|
kind: ElseNode
|
1752
|
+
comment: |
|
1753
|
+
Represents the else clause of the case match.
|
1754
|
+
|
1755
|
+
case true; in false; else; end
|
1756
|
+
^^^^
|
1393
1757
|
- name: case_keyword_loc
|
1394
1758
|
type: location
|
1759
|
+
comment: |
|
1760
|
+
Represents the location of the `case` keyword.
|
1761
|
+
|
1762
|
+
case true; in false; end
|
1763
|
+
^^^^
|
1395
1764
|
- name: end_keyword_loc
|
1396
1765
|
type: location
|
1766
|
+
comment: |
|
1767
|
+
Represents the location of the `end` keyword.
|
1768
|
+
|
1769
|
+
case true; in false; end
|
1770
|
+
^^^
|
1397
1771
|
comment: |
|
1398
1772
|
Represents the use of a case statement for pattern matching.
|
1399
1773
|
|
@@ -1406,16 +1780,41 @@ nodes:
|
|
1406
1780
|
- name: predicate
|
1407
1781
|
type: node?
|
1408
1782
|
kind: non-void expression
|
1783
|
+
comment: |
|
1784
|
+
Represents the predicate of the case statement. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1785
|
+
|
1786
|
+
case true; when false; end
|
1787
|
+
^^^^
|
1409
1788
|
- name: conditions
|
1410
1789
|
type: node[]
|
1411
1790
|
kind: WhenNode
|
1791
|
+
comment: |
|
1792
|
+
Represents the conditions of the case statement.
|
1793
|
+
|
1794
|
+
case true; when false; end
|
1795
|
+
^^^^^^^^^^
|
1412
1796
|
- name: else_clause
|
1413
1797
|
type: node?
|
1414
1798
|
kind: ElseNode
|
1799
|
+
comment: |
|
1800
|
+
Represents the else clause of the case statement.
|
1801
|
+
|
1802
|
+
case true; when false; else; end
|
1803
|
+
^^^^
|
1415
1804
|
- name: case_keyword_loc
|
1416
1805
|
type: location
|
1806
|
+
comment: |
|
1807
|
+
Represents the location of the `case` keyword.
|
1808
|
+
|
1809
|
+
case true; when false; end
|
1810
|
+
^^^^
|
1417
1811
|
- name: end_keyword_loc
|
1418
1812
|
type: location
|
1813
|
+
comment: |
|
1814
|
+
Represents the location of the `end` keyword.
|
1815
|
+
|
1816
|
+
case true; when false; end
|
1817
|
+
^^^
|
1419
1818
|
comment: |
|
1420
1819
|
Represents the use of a case statement.
|
1421
1820
|
|
@@ -1458,13 +1857,33 @@ nodes:
|
|
1458
1857
|
fields:
|
1459
1858
|
- name: name
|
1460
1859
|
type: constant
|
1860
|
+
comment: |
|
1861
|
+
The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
|
1862
|
+
|
1863
|
+
@@target &&= value # name `:@@target`
|
1864
|
+
^^^^^^^^
|
1461
1865
|
- name: name_loc
|
1462
1866
|
type: location
|
1867
|
+
comment: |
|
1868
|
+
Represents the location of the variable name.
|
1869
|
+
|
1870
|
+
@@target &&= value
|
1871
|
+
^^^^^^^^
|
1463
1872
|
- name: operator_loc
|
1464
1873
|
type: location
|
1874
|
+
comment: |
|
1875
|
+
Represents the location of the `&&=` operator.
|
1876
|
+
|
1877
|
+
@@target &&= value
|
1878
|
+
^^^
|
1465
1879
|
- name: value
|
1466
1880
|
type: node
|
1467
1881
|
kind: non-void expression
|
1882
|
+
comment: |
|
1883
|
+
Represents the value being assigned. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
1884
|
+
|
1885
|
+
@@target &&= value
|
1886
|
+
^^^^^
|
1468
1887
|
comment: |
|
1469
1888
|
Represents the use of the `&&=` operator for assignment to a class variable.
|
1470
1889
|
|
@@ -2726,6 +3145,7 @@ nodes:
|
|
2726
3145
|
- EmbeddedStatementsNode
|
2727
3146
|
- EmbeddedVariableNode
|
2728
3147
|
- InterpolatedStringNode # `"a" "#{b}"`
|
3148
|
+
- on error: XStringNode # `<<`FOO` "bar"
|
2729
3149
|
- name: closing_loc
|
2730
3150
|
type: location?
|
2731
3151
|
newline: parts
|
@@ -3437,6 +3857,7 @@ nodes:
|
|
3437
3857
|
^^^^^^^
|
3438
3858
|
end
|
3439
3859
|
- name: ParenthesesNode
|
3860
|
+
flags: ParenthesesNodeFlags
|
3440
3861
|
fields:
|
3441
3862
|
- name: body
|
3442
3863
|
type: node?
|
@@ -3670,6 +4091,8 @@ nodes:
|
|
3670
4091
|
- on error: BackReferenceReadNode # => begin; rescue => $&; end
|
3671
4092
|
- on error: NumberedReferenceReadNode # => begin; rescue => $1; end
|
3672
4093
|
- on error: MissingNode # begin; rescue =>; end
|
4094
|
+
- name: then_keyword_loc
|
4095
|
+
type: location?
|
3673
4096
|
- name: statements
|
3674
4097
|
type: node?
|
3675
4098
|
kind: StatementsNode
|
@@ -3967,6 +4390,8 @@ nodes:
|
|
3967
4390
|
fields:
|
3968
4391
|
- name: keyword_loc
|
3969
4392
|
type: location
|
4393
|
+
- name: do_keyword_loc
|
4394
|
+
type: location?
|
3970
4395
|
- name: closing_loc
|
3971
4396
|
type: location?
|
3972
4397
|
- name: predicate
|
@@ -4008,6 +4433,8 @@ nodes:
|
|
4008
4433
|
fields:
|
4009
4434
|
- name: keyword_loc
|
4010
4435
|
type: location
|
4436
|
+
- name: do_keyword_loc
|
4437
|
+
type: location?
|
4011
4438
|
- name: closing_loc
|
4012
4439
|
type: location?
|
4013
4440
|
- name: predicate
|