Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@do_not_delete is also allowed with the old syntax #1330

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 14 additions & 43 deletions examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ enum private Enum64 : uint64 { // 64 bit enum, private

[export]
def enum_use_example {
let bf = MyEnum.ONE;
debug(bf);
let bf : MyEnum = MyEnum.ONE;
}

///////////
Expand All @@ -121,8 +120,7 @@ bitfield BitfieldWithTrailingComma {

[export]
def bitfield_use_example {
let bf = MyBitfield.ONE;
debug(bf);
let bf : MyBitfield = MyBitfield.ONE;
}

////////////////////
Expand All @@ -144,46 +142,29 @@ struct Mks {
[export]
def test_make_struct {
let a : Mks = Mks(); // with default values
debug(a);
let A : Mks = default<Mks>; // with default values, same as Mks()
debug(A);
let b : Mks = Mks(a=2,b=3.0); // with values overwritten
debug(b);
let c : Mks = Mks(a=4); // with some values overwritten
debug(c);
let C : Mks = Mks(5); // with constructor
debug(C);
let CC : Mks = Mks(1,2,3); // with complex constructor
debug(CC);
let d : Mks = struct<Mks>(a=2,b=3.0); // with values overwritten
debug(d);
let e : Mks[3] = struct<Mks>(a=1,b=1.0;a=2,b=2.0;a=3,b=3.0); // this is array of structures // TODO: do we need better syntax_error
debug(e);
unsafe {
let h : Mks = default<Mks> uninitialized; // uninitialized, a=0, b=0.0
debug(h);
let i : Mks = struct<Mks>(uninitialized a=1); // uninitialized, a=1, b=0.0
debug(i);
}
}

[export]
def test_new_struct {
let a : Mks* = new Mks(); // Mks*, on heap - default values
debug(a);
let A : Mks* = new default<Mks>; // Mks*, on heap - default values
debug(A);
let b : Mks* = new Mks(5); // Mks*, on heap - with constructor
debug(b);
let c : Mks* = new<Mks>(a=1,b=2.0); // Mks*, on heap - with values overwritten
debug(c);
let d : Mks*[10] = new<Mks[10]>(); // dim of 10 elements
debug(d);
unsafe {
let j : Mks* = new<Mks>(uninitialized b=2.0); // Mks* - on heap, uninitialized, a=0, b=2.0
debug(j);
let h : Mks* = new default<Mks> uninitialized; // Mks* - on heap, uninitialized, a=0, b=0.0
debug(h);
};
}

Expand All @@ -199,13 +180,9 @@ tuple Tup {
[export]
def test_tuples {
let a : tuple<int;float;string> = (1,2.,"3");
debug(a);
let b : tuple<int;float;string> = tuple(1,2.,"3");
debug(b);
let c : tuple<int;float;string> = tuple<Tup>(a=1,b=2.,c="3");
debug(c);
let e : tuple<int;float;string> = tuple<Tup>(uninitialized a=1); // a=1,b=0.0,c=""
debug(e);
let f : tuple<int;float;string>* = new tuple(1,2.,"3"); // on heap
}

Expand All @@ -222,9 +199,7 @@ variant Varr {
def test_variants {
// NOTE - variant can't be uninitialized (it just makes no sense)
let a : variant<a:int;b:float;c:string> = Varr(a=1);
debug(a);
let b : variant<a:int;b:float;c:string> = variant<Varr>(a=1);
debug(b);
}

/////////
Expand All @@ -233,29 +208,29 @@ def test_variants {
[export]
def test_arrays {
let a : array<int> <- [1,2,3,4,5]; // array of integers
debug(a);
let c : array<int> <- array(1,2,3,4,5); // array of integers
debug(c);
let d : array<int> <- array<int>(1,2,3,4,5); // array of integers
debug(d);
let b : int[5] = dim(1,2,3,4,5); // fixed size array of integers
debug(b);
let e : int[5] = dim<int>(1,2,3,4,5); // fixed size array of integers
debug(e);
let g : array<Mks> <- [ Mks(1), Mks(2,3,4) ]; // array of structures
debug(g);
let f : Mks[2] <- struct<Mks>(a=1,b=2.0; a=3,b=4.0);
debug(f);
let G : array<Mks> <- array struct<Mks>(a=1,b=2.0; a=3,b=4.0); // array of structures
debug(G);
let h : Tup[2] <- tuple<Tup>(a=1,b=2.,c="3"; a=4,b=5.,c="6");
debug(h);
let H : array<Tup> <- array tuple<Tup>(a=1,b=2.,c="3"; a=4,b=5.,c="6"); // array of tuples
debug(H);
let v : Varr[6] <- variant<Varr>(a=1; b=2.; c="3"; a=4; b=5.; c="6");
debug(v);
let V : array<Varr> <- array variant<Varr>(a=1; b=2.; c="3"; a=4; b=5.; c="6"); // array of variants
debug(V);
}

////////
// table

def test_tables() {
let a : table<int> <- { 1, 2, 3, 4, 5 }; // table of integers, keys only
let b : table<int> <- table<int>(1,2,3,4,5); // table of integers, keys only
let B : table<int> <- table(1,2,3,4,5); // table of integers, keys only
let c : table<int;int> <- { 1=>1, 2=>2, 3=>3, 4=>4, 5=>5 }; // table of integers, key-value pairs
let d : table<int;int> <- table<int;int>(1=>1,2=>2,3=>3,4=>4,5=>5); // table of integers, key-value pairs
let D : table<int;int> <- table(1=>1,2=>2,3=>3,4=>4,5=>5); // table of integers, key-value pairs
}

/////////////////
Expand All @@ -264,13 +239,9 @@ def test_arrays {
[export]
def test_comprehensions {
let arr_comp : array<int> <- [for x in range(1,100); x*x; where x%2==0]; // array comprehension
debug(arr_comp);
let iter_comp : iterator<int> <- [iterator for x in range(1,100); x*x; where x%2==0]; // iterator comprehension
debug(iter_comp);
let set_comp : table<int> <- {for x in range(1,100); x*x; where x%2==0}; // set comprehension
debug(set_comp);
let table_comp : table<int;string> <- {for x in range(1,10); x=>"{x*x}"; where x%2==0}; // table comprehension
debug(table_comp);
}

///////
Expand Down
144 changes: 72 additions & 72 deletions src/parser/ds2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,78 +1036,78 @@ static const yytype_int16 yyrline[] =
827, 828, 832, 838, 844, 850, 858, 868, 877, 884,
885, 886, 887, 888, 889, 893, 898, 906, 907, 908,
912, 913, 914, 915, 916, 917, 918, 919, 925, 928,
934, 937, 942, 943, 944, 948, 961, 979, 982, 990,
1001, 1012, 1023, 1026, 1033, 1037, 1044, 1045, 1049, 1050,
1051, 1055, 1058, 1065, 1069, 1070, 1071, 1072, 1073, 1074,
1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084,
1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094,
1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104,
1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114,
1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124,
1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134,
1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144,
1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1157, 1175,
1176, 1177, 1181, 1187, 1187, 1204, 1208, 1219, 1228, 1240,
1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250,
1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260,
1264, 1269, 1275, 1281, 1292, 1293, 1297, 1298, 1302, 1306,
1313, 1313, 1313, 1319, 1319, 1319, 1328, 1362, 1365, 1368,
1371, 1377, 1378, 1389, 1393, 1396, 1404, 1404, 1404, 1410,
1413, 1417, 1421, 1428, 1434, 1438, 1442, 1445, 1448, 1456,
1459, 1462, 1470, 1473, 1481, 1484, 1487, 1495, 1501, 1502,
1503, 1507, 1508, 1512, 1513, 1517, 1522, 1530, 1536, 1548,
1551, 1557, 1557, 1557, 1560, 1560, 1560, 1565, 1565, 1565,
1573, 1573, 1573, 1579, 1589, 1600, 1615, 1618, 1624, 1625,
1632, 1643, 1644, 1645, 1649, 1650, 1651, 1652, 1656, 1661,
1669, 1670, 1674, 1679, 1686, 1693, 1701, 1702, 1703, 1704,
1705, 1706, 1707, 1711, 1712, 1713, 1714, 1715, 1716, 1717,
1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727,
1728, 1729, 1733, 1734, 1735, 1736, 1741, 1742, 1743, 1744,
1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754,
1755, 1756, 1757, 1762, 1769, 1781, 1786, 1796, 1800, 1807,
1810, 1810, 1810, 1815, 1815, 1815, 1828, 1832, 1836, 1841,
1848, 1848, 1848, 1855, 1859, 1868, 1872, 1875, 1881, 1882,
1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892,
1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902,
1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912,
1913, 1914, 1915, 1916, 1922, 1923, 1924, 1925, 1926, 1939,
1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949,
1950, 1953, 1956, 1957, 1960, 1960, 1960, 1963, 1968, 1972,
1976, 1976, 1976, 1981, 1984, 1988, 1988, 1988, 1993, 1996,
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2010,
2014, 2015, 2016, 2017, 2018, 2019, 2020, 2024, 2028, 2032,
2036, 2040, 2044, 2048, 2052, 2056, 2063, 2064, 2068, 2069,
2070, 2074, 2075, 2079, 2080, 2081, 2085, 2086, 2090, 2101,
2104, 2104, 2123, 2122, 2136, 2135, 2151, 2160, 2170, 2171,
2175, 2178, 2187, 2188, 2192, 2195, 2198, 2214, 2223, 2224,
2228, 2231, 2234, 2248, 2249, 2253, 2259, 2265, 2268, 2272,
2278, 2287, 2288, 2289, 2293, 2294, 2298, 2305, 2310, 2319,
2325, 2336, 2339, 2344, 2349, 2357, 2368, 2371, 2371, 2391,
2392, 2396, 2397, 2398, 2402, 2405, 2405, 2423, 2427, 2434,
2437, 2450, 2467, 2468, 2469, 2474, 2474, 2500, 2501, 2505,
2506, 2510, 2511, 2512, 2516, 2526, 2529, 2535, 2540, 2535,
2555, 2556, 2560, 2561, 2565, 2571, 2572, 2576, 2577, 2578,
2582, 2585, 2591, 2596, 2591, 2610, 2617, 2622, 2631, 2637,
2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657,
2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667,
2668, 2669, 2670, 2671, 2672, 2673, 2674, 2678, 2679, 2680,
2681, 2682, 2683, 2684, 2685, 2689, 2700, 2704, 2711, 2723,
2730, 2739, 2744, 2754, 2767, 2767, 2767, 2780, 2784, 2791,
2795, 2802, 2803, 2804, 2805, 2806, 2821, 2827, 2827, 2827,
2831, 2836, 2843, 2843, 2850, 2854, 2858, 2863, 2868, 2873,
2878, 2882, 2886, 2891, 2895, 2899, 2904, 2904, 2904, 2910,
2917, 2917, 2917, 2922, 2922, 2922, 2928, 2928, 2928, 2933,
2937, 2937, 2937, 2942, 2942, 2942, 2951, 2955, 2955, 2955,
2960, 2960, 2960, 2969, 2973, 2973, 2973, 2978, 2978, 2978,
2987, 2987, 2987, 2993, 2993, 2993, 3002, 3005, 3016, 3032,
3037, 3042, 3032, 3067, 3072, 3078, 3067, 3103, 3108, 3113,
3103, 3143, 3144, 3145, 3146, 3147, 3151, 3158, 3165, 3171,
3177, 3184, 3191, 3197, 3207, 3215, 3220, 3227, 3228, 3232,
3232, 3232, 3240, 3240, 3240, 3247, 3247, 3247, 3254, 3254,
3254, 3265, 3271, 3277, 3283, 3283, 3283, 3293, 3301, 3301,
3301, 3311, 3311, 3311, 3321, 3321, 3321, 3331, 3339, 3339,
3339, 3347, 3354, 3354, 3354, 3364, 3367, 3373, 3381, 3389,
3397, 3410, 3411, 3415, 3416, 3421, 3424, 3427
934, 937, 943, 944, 945, 949, 962, 980, 983, 991,
1002, 1013, 1024, 1027, 1034, 1038, 1045, 1046, 1050, 1051,
1052, 1056, 1059, 1066, 1070, 1071, 1072, 1073, 1074, 1075,
1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085,
1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095,
1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105,
1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115,
1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125,
1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135,
1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145,
1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1158, 1176,
1177, 1178, 1182, 1188, 1188, 1205, 1209, 1220, 1229, 1241,
1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251,
1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261,
1265, 1270, 1276, 1282, 1293, 1294, 1298, 1299, 1303, 1307,
1314, 1314, 1314, 1320, 1320, 1320, 1329, 1363, 1366, 1369,
1372, 1378, 1379, 1390, 1394, 1397, 1405, 1405, 1405, 1411,
1414, 1418, 1422, 1429, 1435, 1439, 1443, 1446, 1449, 1457,
1460, 1463, 1471, 1474, 1482, 1485, 1488, 1496, 1502, 1503,
1504, 1508, 1509, 1513, 1514, 1518, 1523, 1531, 1537, 1549,
1552, 1558, 1558, 1558, 1561, 1561, 1561, 1566, 1566, 1566,
1574, 1574, 1574, 1580, 1590, 1601, 1616, 1619, 1625, 1626,
1633, 1644, 1645, 1646, 1650, 1651, 1652, 1653, 1657, 1662,
1670, 1671, 1675, 1680, 1687, 1694, 1702, 1703, 1704, 1705,
1706, 1707, 1708, 1712, 1713, 1714, 1715, 1716, 1717, 1718,
1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728,
1729, 1730, 1734, 1735, 1736, 1737, 1742, 1743, 1744, 1745,
1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755,
1756, 1757, 1758, 1763, 1770, 1782, 1787, 1797, 1801, 1808,
1811, 1811, 1811, 1816, 1816, 1816, 1829, 1833, 1837, 1842,
1849, 1849, 1849, 1856, 1860, 1869, 1873, 1876, 1882, 1883,
1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893,
1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903,
1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913,
1914, 1915, 1916, 1917, 1923, 1924, 1925, 1926, 1927, 1940,
1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950,
1951, 1954, 1957, 1958, 1961, 1961, 1961, 1964, 1969, 1973,
1977, 1977, 1977, 1982, 1985, 1989, 1989, 1989, 1994, 1997,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2011,
2015, 2016, 2017, 2018, 2019, 2020, 2021, 2025, 2029, 2033,
2037, 2041, 2045, 2049, 2053, 2057, 2064, 2065, 2069, 2070,
2071, 2075, 2076, 2080, 2081, 2082, 2086, 2087, 2091, 2102,
2105, 2105, 2124, 2123, 2137, 2136, 2152, 2161, 2171, 2172,
2176, 2179, 2188, 2189, 2193, 2196, 2199, 2215, 2224, 2225,
2229, 2232, 2235, 2249, 2250, 2254, 2260, 2266, 2269, 2273,
2279, 2288, 2289, 2290, 2294, 2295, 2299, 2306, 2311, 2320,
2326, 2337, 2340, 2345, 2350, 2358, 2369, 2372, 2372, 2392,
2393, 2397, 2398, 2399, 2403, 2406, 2406, 2424, 2428, 2435,
2438, 2451, 2468, 2469, 2470, 2475, 2475, 2501, 2502, 2506,
2507, 2511, 2512, 2513, 2517, 2527, 2530, 2536, 2541, 2536,
2556, 2557, 2561, 2562, 2566, 2572, 2573, 2577, 2578, 2579,
2583, 2586, 2592, 2597, 2592, 2611, 2618, 2623, 2632, 2638,
2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658,
2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668,
2669, 2670, 2671, 2672, 2673, 2674, 2675, 2679, 2680, 2681,
2682, 2683, 2684, 2685, 2686, 2690, 2701, 2705, 2712, 2724,
2731, 2740, 2745, 2755, 2768, 2768, 2768, 2781, 2785, 2792,
2796, 2803, 2804, 2805, 2806, 2807, 2822, 2828, 2828, 2828,
2832, 2837, 2844, 2844, 2851, 2855, 2859, 2864, 2869, 2874,
2879, 2883, 2887, 2892, 2896, 2900, 2905, 2905, 2905, 2911,
2918, 2918, 2918, 2923, 2923, 2923, 2929, 2929, 2929, 2934,
2938, 2938, 2938, 2943, 2943, 2943, 2952, 2956, 2956, 2956,
2961, 2961, 2961, 2970, 2974, 2974, 2974, 2979, 2979, 2979,
2988, 2988, 2988, 2994, 2994, 2994, 3003, 3006, 3017, 3033,
3038, 3043, 3033, 3068, 3073, 3079, 3068, 3104, 3109, 3114,
3104, 3144, 3145, 3146, 3147, 3148, 3152, 3159, 3166, 3172,
3178, 3185, 3192, 3198, 3208, 3216, 3221, 3228, 3229, 3233,
3233, 3233, 3241, 3241, 3241, 3248, 3248, 3248, 3255, 3255,
3255, 3266, 3272, 3278, 3284, 3284, 3284, 3294, 3302, 3302,
3302, 3312, 3312, 3312, 3322, 3322, 3322, 3332, 3340, 3340,
3340, 3348, 3355, 3355, 3355, 3365, 3368, 3374, 3382, 3390,
3398, 3411, 3412, 3416, 3417, 3422, 3425, 3428
};
#endif

Expand Down
1 change: 1 addition & 0 deletions src/parser/ds2_parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ metadata_argument_list
$$ = ast_annotationArgumentListEntry(scanner,$argL,$arg);
}
;

annotation_declaration_name
: name_in_namespace[name] { $$ = $name; }
| DAS_REQUIRE { $$ = new string("require"); }
Expand Down
Loading
Loading