How to use set_location method in pytractor

Best Python code snippet using pytractor_python

test_parser.py

Source:test_parser.py Github

copy

Full Screen

...751ast_001 = DefModule("sample_001", [752 DefGrammar("X", [], [753 DefRule(754 "start",755 Sym("a") .set_location(name_001, 5, 14)\756 ['+'] .set_location(name_001, 5, 17),757 False758 ).set_location(name_001, 5, 5)759 ]).set_location(name_001, 4, 3)760]).set_location(name_001, 3, 1)761test_samples.append((True, name_001, sample_001, ast_001))762name_002 = "sample_002.g"763sample_002 = """\764module sample_002765 x = "\\u012f";766end767"""768ast_002 = DefModule("sample_002", [769 SetLocal(770 "x",771 Const("\u012f").set_location(name_002, 2, 7)772 ).set_location(name_002, 2, 5)773]).set_location(name_002, 1, 1)774test_samples.append((True, name_002, sample_002, ast_002))775name_003 = "sample_003.g"776sample_003 = """\777-- Module expected.778"""779ast_003 = None780test_samples.append((False, name_003, sample_003, ast_003))781name_004 = "sample_004.g"782sample_004 = """\783module A784end785-- Expected end of input.786module B787end788"""789ast_004 = None790test_samples.append((False, name_004, sample_004, ast_004))791name_005 = "sample_005.g"792sample_005 = """\793module794end795"""796ast_005 = None797test_samples.append((False, name_005, sample_005, ast_005))798name_006 = "sample_006.g"799sample_006 = """\800module A801"""802ast_006 = None803test_samples.append((False, name_006, sample_006, ast_006))804name_007 = "sample_007.g"805sample_007 = """\806module A807 module B808 end809 module C810 end811end812"""813ast_007 = DefModule("A", [814 DefModule("B", []).set_location(name_007, 3, 3),815 DefModule("C", []).set_location(name_007, 6, 3)816]).set_location(name_007, 1, 1)817test_samples.append((True, name_007, sample_007, ast_007))818name_008 = "sample_008.g"819sample_008 = """\820module A821 grammar 1 end822end823"""824ast_008 = None825test_samples.append((False, name_008, sample_008, ast_008))826name_009 = "sample_009.g"827sample_009 = """\828module A829 grammar G( end830end831"""832ast_009 = None833test_samples.append((False, name_009, sample_009, ast_009))834name_010 = "sample_010.g"835sample_010 = """\836module A837 grammar G () end838end839"""840ast_010 = DefModule("A", [841 DefGrammar("G", [], []).set_location(name_010, 2, 3)842]).set_location(name_010, 1, 1)843test_samples.append((True, name_010, sample_010, ast_010))844name_011 = "sample_011.g"845sample_011 = """\846module A847 grammar G (1) end848end849"""850ast_011 = None851test_samples.append((False, name_011, sample_011, ast_011))852name_012 = "sample_012.g"853sample_012 = """\854module A855 grammar G (G1) end856end857"""858ast_012 = DefModule("A", [859 DefGrammar("G", [("G1", Location(name_012, 2, 14))], [860 ]).set_location(name_012, 2, 3)861]).set_location(name_012, 1, 1)862test_samples.append((True, name_012, sample_012, ast_012))863name_013 = "sample_013.g"864sample_013 = """\865module A866 grammar G (G1,) end867end868"""869ast_013 = None870test_samples.append((False, name_013, sample_013, ast_013))871name_014 = "sample_014.g"872sample_014 = """\873module A874 grammar G (G1, G2) end875end876"""877ast_014 = DefModule("A", [878 DefGrammar("G", [879 ("G1", Location(name_014, 2, 14)),880 ("G2", Location(name_014, 2, 18))881 ], [882 ]).set_location(name_014, 2, 3)883]).set_location(name_014, 1, 1)884test_samples.append((True, name_014, sample_014, ast_014))885name_015 = "sample_015.g"886sample_015 = """\887module A888 grammar G889 .x = 1;890 a -> "b";891 .y = 2;892 .z = 3;893 b -> "c";894 c -> "d";895 d: "e";896 end897end898"""899ast_015 = DefModule("A", [900 DefGrammar("G", [], [901 SetLocal(902 "x",903 Const(1).set_location(name_015, 3, 10)904 ).set_location(name_015, 3, 8),905 DefRule(906 "a",907 Sym("b").set_location(name_015, 4, 10),908 False909 ).set_location(name_015, 4, 5),910 SetLocal(911 "y",912 Const(2).set_location(name_015, 5, 10)913 ).set_location(name_015, 5, 8),914 SetLocal(915 "z",916 Const(3).set_location(name_015, 6, 10)917 ).set_location(name_015, 6, 8),918 DefRule(919 "b",920 Sym("c").set_location(name_015, 7, 10),921 False922 ).set_location(name_015, 7, 5),923 DefRule(924 "c",925 Sym("d").set_location(name_015, 8, 10),926 False927 ).set_location(name_015, 8, 5),928 DefRule(929 "d",930 Sym("e").set_location(name_015, 9, 8),931 True932 ).set_location(name_015, 9, 5)933 ]).set_location(name_015, 2, 3)934]).set_location(name_015, 1, 1)935test_samples.append((True, name_015, sample_015, ast_015))936name_016 = "sample_016.g"937sample_016 = """\938module A939 grammar G940 a - "a";941 end942end943"""944ast_016 = None945test_samples.append((False, name_016, sample_016, ast_016))946name_017 = "sample_017.g"947sample_017 = """\948module A949 grammar G950 a -> "a" | "b";951 b -> "a" | "b" | "c";952 end953end954"""955ast_017 = DefModule("A", [956 DefGrammar("G", [], [957 DefRule(958 "a",959 Alternation(960 Sym("a").set_location(name_017, 3, 10),961 Sym("b").set_location(name_017, 3, 16)962 ).set_location(name_017, 3, 14),963 False964 ).set_location(name_017, 3, 5),965 DefRule(966 "b",967 Alternation(968 Alternation(969 Sym("a").set_location(name_017, 4, 10),970 Sym("b").set_location(name_017, 4, 16)971 ).set_location(name_017, 4, 14),972 Sym("c").set_location(name_017, 4, 22)973 ).set_location(name_017, 4, 20),974 False975 ).set_location(name_017, 4, 5)976 ]).set_location(name_017, 2, 3)977]).set_location(name_017, 1, 1)978test_samples.append((True, name_017, sample_017, ast_017))979name_018 = "sample_018.g"980sample_018 = """\981module A982 grammar G983 a -> "a" | "b" - "c" - "d";984 end985end986"""987ast_018 = DefModule("A", [988 DefGrammar("G", [], [989 DefRule(990 "a",991 Alternation(992 Sym("a").set_location(name_018, 3, 10),993 SetMinus(994 SetMinus(995 Sym("b").set_location(name_018, 3, 16),996 Sym("c").set_location(name_018, 3, 22)997 ).set_location(name_018, 3, 20),998 Sym("d").set_location(name_018, 3, 28)999 ).set_location(name_018, 3, 26)1000 ).set_location(name_018, 3, 14),1001 False1002 ).set_location(name_018, 3, 5)1003 ]).set_location(name_018, 2, 3)1004]).set_location(name_018, 1, 1)1005test_samples.append((True, name_018, sample_018, ast_018))1006name_019 = "sample_019.g"1007sample_019 = """\1008module A1009 grammar G1010 a->"a""b""c""d";1011 end1012end1013"""1014ast_019 = DefModule("A", [1015 DefGrammar("G", [], [1016 DefRule(1017 "a",1018 Catenation(1019 Catenation(1020 Catenation(1021 Sym("a").set_location(name_019, 3, 8),1022 Sym("b").set_location(name_019, 3, 11)1023 ).set_location(name_019, 3, 11),1024 Sym("c").set_location(name_019, 3, 14)1025 ).set_location(name_019, 3, 14),1026 Sym("d").set_location(name_019, 3, 17)1027 ).set_location(name_019, 3, 17),1028 False1029 ).set_location(name_019, 3, 5)1030 ]).set_location(name_019, 2, 3)1031]).set_location(name_019, 1, 1)1032test_samples.append((True, name_019, sample_019, ast_019))1033name_020 = "sample_020.g"1034sample_020 = """\1035module A1036 grammar G(_G)1037 a -> "a" - "b" "c" | "d";1038 end1039end1040"""1041ast_020 = DefModule("A", [1042 DefGrammar("G", [("_G", Location(name_020, 2, 13))], [1043 DefRule(1044 "a",1045 Alternation(1046 SetMinus(1047 Sym("a").set_location(name_020, 3, 10),1048 Catenation(1049 Sym("b").set_location(name_020, 3, 16),1050 Sym("c").set_location(name_020, 3, 20)1051 ).set_location(name_020, 3, 20)1052 ).set_location(name_020, 3, 14),1053 Sym("d").set_location(name_020, 3, 26)1054 ).set_location(name_020, 3, 24),1055 False1056 ).set_location(name_020, 3, 5)1057 ]).set_location(name_020, 2, 3)1058]).set_location(name_020, 1, 1)1059test_samples.append((True, name_020, sample_020, ast_020))1060name_021 = "sample_021.g"1061sample_021 = """\1062module A1063 grammar G1064 a -> "a"*;1065 end1066end1067"""1068ast_021 = DefModule("A", [1069 DefGrammar("G", [], [1070 DefRule(1071 "a",1072 Iteration(1073 Sym("a").set_location(name_021, 3, 10)1074 ).set_location(name_021, 3, 13),1075 False1076 ).set_location(name_021, 3, 5)1077 ]).set_location(name_021, 2, 3)1078]).set_location(name_021, 1, 1)1079test_samples.append((True, name_021, sample_021, ast_021))1080name_022 = "sample_022.g"1081sample_022 = """\1082module A1083 grammar G1084 a -> "a"+;1085 end1086end1087"""1088ast_022 = DefModule("A", [1089 DefGrammar("G", [], [1090 DefRule(1091 "a",1092 PositiveIteration(1093 Sym("a").set_location(name_022, 3, 10)1094 ).set_location(name_022, 3, 13),1095 False1096 ).set_location(name_022, 3, 5)1097 ]).set_location(name_022, 2, 3)1098]).set_location(name_022, 1, 1)1099test_samples.append((True, name_022, sample_022, ast_022))1100name_023 = "sample_023.g"1101sample_023 = """\1102module A1103 grammar G1104 a -> "a" ?;1105 end1106end1107"""1108ast_023 = DefModule("A", [1109 DefGrammar("G", [], [1110 DefRule(1111 "a",1112 Optional(1113 Sym("a").set_location(name_023, 3, 10)1114 ).set_location(name_023, 3, 14),1115 False1116 ).set_location(name_023, 3, 5)1117 ]).set_location(name_023, 2, 3)1118]).set_location(name_023, 1, 1)1119test_samples.append((True, name_023, sample_023, ast_023))1120name_024 = "sample_024.g"1121sample_024 = """\1122module A1123 grammar G1124 a -> "a"* "b"? | "c"+ + - "d"*+?;1125 end1126end1127"""1128ast_024 = DefModule("A", [1129 DefGrammar("G", [], [1130 DefRule(1131 "a",1132 Alternation(1133 Catenation(1134 Iteration(1135 Sym("a").set_location(name_024, 3, 10)1136 ).set_location(name_024, 3, 13),1137 Optional(1138 Sym("b").set_location(name_024, 3, 15)1139 ).set_location(name_024, 3, 18)1140 ).set_location(name_024, 3, 15),1141 SetMinus(1142 PositiveIteration(1143 PositiveIteration(1144 Sym("c").set_location(name_024, 3, 22)1145 ).set_location(name_024, 3, 25)1146 ).set_location(name_024, 3, 27),1147 Optional(1148 PositiveIteration(1149 Iteration(1150 Sym("d").set_location(name_024, 3, 31)1151 ).set_location(name_024, 3, 34)1152 ).set_location(name_024, 3, 35)1153 ).set_location(name_024, 3, 36)1154 ).set_location(name_024, 3, 29)1155 ).set_location(name_024, 3, 20),1156 False1157 ).set_location(name_024, 3, 5)1158 ]).set_location(name_024, 2, 3)1159]).set_location(name_024, 1, 1)1160test_samples.append((True, name_024, sample_024, ast_024))1161name_025 = "sample_025.g"1162sample_025 = """\1163module A1164 grammar G1165 a -> -"a";1166 b -> ~"b";1167 end1168end1169"""1170ast_025 = DefModule("A", [1171 DefGrammar("G", [], [1172 DefRule(1173 "a",1174 DoNotRecord(1175 Sym("a").set_location(name_025, 3, 11)1176 ).set_location(name_025, 3, 10),1177 False1178 ).set_location(name_025, 3, 5),1179 DefRule(1180 "b",1181 Complement(1182 Sym("b").set_location(name_025, 4, 11)1183 ).set_location(name_025, 4, 10),1184 False1185 ).set_location(name_025, 4, 5)1186 ]).set_location(name_025, 2, 3)1187]).set_location(name_025, 1, 1)1188test_samples.append((True, name_025, sample_025, ast_025))1189name_026 = "sample_026.g"1190sample_026 = """\1191module A1192 grammar G1193 a -> -~"a" - - -"b";1194 end1195end1196"""1197ast_026 = DefModule("A", [1198 DefGrammar("G", [], [1199 DefRule(1200 "a",1201 SetMinus(1202 DoNotRecord(1203 Complement(1204 Sym("a").set_location(name_026, 3, 12)1205 ).set_location(name_026, 3, 11)1206 ).set_location(name_026, 3, 10),1207 DoNotRecord(1208 DoNotRecord(1209 Sym("b").set_location(name_026, 3, 21)1210 ).set_location(name_026, 3, 20)1211 ).set_location(name_026, 3, 18)1212 ).set_location(name_026, 3, 16),1213 False1214 ).set_location(name_026, 3, 5)1215 ]).set_location(name_026, 2, 3)1216]).set_location(name_026, 1, 1)1217test_samples.append((True, name_026, sample_026, ast_026))1218name_027 = "sample_027.g"1219sample_027 = """\1220module A1221 grammar G1222 a -> "a"'letter_a;1223 end1224end1225"""1226ast_027 = DefModule("A", [1227 DefGrammar("G", [], [1228 DefRule(1229 "a",1230 Label(1231 Sym("a").set_location(name_027, 3, 10),1232 Var("letter_a").set_location(name_027, 3, 14)1233 ).set_location(name_027, 3, 13),1234 False1235 ).set_location(name_027, 3, 5)1236 ]).set_location(name_027, 2, 3)1237]).set_location(name_027, 1, 1)1238test_samples.append((True, name_027, sample_027, ast_027))1239name_028 = "sample_028.g"1240sample_028 = """\1241module A1242 grammar G1243 a -> "a" ' letter_a ' x;1244 end1245end1246"""1247ast_028 = None1248test_samples.append((False, name_028, sample_028, ast_028))1249name_029 = "sample_029.g"1250sample_029 = """\1251module A1252 grammar G1253 a -> "a"''letter_a;1254 end1255end1256"""1257ast_029 = None1258test_samples.append((False, name_029, sample_029, ast_029))1259name_030 = "sample_030.g"1260sample_030 = """\1261module A1262 grammar G1263 a -> letter_a;1264 b -> eps;1265 c -> (a);1266 d -> {};1267 end1268end1269"""1270ast_030 = DefModule("A", [1271 DefGrammar("G", [], [1272 DefRule(1273 "a",1274 Var("letter_a").set_location(name_030, 3, 10),1275 False1276 ).set_location(name_030, 3, 5),1277 DefRule(1278 "b",1279 Epsilon().set_location(name_030, 4, 10),1280 False1281 ).set_location(name_030, 4, 5),1282 DefRule(1283 "c",1284 Var("a").set_location(name_030, 5, 11),1285 False1286 ).set_location(name_030, 5, 5),1287 DefRule(1288 "d",1289 Action(1290 ABlock([]).set_location(name_030, 6, 10)1291 ).set_location(name_030, 6, 10),1292 False1293 ).set_location(name_030, 6, 5)1294 ]).set_location(name_030, 2, 3)1295]).set_location(name_030, 1, 1)1296test_samples.append((True, name_030, sample_030, ast_030))1297name_031 = "sample_031.g"1298sample_031 = """\1299module A1300 grammar G1301 a -> #1302 end1303end1304"""1305ast_031 = None1306test_samples.append((False, name_031, sample_031, ast_031))1307name_032 = "sample_032.g"1308sample_032 = """\1309module A1310 grammar G1311 a ->1312"""1313ast_032 = None1314test_samples.append((False, name_032, sample_032, ast_032))1315name_033 = "sample_033.g"1316sample_033 = """\1317module A1318 grammar G1319 a -> "b".."c";1320 end1321end1322"""1323ast_033 = DefModule("A", [1324 DefGrammar("G", [], [1325 DefRule(1326 "a",1327 Range(1328 Sym("b").set_location(name_033, 3, 10),1329 Sym("c").set_location(name_033, 3, 15)1330 ).set_location(name_033, 3, 10),1331 False1332 ).set_location(name_033, 3, 5)1333 ]).set_location(name_033, 2, 3)1334]).set_location(name_033, 1, 1)1335test_samples.append((True, name_033, sample_033, ast_033))1336name_034 = "sample_034.g"1337sample_034 = """\1338module A1339 grammar G1340 a -> "" | "ab";1341 end1342end1343"""1344ast_034 = DefModule("A", [1345 DefGrammar("G", [], [1346 DefRule(1347 "a",1348 Alternation(1349 Epsilon().set_location(name_034, 3, 10),1350 Literal("ab").set_location(name_034, 3, 15)1351 ).set_location(name_034, 3, 13),1352 False1353 ).set_location(name_034, 3, 5)1354 ]).set_location(name_034, 2, 3)1355]).set_location(name_034, 1, 1)1356test_samples.append((True, name_034, sample_034, ast_034))1357name_035 = "sample_035.g"1358sample_035 = """\1359module A1360 grammar G1361 a -> "" .. "a";1362 end1363end1364"""1365ast_035 = None1366test_samples.append((False, name_035, sample_035, ast_035))1367name_036 = "sample_036.g"1368sample_036 = """\1369module A1370 grammar G1371 a -> "ab" .. "a";1372 end1373end1374"""1375ast_036 = None1376test_samples.append((False, name_036, sample_036, ast_036))1377name_037 = "sample_037.g"1378sample_037 = """\1379module A1380 grammar G1381 a -> "a" .. "";1382 end1383end1384"""1385ast_037 = None1386test_samples.append((False, name_037, sample_037, ast_037))1387name_038 = "sample_038.g"1388sample_038 = """\1389module A1390 grammar G1391 a -> "a" .. "aa";1392 end1393end1394"""1395ast_038 = None1396test_samples.append((False, name_038, sample_038, ast_038))1397name_039 = "sample_039.g"1398sample_039 = """\1399module A1400 grammar G1401 a -> "b" .. "a";1402 end1403end1404"""1405ast_039 = None1406test_samples.append((False, name_039, sample_039, ast_039))1407name_040 = "sample_040.g"1408sample_040 = """\1409module A1410 x = y;1411end1412"""1413ast_040 = DefModule("A", [1414 SetLocal(1415 "x",1416 GetLocal("y").set_location(name_040, 2, 7)1417 ).set_location(name_040, 2, 5)1418]).set_location(name_040, 1, 1)1419test_samples.append((True, name_040, sample_040, ast_040))1420name_041 = "sample_041.g"1421sample_041 = """\1422module A1423 x += y;1424end1425"""1426ast_041 = DefModule("A", [1427 SetLocal(1428 "x",1429 Add(1430 GetLocal("x").set_location(name_041, 2, 3),1431 GetLocal("y").set_location(name_041, 2, 8)1432 ).set_location(name_041, 2, 5)1433 ).set_location(name_041, 2, 5)1434]).set_location(name_041, 1, 1)1435test_samples.append((True, name_041, sample_041, ast_041))1436name_042 = "sample_042.g"1437sample_042 = """\1438module A1439 x = y += z;1440end1441"""1442ast_042 = DefModule("A", [1443 SetLocal(1444 "y",1445 Add(1446 GetLocal("y").set_location(name_042, 2, 7),1447 GetLocal("z").set_location(name_042, 2, 12)1448 ).set_location(name_042, 2, 9)1449 ).set_location(name_042, 2, 9),1450 SetLocal(1451 "x",1452 GetLocal("y").set_location(name_042, 2, 7)1453 ).set_location(name_042, 2, 5)1454]).set_location(name_042, 1, 1)1455test_samples.append((True, name_042, sample_042, ast_042))1456name_043 = "sample_043.g"1457sample_043 = """\1458module A1459 x -= y;1460end1461"""1462ast_043 = DefModule("A", [1463 SetLocal(1464 "x",1465 Sub(1466 GetLocal("x").set_location(name_043, 2, 3),1467 GetLocal("y").set_location(name_043, 2, 8)1468 ).set_location(name_043, 2, 5)1469 ).set_location(name_043, 2, 5)1470]).set_location(name_043, 1, 1)1471test_samples.append((True, name_043, sample_043, ast_043))1472name_044 = "sample_044.g"1473sample_044 = """\1474module A1475 x *= y;1476end1477"""1478ast_044 = DefModule("A", [1479 SetLocal(1480 "x",1481 Mul(1482 GetLocal("x").set_location(name_044, 2, 3),1483 GetLocal("y").set_location(name_044, 2, 8)1484 ).set_location(name_044, 2, 5)1485 ).set_location(name_044, 2, 5)1486]).set_location(name_044, 1, 1)1487test_samples.append((True, name_044, sample_044, ast_044))1488name_045 = "sample_045.g"1489sample_045 = """\1490module A1491 x /= y;1492end1493"""1494ast_045 = DefModule("A", [1495 SetLocal(1496 "x",1497 Div(1498 GetLocal("x").set_location(name_045, 2, 3),1499 GetLocal("y").set_location(name_045, 2, 8)1500 ).set_location(name_045, 2, 5)1501 ).set_location(name_045, 2, 5)1502]).set_location(name_045, 1, 1)1503test_samples.append((True, name_045, sample_045, ast_045))1504name_046 = "sample_046.g"1505sample_046 = """\1506module A1507 x %= y;1508end1509"""1510ast_046 = DefModule("A", [1511 SetLocal(1512 "x",1513 Mod(1514 GetLocal("x").set_location(name_046, 2, 3),1515 GetLocal("y").set_location(name_046, 2, 8)1516 ).set_location(name_046, 2, 5)1517 ).set_location(name_046, 2, 5)1518]).set_location(name_046, 1, 1)1519test_samples.append((True, name_046, sample_046, ast_046))1520name_047 = "sample_047.g"1521sample_047 = """\1522module A1523 x &= y;1524end1525"""1526ast_047 = DefModule("A", [1527 SetLocal(1528 "x",1529 BitAnd(1530 GetLocal("x").set_location(name_047, 2, 3),1531 GetLocal("y").set_location(name_047, 2, 8)1532 ).set_location(name_047, 2, 5)1533 ).set_location(name_047, 2, 5)1534]).set_location(name_047, 1, 1)1535test_samples.append((True, name_047, sample_047, ast_047))1536name_048 = "sample_048.g"1537sample_048 = """\1538module A1539 x |= y;1540end1541"""1542ast_048 = DefModule("A", [1543 SetLocal(1544 "x",1545 BitOr(1546 GetLocal("x").set_location(name_048, 2, 3),1547 GetLocal("y").set_location(name_048, 2, 8)1548 ).set_location(name_048, 2, 5)1549 ).set_location(name_048, 2, 5)1550]).set_location(name_048, 1, 1)1551test_samples.append((True, name_048, sample_048, ast_048))1552name_049 = "sample_049.g"1553sample_049 = """\1554module A1555 x ^= y;1556end1557"""1558ast_049 = DefModule("A", [1559 SetLocal(1560 "x",1561 BitXor(1562 GetLocal("x").set_location(name_049, 2, 3),1563 GetLocal("y").set_location(name_049, 2, 8)1564 ).set_location(name_049, 2, 5)1565 ).set_location(name_049, 2, 5)1566]).set_location(name_049, 1, 1)1567test_samples.append((True, name_049, sample_049, ast_049))1568name_050 = "sample_050.g"1569sample_050 = """\1570module A1571 x <<= y;1572end1573"""1574ast_050 = DefModule("A", [1575 SetLocal(1576 "x",1577 ShiftL(1578 GetLocal("x").set_location(name_050, 2, 3),1579 GetLocal("y").set_location(name_050, 2, 9)1580 ).set_location(name_050, 2, 5)1581 ).set_location(name_050, 2, 5)1582]).set_location(name_050, 1, 1)1583test_samples.append((True, name_050, sample_050, ast_050))1584name_051 = "sample_051.g"1585sample_051 = """\1586module A1587 x >>= y;1588end1589"""1590ast_051 = DefModule("A", [1591 SetLocal(1592 "x",1593 ShiftR(1594 GetLocal("x").set_location(name_051, 2, 3),1595 GetLocal("y").set_location(name_051, 2, 9)1596 ).set_location(name_051, 2, 5)1597 ).set_location(name_051, 2, 5)1598]).set_location(name_051, 1, 1)1599test_samples.append((True, name_051, sample_051, ast_051))1600name_052 = "sample_052.g"1601sample_052 = """\1602module A1603 x &&= y;1604end1605"""1606ast_052 = DefModule("A", [1607 SetLocal(1608 "x",1609 And(1610 GetLocal("x").set_location(name_052, 2, 3),1611 GetLocal("y").set_location(name_052, 2, 9)1612 ).set_location(name_052, 2, 5)1613 ).set_location(name_052, 2, 5)1614]).set_location(name_052, 1, 1)1615test_samples.append((True, name_052, sample_052, ast_052))1616name_053 = "sample_053.g"1617sample_053 = """\1618module A1619 x ||= y;1620end1621"""1622ast_053 = DefModule("A", [1623 SetLocal(1624 "x",1625 Or(1626 GetLocal("x").set_location(name_053, 2, 3),1627 GetLocal("y").set_location(name_053, 2, 9)1628 ).set_location(name_053, 2, 5)1629 ).set_location(name_053, 2, 5)1630]).set_location(name_053, 1, 1)1631test_samples.append((True, name_053, sample_053, ast_053))1632name_054 = "sample_054.g"1633sample_054 = """\1634module A1635 x .= y;1636end1637"""1638ast_054 = DefModule("A", [1639 SetLocal(1640 "x",1641 Concat(1642 GetLocal("x").set_location(name_054, 2, 3),1643 GetLocal("y").set_location(name_054, 2, 8)1644 ).set_location(name_054, 2, 5)1645 ).set_location(name_054, 2, 5)1646]).set_location(name_054, 1, 1)1647test_samples.append((True, name_054, sample_054, ast_054))1648name_055 = "sample_055.g"1649sample_055 = """\1650module A1651 x ++= y;1652end1653"""1654ast_055 = DefModule("A", [1655 SetLocal(1656 "x",1657 Join(1658 GetLocal("x").set_location(name_055, 2, 3),1659 GetLocal("y").set_location(name_055, 2, 9)1660 ).set_location(name_055, 2, 5)1661 ).set_location(name_055, 2, 5)1662]).set_location(name_055, 1, 1)1663test_samples.append((True, name_055, sample_055, ast_055))1664name_056 = "sample_056.g"1665sample_056 = """\1666module A1667 x ~~= y;1668end1669"""1670ast_056 = DefModule("A", [1671 SetLocal(1672 "x",1673 Merge(1674 GetLocal("x").set_location(name_056, 2, 3),1675 GetLocal("y").set_location(name_056, 2, 9)1676 ).set_location(name_056, 2, 5)1677 ).set_location(name_056, 2, 5)1678]).set_location(name_056, 1, 1)1679test_samples.append((True, name_056, sample_056, ast_056))1680name_057 = "sample_057.g"1681sample_057 = """\1682module A1683 x || y;1684end1685"""1686ast_057 = DefModule("A", [1687 Or(1688 GetLocal("x").set_location(name_057, 2, 3),1689 GetLocal("y").set_location(name_057, 2, 8)1690 ).set_location(name_057, 2, 5)1691]).set_location(name_057, 1, 1)1692test_samples.append((True, name_057, sample_057, ast_057))1693name_058 = "sample_058.g"1694sample_058 = """\1695module A1696 x && y;1697end1698"""1699ast_058 = DefModule("A", [1700 And(1701 GetLocal("x").set_location(name_058, 2, 3),1702 GetLocal("y").set_location(name_058, 2, 8)1703 ).set_location(name_058, 2, 5)1704]).set_location(name_058, 1, 1)1705test_samples.append((True, name_058, sample_058, ast_058))1706name_059 = "sample_059.g"1707sample_059 = """\1708module A1709 a && b || c && d || e && f && g;1710end1711"""1712ast_059 = DefModule("A", [1713 Or(1714 Or(1715 And(1716 GetLocal("a").set_location(name_059, 2, 3),1717 GetLocal("b").set_location(name_059, 2, 8)1718 ).set_location(name_059, 2, 5),1719 And(1720 GetLocal("c").set_location(name_059, 2, 13),1721 GetLocal("d").set_location(name_059, 2, 18)1722 ).set_location(name_059, 2, 15)1723 ).set_location(name_059, 2, 10),1724 And(1725 And(1726 GetLocal("e").set_location(name_059, 2, 23),1727 GetLocal("f").set_location(name_059, 2, 28)1728 ).set_location(name_059, 2, 25),1729 GetLocal("g").set_location(name_059, 2, 33)1730 ).set_location(name_059, 2, 30)1731 ).set_location(name_059, 2, 20)1732]).set_location(name_059, 1, 1)1733test_samples.append((True, name_059, sample_059, ast_059))1734name_060 = "sample_060.g"1735sample_060 = """\1736module A1737 a < b;1738end1739"""1740ast_060 = DefModule("A", [1741 Lt(1742 GetLocal("a").set_location(name_060, 2, 3),1743 GetLocal("b").set_location(name_060, 2, 7)1744 ).set_location(name_060, 2, 5)1745]).set_location(name_060, 1, 1)1746test_samples.append((True, name_060, sample_060, ast_060))1747name_061 = "sample_061.g"1748sample_061 = """\1749module A1750 a > b;1751end1752"""1753ast_061 = DefModule("A", [1754 Gt(1755 GetLocal("a").set_location(name_061, 2, 3),1756 GetLocal("b").set_location(name_061, 2, 7)1757 ).set_location(name_061, 2, 5)1758]).set_location(name_061, 1, 1)1759test_samples.append((True, name_061, sample_061, ast_061))1760name_062 = "sample_062.g"1761sample_062 = """\1762module A1763 a <= b;1764end1765"""1766ast_062 = DefModule("A", [1767 Le(1768 GetLocal("a").set_location(name_062, 2, 3),1769 GetLocal("b").set_location(name_062, 2, 8)1770 ).set_location(name_062, 2, 5)1771]).set_location(name_062, 1, 1)1772test_samples.append((True, name_062, sample_062, ast_062))1773name_063 = "sample_063.g"1774sample_063 = """\1775module A1776 a >= b;1777end1778"""1779ast_063 = DefModule("A", [1780 Ge(1781 GetLocal("a").set_location(name_063, 2, 3),1782 GetLocal("b").set_location(name_063, 2, 8)1783 ).set_location(name_063, 2, 5)1784]).set_location(name_063, 1, 1)1785test_samples.append((True, name_063, sample_063, ast_063))1786name_064 = "sample_064.g"1787sample_064 = """\1788module A1789 a == b;1790end1791"""1792ast_064 = DefModule("A", [1793 Eq(1794 GetLocal("a").set_location(name_064, 2, 3),1795 GetLocal("b").set_location(name_064, 2, 8)1796 ).set_location(name_064, 2, 5)1797]).set_location(name_064, 1, 1)1798test_samples.append((True, name_064, sample_064, ast_064))1799name_065 = "sample_065.g"1800sample_065 = """\1801module A1802 a != b;1803end1804"""1805ast_065 = DefModule("A", [1806 Ne(1807 GetLocal("a").set_location(name_065, 2, 3),1808 GetLocal("b").set_location(name_065, 2, 8)1809 ).set_location(name_065, 2, 5)1810]).set_location(name_065, 1, 1)1811test_samples.append((True, name_065, sample_065, ast_065))1812name_066 = "sample_066.g"1813sample_066 = """\1814module A1815 a === b;1816end1817"""1818ast_066 = DefModule("A", [1819 Is(1820 GetLocal("a").set_location(name_066, 2, 3),1821 GetLocal("b").set_location(name_066, 2, 9)1822 ).set_location(name_066, 2, 5)1823]).set_location(name_066, 1, 1)1824test_samples.append((True, name_066, sample_066, ast_066))1825name_067 = "sample_067.g"1826sample_067 = """\1827module A1828 a in b;1829end1830"""1831ast_067 = DefModule("A", [1832 Contains(1833 GetLocal("a").set_location(name_067, 2, 3),1834 GetLocal("b").set_location(name_067, 2, 8)1835 ).set_location(name_067, 2, 5)1836]).set_location(name_067, 1, 1)1837test_samples.append((True, name_067, sample_067, ast_067))1838name_068 = "sample_068.g"1839sample_068 = """\1840module A1841 a < x && x < b;1842end1843"""1844ast_068 = DefModule("A", [1845 And(1846 Lt(1847 GetLocal("a").set_location(name_068, 2, 3),1848 GetLocal("x").set_location(name_068, 2, 7)1849 ).set_location(name_068, 2, 5),1850 Lt(1851 GetLocal("x").set_location(name_068, 2, 12),1852 GetLocal("b").set_location(name_068, 2, 16)1853 ).set_location(name_068, 2, 14)1854 ).set_location(name_068, 2, 9)1855]).set_location(name_068, 1, 1)1856test_samples.append((True, name_068, sample_068, ast_068))1857name_069 = "sample_069.g"1858sample_069 = """\1859module A1860 a < x < b;1861end1862"""1863ast_069 = None1864test_samples.append((False, name_069, sample_069, ast_069))1865name_070 = "sample_070.g"1866sample_070 = """\1867module A1868 a | b;1869end1870"""1871ast_070 = DefModule("A", [1872 BitOr(1873 GetLocal("a").set_location(name_070, 2, 3),1874 GetLocal("b").set_location(name_070, 2, 7)1875 ).set_location(name_070, 2, 5)1876]).set_location(name_070, 1, 1)1877test_samples.append((True, name_070, sample_070, ast_070))1878name_071 = "sample_071.g"1879sample_071 = """\1880module A1881 a & b;1882end1883"""1884ast_071 = DefModule("A", [1885 BitAnd(1886 GetLocal("a").set_location(name_071, 2, 3),1887 GetLocal("b").set_location(name_071, 2, 7)1888 ).set_location(name_071, 2, 5)1889]).set_location(name_071, 1, 1)1890test_samples.append((True, name_071, sample_071, ast_071))1891name_072 = "sample_072.g"1892sample_072 = """\1893module A1894 a ^ b;1895end1896"""1897ast_072 = DefModule("A", [1898 BitXor(1899 GetLocal("a").set_location(name_072, 2, 3),1900 GetLocal("b").set_location(name_072, 2, 7)1901 ).set_location(name_072, 2, 5)1902]).set_location(name_072, 1, 1)1903test_samples.append((True, name_072, sample_072, ast_072))1904name_073 = "sample_073.g"1905sample_073 = """\1906module A1907 a | b | c;1908 a | b & c;1909 a | b ^ c;1910 a & b | c;1911 a & b & c;1912 a & b ^ c;1913 a ^ b | c;1914 a ^ b & c;1915 a ^ b ^ c;1916end1917"""1918ast_073 = DefModule("A", [1919 # a | b | c == (a | b) | c1920 BitOr(1921 BitOr(1922 GetLocal("a").set_location(name_073, 2, 3),1923 GetLocal("b").set_location(name_073, 2, 7)1924 ).set_location(name_073, 2, 5),1925 GetLocal("c").set_location(name_073, 2, 11)1926 ).set_location(name_073, 2, 9),1927 # a | b & c == a | (b & c)1928 BitOr(1929 GetLocal("a").set_location(name_073, 3, 3),1930 BitAnd(1931 GetLocal("b").set_location(name_073, 3, 7),1932 GetLocal("c").set_location(name_073, 3, 11)1933 ).set_location(name_073, 3, 9)1934 ).set_location(name_073, 3, 5),1935 # a | b ^ c == a | (b ^ c)1936 BitOr(1937 GetLocal("a").set_location(name_073, 4, 3),1938 BitXor(1939 GetLocal("b").set_location(name_073, 4, 7),1940 GetLocal("c").set_location(name_073, 4, 11)1941 ).set_location(name_073, 4, 9)1942 ).set_location(name_073, 4, 5),1943 # a & b | c == (a & b) | c1944 BitOr(1945 BitAnd(1946 GetLocal("a").set_location(name_073, 6, 3),1947 GetLocal("b").set_location(name_073, 6, 7)1948 ).set_location(name_073, 6, 5),1949 GetLocal("c").set_location(name_073, 6, 11)1950 ).set_location(name_073, 6, 9),1951 # a & b & c == (a & b) & c1952 BitAnd(1953 BitAnd(1954 GetLocal("a").set_location(name_073, 7, 3),1955 GetLocal("b").set_location(name_073, 7, 7)1956 ).set_location(name_073, 7, 5),1957 GetLocal("c").set_location(name_073, 7, 11)1958 ).set_location(name_073, 7, 9),1959 # a & b ^ c == a & (b ^ c)1960 BitAnd(1961 GetLocal("a").set_location(name_073, 8, 3),1962 BitXor(1963 GetLocal("b").set_location(name_073, 8, 7),1964 GetLocal("c").set_location(name_073, 8, 11)1965 ).set_location(name_073, 8, 9)1966 ).set_location(name_073, 8, 5),1967 # a ^ b | c == (a ^ b) | c1968 BitOr(1969 BitXor(1970 GetLocal("a").set_location(name_073, 10, 3),1971 GetLocal("b").set_location(name_073, 10, 7)1972 ).set_location(name_073, 10, 5),1973 GetLocal("c").set_location(name_073, 10, 11)1974 ).set_location(name_073, 10, 9),1975 # a ^ b & c == (a ^ b) & c1976 BitAnd(1977 BitXor(1978 GetLocal("a").set_location(name_073, 11, 3),1979 GetLocal("b").set_location(name_073, 11, 7)1980 ).set_location(name_073, 11, 5),1981 GetLocal("c").set_location(name_073, 11, 11)1982 ).set_location(name_073, 11, 9),1983 # a ^ b ^ c == (a ^ b) ^ c1984 BitXor(1985 BitXor(1986 GetLocal("a").set_location(name_073, 12, 3),1987 GetLocal("b").set_location(name_073, 12, 7)1988 ).set_location(name_073, 12, 5),1989 GetLocal("c").set_location(name_073, 12, 11)1990 ).set_location(name_073, 12, 9)1991]).set_location(name_073, 1, 1)1992test_samples.append((True, name_073, sample_073, ast_073))1993name_074 = "sample_074.g"1994sample_074 = """\1995module A1996 a << b;1997end1998"""1999ast_074 = DefModule("A", [2000 ShiftL(2001 GetLocal("a").set_location(name_074, 2, 3),2002 GetLocal("b").set_location(name_074, 2, 8)2003 ).set_location(name_074, 2, 5)2004]).set_location(name_074, 1, 1)2005test_samples.append((True, name_074, sample_074, ast_074))2006name_075 = "sample_075.g"2007sample_075 = """\2008module A2009 a >> b;2010end2011"""2012ast_075 = DefModule("A", [2013 ShiftR(2014 GetLocal("a").set_location(name_075, 2, 3),2015 GetLocal("b").set_location(name_075, 2, 8)2016 ).set_location(name_075, 2, 5)2017]).set_location(name_075, 1, 1)2018test_samples.append((True, name_075, sample_075, ast_075))2019name_076 = "sample_076.g"2020sample_076 = """\2021module A2022 a + b;2023end2024"""2025ast_076 = DefModule("A", [2026 Add(2027 GetLocal("a").set_location(name_076, 2, 3),2028 GetLocal("b").set_location(name_076, 2, 7)2029 ).set_location(name_076, 2, 5)2030]).set_location(name_076, 1, 1)2031test_samples.append((True, name_076, sample_076, ast_076))2032name_077 = "sample_077.g"2033sample_077 = """\2034module A2035 a - b;2036end2037"""2038ast_077 = DefModule("A", [2039 Sub(2040 GetLocal("a").set_location(name_077, 2, 3),2041 GetLocal("b").set_location(name_077, 2, 7)2042 ).set_location(name_077, 2, 5)2043]).set_location(name_077, 1, 1)2044test_samples.append((True, name_077, sample_077, ast_077))2045name_078 = "sample_078.g"2046sample_078 = """\2047module A2048 a . b;2049end2050"""2051ast_078 = DefModule("A", [2052 Concat(2053 GetLocal("a").set_location(name_078, 2, 3),2054 GetLocal("b").set_location(name_078, 2, 7)2055 ).set_location(name_078, 2, 5)2056]).set_location(name_078, 1, 1)2057test_samples.append((True, name_078, sample_078, ast_078))2058name_079 = "sample_079.g"2059sample_079 = """\2060module A2061 a ++ b;2062end2063"""2064ast_079 = DefModule("A", [2065 Join(2066 GetLocal("a").set_location(name_079, 2, 3),2067 GetLocal("b").set_location(name_079, 2, 8)2068 ).set_location(name_079, 2, 5)2069]).set_location(name_079, 1, 1)2070test_samples.append((True, name_079, sample_079, ast_079))2071name_080 = "sample_080.g"2072sample_080 = """\2073module A2074 a ~~ b;2075end2076"""2077ast_080 = DefModule("A", [2078 Merge(2079 GetLocal("a").set_location(name_080, 2, 3),2080 GetLocal("b").set_location(name_080, 2, 8)2081 ).set_location(name_080, 2, 5)2082]).set_location(name_080, 1, 1)2083test_samples.append((True, name_080, sample_080, ast_080))2084name_081 = "sample_081.g"2085sample_081 = """\2086module A2087 a * b;2088end2089"""2090ast_081 = DefModule("A", [2091 Mul(2092 GetLocal("a").set_location(name_081, 2, 3),2093 GetLocal("b").set_location(name_081, 2, 7)2094 ).set_location(name_081, 2, 5)2095]).set_location(name_081, 1, 1)2096test_samples.append((True, name_081, sample_081, ast_081))2097name_082 = "sample_082.g"2098sample_082 = """\2099module A2100 a / b;2101end2102"""2103ast_082 = DefModule("A", [2104 Div(2105 GetLocal("a").set_location(name_082, 2, 3),2106 GetLocal("b").set_location(name_082, 2, 7)2107 ).set_location(name_082, 2, 5)2108]).set_location(name_082, 1, 1)2109test_samples.append((True, name_082, sample_082, ast_082))2110name_083 = "sample_083.g"2111sample_083 = """\2112module A2113 a % b;2114end2115"""2116ast_083 = DefModule("A", [2117 Mod(2118 GetLocal("a").set_location(name_083, 2, 3),2119 GetLocal("b").set_location(name_083, 2, 7)2120 ).set_location(name_083, 2, 5)2121]).set_location(name_083, 1, 1)2122test_samples.append((True, name_083, sample_083, ast_083))2123name_084 = "sample_084.g"2124sample_084 = """\2125module A2126 a b;2127end2128"""2129ast_084 = DefModule("A", [2130 Call(2131 GetLocal("a").set_location(name_084, 2, 3),2132 GetLocal("b").set_location(name_084, 2, 5)2133 ).set_location(name_084, 2, 5)2134]).set_location(name_084, 1, 1)2135test_samples.append((True, name_084, sample_084, ast_084))2136name_085 = "sample_085.g"2137sample_085 = """\2138module A2139 a b c;2140end2141"""2142ast_085 = DefModule("A", [2143 Call(2144 GetLocal("a").set_location(name_085, 2, 3),2145 GetLocal("b").set_location(name_085, 2, 5),2146 GetLocal("c").set_location(name_085, 2, 7)2147 ).set_location(name_085, 2, 5)2148]).set_location(name_085, 1, 1)2149test_samples.append((True, name_085, sample_085, ast_085))2150name_086 = "sample_086.g"2151sample_086 = """\2152module A2153 a b 'c;2154end2155"""2156ast_086 = DefModule("A", [2157 Call(2158 GetLocal("a").set_location(name_086, 2, 3),2159 GetLocal("b").set_location(name_086, 2, 5),2160 GetLocal("c").set_location(name_086, 2, 8)2161 ).set_location(name_086, 2, 5)2162]).set_location(name_086, 1, 1)2163test_samples.append((True, name_086, sample_086, ast_086))2164name_087 = "sample_087.g"2165sample_087 = """\2166module A2167 a 'b 'c;2168end2169"""2170ast_087 = DefModule("A", [2171 Call(2172 GetLocal("a").set_location(name_087, 2, 3),2173 GetLocal("b").set_location(name_087, 2, 6),2174 GetLocal("c").set_location(name_087, 2, 9)2175 ).set_location(name_087, 2, 5)2176]).set_location(name_087, 1, 1)2177test_samples.append((True, name_087, sample_087, ast_087))2178name_088 = "sample_088.g"2179sample_088 = """\2180module A2181 -a; !b; ~c; -!~d; e - - -f;2182end2183"""2184ast_088 = DefModule("A", [2185 Neg(2186 GetLocal("a").set_location(name_088, 2, 4)2187 ).set_location(name_088, 2, 3),2188 Not(2189 GetLocal("b").set_location(name_088, 2, 8)2190 ).set_location(name_088, 2, 7),2191 Inv(2192 GetLocal("c").set_location(name_088, 2, 12)2193 ).set_location(name_088, 2, 11),2194 Neg(2195 Not(2196 Inv(2197 GetLocal("d").set_location(name_088, 2, 18)2198 ).set_location(name_088, 2, 17)2199 ).set_location(name_088, 2, 16)2200 ).set_location(name_088, 2, 15),2201 Sub(2202 GetLocal("e").set_location(name_088, 2, 21),2203 Neg(2204 Neg(2205 GetLocal("f").set_location(name_088, 2, 28)2206 ).set_location(name_088, 2, 27)2207 ).set_location(name_088, 2, 25)2208 ).set_location(name_088, 2, 23)2209]).set_location(name_088, 1, 1)2210test_samples.append((True, name_088, sample_088, ast_088))2211name_089 = "sample_089.g"2212sample_089 = """\2213module A2214 a[b]; c[d][e]; f[g[h]];2215end2216"""2217ast_089 = DefModule("A", [2218 GetItem(2219 GetLocal("a").set_location(name_089, 2, 3),2220 GetLocal("b").set_location(name_089, 2, 5)2221 ).set_location(name_089, 2, 4),2222 GetItem(2223 GetItem(2224 GetLocal("c").set_location(name_089, 2, 9),2225 GetLocal("d").set_location(name_089, 2, 11)2226 ).set_location(name_089, 2, 10),2227 GetLocal("e").set_location(name_089, 2, 14)2228 ).set_location(name_089, 2, 13),2229 GetItem(2230 GetLocal("f").set_location(name_089, 2, 18),2231 GetItem(2232 GetLocal("g").set_location(name_089, 2, 20),2233 GetLocal("h").set_location(name_089, 2, 22)2234 ).set_location(name_089, 2, 21)2235 ).set_location(name_089, 2, 19)2236]).set_location(name_089, 1, 1)2237test_samples.append((True, name_089, sample_089, ast_089))2238name_090 = "sample_090.g"2239sample_090 = """\2240module A2241 a:b; c:d:e:f;2242end2243"""2244ast_090 = DefModule("A", [2245 GetMember(2246 GetLocal("a").set_location(name_090, 2, 3), "b"2247 ).set_location(name_090, 2, 4),2248 GetMember(2249 GetMember(2250 GetMember(2251 GetLocal("c").set_location(name_090, 2, 8),2252 "d"2253 ).set_location(name_090, 2, 9),2254 "e"2255 ).set_location(name_090, 2, 11),2256 "f"2257 ).set_location(name_090, 2, 13)2258]).set_location(name_090, 1, 1)2259test_samples.append((True, name_090, sample_090, ast_090))2260name_091 = "sample_091.g"2261sample_091 = """\2262module A2263 !2264"""2265ast_091 = None2266test_samples.append((False, name_091, sample_091, ast_091))2267name_092 = "sample_092.g"2268sample_092 = """\2269module A2270 a;2271end2272"""2273ast_092 = DefModule("A", [2274 GetLocal("a").set_location(name_092, 2, 3)2275]).set_location(name_092, 1, 1)2276test_samples.append((True, name_092, sample_092, ast_092))2277name_093 = "sample_093.g"2278sample_093 = """\2279module A2280 $1;2281end2282"""2283ast_093 = None2284test_samples.append((False, name_093, sample_093, ast_093))2285name_094 = "sample_094.g"2286sample_094 = """\2287module A2288 $a;2289end2290"""2291ast_094 = DefModule("A", [2292 GetLocal("a").set_location(name_094, 2, 4)2293]).set_location(name_094, 1, 1)2294test_samples.append((True, name_094, sample_094, ast_094))2295name_095 = "sample_095.g"2296sample_095 = """\2297module A2298 #1;2299end2300"""2301ast_095 = None2302test_samples.append((False, name_095, sample_095, ast_095))2303name_096 = "sample_096.g"2304sample_096 = """\2305module A2306 #a;2307end2308"""2309ast_096 = None2310test_samples.append((False, name_096, sample_096, ast_096))2311name_097 = "sample_097.g"2312sample_097 = """\2313module A2314 $(a = 1);2315end2316"""2317ast_097 = None2318test_samples.append((False, name_097, sample_097, ast_097))2319name_098 = "sample_098.g"2320sample_098 = """\2321module A2322 $(a); $(a b); $(a `b);2323end2324"""2325ast_098 = DefModule("A", [2326 Expand(2327 GetLocal("a").set_location(name_098, 2, 5)2328 ).set_location(name_098, 2, 3),2329 Expand(2330 Call(2331 GetLocal("a").set_location(name_098, 2, 11),2332 GetLocal("b").set_location(name_098, 2, 13)2333 ).set_location(name_098, 2, 13)2334 ).set_location(name_098, 2, 9),2335 Expand(2336 GetLocal("a").set_location(name_098, 2, 19),2337 GetLocal("b").set_location(name_098, 2, 22)2338 ).set_location(name_098, 2, 17)2339]).set_location(name_098, 1, 1)2340test_samples.append((True, name_098, sample_098, ast_098))2341name_099 = "sample_099.g"2342sample_099 = """\2343module A2344 $(a `b = 1);2345end2346"""2347ast_099 = None2348test_samples.append((False, name_099, sample_099, ast_099))2349name_100 = "sample_100.g"2350sample_100 = """\2351module A2352 1; 1.5; "abc";2353end2354"""2355ast_100 = DefModule("A", [2356 Const(1).set_location(name_100, 2, 3),2357 Const(1.5).set_location(name_100, 2, 6),2358 Const("abc").set_location(name_100, 2, 11)2359]).set_location(name_100, 1, 1)2360test_samples.append((True, name_100, sample_100, ast_100))2361name_101 = "sample_101.g"2362sample_101 = """\2363module A2364 (a);2365end2366"""2367ast_101 = DefModule("A", [2368 GetLocal("a").set_location(name_101, 2, 4)2369]).set_location(name_101, 1, 1)2370test_samples.append((True, name_101, sample_101, ast_101))2371name_102 = "sample_102.g"2372sample_102 = """\2373module A2374 (a = 1);2375end2376"""2377ast_102 = None2378test_samples.append((False, name_102, sample_102, ast_102))2379name_103 = "sample_103.g"2380sample_103 = """\2381module A2382 (a, );2383end2384"""2385ast_103 = None2386test_samples.append((False, name_103, sample_103, ast_103))2387name_104 = "sample_104.g"2388sample_104 = """\2389module A2390 (a, b = 2);2391end2392"""2393ast_104 = None2394test_samples.append((False, name_104, sample_104, ast_104))2395name_105 = "sample_105.g"2396sample_105 = """\2397module A2398 (1, 2);2399end2400"""2401ast_105 = DefModule("A", [2402 NewPair(2403 Const(1).set_location(name_105, 2, 4),2404 Const(2).set_location(name_105, 2, 7)2405 ).set_location(name_105, 2, 3)2406]).set_location(name_105, 1, 1)2407test_samples.append((True, name_105, sample_105, ast_105))2408name_106 = "sample_106.g"2409sample_106 = """\2410module A2411 (a, b, c);2412end2413"""2414ast_106 = None2415test_samples.append((False, name_106, sample_106, ast_106))2416name_107 = "sample_107.g"2417sample_107 = """\2418module A2419 [];2420end2421"""2422ast_107 = DefModule("A", [2423 NewList(2424 ).set_location(name_107, 2, 3)2425]).set_location(name_107, 1, 1)2426test_samples.append((True, name_107, sample_107, ast_107))2427name_108 = "sample_108.g"2428sample_108 = """\2429module A2430 [2431end2432"""2433ast_108 = None2434test_samples.append((False, name_108, sample_108, ast_108))2435name_109 = "sample_109.g"2436sample_109 = """\2437module A2438 [1];2439end2440"""2441ast_109 = DefModule("A", [2442 NewList(2443 Const(1).set_location(name_109, 2, 4)2444 ).set_location(name_109, 2, 3)2445]).set_location(name_109, 1, 1)2446test_samples.append((True, name_109, sample_109, ast_109))2447name_110 = "sample_110.g"2448sample_110 = """\2449module A2450 [12451end2452"""2453ast_110 = None2454test_samples.append((False, name_110, sample_110, ast_110))2455name_111 = "sample_111.g"2456sample_111 = """\2457module A2458 [a = 1];2459end2460"""2461ast_111 = None2462test_samples.append((False, name_111, sample_111, ast_111))2463name_112 = "sample_112.g"2464sample_112 = """\2465module A2466 [1, 2];2467end2468"""2469ast_112 = DefModule("A", [2470 NewList(2471 Const(1).set_location(name_112, 2, 4),2472 Const(2).set_location(name_112, 2, 7)2473 ).set_location(name_112, 2, 3)2474]).set_location(name_112, 1, 1)2475test_samples.append((True, name_112, sample_112, ast_112))2476name_113 = "sample_113.g"2477sample_113 = """\2478module A2479 [1, 2, 3];2480end2481"""2482ast_113 = DefModule("A", [2483 NewList(2484 Const(1).set_location(name_113, 2, 4),2485 Const(2).set_location(name_113, 2, 7),2486 Const(3).set_location(name_113, 2, 10)2487 ).set_location(name_113, 2, 3)2488]).set_location(name_113, 1, 1)2489test_samples.append((True, name_113, sample_113, ast_113))2490name_114 = "sample_114.g"2491sample_114 = """\2492module A2493 [a,];2494end2495"""2496ast_114 = None2497test_samples.append((False, name_114, sample_114, ast_114))2498name_115 = "sample_115.g"2499sample_115 = """\2500module A2501 [a, b => c];2502end2503"""2504ast_115 = None2505test_samples.append((False, name_115, sample_115, ast_115))2506name_116 = "sample_116.g"2507sample_116 = """\2508module A2509 [a => ];2510end2511"""2512ast_116 = None2513test_samples.append((False, name_116, sample_116, ast_116))2514name_117 = "sample_117.g"2515sample_117 = """\2516module A2517 [1 => 2, 3];2518end2519"""2520ast_117 = None2521test_samples.append((False, name_117, sample_117, ast_117))2522name_118 = "sample_118.g"2523sample_118 = """\2524module A2525 [1 => 2];2526 [3 => 4, 5 => 6];2527 ["a" => "b", "c" => "d", "e" => "f"];2528end2529"""2530ast_118 = DefModule("A", [2531 NewHashMap(2532 (2533 Const(1).set_location(name_118, 2, 4),2534 Const(2).set_location(name_118, 2, 9)2535 )2536 ).set_location(name_118, 2, 3),2537 NewHashMap(2538 (2539 Const(3).set_location(name_118, 3, 4),2540 Const(4).set_location(name_118, 3, 9)2541 ),2542 (2543 Const(5).set_location(name_118, 3, 12),2544 Const(6).set_location(name_118, 3, 17)2545 )2546 ).set_location(name_118, 3, 3),2547 NewHashMap(2548 (2549 Const("a").set_location(name_118, 4, 4),2550 Const("b").set_location(name_118, 4, 11)2551 ),2552 (2553 Const("c").set_location(name_118, 4, 16),2554 Const("d").set_location(name_118, 4, 23)2555 ),2556 (2557 Const("e").set_location(name_118, 4, 28),2558 Const("f").set_location(name_118, 4, 35)2559 )2560 ).set_location(name_118, 4, 3)2561]).set_location(name_118, 1, 1)2562test_samples.append((True, name_118, sample_118, ast_118))2563name_119 = "sample_119.g"2564sample_119 = """\2565module A2566 ({2567end2568"""2569ast_119 = None2570test_samples.append((False, name_119, sample_119, ast_119))2571name_120 = "sample_120.g"2572sample_120 = """\2573module A2574 ({|2575end2576"""2577ast_120 = None2578test_samples.append((False, name_120, sample_120, ast_120))2579name_121 = "sample_121.g"2580sample_121 = """\2581module A2582 ({|x2583end2584"""2585ast_121 = None2586test_samples.append((False, name_121, sample_121, ast_121))2587name_122 = "sample_122.g"2588sample_122 = """\2589module A2590 ({|x y2591end2592"""2593ast_122 = None2594test_samples.append((False, name_122, sample_122, ast_122))2595name_123 = "sample_123.g"2596sample_123 = """\2597module A2598 ({|x y ...2599end2600"""2601ast_123 = None2602test_samples.append((False, name_123, sample_123, ast_123))2603name_124 = "sample_124.g"2604sample_124 = """\2605module A2606 ({|x y ...z2607end2608"""2609ast_124 = None2610test_samples.append((False, name_124, sample_124, ast_124))2611name_125 = "sample_125.g"2612sample_125 = """\2613module A2614 ({|x ...2615end2616"""2617ast_125 = None2618test_samples.append((False, name_125, sample_125, ast_125))2619name_126 = "sample_126.g"2620sample_126 = """\2621module A2622 ({|x ...y2623end2624"""2625ast_126 = None2626test_samples.append((False, name_126, sample_126, ast_126))2627name_127 = "sample_127.g"2628sample_127 = """\2629module A2630 ({|...2631end2632"""2633ast_127 = None2634test_samples.append((False, name_127, sample_127, ast_127))2635name_128 = "sample_128.g"2636sample_128 = """\2637module A2638 ({|...x2639end2640"""2641ast_128 = None2642test_samples.append((False, name_128, sample_128, ast_128))2643name_129 = "sample_129.g"2644sample_129 = """\2645module A2646 ({|x ...y|2647end2648"""2649ast_129 = None2650test_samples.append((False, name_129, sample_129, ast_129))2651name_130 = "sample_130.g"2652sample_130 = """\2653module A2654 ({|x ...y| a = 2;});2655end2656"""2657ast_130 = DefModule("A", [2658 Lambda(2659 ["x", "y"], True, [2660 SetLocal(2661 "a",2662 Const(2).set_location(name_130, 2, 18)2663 ).set_location(name_130, 2, 16)2664 ], ["a"]2665 ).set_location(name_130, 2, 4)2666]).set_location(name_130, 1, 1)2667test_samples.append((True, name_130, sample_130, ast_130))2668name_131 = "sample_131.g"2669sample_131 = """\2670module A2671 {a = 1;}2672end2673"""2674ast_131 = DefModule("A", [2675 Block(2676 SetLocal(2677 "a",2678 Const(1).set_location(name_131, 2, 8)2679 ).set_location(name_131, 2, 6)2680 ).set_location(name_131, 2, 3)2681]).set_location(name_131, 1, 1)2682test_samples.append((True, name_131, sample_131, ast_131))2683name_132 = "sample_132.g"2684sample_132 = """\2685module A2686 {2687"""2688ast_132 = None2689test_samples.append((False, name_132, sample_132, ast_132))2690def sl_(n, f, l, c):2691 n.deferred.append(SetLocation(f, l, c))2692 return n2693#-def2694name_133 = "sample_133.g"2695sample_133 = """\2696module A2697 defmacro mac x y (#x + #y;)2698end2699"""2700ast_133 = DefModule("A", [2701 DefMacro("mac", ["x", "y"], [2702 sl_(MacroNode(Add,2703 sl_(MacroNodeParam("x"), name_133, 2, 21),2704 sl_(MacroNodeParam("y"), name_133, 2, 35)2705 ), name_133, 2, 24)2706 ]).set_location(name_133, 2, 3)2707]).set_location(name_133, 1, 1)2708test_samples.append((True, name_133, sample_133, ast_133))2709name_134 = "sample_134.g"2710sample_134 = """\2711module A2712 define f {2713 }2714end2715"""2716ast_134 = DefModule("A", [2717 Define("f", [], [], False, []).set_location(name_134, 2, 3)2718]).set_location(name_134, 1, 1)2719test_samples.append((True, name_134, sample_134, ast_134))2720name_135 = "sample_135.g"2721sample_135 = """\2722module A2723 define f {2724 defmacro m ()2725 }2726end2727"""2728ast_135 = None2729test_samples.append((False, name_135, sample_135, ast_135))2730name_136 = "sample_136.g"2731sample_136 = """\2732module A2733 defmacro m1 (2734 defmacro m2 ()2735 )2736end2737"""2738ast_136 = None2739test_samples.append((False, name_136, sample_136, ast_136))2740name_137 = "sample_137.g"2741sample_137 = """\2742module A2743 defmacro m1 ()2744 define f {}2745 defmacro m2 ()2746 define g {}2747end2748"""2749ast_137 = DefModule("A", [2750 DefMacro("m1", [], []).set_location(name_137, 2, 3),2751 Define("f", [], [], False, []).set_location(name_137, 3, 3),2752 DefMacro("m2", [], []).set_location(name_137, 4, 3),2753 Define("g", [], [], False, []).set_location(name_137, 5, 3)2754]).set_location(name_137, 1, 1)2755test_samples.append((True, name_137, sample_137, ast_137))2756name_138 = "sample_138.g"2757sample_138 = """\2758module A2759 define f {}2760 defmacro m1 ()2761 define g {}2762 defmacro m2 ()2763end2764"""2765ast_138 = DefModule("A", [2766 Define("f", [], [], False, []).set_location(name_138, 2, 3),2767 DefMacro("m1", [], []).set_location(name_138, 3, 3),2768 Define("g", [], [], False, []).set_location(name_138, 4, 3),2769 DefMacro("m2", [], []).set_location(name_138, 5, 3)2770]).set_location(name_138, 1, 1)2771test_samples.append((True, name_138, sample_138, ast_138))2772name_139 = "sample_139.g"2773sample_139 = """\2774module A2775 defmacro m (2776 define f {}2777 )2778end2779"""2780ast_139 = None2781test_samples.append((False, name_139, sample_139, ast_139))2782name_140 = "sample_140.g"2783sample_140 = """\2784module A2785 define f x y ...z {2786 t = x + y;2787 {2788 u = a + b;2789 }2790 }2791end2792"""2793ast_140 = DefModule("A", [2794 Define("f", ["t"], ["x", "y", "z"], True, [2795 SetLocal(2796 "t",2797 Add(2798 GetLocal("x").set_location(name_140, 3, 9),2799 GetLocal("y").set_location(name_140, 3, 13)2800 ).set_location(name_140, 3, 11)2801 ).set_location(name_140, 3, 7),2802 Block(2803 SetLocal(2804 "u",2805 Add(2806 GetLocal("a").set_location(name_140, 5, 11),2807 GetLocal("b").set_location(name_140, 5, 15)2808 ).set_location(name_140, 5, 13)2809 ).set_location(name_140, 5, 9)2810 ).set_location(name_140, 4, 5)2811 ]).set_location(name_140, 2, 3)2812]).set_location(name_140, 1, 1)2813test_samples.append((True, name_140, sample_140, ast_140))2814name_141 = "sample_141.g"2815sample_141 = """\2816module A -- 12817 define f x y z { -- 22818 if (x > y) { -- 32819 t = z; -- 42820 } -- 52821 { -- 62822 if (x > y) { -- 72823 u = z; -- 82824 } -- 92825 } -- 102826 if !z { -- 112827 a = 1; -- 122828 } -- 132829 else { -- 142830 b = 1; -- 152831 } -- 162832 if 1 { -- 172833 a = 1; -- 182834 } -- 192835 elif 2 { -- 202836 b = 2; -- 212837 } -- 222838 } -- 232839end -- 242840"""2841ast_141 = DefModule("A", [2842 Define("f", ["t", "a", "b"], ["x", "y", "z"], False, [2843 If(2844 Gt(2845 GetLocal("x").set_location(name_141, 3, 9),2846 GetLocal("y").set_location(name_141, 3, 13)2847 ).set_location(name_141, 3, 11),2848 [2849 SetLocal(2850 "t",2851 GetLocal("z").set_location(name_141, 4, 11)2852 ).set_location(name_141, 4, 9)2853 ],2854 []2855 ).set_location(name_141, 3, 5),2856 Block(2857 If(2858 Gt(2859 GetLocal("x").set_location(name_141, 7, 11),2860 GetLocal("y").set_location(name_141, 7, 15)2861 ).set_location(name_141, 7, 13),2862 [2863 SetLocal(2864 "u",2865 GetLocal("z").set_location(name_141, 8, 13)2866 ).set_location(name_141, 8, 11)2867 ],2868 []2869 ).set_location(name_141, 7, 7)2870 ).set_location(name_141, 6, 5),2871 If(2872 Not(2873 GetLocal("z").set_location(name_141, 11, 9)2874 ).set_location(name_141, 11, 8),2875 [2876 SetLocal(2877 "a",2878 Const(1).set_location(name_141, 12, 11)2879 ).set_location(name_141, 12, 9)2880 ],2881 [2882 SetLocal(2883 "b",2884 Const(1).set_location(name_141, 15, 11)2885 ).set_location(name_141, 15, 9)2886 ]2887 ).set_location(name_141, 11, 5),2888 If(2889 Const(1).set_location(name_141, 17, 8),2890 [2891 SetLocal(2892 "a",2893 Const(1).set_location(name_141, 18, 11)2894 ).set_location(name_141, 18, 9)2895 ],2896 [2897 If(2898 Const(2).set_location(name_141, 20, 10),2899 [2900 SetLocal(2901 "b",2902 Const(2).set_location(name_141, 21, 11)2903 ).set_location(name_141, 21, 9)2904 ],2905 []2906 ).set_location(name_141, 20, 5)2907 ]2908 ).set_location(name_141, 17, 5)2909 ]).set_location(name_141, 2, 3)2910]).set_location(name_141, 1, 1)2911test_samples.append((True, name_141, sample_141, ast_141))2912name_142 = "sample_142.g"2913sample_142 = """\2914module A2915 if 1 {1;}2916 elif 2 {2;}2917 else {0;}2918end2919"""2920ast_142 = DefModule("A", [2921 If(2922 Const(1).set_location(name_142, 2, 6),2923 [Const(1).set_location(name_142, 2, 9)],2924 [2925 If(2926 Const(2).set_location(name_142, 3, 8),2927 [Const(2).set_location(name_142, 3, 11)],2928 [Const(0).set_location(name_142, 4, 9)]2929 ).set_location(name_142, 3, 3)2930 ]2931 ).set_location(name_142, 2, 3)2932]).set_location(name_142, 1, 1)2933test_samples.append((True, name_142, sample_142, ast_142))2934name_143 = "sample_143.g"2935sample_143 = """\2936module A2937 if 1 {1;}2938 elif 2 {2;}2939 elif 3 {3;}2940end2941"""2942ast_143 = DefModule("A", [2943 If(2944 Const(1).set_location(name_143, 2, 6),2945 [Const(1).set_location(name_143, 2, 9)],2946 [2947 If(2948 Const(2).set_location(name_143, 3, 8),2949 [Const(2).set_location(name_143, 3, 11)],2950 [2951 If(2952 Const(3).set_location(name_143, 4, 8),2953 [Const(3).set_location(name_143, 4, 11)],2954 []2955 ).set_location(name_143, 4, 3)2956 ]2957 ).set_location(name_143, 3, 3)2958 ]2959 ).set_location(name_143, 2, 3)2960]).set_location(name_143, 1, 1)2961test_samples.append((True, name_143, sample_143, ast_143))2962name_144 = "sample_144.g"2963sample_144 = """\2964module A2965 if 1 {1;}2966 elif 2 {2;}2967 elif 3 {3;}2968 else {0;}2969end2970"""2971ast_144 = DefModule("A", [2972 If(2973 Const(1).set_location(name_144, 2, 6),2974 [Const(1).set_location(name_144, 2, 9)],2975 [2976 If(2977 Const(2).set_location(name_144, 3, 8),2978 [Const(2).set_location(name_144, 3, 11)],2979 [2980 If(2981 Const(3).set_location(name_144, 4, 8),2982 [Const(3).set_location(name_144, 4, 11)],2983 [Const(0).set_location(name_144, 5, 9)]2984 ).set_location(name_144, 4, 3)2985 ]2986 ).set_location(name_144, 3, 3)2987 ]2988 ).set_location(name_144, 2, 3)2989]).set_location(name_144, 1, 1)2990test_samples.append((True, name_144, sample_144, ast_144))2991name_145 = "sample_145.g"2992sample_145 = """\2993module A2994 if 1 {1;}2995 elif 2 {2;}2996 elif 3 {3;}2997 elif 4 {4;}2998 else {0;}2999end3000"""3001ast_145 = DefModule("A", [3002 If(3003 Const(1).set_location(name_145, 2, 6),3004 [Const(1).set_location(name_145, 2, 9)],3005 [3006 If(3007 Const(2).set_location(name_145, 3, 8),3008 [Const(2).set_location(name_145, 3, 11)],3009 [3010 If(3011 Const(3).set_location(name_145, 4, 8),3012 [Const(3).set_location(name_145, 4, 11)],3013 [3014 If(3015 Const(4).set_location(name_145, 5, 8),3016 [Const(4).set_location(name_145, 5, 11)],3017 [Const(0).set_location(name_145, 6, 9)]3018 ).set_location(name_145, 5, 3)3019 ]3020 ).set_location(name_145, 4, 3)3021 ]3022 ).set_location(name_145, 3, 3)3023 ]3024 ).set_location(name_145, 2, 3)3025]).set_location(name_145, 1, 1)3026test_samples.append((True, name_145, sample_145, ast_145))3027name_146 = "sample_146.g"3028sample_146 = """\3029module A3030 define f ...args {3031 foreach x args {3032 u = x;3033 }3034 while 0 {3035 v = 1;3036 }3037 do {3038 w = 0;3039 } while 1;3040 break; continue;3041 return;3042 return 1;3043 }3044end3045"""3046ast_146 = DefModule("A", [3047 Define("f", ["x", "u", "v", "w"], ["args"], True, [3048 Foreach(3049 "x",3050 GetLocal("args").set_location(name_146, 3, 15),3051 [3052 SetLocal(3053 "u",3054 GetLocal("x").set_location(name_146, 4, 11)3055 ).set_location(name_146, 4, 9)3056 ]3057 ).set_location(name_146, 3, 5),3058 While(3059 Const(0).set_location(name_146, 6, 11),3060 [3061 SetLocal(3062 "v",3063 Const(1).set_location(name_146, 7, 11)3064 ).set_location(name_146, 7, 9)3065 ]3066 ).set_location(name_146, 6, 5),3067 DoWhile(3068 [3069 SetLocal(3070 "w",3071 Const(0).set_location(name_146, 10, 11)3072 ).set_location(name_146, 10, 9)3073 ],3074 Const(1).set_location(name_146, 11, 13)3075 ).set_location(name_146, 9, 5),3076 Break().set_location(name_146, 12, 5),3077 Continue().set_location(name_146, 12, 12),3078 Return().set_location(name_146, 13, 5),3079 Return(3080 Const(1).set_location(name_146, 14, 12)3081 ).set_location(name_146, 14, 5)3082 ]).set_location(name_146, 2, 3),3083]).set_location(name_146, 1, 1)3084test_samples.append((True, name_146, sample_146, ast_146))3085name_147 = "sample_147.g"3086sample_147 = """\3087module A3088 define f {3089 try {3090 }3091 }3092end3093"""3094ast_147 = DefModule("A", [3095 Define("f", [], [], False, [3096 TryCatchFinally(3097 [], [], []3098 ).set_location(name_147, 3, 5)3099 ]).set_location(name_147, 2, 3)3100]).set_location(name_147, 1, 1)3101test_samples.append((True, name_147, sample_147, ast_147))3102name_148 = "sample_148.g"3103sample_148 = """\3104module A3105 define f {3106 try {3107 a = 1;3108 }3109 catch Error {3110 b = 1;3111 }3112 }3113end3114"""3115ast_148 = DefModule("A", [3116 Define("f", ["a", "b"], [], False, [3117 TryCatchFinally(3118 [3119 SetLocal(3120 "a",3121 Const(1).set_location(name_148, 4, 11)3122 ).set_location(name_148, 4, 9)3123 ],3124 [3125 ("Error", None, [3126 SetLocal(3127 "b",3128 Const(1).set_location(name_148, 7, 11)3129 ).set_location(name_148, 7, 9)3130 ])3131 ],3132 []3133 ).set_location(name_148, 3, 5)3134 ]).set_location(name_148, 2, 3)3135]).set_location(name_148, 1, 1)3136test_samples.append((True, name_148, sample_148, ast_148))3137name_149 = "sample_149.g"3138sample_149 = """\3139module A3140 define f {3141 try {3142 a = 1;3143 }3144 catch Error e {3145 b = 1;3146 }3147 }3148end3149"""3150ast_149 = DefModule("A", [3151 Define("f", ["a", "e", "b"], [], False, [3152 TryCatchFinally(3153 [3154 SetLocal(3155 "a",3156 Const(1).set_location(name_149, 4, 11)3157 ).set_location(name_149, 4, 9)3158 ],3159 [3160 ("Error", "e", [3161 SetLocal(3162 "b",3163 Const(1).set_location(name_149, 7, 11)3164 ).set_location(name_149, 7, 9)3165 ])3166 ],3167 []3168 ).set_location(name_149, 3, 5)3169 ]).set_location(name_149, 2, 3)3170]).set_location(name_149, 1, 1)3171test_samples.append((True, name_149, sample_149, ast_149))3172name_150 = "sample_150.g"3173sample_150 = """\3174module A3175 define f {3176 try {3177 a = 1;3178 }3179 finally {3180 b = 1;3181 }3182 }3183end3184"""3185ast_150 = DefModule("A", [3186 Define("f", ["a", "b"], [], False, [3187 TryCatchFinally(3188 [3189 SetLocal(3190 "a",3191 Const(1).set_location(name_150, 4, 11)3192 ).set_location(name_150, 4, 9)3193 ],3194 [],3195 [3196 SetLocal(3197 "b",3198 Const(1).set_location(name_150, 7, 11)3199 ).set_location(name_150, 7, 9)3200 ]3201 ).set_location(name_150, 3, 5)3202 ]).set_location(name_150, 2, 3)3203]).set_location(name_150, 1, 1)3204test_samples.append((True, name_150, sample_150, ast_150))3205name_151 = "sample_151.g"3206sample_151 = """\3207module A3208 define f {3209 try {3210 a = 1;3211 }3212 catch Error {3213 b = 1;3214 }3215 catch Error e {3216 c = 1;3217 }3218 catch Error e {3219 d = 1;3220 }3221 finally {3222 e = 1;3223 }3224 }3225end3226"""3227ast_151 = DefModule("A", [3228 Define("f", ["a", "b", "e", "c", "d"], [], False, [3229 TryCatchFinally(3230 [3231 SetLocal(3232 "a",3233 Const(1).set_location(name_151, 4, 11)3234 ).set_location(name_151, 4, 9)3235 ],3236 [3237 ("Error", None, [3238 SetLocal(3239 "b",3240 Const(1).set_location(name_151, 7, 11)3241 ).set_location(name_151, 7, 9)3242 ]),3243 ("Error", "e", [3244 SetLocal(3245 "c",3246 Const(1).set_location(name_151, 10, 11)3247 ).set_location(name_151, 10, 9)3248 ]),3249 ("Error", "e", [3250 SetLocal(3251 "d",3252 Const(1).set_location(name_151, 13, 11)3253 ).set_location(name_151, 13, 9)3254 ])3255 ],3256 [3257 SetLocal(3258 "e",3259 Const(1).set_location(name_151, 16, 11)3260 ).set_location(name_151, 16, 9)3261 ]3262 ).set_location(name_151, 3, 5)3263 ]).set_location(name_151, 2, 3)3264]).set_location(name_151, 1, 1)3265test_samples.append((True, name_151, sample_151, ast_151))3266name_152 = "sample_152.g"3267sample_152 = """\3268module A3269 throw e;3270 throw Error, "Operation fails";3271end3272"""3273ast_152 = DefModule("A", [3274 Rethrow(3275 GetLocal("e").set_location(name_152, 2, 9)3276 ).set_location(name_152, 2, 3),3277 Throw(3278 GetLocal("Error").set_location(name_152, 3, 9),3279 Const("Operation fails").set_location(name_152, 3, 16)3280 ).set_location(name_152, 3, 3)3281]).set_location(name_152, 1, 1)3282test_samples.append((True, name_152, sample_152, ast_152))3283name_153 = "sample_153.g"3284sample_153 = """\3285module A3286 defmacro m (-1;)3287end3288"""3289ast_153 = DefModule("A", [3290 DefMacro("m", [], [3291 sl_(MacroNode(Neg,3292 sl_(MacroNode(Const,3293 MacroNodeAtom(1)3294 ), name_153, 2, 16)3295 ), name_153, 2, 15)3296 ]).set_location(name_153, 2, 3)3297]).set_location(name_153, 1, 1)3298test_samples.append((True, name_153, sample_153, ast_153))3299name_154 = "sample_154.g"3300sample_154 = """\3301module A3302 defmacro m (a[0];)3303end3304"""3305ast_154 = DefModule("A", [3306 DefMacro("m", [], [3307 sl_(MacroNode(GetItem,3308 sl_(MacroNode(GetLocal,3309 MacroNodeAtom("a")3310 ), name_154, 2, 15),3311 sl_(MacroNode(Const,3312 MacroNodeAtom(0)3313 ), name_154, 2, 17)3314 ), name_154, 2, 16)3315 ]).set_location(name_154, 2, 3)3316]).set_location(name_154, 1, 1)3317test_samples.append((True, name_154, sample_154, ast_154))3318name_155 = "sample_155.g"3319sample_155 = """\3320module A3321 defmacro m (a:b;)3322end3323"""3324ast_155 = DefModule("A", [3325 DefMacro("m", [], [3326 sl_(MacroNode(GetMember,3327 sl_(MacroNode(GetLocal,3328 MacroNodeAtom("a")3329 ), name_155, 2, 15),3330 MacroNodeAtom("b")3331 ), name_155, 2, 16)3332 ]).set_location(name_155, 2, 3)3333]).set_location(name_155, 1, 1)3334test_samples.append((True, name_155, sample_155, ast_155))3335name_156 = "sample_156.g"3336sample_156 = """\3337module A3338 defmacro m (x = y;)3339end3340"""3341ast_156 = DefModule("A", [3342 DefMacro("m", [], [3343 sl_(MacroNode(SetLocal,3344 MacroNodeAtom("x"),3345 sl_(MacroNode(GetLocal,3346 MacroNodeAtom("y")3347 ), name_156, 2, 19)3348 ), name_156, 2, 17)3349 ]).set_location(name_156, 2, 3)3350]).set_location(name_156, 1, 1)3351test_samples.append((True, name_156, sample_156, ast_156))3352name_157 = "sample_157.g"3353sample_157 = """\3354module A3355 defmacro m (x += y;)3356end3357"""3358ast_157 = DefModule("A", [3359 DefMacro("m", [], [3360 sl_(MacroNode(SetLocal,3361 MacroNodeAtom("x"),3362 sl_(MacroNode(Add,3363 sl_(MacroNode(GetLocal,3364 MacroNodeAtom("x")3365 ), name_157, 2, 15),3366 sl_(MacroNode(GetLocal,3367 MacroNodeAtom("y")3368 ), name_157, 2, 20)3369 ), name_157, 2, 17)3370 ), name_157, 2, 17)3371 ]).set_location(name_157, 2, 3)3372]).set_location(name_157, 1, 1)3373test_samples.append((True, name_157, sample_157, ast_157))3374name_158 = "sample_158.g"3375sample_158 = """\3376module A3377 defmacro m (x[y] = z;)3378 x[y] = z;3379end3380"""3381ast_158 = DefModule("A", [3382 DefMacro("m", [], [3383 sl_(MacroNode(SetItem,3384 sl_(MacroNode(GetLocal,3385 MacroNodeAtom("x")3386 ), name_158, 2, 15),3387 sl_(MacroNode(GetLocal,3388 MacroNodeAtom("y")3389 ), name_158, 2, 17),3390 sl_(MacroNode(GetLocal,3391 MacroNodeAtom("z")3392 ), name_158, 2, 22)3393 ), name_158, 2, 20)3394 ]).set_location(name_158, 2, 3),3395 SetItem(3396 GetLocal("x").set_location(name_158, 3, 3),3397 GetLocal("y").set_location(name_158, 3, 5),3398 GetLocal("z").set_location(name_158, 3, 10)3399 ).set_location(name_158, 3, 8)3400]).set_location(name_158, 1, 1)3401test_samples.append((True, name_158, sample_158, ast_158))3402name_159 = "sample_159.g"3403sample_159 = """\3404module A3405 defmacro m (x[y] += z;)3406 x[y] += z;3407end3408"""3409ast_159 = DefModule("A", [3410 DefMacro("m", [], [3411 sl_(MacroNode(SetItem,3412 sl_(MacroNode(GetLocal,3413 MacroNodeAtom("x")3414 ), name_159, 2, 15),3415 sl_(MacroNode(GetLocal,3416 MacroNodeAtom("y")3417 ), name_159, 2, 17),3418 sl_(MacroNode(Add,3419 sl_(MacroNode(GetItem,3420 sl_(MacroNode(GetLocal,3421 MacroNodeAtom("x")3422 ), name_159, 2, 15),3423 sl_(MacroNode(GetLocal,3424 MacroNodeAtom("y")3425 ), name_159, 2, 17)3426 ), name_159, 2, 16),3427 sl_(MacroNode(GetLocal,3428 MacroNodeAtom("z")3429 ), name_159, 2, 23)3430 ), name_159, 2, 20)3431 ), name_159, 2, 20)3432 ]).set_location(name_159, 2, 3),3433 SetItem(3434 GetLocal("x").set_location(name_159, 3, 3),3435 GetLocal("y").set_location(name_159, 3, 5),3436 Add(3437 GetItem(3438 GetLocal("x").set_location(name_159, 3, 3),3439 GetLocal("y").set_location(name_159, 3, 5)3440 ).set_location(name_159, 3, 4),3441 GetLocal("z").set_location(name_159, 3, 11)3442 ).set_location(name_159, 3, 8)3443 ).set_location(name_159, 3, 8)3444]).set_location(name_159, 1, 1)3445test_samples.append((True, name_159, sample_159, ast_159))3446name_160 = "sample_160.g"3447sample_160 = """\3448module A3449 defmacro m (x:y = z;)3450 x:y = z;3451end3452"""3453ast_160 = DefModule("A", [3454 DefMacro("m", [], [3455 sl_(MacroNode(SetMember,3456 sl_(MacroNode(GetLocal,3457 MacroNodeAtom("x")3458 ), name_160, 2, 15),3459 MacroNodeAtom("y"),3460 sl_(MacroNode(GetLocal,3461 MacroNodeAtom("z")3462 ), name_160, 2, 21)3463 ), name_160, 2, 19)3464 ]).set_location(name_160, 2, 3),3465 SetMember(3466 GetLocal("x").set_location(name_160, 3, 3),3467 "y",3468 GetLocal("z").set_location(name_160, 3, 9)3469 ).set_location(name_160, 3, 7)3470]).set_location(name_160, 1, 1)3471test_samples.append((True, name_160, sample_160, ast_160))3472name_161 = "sample_161.g"3473sample_161 = """\3474module A3475 defmacro m (x:y += z;)3476 x:y += z;3477end3478"""3479ast_161 = DefModule("A", [3480 DefMacro("m", [], [3481 sl_(MacroNode(SetMember,3482 sl_(MacroNode(GetLocal,3483 MacroNodeAtom("x")3484 ), name_161, 2, 15),3485 MacroNodeAtom("y"),3486 sl_(MacroNode(Add,3487 sl_(MacroNode(GetMember,3488 sl_(MacroNode(GetLocal,3489 MacroNodeAtom("x")3490 ), name_161, 2, 15),3491 MacroNodeAtom("y")3492 ), name_161, 2, 16),3493 sl_(MacroNode(GetLocal,3494 MacroNodeAtom("z")3495 ), name_161, 2, 22)3496 ), name_161, 2, 19)3497 ), name_161, 2, 19)3498 ]).set_location(name_161, 2, 3),3499 SetMember(3500 GetLocal("x").set_location(name_161, 3, 3),3501 "y",3502 Add(3503 GetMember(3504 GetLocal("x").set_location(name_161, 3, 3),3505 "y"3506 ).set_location(name_161, 3, 4),3507 GetLocal("z").set_location(name_161, 3, 10)3508 ).set_location(name_161, 3, 7)3509 ).set_location(name_161, 3, 7)3510]).set_location(name_161, 1, 1)3511test_samples.append((True, name_161, sample_161, ast_161))3512name_162 = "sample_162.g"3513sample_162 = """\3514module A3515 1 = 2;3516end3517"""3518ast_162 = None3519test_samples.append((False, name_162, sample_162, ast_162))3520name_163 = "sample_163.g"3521sample_163 = """\3522module A3523 defmacro m (f a b $c;)3524end3525"""3526ast_163 = DefModule("A", [3527 DefMacro("m", [], [3528 sl_(MacroNode(Call,3529 sl_(MacroNode(GetLocal,3530 MacroNodeAtom("f")3531 ), name_163, 2, 15),3532 sl_(MacroNode(GetLocal,3533 MacroNodeAtom("a")3534 ), name_163, 2, 17),3535 sl_(MacroNode(GetLocal,3536 MacroNodeAtom("b")3537 ), name_163, 2, 19),3538 sl_(MacroNode(GetLocal,3539 MacroNodeAtom("c")3540 ), name_163, 2, 22)3541 ), name_163, 2, 17)3542 ]).set_location(name_163, 2, 3)3543]).set_location(name_163, 1, 1)3544test_samples.append((True, name_163, sample_163, ast_163))3545name_164 = "sample_164.g"3546sample_164 = """\3547module A3548 defmacro m ($(m `a `b);)3549end3550"""3551ast_164 = DefModule("A", [3552 DefMacro("m", [], [3553 sl_(MacroNode(Expand,3554 sl_(MacroNode(GetLocal,3555 MacroNodeAtom("m")3556 ), name_164, 2, 17),3557 sl_(MacroNode(GetLocal,3558 MacroNodeAtom("a")3559 ), name_164, 2, 20),3560 sl_(MacroNode(GetLocal,3561 MacroNodeAtom("b")3562 ), name_164, 2, 23)3563 ), name_164, 2, 15)3564 ]).set_location(name_164, 2, 3)3565]).set_location(name_164, 1, 1)3566test_samples.append((True, name_164, sample_164, ast_164))3567name_165 = "sample_165.g"3568sample_165 = """\3569module A3570 defmacro m ((1, 2);)3571end3572"""3573ast_165 = DefModule("A", [3574 DefMacro("m", [], [3575 sl_(MacroNode(NewPair,3576 sl_(MacroNode(Const,3577 MacroNodeAtom(1)3578 ), name_165, 2, 16),3579 sl_(MacroNode(Const,3580 MacroNodeAtom(2)3581 ), name_165, 2, 19)3582 ), name_165, 2, 15)3583 ]).set_location(name_165, 2, 3)3584]).set_location(name_165, 1, 1)3585test_samples.append((True, name_165, sample_165, ast_165))3586name_166 = "sample_166.g"3587sample_166 = """\3588module A3589 defmacro m ([1, 2];)3590end3591"""3592ast_166 = DefModule("A", [3593 DefMacro("m", [], [3594 sl_(MacroNode(NewList,3595 sl_(MacroNode(Const,3596 MacroNodeAtom(1)3597 ), name_166, 2, 16),3598 sl_(MacroNode(Const,3599 MacroNodeAtom(2)3600 ), name_166, 2, 19)3601 ), name_166, 2, 15)3602 ]).set_location(name_166, 2, 3)3603]).set_location(name_166, 1, 1)3604test_samples.append((True, name_166, sample_166, ast_166))3605name_167 = "sample_167.g"3606sample_167 = """\3607module A3608 defmacro m ([1 => 2];)3609end3610"""3611ast_167 = DefModule("A", [3612 DefMacro("m", [], [3613 sl_(MacroNode(NewHashMap,3614 sl_(MacroNode(NewPair,3615 sl_(MacroNode(Const,3616 MacroNodeAtom(1)3617 ), name_167, 2, 16),3618 sl_(MacroNode(Const,3619 MacroNodeAtom(2)3620 ), name_167, 2, 21)3621 ), name_167, 2, 16)3622 ), name_167, 2, 15)3623 ]).set_location(name_167, 2, 3)3624]).set_location(name_167, 1, 1)3625test_samples.append((True, name_167, sample_167, ast_167))3626name_168 = "sample_168.g"3627sample_168 = """\3628module A3629 defmacro m (({|x y ...z| t = 1; x = 2;});)3630end3631"""3632ast_168 = DefModule("A", [3633 DefMacro("m", [], [3634 sl_(MacroNode(Lambda,3635 MacroNodeAtom(["x", "y", "z"]),3636 MacroNodeAtom(True),3637 MacroNodeSequence(3638 sl_(MacroNode(SetLocal,3639 MacroNodeAtom("t"),3640 sl_(MacroNode(Const,3641 MacroNodeAtom(1)3642 ), name_168, 2, 32)3643 ), name_168, 2, 30),3644 sl_(MacroNode(SetLocal,3645 MacroNodeAtom("x"),3646 sl_(MacroNode(Const,3647 MacroNodeAtom(2)3648 ), name_168, 2, 39)3649 ), name_168, 2, 37)3650 ),3651 MacroNodeAtom(["t"])3652 ), name_168, 2, 16)3653 ]).set_location(name_168, 2, 3)3654]).set_location(name_168, 1, 1)3655test_samples.append((True, name_168, sample_168, ast_168))3656name_169 = "sample_169.g"3657sample_169 = """\3658module A3659 defmacro m ({1; 2; 3;})3660end3661"""3662ast_169 = DefModule("A", [3663 DefMacro("m", [], [3664 sl_(MacroNode(Block,3665 sl_(MacroNode(Const,3666 MacroNodeAtom(1)3667 ), name_169, 2, 16),3668 sl_(MacroNode(Const,3669 MacroNodeAtom(2)3670 ), name_169, 2, 19),3671 sl_(MacroNode(Const,3672 MacroNodeAtom(3)3673 ), name_169, 2, 22)3674 ), name_169, 2, 15)3675 ]).set_location(name_169, 2, 3)3676]).set_location(name_169, 1, 1)3677test_samples.append((True, name_169, sample_169, ast_169))3678name_170 = "sample_170.g"3679sample_170 = """\3680module A3681 defmacro m (3682 if 1 {1;}3683 elif 2 {2;}3684 else {3;}3685 )3686end3687"""3688ast_170 = DefModule("A", [3689 DefMacro("m", [], [3690 sl_(MacroNode(If,3691 sl_(MacroNode(Const,3692 MacroNodeAtom(1)3693 ), name_170, 3, 8),3694 MacroNodeSequence(3695 sl_(MacroNode(Const,3696 MacroNodeAtom(1)3697 ), name_170, 3, 11)3698 ),3699 MacroNodeSequence(3700 sl_(MacroNode(If,3701 sl_(MacroNode(Const,3702 MacroNodeAtom(2)3703 ), name_170, 4, 10),3704 MacroNodeSequence(3705 sl_(MacroNode(Const,3706 MacroNodeAtom(2)3707 ), name_170, 4, 13)3708 ),3709 MacroNodeSequence(3710 sl_(MacroNode(Const,3711 MacroNodeAtom(3)3712 ), name_170, 5, 11)3713 )3714 ), name_170, 4, 5)3715 )3716 ), name_170, 3, 5)3717 ]).set_location(name_170, 2, 3)3718]).set_location(name_170, 1, 1)3719test_samples.append((True, name_170, sample_170, ast_170))3720name_171 = "sample_171.g"3721sample_171 = """\3722module A3723 defmacro m (foreach i x {1;})3724end3725"""3726ast_171 = DefModule("A", [3727 DefMacro("m", [], [3728 sl_(MacroNode(Foreach,3729 MacroNodeAtom("i"),3730 sl_(MacroNode(GetLocal,3731 MacroNodeAtom("x")3732 ), name_171, 2, 25),3733 MacroNodeSequence(3734 sl_(MacroNode(Const,3735 MacroNodeAtom(1)3736 ), name_171, 2, 28)3737 )3738 ), name_171, 2, 15)3739 ]).set_location(name_171, 2, 3)3740]).set_location(name_171, 1, 1)3741test_samples.append((True, name_171, sample_171, ast_171))3742name_172 = "sample_172.g"3743sample_172 = """\3744module A3745 defmacro m (while x {y;})3746end3747"""3748ast_172 = DefModule("A", [3749 DefMacro("m", [], [3750 sl_(MacroNode(While,3751 sl_(MacroNode(GetLocal,3752 MacroNodeAtom("x")3753 ), name_172, 2, 21),3754 MacroNodeSequence(3755 sl_(MacroNode(GetLocal,3756 MacroNodeAtom("y")3757 ), name_172, 2, 24)3758 )3759 ), name_172, 2, 15)3760 ]).set_location(name_172, 2, 3)3761]).set_location(name_172, 1, 1)3762test_samples.append((True, name_172, sample_172, ast_172))3763name_173 = "sample_173.g"3764sample_173 = """\3765module A3766 defmacro m (do {x;} while y;)3767end3768"""3769ast_173 = DefModule("A", [3770 DefMacro("m", [], [3771 sl_(MacroNode(DoWhile,3772 MacroNodeSequence(3773 sl_(MacroNode(GetLocal,3774 MacroNodeAtom("x")3775 ), name_173, 2, 19)3776 ),3777 sl_(MacroNode(GetLocal,3778 MacroNodeAtom("y")3779 ), name_173, 2, 29)3780 ), name_173, 2, 15)3781 ]).set_location(name_173, 2, 3)3782]).set_location(name_173, 1, 1)3783test_samples.append((True, name_173, sample_173, ast_173))3784name_174 = "sample_174.g"3785sample_174 = """\3786module A3787 defmacro m (break; continue; return; return 0;)3788end3789"""3790ast_174 = DefModule("A", [3791 DefMacro("m", [], [3792 sl_(MacroNode(Break), name_174, 2, 15),3793 sl_(MacroNode(Continue), name_174, 2, 22),3794 sl_(MacroNode(Return), name_174, 2, 32),3795 sl_(MacroNode(Return,3796 sl_(MacroNode(Const,3797 MacroNodeAtom(0)3798 ), name_174, 2, 47)3799 ), name_174, 2, 40)3800 ]).set_location(name_174, 2, 3)3801]).set_location(name_174, 1, 1)3802test_samples.append((True, name_174, sample_174, ast_174))3803name_175 = "sample_175.g"3804sample_175 = """\3805module A3806 defmacro m (3807 try {3808 1;3809 }3810 catch Error e {3811 e;3812 }3813 finally {3814 0;3815 }3816 )3817end3818"""3819ast_175 = DefModule("A", [3820 DefMacro("m", [], [3821 sl_(MacroNode(TryCatchFinally,3822 MacroNodeSequence(3823 sl_(MacroNode(Const,3824 MacroNodeAtom(1)3825 ), name_175, 4, 7)3826 ),3827 MacroNodeSequence(3828 MacroNodeSequence(3829 MacroNodeAtom("Error"),3830 MacroNodeAtom("e"),3831 MacroNodeSequence(3832 sl_(MacroNode(GetLocal,3833 MacroNodeAtom("e")3834 ), name_175, 7, 7)3835 )3836 )3837 ),3838 MacroNodeSequence(3839 sl_(MacroNode(Const,3840 MacroNodeAtom(0)3841 ), name_175, 10, 7)3842 )3843 ), name_175, 3, 5)3844 ]).set_location(name_175, 2, 3)3845]).set_location(name_175, 1, 1)3846test_samples.append((True, name_175, sample_175, ast_175))3847name_176 = "sample_176.g"3848sample_176 = """\3849module A3850 defmacro m (throw e; throw Error, "failed";)3851end3852"""3853ast_176 = DefModule("A", [3854 DefMacro("m", [], [3855 sl_(MacroNode(Rethrow,3856 sl_(MacroNode(GetLocal,3857 MacroNodeAtom("e")3858 ), name_176, 2, 21)3859 ), name_176, 2, 15),3860 sl_(MacroNode(Throw,3861 sl_(MacroNode(GetLocal,3862 MacroNodeAtom("Error")3863 ), name_176, 2, 30),3864 sl_(MacroNode(Const,3865 MacroNodeAtom("failed")3866 ), name_176, 2, 37)3867 ), name_176, 2, 24)3868 ]).set_location(name_176, 2, 3)3869]).set_location(name_176, 1, 1)3870test_samples.append((True, name_176, sample_176, ast_176))3871name_177 = "sample_177.g"3872sample_177 = """\3873module A3874 grammar G3875 a -> {3876 {a;}3877 };3878 end3879end3880"""3881ast_177 = DefModule("A", [3882 DefGrammar("G", [], [3883 DefRule(3884 "a",3885 Action(3886 ABlock([3887 ABlock([3888 AId("a").set_location(name_177, 4, 8)3889 ]).set_location(name_177, 4, 7)3890 ]).set_location(name_177, 3, 10)3891 ).set_location(name_177, 3, 10),3892 False3893 ).set_location(name_177, 3, 5)3894 ]).set_location(name_177, 2, 3)3895]).set_location(name_177, 1, 1)3896test_samples.append((True, name_177, sample_177, ast_177))3897name_178 = "sample_178.g"3898sample_178 = """\3899module A3900 grammar G3901 a -> {0;};3902 end3903end3904"""3905ast_178 = DefModule("A", [3906 DefGrammar("G", [], [3907 DefRule(3908 "a",3909 Action(3910 ABlock([3911 AIntLiteral(0).set_location(name_178, 3, 11)3912 ]).set_location(name_178, 3, 10)3913 ).set_location(name_178, 3, 10),3914 False3915 ).set_location(name_178, 3, 5)3916 ]).set_location(name_178, 2, 3)3917]).set_location(name_178, 1, 1)3918test_samples.append((True, name_178, sample_178, ast_178))3919name_179 = "sample_179.g"3920sample_179 = """\3921module A3922 grammar G3923 a -> {2.5;};3924 end3925end3926"""3927ast_179 = DefModule("A", [3928 DefGrammar("G", [], [3929 DefRule(3930 "a",3931 Action(3932 ABlock([3933 AFloatLiteral(2.5).set_location(name_179, 3, 11)3934 ]).set_location(name_179, 3, 10)3935 ).set_location(name_179, 3, 10),3936 False3937 ).set_location(name_179, 3, 5)3938 ]).set_location(name_179, 2, 3)3939]).set_location(name_179, 1, 1)3940test_samples.append((True, name_179, sample_179, ast_179))3941name_180 = "sample_180.g"3942sample_180 = """\3943module A3944 grammar G3945 a -> {("abc");};3946 end3947end3948"""3949ast_180 = DefModule("A", [3950 DefGrammar("G", [], [3951 DefRule(3952 "a",3953 Action(3954 ABlock([3955 AStringLiteral("abc").set_location(name_180, 3, 12)3956 ]).set_location(name_180, 3, 10)3957 ).set_location(name_180, 3, 10),3958 False3959 ).set_location(name_180, 3, 5)3960 ]).set_location(name_180, 2, 3)3961]).set_location(name_180, 1, 1)3962test_samples.append((True, name_180, sample_180, ast_180))3963name_181 = "sample_181.g"3964sample_181 = """\3965module A3966 grammar G3967 a -> {a || b;};3968 end3969end3970"""3971ast_181 = DefModule("A", [3972 DefGrammar("G", [], [3973 DefRule(3974 "a",3975 Action(3976 ABlock([3977 ALogOrExpr(3978 AId("a").set_location(name_181, 3, 11),3979 AId("b").set_location(name_181, 3, 16)3980 ).set_location(name_181, 3, 13)3981 ]).set_location(name_181, 3, 10)3982 ).set_location(name_181, 3, 10),3983 False3984 ).set_location(name_181, 3, 5)3985 ]).set_location(name_181, 2, 3)3986]).set_location(name_181, 1, 1)3987test_samples.append((True, name_181, sample_181, ast_181))3988name_182 = "sample_182.g"3989sample_182 = """\3990module A3991 grammar G3992 a -> {a && b;};3993 end3994end3995"""3996ast_182 = DefModule("A", [3997 DefGrammar("G", [], [3998 DefRule(3999 "a",4000 Action(4001 ABlock([4002 ALogAndExpr(4003 AId("a").set_location(name_182, 3, 11),4004 AId("b").set_location(name_182, 3, 16)4005 ).set_location(name_182, 3, 13)4006 ]).set_location(name_182, 3, 10)4007 ).set_location(name_182, 3, 10),4008 False4009 ).set_location(name_182, 3, 5)4010 ]).set_location(name_182, 2, 3)4011]).set_location(name_182, 1, 1)4012test_samples.append((True, name_182, sample_182, ast_182))4013name_183 = "sample_183.g"4014sample_183 = """\4015module A4016 grammar G4017 a -> {a < b;};4018 end4019end4020"""4021ast_183 = DefModule("A", [4022 DefGrammar("G", [], [4023 DefRule(4024 "a",4025 Action(4026 ABlock([4027 ALtExpr(4028 AId("a").set_location(name_183, 3, 11),4029 AId("b").set_location(name_183, 3, 15)4030 ).set_location(name_183, 3, 13)4031 ]).set_location(name_183, 3, 10)4032 ).set_location(name_183, 3, 10),4033 False4034 ).set_location(name_183, 3, 5)4035 ]).set_location(name_183, 2, 3)4036]).set_location(name_183, 1, 1)4037test_samples.append((True, name_183, sample_183, ast_183))4038name_184 = "sample_184.g"4039sample_184 = """\4040module A4041 grammar G4042 a -> {a > b;};4043 end4044end4045"""4046ast_184 = DefModule("A", [4047 DefGrammar("G", [], [4048 DefRule(4049 "a",4050 Action(4051 ABlock([4052 AGtExpr(4053 AId("a").set_location(name_184, 3, 11),4054 AId("b").set_location(name_184, 3, 15)4055 ).set_location(name_184, 3, 13)4056 ]).set_location(name_184, 3, 10)4057 ).set_location(name_184, 3, 10),4058 False4059 ).set_location(name_184, 3, 5)4060 ]).set_location(name_184, 2, 3)4061]).set_location(name_184, 1, 1)4062test_samples.append((True, name_184, sample_184, ast_184))4063name_185 = "sample_185.g"4064sample_185 = """\4065module A4066 grammar G4067 a -> {a <= b;};4068 end4069end4070"""4071ast_185 = DefModule("A", [4072 DefGrammar("G", [], [4073 DefRule(4074 "a",4075 Action(4076 ABlock([4077 ALeExpr(4078 AId("a").set_location(name_185, 3, 11),4079 AId("b").set_location(name_185, 3, 16)4080 ).set_location(name_185, 3, 13)4081 ]).set_location(name_185, 3, 10)4082 ).set_location(name_185, 3, 10),4083 False4084 ).set_location(name_185, 3, 5)4085 ]).set_location(name_185, 2, 3)4086]).set_location(name_185, 1, 1)4087test_samples.append((True, name_185, sample_185, ast_185))4088name_186 = "sample_186.g"4089sample_186 = """\4090module A4091 grammar G4092 a -> {a >= b;};4093 end4094end4095"""4096ast_186 = DefModule("A", [4097 DefGrammar("G", [], [4098 DefRule(4099 "a",4100 Action(4101 ABlock([4102 AGeExpr(4103 AId("a").set_location(name_186, 3, 11),4104 AId("b").set_location(name_186, 3, 16)4105 ).set_location(name_186, 3, 13)4106 ]).set_location(name_186, 3, 10)4107 ).set_location(name_186, 3, 10),4108 False4109 ).set_location(name_186, 3, 5)4110 ]).set_location(name_186, 2, 3)4111]).set_location(name_186, 1, 1)4112test_samples.append((True, name_186, sample_186, ast_186))4113name_187 = "sample_187.g"4114sample_187 = """\4115module A4116 grammar G4117 a -> {a == b;};4118 end4119end4120"""4121ast_187 = DefModule("A", [4122 DefGrammar("G", [], [4123 DefRule(4124 "a",4125 Action(4126 ABlock([4127 AEqExpr(4128 AId("a").set_location(name_187, 3, 11),4129 AId("b").set_location(name_187, 3, 16)4130 ).set_location(name_187, 3, 13)4131 ]).set_location(name_187, 3, 10)4132 ).set_location(name_187, 3, 10),4133 False4134 ).set_location(name_187, 3, 5)4135 ]).set_location(name_187, 2, 3)4136]).set_location(name_187, 1, 1)4137test_samples.append((True, name_187, sample_187, ast_187))4138name_188 = "sample_188.g"4139sample_188 = """\4140module A4141 grammar G4142 a -> {a != b;};4143 end4144end4145"""4146ast_188 = DefModule("A", [4147 DefGrammar("G", [], [4148 DefRule(4149 "a",4150 Action(4151 ABlock([4152 ANotEqExpr(4153 AId("a").set_location(name_188, 3, 11),4154 AId("b").set_location(name_188, 3, 16)4155 ).set_location(name_188, 3, 13)4156 ]).set_location(name_188, 3, 10)4157 ).set_location(name_188, 3, 10),4158 False4159 ).set_location(name_188, 3, 5)4160 ]).set_location(name_188, 2, 3)4161]).set_location(name_188, 1, 1)4162test_samples.append((True, name_188, sample_188, ast_188))4163name_189 = "sample_189.g"4164sample_189 = """\4165module A4166 grammar G4167 a -> {a | b;};4168 end4169end4170"""4171ast_189 = DefModule("A", [4172 DefGrammar("G", [], [4173 DefRule(4174 "a",4175 Action(4176 ABlock([4177 ABitOrExpr(4178 AId("a").set_location(name_189, 3, 11),4179 AId("b").set_location(name_189, 3, 15)4180 ).set_location(name_189, 3, 13)4181 ]).set_location(name_189, 3, 10)4182 ).set_location(name_189, 3, 10),4183 False4184 ).set_location(name_189, 3, 5)4185 ]).set_location(name_189, 2, 3)4186]).set_location(name_189, 1, 1)4187test_samples.append((True, name_189, sample_189, ast_189))4188name_190 = "sample_190.g"4189sample_190 = """\4190module A4191 grammar G4192 a -> {a & b;};4193 end4194end4195"""4196ast_190 = DefModule("A", [4197 DefGrammar("G", [], [4198 DefRule(4199 "a",4200 Action(4201 ABlock([4202 ABitAndExpr(4203 AId("a").set_location(name_190, 3, 11),4204 AId("b").set_location(name_190, 3, 15)4205 ).set_location(name_190, 3, 13)4206 ]).set_location(name_190, 3, 10)4207 ).set_location(name_190, 3, 10),4208 False4209 ).set_location(name_190, 3, 5)4210 ]).set_location(name_190, 2, 3)4211]).set_location(name_190, 1, 1)4212test_samples.append((True, name_190, sample_190, ast_190))4213name_191 = "sample_191.g"4214sample_191 = """\4215module A4216 grammar G4217 a -> {a ^ b;};4218 end4219end4220"""4221ast_191 = DefModule("A", [4222 DefGrammar("G", [], [4223 DefRule(4224 "a",4225 Action(4226 ABlock([4227 ABitXorExpr(4228 AId("a").set_location(name_191, 3, 11),4229 AId("b").set_location(name_191, 3, 15)4230 ).set_location(name_191, 3, 13)4231 ]).set_location(name_191, 3, 10)4232 ).set_location(name_191, 3, 10),4233 False4234 ).set_location(name_191, 3, 5)4235 ]).set_location(name_191, 2, 3)4236]).set_location(name_191, 1, 1)4237test_samples.append((True, name_191, sample_191, ast_191))4238name_192 = "sample_192.g"4239sample_192 = """\4240module A4241 grammar G4242 a -> {a << b;};4243 end4244end4245"""4246ast_192 = DefModule("A", [4247 DefGrammar("G", [], [4248 DefRule(4249 "a",4250 Action(4251 ABlock([4252 AShiftLeftExpr(4253 AId("a").set_location(name_192, 3, 11),4254 AId("b").set_location(name_192, 3, 16)4255 ).set_location(name_192, 3, 13)4256 ]).set_location(name_192, 3, 10)4257 ).set_location(name_192, 3, 10),4258 False4259 ).set_location(name_192, 3, 5)4260 ]).set_location(name_192, 2, 3)4261]).set_location(name_192, 1, 1)4262test_samples.append((True, name_192, sample_192, ast_192))4263name_193 = "sample_193.g"4264sample_193 = """\4265module A4266 grammar G4267 a -> {a >> b;};4268 end4269end4270"""4271ast_193 = DefModule("A", [4272 DefGrammar("G", [], [4273 DefRule(4274 "a",4275 Action(4276 ABlock([4277 AShiftRightExpr(4278 AId("a").set_location(name_193, 3, 11),4279 AId("b").set_location(name_193, 3, 16)4280 ).set_location(name_193, 3, 13)4281 ]).set_location(name_193, 3, 10)4282 ).set_location(name_193, 3, 10),4283 False4284 ).set_location(name_193, 3, 5)4285 ]).set_location(name_193, 2, 3)4286]).set_location(name_193, 1, 1)4287test_samples.append((True, name_193, sample_193, ast_193))4288name_194 = "sample_194.g"4289sample_194 = """\4290module A4291 grammar G4292 a -> {a + b;};4293 end4294end4295"""4296ast_194 = DefModule("A", [4297 DefGrammar("G", [], [4298 DefRule(4299 "a",4300 Action(4301 ABlock([4302 AAddExpr(4303 AId("a").set_location(name_194, 3, 11),4304 AId("b").set_location(name_194, 3, 15)4305 ).set_location(name_194, 3, 13)4306 ]).set_location(name_194, 3, 10)4307 ).set_location(name_194, 3, 10),4308 False4309 ).set_location(name_194, 3, 5)4310 ]).set_location(name_194, 2, 3)4311]).set_location(name_194, 1, 1)4312test_samples.append((True, name_194, sample_194, ast_194))4313name_195 = "sample_195.g"4314sample_195 = """\4315module A4316 grammar G4317 a -> {a - b;};4318 end4319end4320"""4321ast_195 = DefModule("A", [4322 DefGrammar("G", [], [4323 DefRule(4324 "a",4325 Action(4326 ABlock([4327 ASubExpr(4328 AId("a").set_location(name_195, 3, 11),4329 AId("b").set_location(name_195, 3, 15)4330 ).set_location(name_195, 3, 13)4331 ]).set_location(name_195, 3, 10)4332 ).set_location(name_195, 3, 10),4333 False4334 ).set_location(name_195, 3, 5)4335 ]).set_location(name_195, 2, 3)4336]).set_location(name_195, 1, 1)4337test_samples.append((True, name_195, sample_195, ast_195))4338name_196 = "sample_196.g"4339sample_196 = """\4340module A4341 grammar G4342 a -> {a * b;};4343 end4344end4345"""4346ast_196 = DefModule("A", [4347 DefGrammar("G", [], [4348 DefRule(4349 "a",4350 Action(4351 ABlock([4352 AMulExpr(4353 AId("a").set_location(name_196, 3, 11),4354 AId("b").set_location(name_196, 3, 15)4355 ).set_location(name_196, 3, 13)4356 ]).set_location(name_196, 3, 10)4357 ).set_location(name_196, 3, 10),4358 False4359 ).set_location(name_196, 3, 5)4360 ]).set_location(name_196, 2, 3)4361]).set_location(name_196, 1, 1)4362test_samples.append((True, name_196, sample_196, ast_196))4363name_197 = "sample_197.g"4364sample_197 = """\4365module A4366 grammar G4367 a -> {a / b;};4368 end4369end4370"""4371ast_197 = DefModule("A", [4372 DefGrammar("G", [], [4373 DefRule(4374 "a",4375 Action(4376 ABlock([4377 ADivExpr(4378 AId("a").set_location(name_197, 3, 11),4379 AId("b").set_location(name_197, 3, 15)4380 ).set_location(name_197, 3, 13)4381 ]).set_location(name_197, 3, 10)4382 ).set_location(name_197, 3, 10),4383 False4384 ).set_location(name_197, 3, 5)4385 ]).set_location(name_197, 2, 3)4386]).set_location(name_197, 1, 1)4387test_samples.append((True, name_197, sample_197, ast_197))4388name_198 = "sample_198.g"4389sample_198 = """\4390module A4391 grammar G4392 a -> {a % b;};4393 end4394end4395"""4396ast_198 = DefModule("A", [4397 DefGrammar("G", [], [4398 DefRule(4399 "a",4400 Action(4401 ABlock([4402 AModExpr(4403 AId("a").set_location(name_198, 3, 11),4404 AId("b").set_location(name_198, 3, 15)4405 ).set_location(name_198, 3, 13)4406 ]).set_location(name_198, 3, 10)4407 ).set_location(name_198, 3, 10),4408 False4409 ).set_location(name_198, 3, 5)4410 ]).set_location(name_198, 2, 3)4411]).set_location(name_198, 1, 1)4412test_samples.append((True, name_198, sample_198, ast_198))4413name_199 = "sample_199.g"4414sample_199 = """\4415module A4416 grammar G4417 a -> {-a;};4418 end4419end4420"""4421ast_199 = DefModule("A", [4422 DefGrammar("G", [], [4423 DefRule(4424 "a",4425 Action(4426 ABlock([4427 ANegExpr(4428 AId("a").set_location(name_199, 3, 12)4429 ).set_location(name_199, 3, 11)4430 ]).set_location(name_199, 3, 10)4431 ).set_location(name_199, 3, 10),4432 False4433 ).set_location(name_199, 3, 5)4434 ]).set_location(name_199, 2, 3)4435]).set_location(name_199, 1, 1)4436test_samples.append((True, name_199, sample_199, ast_199))4437name_200 = "sample_200.g"4438sample_200 = """\4439module A4440 grammar G4441 a -> {~a;};4442 end4443end4444"""4445ast_200 = DefModule("A", [4446 DefGrammar("G", [], [4447 DefRule(4448 "a",4449 Action(4450 ABlock([4451 AInvExpr(4452 AId("a").set_location(name_200, 3, 12)4453 ).set_location(name_200, 3, 11)4454 ]).set_location(name_200, 3, 10)4455 ).set_location(name_200, 3, 10),4456 False4457 ).set_location(name_200, 3, 5)4458 ]).set_location(name_200, 2, 3)4459]).set_location(name_200, 1, 1)4460test_samples.append((True, name_200, sample_200, ast_200))4461name_201 = "sample_201.g"4462sample_201 = """\4463module A4464 grammar G4465 a -> {!a;};4466 end4467end4468"""4469ast_201 = DefModule("A", [4470 DefGrammar("G", [], [4471 DefRule(4472 "a",4473 Action(4474 ABlock([4475 ANotExpr(4476 AId("a").set_location(name_201, 3, 12)4477 ).set_location(name_201, 3, 11)4478 ]).set_location(name_201, 3, 10)4479 ).set_location(name_201, 3, 10),4480 False4481 ).set_location(name_201, 3, 5)4482 ]).set_location(name_201, 2, 3)4483]).set_location(name_201, 1, 1)4484test_samples.append((True, name_201, sample_201, ast_201))4485name_202 = "sample_202.g"4486sample_202 = """\4487module A4488 grammar G4489 a -> {a();b(c);d(e, f);};4490 end4491end4492"""4493ast_202 = DefModule("A", [4494 DefGrammar("G", [], [4495 DefRule(4496 "a",4497 Action(4498 ABlock([4499 ACallExpr(4500 AId("a").set_location(name_202, 3, 11),4501 []4502 ).set_location(name_202, 3, 12),4503 ACallExpr(4504 AId("b").set_location(name_202, 3, 15),4505 [4506 AId("c").set_location(name_202, 3, 17)4507 ]4508 ).set_location(name_202, 3, 16),4509 ACallExpr(4510 AId("d").set_location(name_202, 3, 20),4511 [4512 AId("e").set_location(name_202, 3, 22),4513 AId("f").set_location(name_202, 3, 25)4514 ]4515 ).set_location(name_202, 3, 21)4516 ]).set_location(name_202, 3, 10)4517 ).set_location(name_202, 3, 10),4518 False4519 ).set_location(name_202, 3, 5)4520 ]).set_location(name_202, 2, 3)4521]).set_location(name_202, 1, 1)4522test_samples.append((True, name_202, sample_202, ast_202))4523name_203 = "sample_203.g"4524sample_203 = """\4525module A4526 grammar G4527 a -> {a[b];c.d;};4528 end4529end4530"""4531ast_203 = DefModule("A", [4532 DefGrammar("G", [], [4533 DefRule(4534 "a",4535 Action(4536 ABlock([4537 AIndexExpr(4538 AId("a").set_location(name_203, 3, 11),4539 AId("b").set_location(name_203, 3, 13)4540 ).set_location(name_203, 3, 12),4541 AAccessExpr(4542 AId("c").set_location(name_203, 3, 16),4543 AId("d").set_location(name_203, 3, 18)4544 ).set_location(name_203, 3, 17)4545 ]).set_location(name_203, 3, 10)4546 ).set_location(name_203, 3, 10),4547 False4548 ).set_location(name_203, 3, 5)4549 ]).set_location(name_203, 2, 3)4550]).set_location(name_203, 1, 1)4551test_samples.append((True, name_203, sample_203, ast_203))4552name_204 = "sample_204.g"4553sample_204 = """\4554module A4555 grammar G4556 a -> {-a + b * -c > d/f/g;};4557 end4558end4559"""4560ast_204 = DefModule("A", [4561 DefGrammar("G", [], [4562 DefRule(4563 "a",4564 Action(4565 ABlock([4566 AGtExpr(4567 AAddExpr(4568 ANegExpr(4569 AId("a").set_location(name_204, 3, 12)4570 ).set_location(name_204, 3, 11),4571 AMulExpr(4572 AId("b").set_location(name_204, 3, 16),4573 ANegExpr(4574 AId("c").set_location(name_204, 3, 21)4575 ).set_location(name_204, 3, 20)4576 ).set_location(name_204, 3, 18)4577 ).set_location(name_204, 3, 14),4578 ADivExpr(4579 ADivExpr(4580 AId("d").set_location(name_204, 3, 25),4581 AId("f").set_location(name_204, 3, 27)4582 ).set_location(name_204, 3, 26),4583 AId("g").set_location(name_204, 3, 29)4584 ).set_location(name_204, 3, 28)4585 ).set_location(name_204, 3, 23)4586 ]).set_location(name_204, 3, 10)4587 ).set_location(name_204, 3, 10),4588 False4589 ).set_location(name_204, 3, 5)4590 ]).set_location(name_204, 2, 3)4591]).set_location(name_204, 1, 1)4592test_samples.append((True, name_204, sample_204, ast_204))4593name_205 = "sample_205.g"4594sample_205 = """\4595module A4596 grammar G4597 a -> {a = b;};4598 end4599end4600"""4601ast_205 = DefModule("A", [4602 DefGrammar("G", [], [4603 DefRule(4604 "a",4605 Action(4606 ABlock([4607 AAssign(4608 AId("a").set_location(name_205, 3, 11),4609 AId("b").set_location(name_205, 3, 15)4610 ).set_location(name_205, 3, 13)4611 ]).set_location(name_205, 3, 10)4612 ).set_location(name_205, 3, 10),4613 False4614 ).set_location(name_205, 3, 5)4615 ]).set_location(name_205, 2, 3)4616]).set_location(name_205, 1, 1)4617test_samples.append((True, name_205, sample_205, ast_205))4618name_206 = "sample_206.g"4619sample_206 = """\4620module A4621 grammar G4622 a -> {a += b;};4623 end4624end4625"""4626ast_206 = DefModule("A", [4627 DefGrammar("G", [], [4628 DefRule(4629 "a",4630 Action(4631 ABlock([4632 AInplaceAdd(4633 AId("a").set_location(name_206, 3, 11),4634 AId("b").set_location(name_206, 3, 16)4635 ).set_location(name_206, 3, 13)4636 ]).set_location(name_206, 3, 10)4637 ).set_location(name_206, 3, 10),4638 False4639 ).set_location(name_206, 3, 5)4640 ]).set_location(name_206, 2, 3)4641]).set_location(name_206, 1, 1)4642test_samples.append((True, name_206, sample_206, ast_206))4643name_207 = "sample_207.g"4644sample_207 = """\4645module A4646 grammar G4647 a -> {a -= b;};4648 end4649end4650"""4651ast_207 = DefModule("A", [4652 DefGrammar("G", [], [4653 DefRule(4654 "a",4655 Action(4656 ABlock([4657 AInplaceSub(4658 AId("a").set_location(name_207, 3, 11),4659 AId("b").set_location(name_207, 3, 16)4660 ).set_location(name_207, 3, 13)4661 ]).set_location(name_207, 3, 10)4662 ).set_location(name_207, 3, 10),4663 False4664 ).set_location(name_207, 3, 5)4665 ]).set_location(name_207, 2, 3)4666]).set_location(name_207, 1, 1)4667test_samples.append((True, name_207, sample_207, ast_207))4668name_208 = "sample_208.g"4669sample_208 = """\4670module A4671 grammar G4672 a -> {a *= b;};4673 end4674end4675"""4676ast_208 = DefModule("A", [4677 DefGrammar("G", [], [4678 DefRule(4679 "a",4680 Action(4681 ABlock([4682 AInplaceMul(4683 AId("a").set_location(name_208, 3, 11),4684 AId("b").set_location(name_208, 3, 16)4685 ).set_location(name_208, 3, 13)4686 ]).set_location(name_208, 3, 10)4687 ).set_location(name_208, 3, 10),4688 False4689 ).set_location(name_208, 3, 5)4690 ]).set_location(name_208, 2, 3)4691]).set_location(name_208, 1, 1)4692test_samples.append((True, name_208, sample_208, ast_208))4693name_209 = "sample_209.g"4694sample_209 = """\4695module A4696 grammar G4697 a -> {a /= b;};4698 end4699end4700"""4701ast_209 = DefModule("A", [4702 DefGrammar("G", [], [4703 DefRule(4704 "a",4705 Action(4706 ABlock([4707 AInplaceDiv(4708 AId("a").set_location(name_209, 3, 11),4709 AId("b").set_location(name_209, 3, 16)4710 ).set_location(name_209, 3, 13)4711 ]).set_location(name_209, 3, 10)4712 ).set_location(name_209, 3, 10),4713 False4714 ).set_location(name_209, 3, 5)4715 ]).set_location(name_209, 2, 3)4716]).set_location(name_209, 1, 1)4717test_samples.append((True, name_209, sample_209, ast_209))4718name_210 = "sample_210.g"4719sample_210 = """\4720module A4721 grammar G4722 a -> {a %= b;};4723 end4724end4725"""4726ast_210 = DefModule("A", [4727 DefGrammar("G", [], [4728 DefRule(4729 "a",4730 Action(4731 ABlock([4732 AInplaceMod(4733 AId("a").set_location(name_210, 3, 11),4734 AId("b").set_location(name_210, 3, 16)4735 ).set_location(name_210, 3, 13)4736 ]).set_location(name_210, 3, 10)4737 ).set_location(name_210, 3, 10),4738 False4739 ).set_location(name_210, 3, 5)4740 ]).set_location(name_210, 2, 3)4741]).set_location(name_210, 1, 1)4742test_samples.append((True, name_210, sample_210, ast_210))4743name_211 = "sample_211.g"4744sample_211 = """\4745module A4746 grammar G4747 a -> {a &= b;};4748 end4749end4750"""4751ast_211 = DefModule("A", [4752 DefGrammar("G", [], [4753 DefRule(4754 "a",4755 Action(4756 ABlock([4757 AInplaceBitAnd(4758 AId("a").set_location(name_211, 3, 11),4759 AId("b").set_location(name_211, 3, 16)4760 ).set_location(name_211, 3, 13)4761 ]).set_location(name_211, 3, 10)4762 ).set_location(name_211, 3, 10),4763 False4764 ).set_location(name_211, 3, 5)4765 ]).set_location(name_211, 2, 3)4766]).set_location(name_211, 1, 1)4767test_samples.append((True, name_211, sample_211, ast_211))4768name_212 = "sample_212.g"4769sample_212 = """\4770module A4771 grammar G4772 a -> {a |= b;};4773 end4774end4775"""4776ast_212 = DefModule("A", [4777 DefGrammar("G", [], [4778 DefRule(4779 "a",4780 Action(4781 ABlock([4782 AInplaceBitOr(4783 AId("a").set_location(name_212, 3, 11),4784 AId("b").set_location(name_212, 3, 16)4785 ).set_location(name_212, 3, 13)4786 ]).set_location(name_212, 3, 10)4787 ).set_location(name_212, 3, 10),4788 False4789 ).set_location(name_212, 3, 5)4790 ]).set_location(name_212, 2, 3)4791]).set_location(name_212, 1, 1)4792test_samples.append((True, name_212, sample_212, ast_212))4793name_213 = "sample_213.g"4794sample_213 = """\4795module A4796 grammar G4797 a -> {a ^= b;};4798 end4799end4800"""4801ast_213 = DefModule("A", [4802 DefGrammar("G", [], [4803 DefRule(4804 "a",4805 Action(4806 ABlock([4807 AInplaceBitXor(4808 AId("a").set_location(name_213, 3, 11),4809 AId("b").set_location(name_213, 3, 16)4810 ).set_location(name_213, 3, 13)4811 ]).set_location(name_213, 3, 10)4812 ).set_location(name_213, 3, 10),4813 False4814 ).set_location(name_213, 3, 5)4815 ]).set_location(name_213, 2, 3)4816]).set_location(name_213, 1, 1)4817test_samples.append((True, name_213, sample_213, ast_213))4818name_214 = "sample_214.g"4819sample_214 = """\4820module A4821 grammar G4822 a -> {a <<= b;};4823 end4824end4825"""4826ast_214 = DefModule("A", [4827 DefGrammar("G", [], [4828 DefRule(4829 "a",4830 Action(4831 ABlock([4832 AInplaceShiftLeft(4833 AId("a").set_location(name_214, 3, 11),4834 AId("b").set_location(name_214, 3, 17)4835 ).set_location(name_214, 3, 13)4836 ]).set_location(name_214, 3, 10)4837 ).set_location(name_214, 3, 10),4838 False4839 ).set_location(name_214, 3, 5)4840 ]).set_location(name_214, 2, 3)4841]).set_location(name_214, 1, 1)4842test_samples.append((True, name_214, sample_214, ast_214))4843name_215 = "sample_215.g"4844sample_215 = """\4845module A4846 grammar G4847 a -> {a >>= b;};4848 end4849end4850"""4851ast_215 = DefModule("A", [4852 DefGrammar("G", [], [4853 DefRule(4854 "a",4855 Action(4856 ABlock([4857 AInplaceShiftRight(4858 AId("a").set_location(name_215, 3, 11),4859 AId("b").set_location(name_215, 3, 17)4860 ).set_location(name_215, 3, 13)4861 ]).set_location(name_215, 3, 10)4862 ).set_location(name_215, 3, 10),4863 False4864 ).set_location(name_215, 3, 5)4865 ]).set_location(name_215, 2, 3)4866]).set_location(name_215, 1, 1)4867test_samples.append((True, name_215, sample_215, ast_215))4868name_216 = "sample_216.g"4869sample_216 = """\4870module A4871 grammar G4872 a -> {a4873"""4874ast_216 = None4875test_samples.append((False, name_216, sample_216, ast_216))4876name_217 = "sample_217.g"4877sample_217 = """\4878module A4879 grammar G4880 a -> {a < b < c;};4881 end4882end4883"""4884ast_217 = None4885test_samples.append((False, name_217, sample_217, ast_217))4886name_218 = "sample_218.g"4887sample_218 = """\4888module A4889 grammar G4890 a -> {1 = 2;};4891 end4892end4893"""4894ast_218 = None4895test_samples.append((False, name_218, sample_218, ast_218))4896name_219 = "sample_219.g"4897sample_219 = """\4898module A4899 grammar G4900 a -> {if a {}};4901 end4902end4903"""4904ast_219 = DefModule("A", [4905 DefGrammar("G", [], [4906 DefRule(4907 "a",4908 Action(4909 ABlock([4910 AIf(4911 AId("a").set_location(name_219, 3, 14),4912 ABlock([]).set_location(name_219, 3, 16),4913 [],4914 None4915 ).set_location(name_219, 3, 11)4916 ]).set_location(name_219, 3, 10)4917 ).set_location(name_219, 3, 10),4918 False4919 ).set_location(name_219, 3, 5)4920 ]).set_location(name_219, 2, 3)4921]).set_location(name_219, 1, 1)4922test_samples.append((True, name_219, sample_219, ast_219))4923name_220 = "sample_220.g"4924sample_220 = """\4925module A4926 grammar G4927 a -> {if a {} else {}};4928 end4929end4930"""4931ast_220 = DefModule("A", [4932 DefGrammar("G", [], [4933 DefRule(4934 "a",4935 Action(4936 ABlock([4937 AIf(4938 AId("a").set_location(name_220, 3, 14),4939 ABlock([]).set_location(name_220, 3, 16),4940 [],4941 ABlock([]).set_location(name_220, 3, 24)4942 ).set_location(name_220, 3, 11)4943 ]).set_location(name_220, 3, 10)4944 ).set_location(name_220, 3, 10),4945 False4946 ).set_location(name_220, 3, 5)4947 ]).set_location(name_220, 2, 3)4948]).set_location(name_220, 1, 1)4949test_samples.append((True, name_220, sample_220, ast_220))4950name_221 = "sample_221.g"4951sample_221 = """\4952module A4953 grammar G4954 a -> {if a {} elif b {}};4955 end4956end4957"""4958ast_221 = DefModule("A", [4959 DefGrammar("G", [], [4960 DefRule(4961 "a",4962 Action(4963 ABlock([4964 AIf(4965 AId("a").set_location(name_221, 3, 14),4966 ABlock([]).set_location(name_221, 3, 16),4967 [(4968 AId("b").set_location(name_221, 3, 24),4969 ABlock([]).set_location(name_221, 3, 26)4970 )],4971 None4972 ).set_location(name_221, 3, 11)4973 ]).set_location(name_221, 3, 10)4974 ).set_location(name_221, 3, 10),4975 False4976 ).set_location(name_221, 3, 5)4977 ]).set_location(name_221, 2, 3)4978]).set_location(name_221, 1, 1)4979test_samples.append((True, name_221, sample_221, ast_221))4980name_222 = "sample_222.g"4981sample_222 = """\4982module A4983 grammar G4984 a -> {if a {} elif b {} else {}};4985 end4986end4987"""4988ast_222 = DefModule("A", [4989 DefGrammar("G", [], [4990 DefRule(4991 "a",4992 Action(4993 ABlock([4994 AIf(4995 AId("a").set_location(name_222, 3, 14),4996 ABlock([]).set_location(name_222, 3, 16),4997 [(4998 AId("b").set_location(name_222, 3, 24),4999 ABlock([]).set_location(name_222, 3, 26)5000 )],5001 ABlock([]).set_location(name_222, 3, 34)5002 ).set_location(name_222, 3, 11)5003 ]).set_location(name_222, 3, 10)5004 ).set_location(name_222, 3, 10),5005 False5006 ).set_location(name_222, 3, 5)5007 ]).set_location(name_222, 2, 3)5008]).set_location(name_222, 1, 1)5009test_samples.append((True, name_222, sample_222, ast_222))5010name_223 = "sample_223.g"5011sample_223 = """\5012module A5013 grammar G5014 a -> {if a {} elif b {} elif c {}};5015 end5016end5017"""5018ast_223 = DefModule("A", [5019 DefGrammar("G", [], [5020 DefRule(5021 "a",5022 Action(5023 ABlock([5024 AIf(5025 AId("a").set_location(name_223, 3, 14),5026 ABlock([]).set_location(name_223, 3, 16),5027 [(5028 AId("b").set_location(name_223, 3, 24),5029 ABlock([]).set_location(name_223, 3, 26)5030 ), (5031 AId("c").set_location(name_223, 3, 34),5032 ABlock([]).set_location(name_223, 3, 36)5033 )],5034 None5035 ).set_location(name_223, 3, 11)5036 ]).set_location(name_223, 3, 10)5037 ).set_location(name_223, 3, 10),5038 False5039 ).set_location(name_223, 3, 5)5040 ]).set_location(name_223, 2, 3)5041]).set_location(name_223, 1, 1)5042test_samples.append((True, name_223, sample_223, ast_223))5043name_224 = "sample_224.g"5044sample_224 = """\5045module A5046 grammar G5047 a -> {if a {} elif b {} elif c {} else {}};5048 end5049end5050"""5051ast_224 = DefModule("A", [5052 DefGrammar("G", [], [5053 DefRule(5054 "a",5055 Action(5056 ABlock([5057 AIf(5058 AId("a").set_location(name_224, 3, 14),5059 ABlock([]).set_location(name_224, 3, 16),5060 [(5061 AId("b").set_location(name_224, 3, 24),5062 ABlock([]).set_location(name_224, 3, 26)5063 ), (5064 AId("c").set_location(name_224, 3, 34),5065 ABlock([]).set_location(name_224, 3, 36)5066 )],5067 ABlock([]).set_location(name_224, 3, 44)5068 ).set_location(name_224, 3, 11)5069 ]).set_location(name_224, 3, 10)5070 ).set_location(name_224, 3, 10),5071 False5072 ).set_location(name_224, 3, 5)5073 ]).set_location(name_224, 2, 3)5074]).set_location(name_224, 1, 1)5075test_samples.append((True, name_224, sample_224, ast_224))5076name_225 = "sample_225.g"5077sample_225 = """\5078module A5079 grammar G5080 a -> {case a of {b:}};5081 end5082end5083"""5084ast_225 = DefModule("A", [5085 DefGrammar("G", [], [5086 DefRule(5087 "a",5088 Action(5089 ABlock([5090 ACase(5091 AId("a").set_location(name_225, 3, 16),5092 [(5093 AId("b").set_location(name_225, 3, 22),5094 [5095 ]5096 )],5097 None5098 ).set_location(name_225, 3, 11)5099 ]).set_location(name_225, 3, 10)5100 ).set_location(name_225, 3, 10),5101 False5102 ).set_location(name_225, 3, 5)5103 ]).set_location(name_225, 2, 3)5104]).set_location(name_225, 1, 1)5105test_samples.append((True, name_225, sample_225, ast_225))5106name_226 = "sample_226.g"5107sample_226 = """\5108module A5109 grammar G5110 a -> {case a of {b:c;}};5111 end5112end5113"""5114ast_226 = DefModule("A", [5115 DefGrammar("G", [], [5116 DefRule(5117 "a",5118 Action(5119 ABlock([5120 ACase(5121 AId("a").set_location(name_226, 3, 16),5122 [(5123 AId("b").set_location(name_226, 3, 22),5124 [5125 AId("c").set_location(name_226, 3, 24)5126 ]5127 )],5128 None5129 ).set_location(name_226, 3, 11)5130 ]).set_location(name_226, 3, 10)5131 ).set_location(name_226, 3, 10),5132 False5133 ).set_location(name_226, 3, 5)5134 ]).set_location(name_226, 2, 3)5135]).set_location(name_226, 1, 1)5136test_samples.append((True, name_226, sample_226, ast_226))5137name_227 = "sample_227.g"5138sample_227 = """\5139module A5140 grammar G5141 a -> {case a of {b:c;}};5142 end5143end5144"""5145ast_227 = DefModule("A", [5146 DefGrammar("G", [], [5147 DefRule(5148 "a",5149 Action(5150 ABlock([5151 ACase(5152 AId("a").set_location(name_227, 3, 16),5153 [(5154 AId("b").set_location(name_227, 3, 22),5155 [5156 AId("c").set_location(name_227, 3, 24)5157 ]5158 )],5159 None5160 ).set_location(name_227, 3, 11)5161 ]).set_location(name_227, 3, 10)5162 ).set_location(name_227, 3, 10),5163 False5164 ).set_location(name_227, 3, 5)5165 ]).set_location(name_227, 2, 3)5166]).set_location(name_227, 1, 1)5167test_samples.append((True, name_227, sample_227, ast_227))5168name_228 = "sample_228.g"5169sample_228 = """\5170module A5171 grammar G5172 a -> {case a of {b:c;d;}};5173 end5174end5175"""5176ast_228 = DefModule("A", [5177 DefGrammar("G", [], [5178 DefRule(5179 "a",5180 Action(5181 ABlock([5182 ACase(5183 AId("a").set_location(name_228, 3, 16),5184 [(5185 AId("b").set_location(name_228, 3, 22),5186 [5187 AId("c").set_location(name_228, 3, 24),5188 AId("d").set_location(name_228, 3, 26)5189 ]5190 )],5191 None5192 ).set_location(name_228, 3, 11)5193 ]).set_location(name_228, 3, 10)5194 ).set_location(name_228, 3, 10),5195 False5196 ).set_location(name_228, 3, 5)5197 ]).set_location(name_228, 2, 3)5198]).set_location(name_228, 1, 1)5199test_samples.append((True, name_228, sample_228, ast_228))5200name_229 = "sample_229.g"5201sample_229 = """\5202module A5203 grammar G5204 a -> {case a of {b:c:}};5205 end5206end5207"""5208ast_229 = DefModule("A", [5209 DefGrammar("G", [], [5210 DefRule(5211 "a",5212 Action(5213 ABlock([5214 ACase(5215 AId("a").set_location(name_229, 3, 16),5216 [(5217 AId("b").set_location(name_229, 3, 22),5218 [5219 ]5220 ), (5221 AId("c").set_location(name_229, 3, 24),5222 [5223 ]5224 )],5225 None5226 ).set_location(name_229, 3, 11)5227 ]).set_location(name_229, 3, 10)5228 ).set_location(name_229, 3, 10),5229 False5230 ).set_location(name_229, 3, 5)5231 ]).set_location(name_229, 2, 3)5232]).set_location(name_229, 1, 1)5233test_samples.append((True, name_229, sample_229, ast_229))5234name_230 = "sample_230.g"5235sample_230 = """\5236module A5237 grammar G5238 a -> {case a of {b:c:d;}};5239 end5240end5241"""5242ast_230 = DefModule("A", [5243 DefGrammar("G", [], [5244 DefRule(5245 "a",5246 Action(5247 ABlock([5248 ACase(5249 AId("a").set_location(name_230, 3, 16),5250 [(5251 AId("b").set_location(name_230, 3, 22),5252 [5253 ]5254 ), (5255 AId("c").set_location(name_230, 3, 24),5256 [5257 AId("d").set_location(name_230, 3, 26)5258 ]5259 )],5260 None5261 ).set_location(name_230, 3, 11)5262 ]).set_location(name_230, 3, 10)5263 ).set_location(name_230, 3, 10),5264 False5265 ).set_location(name_230, 3, 5)5266 ]).set_location(name_230, 2, 3)5267]).set_location(name_230, 1, 1)5268test_samples.append((True, name_230, sample_230, ast_230))5269name_231 = "sample_231.g"5270sample_231 = """\5271module A5272 grammar G5273 a -> {case a of {b:c;d:}};5274 end5275end5276"""5277ast_231 = DefModule("A", [5278 DefGrammar("G", [], [5279 DefRule(5280 "a",5281 Action(5282 ABlock([5283 ACase(5284 AId("a").set_location(name_231, 3, 16),5285 [(5286 AId("b").set_location(name_231, 3, 22),5287 [5288 AId("c").set_location(name_231, 3, 24)5289 ]5290 ), (5291 AId("d").set_location(name_231, 3, 26),5292 [5293 ]5294 )],5295 None5296 ).set_location(name_231, 3, 11)5297 ]).set_location(name_231, 3, 10)5298 ).set_location(name_231, 3, 10),5299 False5300 ).set_location(name_231, 3, 5)5301 ]).set_location(name_231, 2, 3)5302]).set_location(name_231, 1, 1)5303test_samples.append((True, name_231, sample_231, ast_231))5304name_232 = "sample_232.g"5305sample_232 = """\5306module A5307 grammar G5308 a -> {case a of {b:c;d:e;}};5309 end5310end5311"""5312ast_232 = DefModule("A", [5313 DefGrammar("G", [], [5314 DefRule(5315 "a",5316 Action(5317 ABlock([5318 ACase(5319 AId("a").set_location(name_232, 3, 16),5320 [(5321 AId("b").set_location(name_232, 3, 22),5322 [5323 AId("c").set_location(name_232, 3, 24)5324 ]5325 ), (5326 AId("d").set_location(name_232, 3, 26),5327 [5328 AId("e").set_location(name_232, 3, 28)5329 ]5330 )],5331 None5332 ).set_location(name_232, 3, 11)5333 ]).set_location(name_232, 3, 10)5334 ).set_location(name_232, 3, 10),5335 False5336 ).set_location(name_232, 3, 5)5337 ]).set_location(name_232, 2, 3)5338]).set_location(name_232, 1, 1)5339test_samples.append((True, name_232, sample_232, ast_232))5340name_233 = "sample_233.g"5341sample_233 = """\5342module A5343 grammar G5344 a -> {case a of {b:c;d:e;default:}};5345 end5346end5347"""5348ast_233 = DefModule("A", [5349 DefGrammar("G", [], [5350 DefRule(5351 "a",5352 Action(5353 ABlock([5354 ACase(5355 AId("a").set_location(name_233, 3, 16),5356 [(5357 AId("b").set_location(name_233, 3, 22),5358 [5359 AId("c").set_location(name_233, 3, 24)5360 ]5361 ), (5362 AId("d").set_location(name_233, 3, 26),5363 [5364 AId("e").set_location(name_233, 3, 28)5365 ]5366 )],5367 []5368 ).set_location(name_233, 3, 11)5369 ]).set_location(name_233, 3, 10)5370 ).set_location(name_233, 3, 10),5371 False5372 ).set_location(name_233, 3, 5)5373 ]).set_location(name_233, 2, 3)5374]).set_location(name_233, 1, 1)5375test_samples.append((True, name_233, sample_233, ast_233))5376name_234 = "sample_234.g"5377sample_234 = """\5378module A5379 grammar G5380 a -> {case a of {b:c;d:e;default:f;g;}};5381 end5382end5383"""5384ast_234 = DefModule("A", [5385 DefGrammar("G", [], [5386 DefRule(5387 "a",5388 Action(5389 ABlock([5390 ACase(5391 AId("a").set_location(name_234, 3, 16),5392 [(5393 AId("b").set_location(name_234, 3, 22),5394 [5395 AId("c").set_location(name_234, 3, 24)5396 ]5397 ), (5398 AId("d").set_location(name_234, 3, 26),5399 [5400 AId("e").set_location(name_234, 3, 28)5401 ]5402 )],5403 [5404 AId("f").set_location(name_234, 3, 38),5405 AId("g").set_location(name_234, 3, 40)5406 ]5407 ).set_location(name_234, 3, 11)5408 ]).set_location(name_234, 3, 10)5409 ).set_location(name_234, 3, 10),5410 False5411 ).set_location(name_234, 3, 5)5412 ]).set_location(name_234, 2, 3)5413]).set_location(name_234, 1, 1)5414test_samples.append((True, name_234, sample_234, ast_234))5415name_235 = "sample_235.g"5416sample_235 = """\5417module A5418 grammar G5419 a -> {case a of {default:}};5420 end5421end5422"""5423ast_235 = DefModule("A", [5424 DefGrammar("G", [], [5425 DefRule(5426 "a",5427 Action(5428 ABlock([5429 ACase(5430 AId("a").set_location(name_235, 3, 16),5431 [],5432 []5433 ).set_location(name_235, 3, 11)5434 ]).set_location(name_235, 3, 10)5435 ).set_location(name_235, 3, 10),5436 False5437 ).set_location(name_235, 3, 5)5438 ]).set_location(name_235, 2, 3)5439]).set_location(name_235, 1, 1)5440test_samples.append((True, name_235, sample_235, ast_235))5441name_236 = "sample_236.g"5442sample_236 = """\5443module A5444 grammar G5445 a -> {case a of {}};5446 end5447end5448"""5449ast_236 = DefModule("A", [5450 DefGrammar("G", [], [5451 DefRule(5452 "a",5453 Action(5454 ABlock([5455 ACase(5456 AId("a").set_location(name_236, 3, 16),5457 [],5458 None5459 ).set_location(name_236, 3, 11)5460 ]).set_location(name_236, 3, 10)5461 ).set_location(name_236, 3, 10),5462 False5463 ).set_location(name_236, 3, 5)5464 ]).set_location(name_236, 2, 3)5465]).set_location(name_236, 1, 1)5466test_samples.append((True, name_236, sample_236, ast_236))5467name_237 = "sample_237.g"5468sample_237 = """\5469module A5470 grammar G5471 a -> {case a of {default:a:}};5472 end5473end5474"""5475ast_237 = None5476test_samples.append((False, name_237, sample_237, ast_237))5477name_238 = "sample_238.g"5478sample_238 = """\5479module A5480 grammar G5481 a -> {case a of {a;b:}};5482 end5483end5484"""5485ast_238 = None5486test_samples.append((False, name_238, sample_238, ast_238))5487name_239 = "sample_239.g"5488sample_239 = """\5489module A5490 grammar G5491 a -> {for x : l {}};5492 end5493end5494"""5495ast_239 = DefModule("A", [5496 DefGrammar("G", [], [5497 DefRule(5498 "a",5499 Action(5500 ABlock([5501 AFor(5502 AId("x").set_location(name_239, 3, 15),5503 AId("l").set_location(name_239, 3, 19),5504 ABlock([]).set_location(name_239, 3, 21)5505 ).set_location(name_239, 3, 11)5506 ]).set_location(name_239, 3, 10)5507 ).set_location(name_239, 3, 10),5508 False5509 ).set_location(name_239, 3, 5)5510 ]).set_location(name_239, 2, 3)5511]).set_location(name_239, 1, 1)5512test_samples.append((True, name_239, sample_239, ast_239))5513name_240 = "sample_240.g"5514sample_240 = """\5515module A5516 grammar G5517 a -> {while a {}};5518 end5519end5520"""5521ast_240 = DefModule("A", [5522 DefGrammar("G", [], [5523 DefRule(5524 "a",5525 Action(5526 ABlock([5527 AWhile(5528 AId("a").set_location(name_240, 3, 17),5529 ABlock([]).set_location(name_240, 3, 19)5530 ).set_location(name_240, 3, 11)5531 ]).set_location(name_240, 3, 10)5532 ).set_location(name_240, 3, 10),5533 False5534 ).set_location(name_240, 3, 5)5535 ]).set_location(name_240, 2, 3)5536]).set_location(name_240, 1, 1)5537test_samples.append((True, name_240, sample_240, ast_240))5538name_241 = "sample_241.g"5539sample_241 = """\5540module A5541 grammar G5542 a -> {do {} while a;};5543 end5544end5545"""5546ast_241 = DefModule("A", [5547 DefGrammar("G", [], [5548 DefRule(5549 "a",5550 Action(5551 ABlock([5552 ADoWhile(5553 ABlock([]).set_location(name_241, 3, 14),5554 AId("a").set_location(name_241, 3, 23)5555 ).set_location(name_241, 3, 11)5556 ]).set_location(name_241, 3, 10)5557 ).set_location(name_241, 3, 10),5558 False5559 ).set_location(name_241, 3, 5)5560 ]).set_location(name_241, 2, 3)5561]).set_location(name_241, 1, 1)5562test_samples.append((True, name_241, sample_241, ast_241))5563name_242 = "sample_242.g"5564sample_242 = """\5565module A5566 grammar G5567 a -> {break; continue; return; return x;};5568 end5569end5570"""5571ast_242 = DefModule("A", [5572 DefGrammar("G", [], [5573 DefRule(5574 "a",5575 Action(5576 ABlock([5577 ABreak().set_location(name_242, 3, 11),5578 AContinue().set_location(name_242, 3, 18),5579 AReturn().set_location(name_242, 3, 28),5580 AReturnWithValue(5581 AId("x").set_location(name_242, 3, 43)5582 ).set_location(name_242, 3, 36)5583 ]).set_location(name_242, 3, 10)5584 ).set_location(name_242, 3, 10),5585 False5586 ).set_location(name_242, 3, 5)5587 ]).set_location(name_242, 2, 3)5588]).set_location(name_242, 1, 1)5589test_samples.append((True, name_242, sample_242, ast_242))5590class TestGlapParserCase(unittest.TestCase):5591 def test_parsing(self):5592 for p in test_samples:5593 self.do_parsing_test(*p)5594 #-def5595 def do_parsing_test(self, should_succeed, name, data, ast):5596 result = None5597 if not should_succeed:5598 with self.assertRaises(ParsingError):5599 result = self.parse_data(name, data)5600 else:5601 result = self.parse_data(name, data)5602 self.maxDiff = None...

Full Screen

Full Screen

entities.py

Source:entities.py Github

copy

Full Screen

...21 self.x, self.y, self.width, self.height, self.color, 2)22 def set_color(self, color):23 self.color = color24 self.__bounds_that_actually_draw_correctly.color = color25 def set_location(self, x, y):26 super(Entity, self).set_location(x, y)27 self.__bounds_that_actually_draw_correctly.set_location(self.x, self.y)28 def update(self, delta_time, entities):29 raise NotImplementedError(30 "A class that inherits Entity did not implement the update(delta_time, entities) method")31 def _draw_bounds(self, surface, camera_type):32 self.__bounds_that_actually_draw_correctly.draw(surface, camera_type)33 def draw(self, surface):34 raise NotImplementedError(35 "A class that inherits Entity did not implement the draw(surface) method")36class Direction(IntEnum):37 NONE = 0,38 UP = 1,39 DOWN = 2,40 LEFT = 3,41 RIGHT = 442class Kinetic(Entity):43 def __init__(self, x, y, width, height, speed):44 super(Kinetic, self).__init__(x, y, width, height)45 self.velocity = Vector2()46 self.default_move_speed = speed47 self.move_speed = 048 self.facing = Direction.NONE49 self.collision_rectangles = []50 self.collision_width = 051 def _update_collision_rectangles(self):52 self.collision_width = self.move_speed + 153 self.collision_rectangles = [54 Rect(self.x + self.collision_width, self.y - self.collision_width,55 self.width - self.collision_width * 2, self.collision_width),56 Rect(self.x + self.collision_width, self.y + self.height, self.width -57 self.collision_width * 2, self.collision_width),58 Rect(self.x - self.collision_width, self.y + self.collision_width,59 self.collision_width, self.height - self.collision_width * 2),60 Rect(self.x + self.width, self.y + self.collision_width,61 self.collision_width, self.height - self.collision_width * 2)62 ]63 def _calculate_scaled_speed(self, delta_time):64 self.move_speed = self.default_move_speed * delta_time65 def _collision(self, entities):66 raise NotImplementedError(67 "A class that inherits Kinetic did not implement the collision(surface) method")68 def update(self, delta_time, entities):69 raise NotImplementedError(70 "A class that inherits Kinetic did not implement the update(delta_time, entities) method")71 def _draw_collision_rectangles(self, surface):72 for r in self.collision_rectangles:73 draw_rectangle(74 surface,75 r,76 CameraType.DYNAMIC,77 Color.RED,78 )79class Actor(Kinetic):80 def __init__(self, x, y, width, height, speed):81 super(Actor, self).__init__(x, y, width, height, speed)82 self.input = Input()83 def _update_input(self):84 raise NotImplementedError(85 "A class that inherits Actor did not implement the _update_input() method")86class Player(Actor):87 def __init__(self, x, y, width=10, height=10, speed=50):88 super(Player, self).__init__(x, y, width, height, speed)89 self.sprite = Sprite(self.x - 3, self.y - 22, SpriteType.PLAYER_F)90 self.arms = Sprite(self.x - 3, self.y - 22,91 SpriteType.PLAYER_ARM_SIDE_F)92 self.shadow = Sprite(self.x - 3, self.y - 21, SpriteType.PLAYER_SHADOW)93 self.set_color(Color.RED)94 self.item_carrying = None95 self.animation_walk = Animation(6, 6, 100)96 self.walking = False97 def set_location(self, x, y):98 super(Player, self).set_location(x, y)99 self.sprite.set_location(self.x - 3, self.y - 22)100 self.arms.set_location(self.x - 3, self.y - 22)101 self.shadow.set_location(self.x - 3, self.y - 21)102 if self.item_carrying != None:103 self.item_carrying.set_location(self.x - 3, self.sprite.y - 8)104 def _move(self, direction=Direction.NONE):105 self.facing = direction106 self.walking = True107 if self.facing == Direction.UP:108 self.sprite.set_sprite(SpriteType.PLAYER_B)109 self.arms.set_sprite(SpriteType.PLAYER_ARM_SIDE_B)110 self.set_location(self.x, self.y - self.move_speed)111 self.velocity.y = -1112 if self.facing == Direction.DOWN:113 self.sprite.set_sprite(SpriteType.PLAYER_F)114 self.arms.set_sprite(SpriteType.PLAYER_ARM_SIDE_F)115 self.set_location(self.x, self.y + self.move_speed)116 self.velocity.y = 1117 if self.facing == Direction.LEFT:118 self.sprite.set_sprite(SpriteType.PLAYER_L)119 self.arms.set_sprite(SpriteType.PLAYER_ARM_SIDE_L)120 self.set_location(self.x - self.move_speed, self.y)121 self.velocity.x = -1122 if self.facing == Direction.RIGHT:123 self.sprite.set_sprite(SpriteType.PLAYER_R)124 self.arms.set_sprite(SpriteType.PLAYER_ARM_SIDE_R)125 self.set_location(self.x + self.move_speed, self.y)126 self.velocity.x = 1127 def _update_input(self, delta_time):128 self.input.update(delta_time)129 self.walking = False130 if self.input.pressing(InputType.UP) and not self.input.pressing(InputType.DOWN):131 self._move(Direction.UP)132 if self.input.pressing(InputType.DOWN) and not self.input.pressing(InputType.UP):133 self._move(Direction.DOWN)134 if self.input.pressing(InputType.LEFT) and not self.input.pressing(InputType.RIGHT):135 self._move(Direction.LEFT)136 if self.input.pressing(InputType.RIGHT) and not self.input.pressing(InputType.LEFT):137 self._move(Direction.RIGHT)138 def _rectangle_collision_logic(self, entity):139 # Bottom140 if self.collision_rectangles[0].colliderect(entity.bounds) and self.velocity.y < 0:141 self.set_location(self.x, entity.bounds.bottom)142 # Top143 elif self.collision_rectangles[1].colliderect(entity.bounds) and self.velocity.y > 0:144 self.set_location(self.x, entity.bounds.top - self.bounds.height)145 # Right146 elif self.collision_rectangles[2].colliderect(entity.bounds) and self.velocity.x < 0:147 self.set_location(entity.bounds.right, self.y)148 # Left149 elif self.collision_rectangles[3].colliderect(entity.bounds) and self.velocity.x > 0:150 self.set_location(entity.bounds.left - self.bounds.width, self.y)151 def _collision(self, entities):152 for e in entities:153 if (154 not e.ignore and155 (156 isinstance(e, Building) or157 isinstance(e, Furniture) or158 isinstance(e, Wall) or159 isinstance(e, Tree)160 )161 # isinstance(e, NPC)162 ):163 self._rectangle_collision_logic(e)164 def _update_animation(self, delta_time):165 if self.walking:166 self.animation_walk.update(delta_time)167 self.sprite.set_frame(168 self.animation_walk.current_frame, self.animation_walk.columns)169 self.arms.set_frame(170 self.animation_walk.current_frame, self.animation_walk.columns)171 else:172 self.sprite.set_frame(0, self.animation_walk.columns)173 self.arms.set_frame(0, self.animation_walk.columns)174 def _update_item(self):175 if self.item_carrying != None:176 self.arms.increment_sprite_x(16 * 6)177 def update(self, delta_time, entities):178 self._calculate_scaled_speed(delta_time)179 self._update_input(delta_time)180 self._update_collision_rectangles()181 self._collision(entities)182 self._update_animation(delta_time)183 self._update_item()184 def draw(self, surface):185 if pygine.globals.debug:186 self._draw_bounds(surface, CameraType.DYNAMIC)187 self._draw_collision_rectangles(surface)188 else:189 self.shadow.draw(surface, CameraType.DYNAMIC)190 self.sprite.draw(surface, CameraType.DYNAMIC)191 self.arms.draw(surface, CameraType.DYNAMIC)192 if (self.item_carrying != None):193 self.item_carrying.draw(surface)194class SpeechBubble(Entity):195 def __init__(self, x, y, source, sprite_type=SpriteType.NONE):196 super(SpeechBubble, self).__init__(x, y, 1, 1)197 self.sprite = Sprite(x, y, SpriteType.SPEECH_BUBBLE)198 self.__content = Sprite(x + 8, y + 8, sprite_type)199 self.source = source200 def set_location(self, x, y):201 super(SpeechBubble, self).set_location(x, y)202 self.sprite.set_location(x, y)203 self.__content.set_location(x + 8, y + 8)204 def set_content(self, sprite_type):205 self.__content.set_sprite(sprite_type)206 self.__content.set_location(self.x + 8, self.y + 8)207 def update(self, delta_time, entities):208 pass209 def draw(self, surface):210 self.sprite.draw(surface, CameraType.DYNAMIC)211 self.__content.draw(surface, CameraType.DYNAMIC)212class NPCType(IntEnum):213 MALE = 0214 FEMALE = 1215class NPC(Kinetic):216 def __init__(self, x, y, type, can_move=True, horizontal=True, start_direction=1, walk_duration=5000):217 super(NPC, self).__init__(x, y, 10, 10, 25)218 self.type = type219 self.sprite = Sprite(self.x - 3, self.y - 22, SpriteType.NONE)220 self.shadow = Sprite(self.x - 3, self.y - 21, SpriteType.PLAYER_SHADOW)221 self.speech_bubble = SpeechBubble(self.x - 11, self.y - 32 - 11, self)222 self.radius = 32223 self.show_prompt = False224 self.set_color(Color.RED)225 self.walk_direction = 1 if start_direction >= 0 else -1226 self.horizontal = horizontal227 self.can_move = can_move228 self._walk_timer = Timer(walk_duration, True)229 self.animation_walk = Animation(6, 6, 100)230 self.walking = True231 self._set_walking_sprite()232 self._set_random_emotion()233 def set_location(self, x, y):234 super(NPC, self).set_location(x, y)235 self.sprite.set_location(self.x - 3, self.y - 22)236 self.shadow.set_location(self.x - 3, self.y - 21)237 self.speech_bubble.set_location(self.x - 11, self.y - 32 - 11)238 def _set_random_emotion(self):239 rand = randint(1, 4)240 if rand == 1:241 self.speech_bubble.set_content(SpriteType.FACE_HAPPY)242 elif rand == 2:243 self.speech_bubble.set_content(SpriteType.FACE_SAD)244 elif rand == 3:245 self.speech_bubble.set_content(SpriteType.FACE_MAD)246 elif rand == 4:247 self.speech_bubble.set_content(SpriteType.FACE_SURPRISED)248 def _stop_walking(self):249 if not self.horizontal:250 if self.type == NPCType.MALE:251 self.sprite.set_sprite(SpriteType.NPC_M_F)252 else:253 self.sprite.set_sprite(SpriteType.NPC_F_F)254 self._set_random_emotion()255 self.walking = not self.walking256 def _walk(self, delta_time):257 self._walk_timer.update(delta_time)258 if self._walk_timer.done:259 if random() < 0.25:260 self._stop_walking()261 if self.walking:262 self.walk_direction = -self.walk_direction263 self._set_walking_sprite()264 self._walk_timer.reset()265 self._walk_timer.start()266 if self.walking:267 if self.horizontal:268 self.set_location(self.x + self.move_speed *269 self.walk_direction, self.y)270 else:271 self.set_location(272 self.x, self.y + self.move_speed * self.walk_direction)273 def _set_walking_sprite(self):274 if self.can_move:275 if self.horizontal:276 if self.walk_direction > 0:277 if self.type == NPCType.MALE:278 self.sprite.set_sprite(SpriteType.NPC_M_R)279 else:280 self.sprite.set_sprite(SpriteType.NPC_F_R)281 else:282 if self.type == NPCType.MALE:283 self.sprite.set_sprite(SpriteType.NPC_M_L)284 else:285 self.sprite.set_sprite(SpriteType.NPC_F_L)286 else:287 if self.walk_direction > 0:288 if self.type == NPCType.MALE:289 self.sprite.set_sprite(SpriteType.NPC_M_F)290 else:291 self.sprite.set_sprite(SpriteType.NPC_F_F)292 else:293 if self.type == NPCType.MALE:294 self.sprite.set_sprite(SpriteType.NPC_M_B)295 else:296 self.sprite.set_sprite(SpriteType.NPC_F_B)297 else:298 if self.type == NPCType.MALE:299 self.sprite.set_sprite(SpriteType.NPC_M_F)300 else:301 self.sprite.set_sprite(SpriteType.NPC_F_F)302 def _within_radius(self, e):303 if distance_between(self.center, e.center) <= self.radius:304 self.show_prompt = True305 else:306 self.show_prompt = False307 def _update_conversation(self, entities):308 for e in entities:309 if isinstance(e, Player):310 last = self.show_prompt311 self._within_radius(e)312 if last != self.show_prompt:313 if self.show_prompt:314 entities.append(self.speech_bubble)315 else:316 entities.remove(self.speech_bubble)317 def _update_animation(self, delta_time):318 if self.walking:319 self.animation_walk.update(delta_time)320 self.sprite.set_frame(321 self.animation_walk.current_frame, self.animation_walk.columns)322 else:323 self.sprite.set_frame(0, self.animation_walk.columns)324 def _rectangle_collision_logic(self, entity):325 # Bottom326 if self.collision_rectangles[0].colliderect(entity.bounds) and self.velocity.y < 0:327 self.set_location(self.x, entity.bounds.bottom)328 # Top329 elif self.collision_rectangles[1].colliderect(entity.bounds) and self.velocity.y > 0:330 self.set_location(self.x, entity.bounds.top - self.bounds.height)331 # Right332 elif self.collision_rectangles[2].colliderect(entity.bounds) and self.velocity.x < 0:333 self.set_location(entity.bounds.right, self.y)334 # Left335 elif self.collision_rectangles[3].colliderect(entity.bounds) and self.velocity.x > 0:336 self.set_location(entity.bounds.left - self.bounds.width, self.y)337 def _collision(self, entities):338 for e in entities:339 if (340 isinstance(e, Building) or341 isinstance(e, Tree)342 ):343 self._rectangle_collision_logic(e)344 def update(self, delta_time, entities):345 self._update_conversation(entities)346 self._calculate_scaled_speed(delta_time)347 if self.can_move:348 self._walk(delta_time)349 # self._update_collision_rectangles()350 # self._collision(entities)351 if self.can_move:352 self._update_animation(delta_time)353 def draw(self, surface):354 if pygine.globals.debug:355 self._draw_bounds(surface, CameraType.DYNAMIC)356 else:357 self.shadow.draw(surface, CameraType.DYNAMIC)358 self.sprite.draw(surface, CameraType.DYNAMIC)359class Merchant(NPC):360 def __init__(self, x, y, type, speech_content):361 super(Merchant, self).__init__(x, y, type, can_move=False)362 self.speech_bubble.set_content(speech_content)363 def _update_conversation(self, entities):364 for e in entities:365 if isinstance(e, Player):366 last = self.show_prompt367 self._within_radius(e)368 if last != self.show_prompt:369 if self.show_prompt:370 entities.append(self.speech_bubble)371 else:372 entities.remove(self.speech_bubble)373class Building(Entity):374 def __init__(self, x, y, width, height):375 super(Building, self).__init__(x, y, width, height)376 self.sprite = None377 self.shadow = None378 def update(self, delta_time, entities):379 pass380 def draw(self, surface):381 if pygine.globals.debug:382 self._draw_bounds(surface, CameraType.DYNAMIC)383 else:384 self.shadow.draw(surface, CameraType.DYNAMIC)385 self.sprite.draw(surface, CameraType.DYNAMIC)386class SimpleHouse(Building):387 def __init__(self, x, y):388 super(SimpleHouse, self).__init__(x + 4, y + 24, 40, 40)389 self.sprite = Sprite(self.x - 4, self.y - 24, SpriteType.SIMPLE_HOUSE)390 self.shadow = Sprite(self.x - 4 - 16, self.y - 24,391 SpriteType.SIMPLE_HOUSE_SHADOW)392 self.set_color(Color.RED)393class SpecialHouse(Building):394 def __init__(self, x, y):395 super(SpecialHouse, self).__init__(x + 4, y + 24, 72, 40)396 self.sprite = Sprite(self.x - 4, self.y - 24, SpriteType.SPECIAL_HOUSE)397 self.shadow = Sprite(self.x - 4 - 16, self.y - 24,398 SpriteType.SPECIAL_HOUSE_SHADOW)399 self.set_color(Color.RED)400class Shop(Building):401 def __init__(self, x, y):402 super(Shop, self).__init__(x, y + 64, 80, 32)403 self.sprite = Sprite(self.x, self.y - 64, SpriteType.SHOP)404 self.shadow = Sprite(self.x - 16, self.y - 64,405 SpriteType.SHOP_SHADOW)406 self.set_color(Color.RED)407class Diner(Building):408 def __init__(self, x, y):409 super(Diner, self).__init__(x, y + 32, 128, 32)410 self.sprite = Sprite(self.x, self.y - 32, SpriteType.DINER)411 self.shadow = Sprite(self.x - 16, self.y - 32,412 SpriteType.DINER_SHADOW)413 self.set_color(Color.RED)414class Tree(Entity):415 def __init__(self, x, y):416 super(Tree, self).__init__(x, y, 20, 20)417 self.sprite = Sprite(self.x - 11 - 16, self.y -418 21, SpriteType.TREE_CLUSTER)419 # self.shadow = Sprite(self.x - 11 - 8, self.y - 21,420 # SpriteType.TREE_THING_SHADOW)421 def update(self, delta_time, entities):422 pass423 def draw(self, surface):424 if pygine.globals.debug:425 self._draw_bounds(surface, CameraType.DYNAMIC)426 else:427 # self.shadow.draw(surface, CameraType.DYNAMIC)428 self.sprite.draw(surface, CameraType.DYNAMIC)429class Furniture(Entity):430 def __init__(self, x, y, width, height):431 super(Furniture, self).__init__(x, y, width, height)432 self.sprite = None433 def update(self, delta_time, entities):434 pass435 def draw(self, surface):436 if pygine.globals.debug:437 self._draw_bounds(surface, CameraType.DYNAMIC)438 else:439 self.sprite.draw(surface, CameraType.DYNAMIC)440class FlowerPot(Furniture):441 def __init__(self, x, y):442 super(FlowerPot, self).__init__(x, y + 10, 16, 16)443 self.sprite = Sprite(self.x, self.y - 32, SpriteType.FLOWER_POT)444class Sofa(Furniture):445 def __init__(self, x, y):446 super(Sofa, self).__init__(x + 4, y + 10, 56, 16)447 self.sprite = Sprite(self.x - 4, self.y - 16, SpriteType.SOFA)448class Bed(Furniture):449 def __init__(self, x, y):450 super(Bed, self).__init__(x, y + 10, 32, 48)451 self.sprite = Sprite(self.x, self.y - 16, SpriteType.BED)452class Shelf(Furniture):453 def __init__(self, x, y, empty=True):454 super(Shelf, self).__init__(x, y + 10, 32, 16)455 if empty:456 self.sprite = Sprite(self.x, self.y - 48, SpriteType.SHELF_EMPTY)457 else:458 self.sprite = Sprite(self.x, self.y - 48, SpriteType.SHELF_FULL)459class CounterShop(Furniture):460 def __init__(self, x, y):461 super(CounterShop, self).__init__(x, y + 10, 112, 16)462 self.sprite = Sprite(self.x, self.y - 32, SpriteType.SHOP_COUNTER)463class CounterDiner(Furniture):464 def __init__(self, x, y):465 super(CounterDiner, self).__init__(x, y + 10 + 2, 256, 12)466 self.sprite = Sprite(self.x, self.y - 80 + 12,467 SpriteType.DINER_COUNTER)468class StoolTall(Furniture):469 def __init__(self, x, y):470 super(StoolTall, self).__init__(x, y + 10, 16, 6)471 self.sprite = Sprite(self.x, self.y - 16 - 6, SpriteType.STOOL_TALL)472class StoolShort(Furniture):473 def __init__(self, x, y):474 super(StoolShort, self).__init__(x, y + 10 + 4, 16, 6)475 self.sprite = Sprite(self.x, self.y - 16 - 4, SpriteType.STOOL_SHORT)476class Table(Furniture):477 def __init__(self, x, y):478 super(Table, self).__init__(x, y + 10, 32, 12)479 self.sprite = Sprite(self.x, self.y - 16, SpriteType.TABLE)480class Wall(Entity):481 def __init__(self, x, y, width, height):482 super(Wall, self).__init__(483 x * 16, y * 16 + 10, width * 16, height * 16)484 self.set_color(Color.BLUE)485 def apply_an_offset(self, x_offset, y_offset):486 self.set_location(self.x + x_offset, self.y + y_offset)487 def update(self, delta_time, entities):488 pass489 def draw(self, surface):490 if pygine.globals.debug:491 self._draw_bounds(surface, CameraType.DYNAMIC)492class ItemType(IntEnum):493 COFFEE = 0494 FISH = 1495 CROP = 2496 EGGS = 3497class Item(Entity):498 def __init__(self, x, y, value):499 super(Item, self).__init__(x, y, 16, 16)500 self._processed = False501 self._type = None502 self._sprite = None503 self.value = value504 def set_location(self, x, y):505 super(Item, self).set_location(x, y)506 self._sprite.set_location(self.x, self.y)507 def update(self, delta_time, entities):508 pass509 def draw(self, surface):510 self._sprite.draw(surface, CameraType.DYNAMIC)511class Coffee(Item):512 def __init__(self, x, y, value):513 super(Coffee, self).__init__(x, y, value)514 self._type = ItemType.COFFEE515 self._sprite = Sprite(x, y, SpriteType.COFFEE_RAW)516class Fish(Item):517 def __init__(self, x, y, value):518 super(Fish, self).__init__(x, y, value)519 self._type = ItemType.FISH520 self._sprite = Sprite(x, y, SpriteType.FISH_RAW)521class Crop(Item):522 def __init__(self, x, y, value):523 super(Crop, self).__init__(x, y, value)524 self._type = ItemType.CROP525 self._sprite = Sprite(x, y, SpriteType.CROP_RAW)526class Eggs(Item):527 def __init__(self, x, y, value):528 super(Eggs, self).__init__(x, y, value)529 self._type = ItemType.EGGS530 self._sprite = Sprite(x, y, SpriteType.EGGS_RAW)531class SellPad(Entity):532 def __init__(self, x, y, width, height, direction=Direction.UP):533 super(SellPad, self).__init__(x, y, width, height)534 self.direction = direction535 def __collision(self, entities):536 for e in entities:537 if e.bounds.colliderect(self.bounds):538 if isinstance(e, Player) and e.item_carrying is not None:539 if e.input.pressing(InputType.A) and int(e.facing) == int(self.direction):540 pygine.globals.money += e.item_carrying.value541 e.item_carrying = None542 def update(self, delta_time, entities):543 self.__collision(entities)544 def draw(self, surface):545 if pygine.globals.debug:546 self._draw_bounds(surface, CameraType.DYNAMIC)547###################################################################548#549# Coffee minigame stuff starts here!550#551###################################################################552class Boat(Actor):553 def __init__(self, x, y, beans=50):554 super(Boat, self).__init__(x, y, 83, 16, 50)555 self.beans = beans556 self.playbounds = Rectangle(557 0, 16 * 3, Camera.BOUNDS.width, Camera.BOUNDS.height - 16 * 3)558 self.sprite = Sprite(x - 16, y - 48, SpriteType.BOAT)559 self.shadow = Sprite(x - 16 - 16, y - 16, SpriteType.BOAT_SHADOW)560 self.blinks = 5561 self.invis_duration = 1600562 self.invis_timer = Timer(self.invis_duration)563 self.blink_timer = Timer(self.invis_duration / self.blinks / 2)564 self.damaged = False565 self.flashing = False566 self.dead = False567 def set_location(self, x, y):568 super(Boat, self).set_location(x, y)569 self.sprite.set_location(self.x - 16, self.y - 48)570 self.shadow.set_location(self.x - 16 - 16, self.y - 16)571 def _collision(self, entities):572 for e in entities:573 if not self.damaged:574 if isinstance(e, Bullet) or isinstance(e, Octopus):575 if self.bounds.colliderect(e.bounds):576 e.dead = True577 self.__decrease_health(5)578 elif isinstance(e, Rock):579 if self.bounds.colliderect(e.bounds):580 self.__decrease_health(10)581 self.__bounds_collision()582 def __decrease_health(self, amount):583 self.damaged = True584 self.beans -= amount585 self.invis_timer.start()586 self.blink_timer.start()587 self.sprite.set_sprite(SpriteType.BOAT_OWO)588 def _move(self, direction=Direction.NONE):589 self.facing = direction590 if self.facing == Direction.UP:591 self.set_location(self.x, self.y - self.move_speed)592 self.velocity.y = -1593 if self.facing == Direction.DOWN:594 self.set_location(self.x, self.y + self.move_speed)595 self.velocity.y = 1596 if self.facing == Direction.LEFT:597 self.set_location(self.x - self.move_speed, self.y)598 self.velocity.x = -1599 if self.facing == Direction.RIGHT:600 self.set_location(self.x + self.move_speed, self.y)601 self.velocity.x = 1602 def _update_input(self, delta_time):603 self.input.update(delta_time)604 if self.input.pressing(InputType.UP):605 self._move(Direction.UP)606 if self.input.pressing(InputType.DOWN):607 self._move(Direction.DOWN)608 if self.input.pressing(InputType.LEFT):609 self._move(Direction.LEFT)610 if self.input.pressing(InputType.RIGHT):611 self._move(Direction.RIGHT)612 def __update_health(self, delta_time):613 if self.damaged:614 self.invis_timer.update(delta_time)615 self.blink_timer.update(delta_time)616 if self.blink_timer.done:617 self.flashing = not self.flashing618 self.blink_timer.reset()619 self.blink_timer.start()620 if self.invis_timer.done:621 self.damaged = False622 self.flashing = False623 self.invis_timer.reset()624 self.sprite.set_sprite(SpriteType.BOAT)625 def __bounds_collision(self):626 if self.x < self.playbounds.x:627 self.x = self.playbounds.x628 elif self.x + self.width > self.playbounds.x + self.playbounds.width:629 self.x = self.playbounds.x + self.playbounds.width - self.width630 if self.y < self.playbounds.y:631 self.y = self.playbounds.y632 elif self.y + self.height > self.playbounds.y + self.playbounds.height:633 self.y = self.playbounds.y + self.playbounds.height - self.height634 def __check_death(self):635 if self.beans <= 0:636 # TODO: death logic here, maybe display transition and change scene?637 self.dead = True638 def update(self, delta_time, entities):639 self._calculate_scaled_speed(delta_time)640 if self.dead:641 self.flashing = False642 self.set_location(self.x - self.move_speed / 2 + randint(-2, 0), self.y + self.move_speed)643 return644 self._update_input(delta_time)645 self._collision(entities)646 self.__update_health(delta_time)647 self.__check_death()648 def draw(self, surface):649 if pygine.globals.debug:650 self._draw_bounds(surface, CameraType.DYNAMIC)651 else:652 if not self.flashing:653 self.shadow.draw(surface, CameraType.DYNAMIC)654 self.sprite.draw(surface, CameraType.DYNAMIC)655class Octopus(Kinetic):656 def __init__(self, x, y):657 super(Octopus, self).__init__(x, y, 16, 16, randint(10, 30))658 self.timer = Timer(randint(1, 5) * 1000, True)659 self.sprite = Sprite(x - 16, y - 16, SpriteType.OCTOPUS)660 self.shadow = Sprite(x - 16 - 8, y - 16 + 16,661 SpriteType.OCTOPUS_SHADOW)662 self.i = 0663 def set_location(self, x, y):664 super(Octopus, self).set_location(x, y)665 self.sprite.set_location(self.x - 16, self.y - 16)666 self.shadow.set_location(self.x - 16 - 8, self.y - 16 + 16)667 def __shoot(self, entities):668 entities.append(Bullet(self.x, self.y + self.height / 2, 200))669 def __move(self, delta_time):670 self.i += 1 * delta_time671 self.set_location(672 self.x - self.move_speed,673 self.y + math.sin(self.i)674 )675 def update(self, delta_time, entities): 676 self._calculate_scaled_speed(delta_time)677 self.__move(delta_time)678 self.timer.update(delta_time)679 if self.timer.done:680 if randint(1, 10) <= 7:681 self.__shoot(entities)682 self.timer.reset()683 self.timer.start()684 def draw(self, surface):685 if pygine.globals.debug:686 self._draw_bounds(surface, CameraType.DYNAMIC)687 else:688 self.shadow.draw(surface, CameraType.DYNAMIC)689 self.sprite.draw(surface, CameraType.DYNAMIC)690class Bullet(Kinetic):691 def __init__(self, x, y, speed=50):692 super(Bullet, self).__init__(x, y, 11, 12, speed)693 self.sprite = Sprite(x, y - 2, SpriteType.INK_BULLET)694 self.shadow = Sprite(x, y - 2 + 16, SpriteType.INK_BULLET_SHADOW)695 self.dead = False696 def set_location(self, x, y):697 super(Bullet, self).set_location(x, y)698 self.sprite.set_location(self.x, self.y - 2)699 self.shadow.set_location(self.x, self.y - 2 + 16)700 def update(self, delta_time, entities):701 self._calculate_scaled_speed(delta_time)702 self.set_location(self.x - self.move_speed, self.y)703 def draw(self, surface):704 if pygine.globals.debug:705 self._draw_bounds(surface, CameraType.DYNAMIC)706 else:707 self.shadow.draw(surface, CameraType.DYNAMIC)708 self.sprite.draw(surface, CameraType.DYNAMIC)709class Rock(Kinetic):710 def __init__(self, x, y, speed=75):711 super(Rock, self).__init__(x, y, 34, 14, speed)712 self.sprite = Sprite(x - 7, y - 16, SpriteType.ROCK)713 self.shadow = Sprite(self.x - 7 - 8, self.y -714 16, SpriteType.ROCK_SHADOW)715 self.dead = False716 def set_location(self, x, y):717 super(Rock, self).set_location(x, y)718 self.sprite.set_location(self.x - 7, self.y - 16)719 self.shadow.set_location(self.x - 7 - 8, self.y - 16)720 def update(self, delta_time, entities):721 self._calculate_scaled_speed(delta_time)722 self.set_location(self.x - self.move_speed, self.y)723 def draw(self, surface):724 if pygine.globals.debug:725 self._draw_bounds(surface, CameraType.DYNAMIC)726 else:727 self.shadow.draw(surface, CameraType.DYNAMIC)728 self.sprite.draw(surface, CameraType.DYNAMIC)729class SandWall(Entity):730 def __init__(self, x, y, layer, total_layers):731 super(SandWall, self).__init__(x, y - layer * 10, 64, 32)732 self.layer = layer733 self.sprite = Sprite(734 self.x, self.y, SpriteType.SAND_WALL)735 self.direction = 1736 self.parallax_layers = total_layers737 self.parallax_variance = 10738 self.parallax_speed = 0739 self.calculate_parallax_speed()740 def set_location(self, x, y):741 super(SandWall, self).set_location(x, y)742 self.sprite.set_location(self.x, self.y)743 def set_direction(self, direction):744 self.direction = direction745 self.calculate_parallax_speed()746 def calculate_parallax_speed(self):747 assert (self.parallax_variance > 0), \748 "Parallax Variance must be greater than zero!"749 self.parallax_speed = self.parallax_variance * \750 (self.parallax_layers - (self.layer + 1))**2 * self.direction * -1751 if self.parallax_speed == 0:752 self.parallax_speed = self.parallax_variance / 2 * self.direction * -1753 def update_parallax(self, delta_time): 754 self.set_location(self.x + self.parallax_speed * delta_time, self.y)755 def update(self, delta_time, entities):756 self.update_parallax(delta_time)757 def draw(self, surface):758 self.sprite.draw(surface, CameraType.DYNAMIC)759###################################################################760#761# Crop minigame stuff starts here!762#763###################################################################764class Mole(Entity):765 pass766class Mallet(Entity):767 pass768###################################################################769#770# Fish minigame stuff starts here!771#772###################################################################773class Hook(Actor):774 def __init__(self, ocean_depth):775 super(Hook, self).__init__(0, 0, 13, 13, 80)776 self.ocean_depth = ocean_depth777 self.sprite = Sprite(self.x, self.y - 7, SpriteType.HOOK)778 self.direction = 1779 self.total_hooked_fish = 0780 def set_location(self, x, y):781 super(Hook, self).set_location(x, y)782 self.sprite.set_location(self.x, self.y - 7)783 def __bounds_collision(self):784 if self.x < 0:785 self.x = 0786 elif self.x + self.width > Camera.BOUNDS.width:787 self.x = Camera.BOUNDS.width - self.width788 def _collision(self, entities):789 if self.y + Camera.BOUNDS.height / 2 > self.ocean_depth:790 self.direction = -1791 self.default_move_speed = 100792 self.__bounds_collision()793 for e in entities:794 if isinstance(e, OceanWall):795 if self.direction == -1:796 e.set_direction(-1)797 elif isinstance(e, Fishy) and not e.captured:798 if self.bounds.colliderect(e.bounds):799 e.hook_fish()800 self.total_hooked_fish += 1801 self.direction = -1802 def _move(self, direction=Direction.NONE):803 self.facing = direction804 if self.facing == Direction.LEFT:805 self.set_location(self.x - self.move_speed, self.y)806 self.velocity.x = -1807 if self.facing == Direction.RIGHT:808 self.set_location(self.x + self.move_speed, self.y)809 self.velocity.x = 1810 def _update_input(self, delta_time):811 self.input.update(delta_time)812 if self.input.pressing(InputType.LEFT):813 self._move(Direction.LEFT)814 if self.input.pressing(InputType.RIGHT):815 self._move(Direction.RIGHT)816 def update(self, delta_time, entities):817 self._calculate_scaled_speed(delta_time)818 self._update_input(delta_time)819 self._collision(entities)820 self.set_location(self.x, self.y + self.move_speed * self.direction)821 def draw(self, surface): 822 draw_line(823 surface,824 Camera.BOUNDS.width / 2 - 8, -8,825 self.x + 7, self.y - 6,826 CameraType.DYNAMIC,827 Color.BLACK,828 3829 )830 draw_line(831 surface,832 Camera.BOUNDS.width / 2 - 8, -8,833 self.x + 7, self.y - 6,834 CameraType.DYNAMIC,835 Color.WHITE,836 1837 )838 self.sprite.draw(surface, CameraType.DYNAMIC)839 if pygine.globals.debug:840 self._draw_bounds(surface, CameraType.DYNAMIC)841class OceanWall(Entity):842 def __init__(self, y, left, layer, total_layers):843 super(OceanWall, self).__init__(0 + layer *844 20 if left else Camera.BOUNDS.width - 32 - layer * 20, y, 32, 64)845 self.layer = layer846 self.sprite = Sprite(847 self.x, self.y, SpriteType.ROCK_WALL_L if left else SpriteType.ROCK_WALL_R)848 self.direction = 1849 self.parallax_layers = total_layers850 self.parallax_variance = 10851 self.parallax_speed = 0852 self.calculate_parallax_speed()853 def set_location(self, x, y):854 super(OceanWall, self).set_location(x, y)855 self.sprite.set_location(self.x, self.y)856 def set_direction(self, direction):857 self.direction = direction858 self.calculate_parallax_speed()859 def calculate_parallax_speed(self):860 assert (self.parallax_variance > 0), \861 "Parallax Variance must be greater than zero!"862 self.parallax_speed = self.parallax_variance * \863 (self.parallax_layers - (self.layer + 1))**2 * self.direction * -1864 def update_parallax(self, delta_time):865 self.set_location(self.x, self.y + self.parallax_speed * delta_time)866 def update(self, delta_time, entities):867 self.update_parallax(delta_time)868 def draw(self, surface):869 self.sprite.draw(surface, CameraType.DYNAMIC)870class Fishy(Kinetic):871 def __init__(self, y, left):872 super(Fishy, self).__init__(-32 if left else Camera.BOUNDS.width +873 16, y, 16, 16, randint(1, 10) * 10)874 self.type = randint(0, 1)875 self.velocity.x = -1 if left else 1876 if self.velocity.x > 0:877 if self.type == 0:878 self.sprite = Sprite(879 self.x, self.y, SpriteType.FISH_SMALL_L if left else SpriteType.FISH_SMALL_R)880 elif self.type == 1:881 self.sprite = Sprite(882 self.x, self.y, SpriteType.FISH_LARGE_L if left else SpriteType.FISH_LARGE_R)883 else:884 if self.type == 0:885 self.sprite = Sprite(886 self.x, self.y, SpriteType.FISH_SMALL_L if left else SpriteType.FISH_SMALL_L)887 elif self.type == 1:888 self.sprite = Sprite(889 self.x, self.y, SpriteType.FISH_LARGE_L if left else SpriteType.FISH_LARGE_L)890 self.captured = False891 def set_location(self, x, y):892 super(Fishy, self).set_location(x, y)893 self.sprite.set_location(self.x, self.y)894 def hook_fish(self):895 self.captured = True896 def _update_ai(self):897 self.set_location(self.x + self.move_speed * self.velocity.x, self.y)898 def flip_velocity(self):899 self.velocity.x *= -1900 if self.velocity.x > 0:901 if self.type == 0:902 self.sprite.set_sprite(SpriteType.FISH_SMALL_R)903 elif self.type == 1:904 self.sprite.set_sprite(SpriteType.FISH_LARGE_R)905 else:906 if self.type == 0:907 self.sprite.set_sprite(SpriteType.FISH_SMALL_L)908 elif self.type == 1:909 self.sprite.set_sprite(SpriteType.FISH_LARGE_L)910 def _collision(self, entities):911 if self.captured:912 for e in entities:913 if isinstance(e, Hook):914 if self.velocity.x > 0:915 self.set_location(916 e.x - 6 + randint(-3, 3), e.y + 4 + randint(-3, 3))917 else:918 self.set_location(919 e.x + 2 + randint(-3, 3), e.y + 4 + randint(-3, 3))920 if randint(1, 10) <= 1:921 self.flip_velocity()922 return923 if (self.bounds.left < -32 and self.velocity.x < 0) or (self.bounds.right > Camera.BOUNDS.width + 32 and self.velocity.x > 0):924 self.flip_velocity()925 def update(self, delta_time, entities):926 self._calculate_scaled_speed(delta_time)927 # self._update_collision_rectangles()928 self._update_ai()929 self._collision(entities)930 def draw(self, surface):931 if pygine.globals.debug:932 self._draw_bounds(surface, CameraType.DYNAMIC)...

Full Screen

Full Screen

getdogfood056.py

Source:getdogfood056.py Github

copy

Full Screen

...57inu = 'https://1.bp.blogspot.com/-CpjK6doN9lU/XYhOYM-oK4I/AAAAAAABVHg/68vPZMzgvxUBAYflTAazrX08pgp460KbwCNcBGAsYHQ/s1600/pet_darui_dog.png'58image = AImage(block_size, block_size,100,image=inu)59robot = AImage(block_size, block_size,image=inu)60studio.append(robot)61def set_location(robot, x, y):62 robot.cx = x * block_size + block_size // 263 robot.cy = y * block_size + block_size // 264set_location(robot, 1, 1) 65studio.render() 66set_location(robot, 1, 2)67studio.render()68set_location(robot, 2, 2)69studio.render()70set_location(robot, 3, 2)71studio.render()72set_location(robot, 4, 2)73studio.render()74set_location(robot, 5, 2)75studio.render()76set_location(robot, 6, 2)77studio.render()78set_location(robot, 6, 3)79studio.render()80set_location(robot, 6, 4)81studio.render()82set_location(robot, 6, 5)83studio.render()84set_location(robot, 7, 5)85studio.render()86set_location(robot, 8, 5)87studio.render()88set_location(robot, 8, 4)89studio.render()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful