1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 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 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 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 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 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 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499
|
-------------------------------------------------------------------------------
-- (C) Altran Praxis Limited
-------------------------------------------------------------------------------
--
-- The SPARK toolset is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. The SPARK toolset is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-- Public License for more details. You should have received a copy of the GNU
-- General Public License distributed with the SPARK toolset; see file
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
-- the license.
--
--=============================================================================
with Ada.Characters.Latin_1;
with CommandLineData;
with Debug;
with FileSystem;
with ScreenEcho;
with SPARK_XML;
with SP_Relations;
with SystemErrors;
with XMLReport;
use type CommandLineData.Justification_Options;
package body ErrorHandler
--# own Error_Context is Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# File_Open_Error,
--# Potential_Invalid_Value,
--# Stop_SLI,
--# Total_Error_Count,
--# WarningStatus.SuppressionList;
is
----------------------------------------------------------------------
-- Centralized location for wrapper strings used when appending error explanations
-- to error message strings. These are used by Conversions and in calls to ErrorAccumulator.Start_Msg
Explanation_Prefix : constant String := " [Explanatory note: ";
Explanation_Postfix : constant String := "]";
----------------------------------------------------------------------
--# inherit CommandLineData,
--# Dictionary,
--# ErrorHandler,
--# Error_IO,
--# Error_Types,
--# ExaminerConstants,
--# E_Strings,
--# LexTokenManager,
--# SPARK_IO,
--# SP_Symbols,
--# SystemErrors;
package Conversions
--# own State;
--# initializes State;
is
procedure ToString
(Err_Num : in Error_Types.NumericError;
Purpose : in Error_Types.ConversionRequestSource;
Err_Str : out Error_Types.StringError);
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out State;
--# derives Err_Str from CommandLineData.Content,
--# Dictionary.Dict,
--# Err_Num,
--# LexTokenManager.State,
--# Purpose,
--# State &
--# State from *,
--# CommandLineData.Content,
--# Err_Num,
--# Purpose;
procedure Output_Reference_List (To_File : in SPARK_IO.File_Type);
--# global in CommandLineData.Content;
--# in State;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# State,
--# To_File;
end Conversions;
----------------------------------------------------------------------
--# inherit CommandLineData,
--# Conversions,
--# Dictionary,
--# ErrorHandler,
--# Error_IO,
--# Error_Types,
--# ExaminerConstants,
--# E_Strings,
--# LexTokenManager,
--# SPARK_IO,
--# SP_Symbols,
--# SystemErrors;
package ErrorBuffer
--# own Buffer;
--# initializes Buffer;
is
-- this is a generic add routines called by more closely focussed procedure
procedure Add
(Err_File : in out Error_IO.File_Type;
Err_Type : in Error_Types.Error_Class;
Pos : in LexTokenManager.Token_Position;
Scope : in Dictionary.Scopes;
Error_Number : in Natural;
Reference : in Natural;
Name1, Name2, Name3 : in Error_Types.Names;
Echo_Str : out Error_Types.StringError);
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Buffer;
--# in out Conversions.State;
--# in out SPARK_IO.File_Sys;
--# derives Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Number,
--# Err_Type,
--# Name1,
--# Name2,
--# Name3,
--# Pos,
--# Reference,
--# Scope &
--# Conversions.State from *,
--# Buffer,
--# CommandLineData.Content,
--# Error_Number,
--# Err_Type,
--# Name1,
--# Name2,
--# Name3,
--# Pos,
--# Reference,
--# Scope &
--# Echo_Str from Buffer,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Error_Number,
--# Err_Type,
--# LexTokenManager.State,
--# Name1,
--# Name2,
--# Name3,
--# Pos,
--# Reference,
--# Scope &
--# Err_File from *,
--# Buffer,
--# CommandLineData.Content,
--# Error_Number,
--# Err_Type,
--# Name1,
--# Name2,
--# Name3,
--# Pos,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Buffer,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Number,
--# Err_File,
--# Err_Type,
--# Name1,
--# Name2,
--# Name3,
--# Pos,
--# Reference,
--# Scope;
procedure Flush (Err_File : in out Error_IO.File_Type);
--# global in Dictionary.Dict;
--# in out Buffer;
--# in out SPARK_IO.File_Sys;
--# derives Buffer from * &
--# Err_File from *,
--# Buffer,
--# SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Buffer,
--# Dictionary.Dict,
--# Err_File;
end ErrorBuffer;
----------------------------------------------------------------------
-- This package provides a list of justification (accept) annotations found in the
-- code. When errors are added, the list can be consulted to see whether the error
-- should be displayed or not. The table is populated for the file currently being examined,
-- when the error context changes, the table contents are saved to a temorary file (or memory-based
-- simulation of such a file) so that we can list all the justifications in the report and listing files.
--# inherit CommandLineData,
--# Dictionary,
--# ErrorHandler,
--# E_Strings,
--# LexTokenManager,
--# SPARK_IO,
--# SPARK_XML,
--# SystemErrors,
--# XMLReport;
package Justifications is
type Unmatched_Justification_Iterator is private;
procedure Start_Unit (Which_Table : in out ErrorHandler.Justifications_Data_Tables);
--# derives Which_Table from *;
procedure Set_Current_Unit_Has_Semantic_Errors (Which_Table : in out ErrorHandler.Justifications_Data_Tables);
--# derives Which_Table from *;
procedure First_Unmatched_Justification
(It : out Unmatched_Justification_Iterator;
Which_Table : in ErrorHandler.Justifications_Data_Tables);
--# global in CommandLineData.Content;
--# derives It from CommandLineData.Content,
--# Which_Table;
procedure Next_Unmatched_Justification
(It : in out Unmatched_Justification_Iterator;
Which_Table : in ErrorHandler.Justifications_Data_Tables);
--# global in CommandLineData.Content;
--# derives It from *,
--# CommandLineData.Content,
--# Which_Table;
function Error_Position (It : Unmatched_Justification_Iterator) return LexTokenManager.Token_Position;
function Is_Null_Iterator (It : Unmatched_Justification_Iterator) return Boolean;
procedure End_Unit (Which_Table : in out ErrorHandler.Justifications_Data_Tables);
--# derives Which_Table from *;
procedure Start_Justification
(Which_Table : in out ErrorHandler.Justifications_Data_Tables;
Position : in LexTokenManager.Token_Position;
Line : in LexTokenManager.Line_Numbers;
Kind : in ErrorHandler.Justification_Kinds;
Err_Num : in Natural;
Identifiers : in ErrorHandler.Justification_Identifiers;
Applies_To_All : in Boolean;
Explanation : in E_Strings.T;
Maximum_Justifications_Reached : out Boolean);
--# derives Maximum_Justifications_Reached from Which_Table &
--# Which_Table from *,
--# Applies_To_All,
--# Err_Num,
--# Explanation,
--# Identifiers,
--# Kind,
--# Line,
--# Position;
procedure End_Justification
(Which_Table : in out ErrorHandler.Justifications_Data_Tables;
Line : in LexTokenManager.Line_Numbers;
Unmatched_End : out Boolean);
--# derives Unmatched_End,
--# Which_Table from Line,
--# Which_Table;
procedure Check_Whether_Justified
(Which_Table : in out ErrorHandler.Justifications_Data_Tables;
Line : in LexTokenManager.Token_Position;
Kind : in ErrorHandler.Justification_Kinds;
Err_Num : in Natural;
Identifiers : in ErrorHandler.Justification_Identifiers;
Match_Found : out Boolean);
--# global in CommandLineData.Content;
--# in LexTokenManager.State;
--# derives Match_Found,
--# Which_Table from CommandLineData.Content,
--# Err_Num,
--# Identifiers,
--# Kind,
--# LexTokenManager.State,
--# Line,
--# Which_Table;
procedure Print_Justifications (Which_Table : in ErrorHandler.Justifications_Data_Tables;
File : in SPARK_IO.File_Type);
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# File,
--# Which_Table;
procedure Print_Justifications_XML
(Which_Table : in ErrorHandler.Justifications_Data_Tables;
File : in SPARK_IO.File_Type);
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# in out XMLReport.State;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# File,
--# Which_Table,
--# XMLReport.State &
--# XMLReport.State from *,
--# CommandLineData.Content,
--# Which_Table;
private
type Unmatched_Justification_Iterator is record
Current_Table_Entry : ErrorHandler.Data_Table_Ptr;
Current_Position : LexTokenManager.Token_Position;
end record;
end Justifications;
----------------------------------------------------------------------
--# inherit Ada.Characters.Handling,
--# Ada.Characters.Latin_1,
--# CommandLineData,
--# CommandLineHandler,
--# ErrorHandler,
--# ExaminerConstants,
--# E_Strings,
--# FileSystem,
--# LexTokenManager,
--# ScreenEcho,
--# SPARK_IO,
--# SystemErrors,
--# XMLReport;
package WarningStatus
--# own SuppressionList;
--# initializes SuppressionList;
is
procedure ReadWarningFile;
--# global in CommandLineData.Content;
--# in out ErrorHandler.File_Open_Error;
--# in out LexTokenManager.State;
--# in out SPARK_IO.File_Sys;
--# in out SuppressionList;
--# derives ErrorHandler.File_Open_Error from *,
--# CommandLineData.Content,
--# SPARK_IO.File_Sys &
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# SuppressionList from CommandLineData.Content,
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# SuppressionList;
function Is_Suppressed (The_Element : ErrorHandler.Warning_Elements) return Boolean;
--# global in SuppressionList;
function Pragma_Is_Suppressed (Pragma_Name : LexTokenManager.Lex_String) return Boolean;
--# global in LexTokenManager.State;
--# in SuppressionList;
procedure Output_Warning_List (To_File : in SPARK_IO.File_Type);
--# global in CommandLineData.Content;
--# in LexTokenManager.State;
--# in SuppressionList;
--# in out SPARK_IO.File_Sys;
--# in out XMLReport.State;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# LexTokenManager.State,
--# SuppressionList,
--# To_File,
--# XMLReport.State &
--# XMLReport.State from *,
--# CommandLineData.Content,
--# SuppressionList;
procedure Report_Suppressed_Warnings (To_File : in SPARK_IO.File_Type;
Counter : in ErrorHandler.Counters);
--# global in SuppressionList;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Counter,
--# SuppressionList,
--# To_File;
end WarningStatus;
----------------------------------------------------------------------
Stmt_Width : constant Positive := 4;
Source_Line_Indent : constant Positive := 6;
Error_Line_Length : constant Positive := 80;
XML_Error_Line_Length : constant Positive := 256;
subtype Error_Set_Lengths is Natural range 0 .. ExaminerConstants.MaxErrorSetSize;
subtype Error_Set_Positions is Natural range 1 .. ExaminerConstants.MaxErrorSetSize;
type Error_Struct is record
Err_Num : Natural;
Error : Error_Types.StringError;
end record;
type Error_Array is array (Error_Set_Positions) of Error_Struct;
type Error_Sets is record
Length : Error_Set_Lengths;
Content : Error_Array;
end record;
Empty_Error_Struct : constant Error_Struct := Error_Struct'(0, Error_Types.Empty_StringError);
Empty_Error_Array : constant Error_Array := Error_Array'(Error_Set_Positions => Empty_Error_Struct);
Empty_Error_Set : constant Error_Sets := Error_Sets'(0, Empty_Error_Array);
----------------------------------------------------------------------
--# inherit CommandLineData,
--# ErrorHandler,
--# Error_Types,
--# ExaminerConstants,
--# E_Strings,
--# SPARK_IO,
--# SystemErrors,
--# XMLReport;
package ErrorAccumulator is
type T is private;
Clear : constant T;
function Is_Error_Continuation (The_Error : Error_Types.StringError) return Boolean;
function Is_Error_Start (The_Error : Error_Types.StringError) return Boolean;
function Is_Active (This : T) return Boolean;
procedure Start_Msg
(This : out T;
Start_Error : in ErrorHandler.Error_Struct;
Start_Indent : in Natural;
Explanation : in E_Strings.T;
Line_Length : in Natural;
Indent : in Natural);
--# derives This from Explanation,
--# Indent,
--# Line_Length,
--# Start_Error,
--# Start_Indent;
procedure Flush (This : in out T;
Listing : in SPARK_IO.File_Type);
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Listing,
--# This &
--# This from *;
procedure Add
(This : in out T;
Error : in ErrorHandler.Error_Struct;
End_Pos, Indent : in Natural;
Listing : in SPARK_IO.File_Type);
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# End_Pos,
--# Error,
--# Indent,
--# Listing,
--# This &
--# This from *,
--# End_Pos,
--# Error,
--# Indent;
--#
private
type T is record
Active : Boolean;
Start_Error : ErrorHandler.Error_Struct;
Start_Indent : Natural;
-- following fields only concerned with appending explanation to message after Flush operation
Explanation : E_Strings.T;
Line_Length : Natural;
Indent : Natural;
end record;
Clear : constant T :=
T'
(Active => False,
Start_Error => ErrorHandler.Empty_Error_Struct,
Start_Indent => 0,
Explanation => E_Strings.Empty_String,
Line_Length => 0,
Indent => 0);
end ErrorAccumulator;
----------------------------------------------------------------------
Error_Context_Rec : Error_Contexts;
Echo_Accumulator : ErrorAccumulator.T;
Total_Error_Count : Total_Error_Counts;
File_Open_Error : Boolean := False;
Stop_SLI : Boolean := False;
Potential_Invalid_Value : Boolean := False;
----------------------------------------------------------------------
function Dependency_Err_Number (Err_Type : Full_Depend_Err_Type) return Natural is
Result : Natural;
begin
case Err_Type is
-- Unconditional dependency errors
when Not_Used | Not_Used_New | Not_Used_Continue | Ineff_Init | Ineff_Local_Init | Policy_Violation =>
Result := Dependency_Err_Type'Pos (Err_Type) + Error_Types.UncondDependencyErrorOffset;
-- Conditional dependency errors
when May_Be_Used |
May_Be_Used_New |
May_Be_Used_Continue |
Uninitialised |
Integrity_Violation |
May_Be_Integrity_Violation =>
Result := Dependency_Err_Type'Pos (Err_Type) + Error_Types.CondDependencyErrorOffset;
end case;
return Result;
end Dependency_Err_Number;
----------------------------------------------------------------------
package body Conversions is separate;
----------------------------------------------------------------------
package body ErrorBuffer is separate;
----------------------------------------------------------------------
package body WarningStatus is separate;
----------------------------------------------------------------------
package body Justifications is separate;
----------------------------------------------------------------------
function Symbol_To_Justification_Identifier (Sym : Dictionary.Symbol) return Justification_Identifier is
begin
return Justification_Identifier'(String_Form => LexTokenManager.Null_String,
Symbol_Form => Sym);
end Symbol_To_Justification_Identifier;
function Lex_Str_To_Justification_Identifier (Str : LexTokenManager.Lex_String) return Justification_Identifier is
begin
return Justification_Identifier'(String_Form => Str,
Symbol_Form => Dictionary.NullSymbol);
end Lex_Str_To_Justification_Identifier;
procedure Read_Warning_File
--# global in CommandLineData.Content;
--# in out File_Open_Error;
--# in out LexTokenManager.State;
--# in out SPARK_IO.File_Sys;
--# in out WarningStatus.SuppressionList;
--# derives File_Open_Error from *,
--# CommandLineData.Content,
--# SPARK_IO.File_Sys &
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList from CommandLineData.Content,
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList;
is
begin
WarningStatus.ReadWarningFile;
end Read_Warning_File;
procedure Output_Warning_List (To_File : in SPARK_IO.File_Type)
--# global in CommandLineData.Content;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out SPARK_IO.File_Sys;
--# in out XMLReport.State;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# LexTokenManager.State,
--# To_File,
--# WarningStatus.SuppressionList,
--# XMLReport.State &
--# XMLReport.State from *,
--# CommandLineData.Content,
--# WarningStatus.SuppressionList;
is
begin
WarningStatus.Output_Warning_List (To_File => To_File);
end Output_Warning_List;
----------------------------------------------------------------------
procedure Output_Reference_List (To_File : in SPARK_IO.File_Type)
--# global in CommandLineData.Content;
--# in Conversions.State;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Conversions.State,
--# To_File;
is
begin
Conversions.Output_Reference_List (To_File => To_File);
end Output_Reference_List;
--------------------------------------------------------------------------
function Lex_String_To_Name (Str : LexTokenManager.Lex_String) return Error_Types.Names
--# global in LexTokenManager.State;
is
Result : Error_Types.Names;
begin
if LexTokenManager.Lex_String_Case_Insensitive_Compare (Lex_Str1 => Str,
Lex_Str2 => LexTokenManager.Null_String) =
LexTokenManager.Str_Eq then
Result := Error_Types.NoName;
elsif LexTokenManager.Lex_String_Case_Insensitive_Compare (Lex_Str1 => Str,
Lex_Str2 => LexTokenManager.Main_Program_Token) =
LexTokenManager.Str_Eq then
Result := Error_Types.ThePartitionName;
else
Result :=
Error_Types.Names'(Name_Sort => Error_Types.LexString,
Name_Sym => Dictionary.NullSymbol,
Name_Str => Str,
Pos => 0);
end if;
return Result;
end Lex_String_To_Name;
--------------------------------------------------------------------------
function Symbol_To_Name (Sym : Dictionary.Symbol) return Error_Types.Names is
Result : Error_Types.Names;
begin
if Dictionary.Is_Null_Symbol (Sym) then
Result := Error_Types.NoName;
else
Result :=
Error_Types.Names'(Name_Sort => Error_Types.Symbol,
Name_Sym => Sym,
Name_Str => LexTokenManager.Null_String,
Pos => 0);
end if;
return Result;
end Symbol_To_Name;
--------------------------------------------------------------------------
function SP_Symbol_To_Name (Sym : SP_Symbols.SP_Symbol) return Error_Types.Names is
begin
return Error_Types.Names'
(Name_Sort => Error_Types.ParserSymbol,
Name_Sym => Dictionary.NullSymbol,
Name_Str => LexTokenManager.Null_String,
Pos => SP_Symbols.SP_Symbol'Pos (Sym));
end SP_Symbol_To_Name;
--------------------------------------------------------------------------
procedure Append_String (E_Str : in out Error_Types.StringError;
Str : in String)
--# derives E_Str from *,
--# Str;
is
pragma Inline (Append_String);
begin
E_Strings.Append_String (E_Str => E_Str.Message,
Str => Str);
end Append_String;
------------------------------------------------------------------------
procedure AppendSym (Error : in out Error_Types.StringError;
Sym : in SP_Symbols.SP_Symbol)
--# derives Error from *,
--# Sym;
is separate;
----------------------------------------------------------------------
procedure Append_Lex_String (E_Str : in out Error_Types.StringError;
L_Str : in LexTokenManager.Lex_String)
--# global in LexTokenManager.State;
--# derives E_Str from *,
--# LexTokenManager.State,
--# L_Str;
is
pragma Inline (Append_Lex_String);
begin
E_Strings.Append_Examiner_String
(E_Str1 => E_Str.Message,
E_Str2 => LexTokenManager.Lex_String_To_String (Lex_Str => L_Str));
end Append_Lex_String;
pragma Unreferenced (Append_Lex_String); -- unused at present
----------------------------------------------------------------------
procedure Set_Col (File : in SPARK_IO.File_Type;
Posn : in Positive)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# File,
--# Posn;
is
pragma Inline (Set_Col);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Set_Col (Posn);
else
SPARK_IO.Set_Col (File, Posn);
end if;
end Set_Col;
procedure Put_Char (File : in SPARK_IO.File_Type;
Item : in Character)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# File,
--# Item;
is
pragma Inline (Put_Char);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Put_Char (Item);
else
SPARK_IO.Put_Char (File => File,
Item => Item);
end if;
end Put_Char;
procedure Put_Integer
(File : in SPARK_IO.File_Type;
Item : in Integer;
Width : in Natural;
Base : in SPARK_IO.Number_Base)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Base,
--# File,
--# Item,
--# Width;
is
pragma Inline (Put_Integer);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Put_Integer (Item, Width, Base);
else
SPARK_IO.Put_Integer (File => File,
Item => Item,
Width => Width,
Base => Base);
end if;
end Put_Integer;
procedure New_Line (File : in SPARK_IO.File_Type;
Spacing : in Positive)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# File,
--# Spacing;
is
pragma Inline (New_Line);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.New_Line (Spacing);
else
SPARK_IO.New_Line (File => File,
Spacing => Spacing);
end if;
end New_Line;
procedure Put_Line (File : in SPARK_IO.File_Type;
Item : in String;
Stop : in Natural)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# File,
--# Item,
--# Stop;
is
pragma Inline (Put_Line);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Put_Line (Item);
else
SPARK_IO.Put_Line (File => File,
Item => Item,
Stop => Stop);
end if;
end Put_Line;
procedure Put_E_String (File : in SPARK_IO.File_Type;
E_Str : in E_Strings.T)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# E_Str,
--# File;
is
pragma Inline (Put_E_String);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Put_ExaminerString (E_Str);
else
E_Strings.Put_String (File => File,
E_Str => E_Str);
end if;
end Put_E_String;
pragma Unreferenced (Put_E_String); -- unused at present
procedure Put_E_Line (File : in SPARK_IO.File_Type;
E_Str : in E_Strings.T)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# E_Str,
--# File;
is
pragma Inline (Put_E_Line);
begin
if File = SPARK_IO.Standard_Output then
ScreenEcho.Put_ExaminerLine (E_Str);
else
E_Strings.Put_Line (File => File,
E_Str => E_Str);
end if;
end Put_E_Line;
----------------------------------------------------------------------
procedure Put_Spaces (File : in SPARK_IO.File_Type;
N : in Natural)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# File,
--# N;
is
begin
for I in Natural range 1 .. N loop
Put_Char (File => File,
Item => ' ');
end loop;
end Put_Spaces;
----------------------------------------------------------------------
procedure PrintLine
(Listing : in SPARK_IO.File_Type;
Start_Pos, End_Pos, Indent : in Natural;
Line : in E_Strings.T;
Add_New_Line : in Boolean;
New_Start : out Natural)
--# global in out SPARK_IO.File_Sys;
--# derives New_Start from End_Pos,
--# Indent,
--# Line,
--# Start_Pos &
--# SPARK_IO.File_Sys from *,
--# Add_New_Line,
--# End_Pos,
--# Indent,
--# Line,
--# Listing,
--# Start_Pos;
is separate;
----------------------------------------------------------------------------
package body ErrorAccumulator is separate;
-----------------------------------------------------------------------------
-- String utility used in calls to ErrorAccumulator.Start_Msg to remove explanations from
-- strings being stored in the accumulator so that they can be kept and
-- printed when the accumulator is flushed
-- e.g. if "rage, rage against the dying of the light [Explanatory note: by Dylan Thomas]" is passed
-- in in Estr and ErrorHandlerError.Prefix is set to " [Explanatory note: " then after the call,
-- Estr has "rage, rage against the dying of the light" and
-- Explanation has " [Explanatory note: by Dylan Thomas]"
-- If there is no match for ErrorHandlerError.Prefix then E_Str is unchanged and Explanation
-- is the EmptyString;
procedure Split_String_At_Explanation (E_Str : in out E_Strings.T;
Explanation : out E_Strings.T)
--# derives Explanation,
--# E_Str from E_Str;
is
Start_Point : Natural;
Found_It : Boolean;
begin
E_Strings.Find_Sub_String
(E_Str => E_Str,
Search_String => Explanation_Prefix,
String_Found => Found_It,
String_Start => Start_Point);
if Found_It then
Explanation :=
E_Strings.Section
(E_Str => E_Str,
Start_Pos => Start_Point,
Length => (E_Strings.Get_Length (E_Str => E_Str) - Start_Point) + 1);
-- truncate E_Str to remove Explanation
E_Str := E_Strings.Section (E_Str => E_Str,
Start_Pos => 1,
Length => Start_Point - 1);
else
Explanation := E_Strings.Empty_String;
end if;
end Split_String_At_Explanation; -- one DF error reported on Explanation.Content
-----------------------------------------------------------------------------
procedure Flush_Buffer
--# global in Dictionary.Dict;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives ErrorBuffer.Buffer from * &
--# Error_Context_Rec from *,
--# ErrorBuffer.Buffer,
--# SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec;
is
Err_File : Error_IO.File_Type;
begin
Err_File := Error_Context_Rec.Errs;
ErrorBuffer.Flush (Err_File => Err_File);
Error_Context_Rec.Errs := Err_File;
end Flush_Buffer;
----------------------------------------------------------------------
procedure Inc_Total_Justified_Warnings
--# global in out Total_Error_Count;
--# derives Total_Error_Count from *;
is
begin
if Total_Error_Count.Justified_Warnings = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Errors,
Msg => "");
end if;
Total_Error_Count.Justified_Warnings := Total_Error_Count.Justified_Warnings + 1;
end Inc_Total_Justified_Warnings;
----------------------------------------------------------------------
procedure Echo_Total_Error_Count
--# global in CommandLineData.Content;
--# in Total_Error_Count;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Total_Error_Count;
is
procedure Indent
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *;
is
begin
ScreenEcho.Put_String (" ");
end Indent;
procedure End_Line (Is_Plural : in Boolean)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Is_Plural;
is
begin
if Is_Plural then
ScreenEcho.Put_Line ("s");
else
ScreenEcho.New_Line (1);
end if;
end End_Line;
begin -- Echo_Total_Error_Count
if CommandLineData.Content.Echo and not CommandLineData.Content.Makefile_Mode then
ScreenEcho.New_Line (1);
-- Explicit and summarized warnings are handled separately
-- First explicit counts
if Total_Error_Count.Grand_Total = 0 then
ScreenEcho.Put_Line (" No errors or warnings");
else
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Grand_Total), 5, 10);
if Total_Error_Count.Grand_Total > 1 then
ScreenEcho.Put_Line (" errors or warnings, comprising:");
else
ScreenEcho.Put_Line (" error or warning, comprising:");
end if;
-- List subtotals by category
if Total_Error_Count.Explicit_Error_Count (Syntax_Or_Semantic) > 0 then
Indent;
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Explicit_Error_Count (Syntax_Or_Semantic)), 5, 10);
ScreenEcho.Put_String (" syntax or semantic error");
End_Line (Is_Plural => Total_Error_Count.Explicit_Error_Count (Syntax_Or_Semantic) > 1);
end if;
if Total_Error_Count.Explicit_Error_Count (Flow) > 0 then
Indent;
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Explicit_Error_Count (Flow)), 5, 10);
ScreenEcho.Put_String (" flow error");
End_Line (Is_Plural => Total_Error_Count.Explicit_Error_Count (Flow) > 1);
end if;
if Total_Error_Count.Explicit_Error_Count (Warning) > 0 then
Indent;
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Explicit_Error_Count (Warning)), 5, 10);
ScreenEcho.Put_String (" warning");
End_Line (Is_Plural => Total_Error_Count.Explicit_Error_Count (Warning) > 1);
end if;
end if;
-- Then append summary of suppressed warnings (say nothing at all if total is 0)
if Total_Error_Count.Suppressed_Warnings > 0 then
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Suppressed_Warnings), 5, 10);
ScreenEcho.Put_String (" summarized warning");
End_Line (Is_Plural => Total_Error_Count.Suppressed_Warnings > 1);
end if;
-- Then append summary of justified warnings (say nothing at all if total is 0)
if Total_Error_Count.Justified_Warnings > 0 then
ScreenEcho.Put_Integer (Integer (Total_Error_Count.Justified_Warnings), 5, 10);
ScreenEcho.Put_String (" expected (justified) warning");
End_Line (Is_Plural => Total_Error_Count.Justified_Warnings > 1);
end if;
end if;
end Echo_Total_Error_Count;
----------------------------------------------------------------------
procedure Inc_Message_Count (Err_Type : in Error_Types.Error_Class)
--# global in out Error_Context_Rec;
--# in out Total_Error_Count;
--# derives Error_Context_Rec,
--# Total_Error_Count from *,
--# Err_Type;
is
procedure Inc_Total_Errors_Or_Warnings (Kind : in Counted_Error_Kinds)
--# global in out Total_Error_Count;
--# derives Total_Error_Count from *,
--# Kind;
is
begin
if Total_Error_Count.Grand_Total = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Errors,
Msg => "");
end if;
Total_Error_Count.Grand_Total := Total_Error_Count.Grand_Total + 1;
-- We don't need to guard the following increment because a subtotal can't
-- overflow without the grand total (tested above) overflowing first
Total_Error_Count.Explicit_Error_Count (Kind) := Total_Error_Count.Explicit_Error_Count (Kind) + 1;
end Inc_Total_Errors_Or_Warnings;
begin
if Error_Context_Rec.Num_Message = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Errors,
Msg => "");
end if;
Error_Context_Rec.Num_Message := Error_Context_Rec.Num_Message + 1;
if Err_Type /= Error_Types.NoErr then
if Error_Context_Rec.Num_Errs = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Errors,
Msg => "");
end if;
Error_Context_Rec.Num_Errs := Error_Context_Rec.Num_Errs + 1;
end if;
-- Above lines maintain counts of errors per unit in the current ErrorContext record.
-- We also need to maintain grand totals (in various subcategories) thus:
case Err_Type is
when Error_Types.LexErr | Error_Types.SyntaxErr | Error_Types.SyntaxRec | Error_Types.SemanticErr =>
Inc_Total_Errors_Or_Warnings (Kind => Syntax_Or_Semantic);
when Error_Types.UncondFlowErr |
Error_Types.CondlFlowErr |
Error_Types.UncondDependencyErr |
Error_Types.CondlDependencyErr |
Error_Types.DepSemanticErr | -- refinement inconsistency, treat as a flow error
Error_Types.ControlFlowErr |
Error_Types.IneffectiveStat |
Error_Types.StabilityErr |
Error_Types.UsageErr =>
Inc_Total_Errors_Or_Warnings (Kind => Flow);
when Error_Types.WarningWithPosition | Error_Types.WarningWithoutPosition | Error_Types.Note =>
Inc_Total_Errors_Or_Warnings (Kind => Warning);
when Error_Types.NoErr =>
null;
end case;
end Inc_Message_Count;
---------------------------------------------------------------------------
procedure Inc_Suppressed_Warning_Counter (Warning_Type : in Warning_Elements)
--# global in out Error_Context_Rec;
--# in out Total_Error_Count;
--# derives Error_Context_Rec from *,
--# Warning_Type &
--# Total_Error_Count from *;
is
procedure Inc_Total_Suppressed_Warnings
--# global in out Total_Error_Count;
--# derives Total_Error_Count from *;
is
begin
if Total_Error_Count.Suppressed_Warnings = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Errors,
Msg => "");
end if;
Total_Error_Count.Suppressed_Warnings := Total_Error_Count.Suppressed_Warnings + 1;
end Inc_Total_Suppressed_Warnings;
begin
if Error_Context_Rec.Counter (Warning_Type) = Count'Last then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Too_Many_Suppressed_Warnings,
Msg => "");
end if;
Error_Context_Rec.Counter (Warning_Type) := Error_Context_Rec.Counter (Warning_Type) + 1;
Inc_Total_Suppressed_Warnings; -- above is per file, per kind count; this one is grand total
end Inc_Suppressed_Warning_Counter;
----------------------------------------------------------------------
procedure Move_To_Indent
(Source_File : in SPARK_IO.File_Type;
Line : in E_Strings.T;
Indent : in Natural;
Position : in Integer)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Indent,
--# Line,
--# Position,
--# Source_File;
is
Limit : Integer;
begin
Put_Spaces (File => Source_File,
N => Indent);
if Position > E_Strings.Get_Length (E_Str => Line) then
Limit := E_Strings.Get_Length (E_Str => Line);
else
Limit := Position;
end if;
for I in Natural range 1 .. Limit loop
if E_Strings.Get_Element (E_Str => Line,
Pos => I) = Ada.Characters.Latin_1.HT then
Put_Char (File => Source_File,
Item => Ada.Characters.Latin_1.HT);
else
Put_Char (File => Source_File,
Item => ' ');
end if;
end loop;
for i in Natural range 1 .. Position - Limit loop
Put_Char (File => Source_File,
Item => ' ');
end loop;
end Move_To_Indent;
----------------------------------------------------------------------
procedure GetFileLine
--# global in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Error_Context_Rec,
--# SPARK_IO.File_Sys from Error_Context_Rec,
--# SPARK_IO.File_Sys;
is separate;
----------------------------------------------------------------------
procedure Print_Source_Line (To_File : in SPARK_IO.File_Type)
--# global in CommandLineData.Content;
--# in Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# To_File;
is
begin
if not CommandLineData.Content.Plain_Output then
Put_Integer (File => To_File,
Item => Integer (Error_Context_Rec.Line_No),
Width => Stmt_Width,
Base => 10);
end if;
Set_Col (File => To_File,
Posn => Source_Line_Indent + 1);
Put_E_Line (File => To_File,
E_Str => Error_Context_Rec.Current_Line);
end Print_Source_Line;
----------------------------------------------------------------------
function Error_Has_Position_Inline (Err_Type : in Error_Types.Error_Class) return Boolean is
begin
return not (Err_Type = Error_Types.UncondDependencyErr or
Err_Type = Error_Types.NoErr or
Err_Type = Error_Types.CondlDependencyErr or
Err_Type = Error_Types.DepSemanticErr or
Err_Type = Error_Types.UsageErr or
Err_Type = Error_Types.Note or
Err_Type = Error_Types.WarningWithoutPosition);
end Error_Has_Position_Inline;
----------------------------------------------------------------------
function Convert_Message_Id (Message_Id : Natural;
Err_Type : Error_Types.Error_Class) return Natural is
Id : Natural;
begin
case Err_Type is
when Error_Types.CondlDependencyErr =>
if Message_Id = Dependency_Err_Number (May_Be_Used_New) then
Id := Dependency_Err_Number (May_Be_Used);
else
Id := Message_Id;
end if;
when Error_Types.UncondDependencyErr =>
if Message_Id = Dependency_Err_Number (Not_Used_New) then
Id := Dependency_Err_Number (Not_Used);
else
Id := Message_Id;
end if;
when others =>
Id := Message_Id;
end case;
return Id;
end Convert_Message_Id;
procedure Put_Message_Id (File : in SPARK_IO.File_Type;
Message_Id : in Natural;
Err_Type : in Error_Types.Error_Class)
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Err_Type,
--# File,
--# Message_Id;
is
begin
if Message_Id = 0 then
SPARK_IO.Put_Char (File => File,
Item => ' ');
else
SPARK_IO.Put_Integer
(File => File,
Item => Convert_Message_Id (Message_Id => Message_Id,
Err_Type => Err_Type),
Width => 3,
Base => 10);
if CommandLineData.Content.Brief then
SPARK_IO.Put_String (File => File,
Item => " - ",
Stop => 0);
else
SPARK_IO.Put_String (File => File,
Item => ": ",
Stop => 0);
end if;
end if;
end Put_Message_Id;
function Get_Error_Class (Err_Class : in Error_Types.Error_Class) return E_Strings.T is
Tmp_String : E_Strings.T;
begin
case Err_Class is
when Error_Types.LexErr =>
Tmp_String := E_Strings.Copy_String (Str => "Lexical Error");
when Error_Types.SyntaxErr =>
Tmp_String := E_Strings.Copy_String (Str => "Syntax Error");
when Error_Types.SyntaxRec =>
Tmp_String := E_Strings.Copy_String (Str => "Syntax Recovery");
when Error_Types.SemanticErr =>
Tmp_String := E_Strings.Copy_String (Str => "Semantic Error");
when Error_Types.ControlFlowErr =>
Tmp_String := E_Strings.Copy_String (Str => "Illegal Structure");
when Error_Types.UncondFlowErr |
Error_Types.UncondDependencyErr |
Error_Types.IneffectiveStat |
Error_Types.StabilityErr |
Error_Types.UsageErr |
Error_Types.DepSemanticErr =>
Tmp_String := E_Strings.Copy_String (Str => "Flow Error");
when Error_Types.CondlFlowErr |
Error_Types.CondlDependencyErr |
Error_Types.WarningWithPosition |
Error_Types.WarningWithoutPosition =>
Tmp_String := E_Strings.Copy_String (Str => "Warning");
when Error_Types.Note =>
Tmp_String := E_Strings.Copy_String (Str => "Note");
when Error_Types.NoErr =>
Tmp_String := E_Strings.Copy_String (Str => "No Error");
end case;
return Tmp_String;
end Get_Error_Class;
procedure Output_Error_Marker
(File : in SPARK_IO.File_Type;
Err_Type : in Error_Types.Error_Class;
Message_Id : in Natural;
Err_Count : in Natural)
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Err_Count,
--# Err_Type,
--# File,
--# Message_Id;
is
procedure Output_Full_Error_Name (File : in SPARK_IO.File_Type;
Err_Type : in Error_Types.Error_Class)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Err_Type,
--# File;
is
begin
case Err_Type is
when Error_Types.LexErr =>
SPARK_IO.Put_String (File => File,
Item => "Lexical Error :",
Stop => 0);
when Error_Types.SyntaxErr =>
SPARK_IO.Put_String (File => File,
Item => "Syntax Error :",
Stop => 0);
when Error_Types.SyntaxRec =>
SPARK_IO.Put_String (File => File,
Item => "Syntax Recovery :",
Stop => 0);
when Error_Types.SemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "Semantic Error :",
Stop => 0);
when Error_Types.ControlFlowErr =>
SPARK_IO.Put_String (File => File,
Item => "Illegal Structure :",
Stop => 0);
when Error_Types.CondlFlowErr |
Error_Types.CondlDependencyErr |
Error_Types.UncondFlowErr |
Error_Types.UncondDependencyErr |
Error_Types.IneffectiveStat |
Error_Types.StabilityErr |
Error_Types.UsageErr |
Error_Types.DepSemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "Flow Error :",
Stop => 0);
when Error_Types.WarningWithPosition | Error_Types.WarningWithoutPosition =>
SPARK_IO.Put_String (File => File,
Item => "Warning :",
Stop => 0);
when Error_Types.Note =>
SPARK_IO.Put_String (File => File,
Item => "Note :",
Stop => 0);
when Error_Types.NoErr =>
null;
end case;
end Output_Full_Error_Name;
procedure Output_Error_Flash (File : in SPARK_IO.File_Type;
Err_Type : in Error_Types.Error_Class)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Err_Type,
--# File;
is
begin
case Err_Type is
when Error_Types.LexErr |
Error_Types.SyntaxErr |
Error_Types.SyntaxRec |
Error_Types.ControlFlowErr |
Error_Types.SemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "***",
Stop => 0);
when Error_Types.UncondFlowErr |
Error_Types.UncondDependencyErr |
Error_Types.IneffectiveStat |
Error_Types.StabilityErr |
Error_Types.UsageErr |
Error_Types.DepSemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "!!!",
Stop => 0);
when Error_Types.CondlFlowErr | Error_Types.CondlDependencyErr =>
SPARK_IO.Put_String (File => File,
Item => "???",
Stop => 0);
when Error_Types.NoErr =>
SPARK_IO.Put_String (File => File,
Item => "+++ ",
Stop => 0);
when Error_Types.WarningWithPosition | Error_Types.WarningWithoutPosition | Error_Types.Note =>
SPARK_IO.Put_String (File => File,
Item => "---",
Stop => 0);
end case;
end Output_Error_Flash;
----------------------------------------------------------------------
procedure Output_Error_Count (File : in SPARK_IO.File_Type;
Err_Count : in Natural)
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Err_Count,
--# File;
is
begin
if (Err_Count = 0) or CommandLineData.Content.Plain_Output then
SPARK_IO.Put_String (File => File,
Item => " ",
Stop => 0);
else
SPARK_IO.Put_String (File => File,
Item => " (",
Stop => 0);
Put_Integer (File => File,
Item => Err_Count,
Width => 3,
Base => 10);
SPARK_IO.Put_String (File => File,
Item => ") ",
Stop => 0);
end if;
end Output_Error_Count;
begin --Output_Error_Marker
Output_Error_Flash (File => File,
Err_Type => Err_Type);
if Err_Type /= Error_Types.NoErr then
Output_Error_Count (File => File,
Err_Count => Err_Count);
Output_Full_Error_Name (File => File,
Err_Type => Err_Type);
Put_Message_Id (File => File,
Message_Id => Message_Id,
Err_Type => Err_Type);
else
Output_Full_Error_Name (File => File,
Err_Type => Err_Type);
end if;
end Output_Error_Marker;
procedure Output_Brief_Error_Marker
(File : in SPARK_IO.File_Type;
Err_Type : in Error_Types.Error_Class;
Message_Id : in Natural)
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Err_Type,
--# File,
--# Message_Id;
is
procedure Output_Brief_Error_Name (File : in SPARK_IO.File_Type;
Err_Type : in Error_Types.Error_Class)
--# global in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# Err_Type,
--# File;
is
begin
case Err_Type is
when Error_Types.LexErr =>
SPARK_IO.Put_String (File => File,
Item => "Lexical Error ",
Stop => 0);
when Error_Types.SyntaxErr =>
SPARK_IO.Put_String (File => File,
Item => "Syntax Error ",
Stop => 0);
when Error_Types.SyntaxRec =>
SPARK_IO.Put_String (File => File,
Item => "Syntax Recovery ",
Stop => 0);
when Error_Types.SemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "Semantic Error ",
Stop => 0);
when Error_Types.ControlFlowErr =>
SPARK_IO.Put_String (File => File,
Item => "Illegal Structure ",
Stop => 0);
when Error_Types.CondlFlowErr |
Error_Types.CondlDependencyErr |
Error_Types.UncondFlowErr |
Error_Types.UncondDependencyErr |
Error_Types.IneffectiveStat |
Error_Types.StabilityErr |
Error_Types.UsageErr |
Error_Types.DepSemanticErr =>
SPARK_IO.Put_String (File => File,
Item => "Flow Error ",
Stop => 0);
when Error_Types.WarningWithPosition | Error_Types.WarningWithoutPosition =>
SPARK_IO.Put_String (File => File,
Item => "Warning ",
Stop => 0);
when Error_Types.Note =>
SPARK_IO.Put_String (File => File,
Item => "Note ",
Stop => 0);
when Error_Types.NoErr =>
null;
end case;
end Output_Brief_Error_Name;
begin
if Err_Type /= Error_Types.NoErr then
Output_Brief_Error_Name (File => File,
Err_Type => Err_Type);
Put_Message_Id (File => File,
Message_Id => Message_Id,
Err_Type => Err_Type);
end if;
end Output_Brief_Error_Marker;
---------------------------------------------------------------------------
procedure EchoErrorEntry (Echo_File : in SPARK_IO.File_Type;
Error : in Error_Types.StringError)
--# global in CommandLineData.Content;
--# in out Echo_Accumulator;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Echo_Accumulator from *,
--# CommandLineData.Content,
--# Error,
--# Error_Context_Rec &
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Echo_Accumulator,
--# Echo_File,
--# Error,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys;
is separate;
---------------------------------------------------------------------------
procedure Flush_Echo_Messages
--# global in out Echo_Accumulator;
--# in out SPARK_IO.File_Sys;
--# derives Echo_Accumulator,
--# SPARK_IO.File_Sys from *,
--# Echo_Accumulator;
is
Was_Active : Boolean;
begin
Was_Active := ErrorAccumulator.Is_Active (This => Echo_Accumulator);
ErrorAccumulator.Flush (This => Echo_Accumulator,
Listing => SPARK_IO.Standard_Output);
if Was_Active then
New_Line (File => SPARK_IO.Standard_Output,
Spacing => 1);
end if;
end Flush_Echo_Messages;
----------------------------------------------------------------------
procedure Error_Init (Source_File_Name : in E_Strings.T;
Echo : in Boolean)
--# global in Dictionary.Dict;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Echo_Accumulator,
--# ErrorBuffer.Buffer from * &
--# Error_Context_Rec from *,
--# Dictionary.Dict,
--# Echo,
--# ErrorBuffer.Buffer,
--# Source_File_Name,
--# SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Source_File_Name;
is
Source_File : SPARK_IO.File_Type := SPARK_IO.Null_File;
Err_File : Error_IO.File_Type := Error_IO.Null_File;
Success : SPARK_IO.File_Status;
OK_Temp_File : Boolean;
New_Context : Error_Contexts;
begin
Error_IO.Create (Err_File, Success);
OK_Temp_File := Success = SPARK_IO.Ok;
if not OK_Temp_File then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Error_Handler_Temporary_Files,
Msg => "in Error_Init");
end if;
New_Context.Errs := Err_File;
New_Context.Line_No := 0;
New_Context.Source_File_Name := Source_File_Name;
New_Context.Num_Errs := 0;
New_Context.Num_Message := 0;
New_Context.Severity := No_Error;
New_Context.Recovery_Messages := False;
New_Context.Echo := Echo;
New_Context.Current_Line := E_Strings.Empty_String;
New_Context.Counter := Counters'(others => 0);
New_Context.Source := SPARK_IO.Null_File;
New_Context.Justifications_Data_Table := Empty_Justifications_Data_Table;
--# accept Flow, 10, Error_Context_Rec, "Flush changes buffer but we need to initialize it anyway";
Flush_Buffer;
--# end accept;
Error_Context_Rec := New_Context;
FileSystem.Open_Source_File (File => Source_File,
Name => Source_File_Name,
Status => Success);
Error_Context_Rec.Source := Source_File;
if not (Success = SPARK_IO.Ok) then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Error_Handler_Source,
Msg => "in Error_Init");
end if;
Flush_Echo_Messages;
end Error_Init;
---------------------------------------------------------------------------
procedure Spark_Make_Init
--# global in Dictionary.Dict;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Echo_Accumulator,
--# ErrorBuffer.Buffer from * &
--# Error_Context_Rec from SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec;
is
Err_File : Error_IO.File_Type := Error_IO.Null_File;
Unused : SPARK_IO.File_Status;
New_Context : Error_Contexts;
begin
--# accept Flow, 10, Unused, "Design decision not to check file status";
Error_IO.Create (File => Err_File,
Status => Unused);
--# end accept;
New_Context.Errs := Err_File;
New_Context.Line_No := 0;
New_Context.Num_Errs := 0;
New_Context.Num_Message := 0;
New_Context.Severity := No_Error;
New_Context.Source_File_Name := E_Strings.Empty_String;
New_Context.Recovery_Messages := False;
New_Context.Echo := False; --Echo;
New_Context.Current_Line := E_Strings.Empty_String;
New_Context.Counter := Counters'(others => 0);
New_Context.Source := SPARK_IO.Null_File;
New_Context.Justifications_Data_Table := Empty_Justifications_Data_Table;
--# accept Flow, 10, Error_Context_Rec, "Flush changes buffer but we need to initialize it anyway";
Flush_Buffer;
--# end accept;
Error_Context_Rec := New_Context;
Flush_Echo_Messages;
--# accept Flow, 33, Unused, "Consequence of earlier deliberate non-use";
end Spark_Make_Init;
-----------------------------------------------------------------------------
procedure Get_Error_Context (Context : out Error_Contexts)
--# global in Dictionary.Dict;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Context,
--# Error_Context_Rec from ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys &
--# Echo_Accumulator,
--# ErrorBuffer.Buffer from * &
--# SPARK_IO.File_Sys from *,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec;
is
Source_File : SPARK_IO.File_Type;
Success : SPARK_IO.File_Status;
begin
Flush_Buffer;
Source_File := Error_Context_Rec.Source;
--# accept Flow, 10, Success, "Intentional non use of file return code";
SPARK_IO.Close (Source_File, Success);
--# end accept;
Error_Context_Rec.Source := Source_File;
Context := Error_Context_Rec;
Flush_Echo_Messages;
--# accept Flow, 33, Success, "Consequence of earlier non-use";
end Get_Error_Context;
-----------------------------------------------------------------------------
procedure Set_Error_Context (Context : in Error_Contexts)
--# global in Dictionary.Dict;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Echo_Accumulator,
--# ErrorBuffer.Buffer from * &
--# Error_Context_Rec from *,
--# Context,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# SPARK_IO.File_Sys &
--# SPARK_IO.File_Sys from *,
--# Context,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec;
is
Success : SPARK_IO.File_Status;
Source_File : SPARK_IO.File_Type;
begin
--# accept Flow, 10, Error_Context_Rec, "Flush changes buffer but we need to initialize it anyway";
Flush_Buffer;
--# end accept;
Error_Context_Rec := Context;
Source_File := Error_Context_Rec.Source;
--# accept Flow, 10, Success, "Intentional non use of file return code";
FileSystem.Open_Source_File (File => Source_File,
Name => Error_Context_Rec.Source_File_Name,
Status => Success);
--# end accept;
Error_Context_Rec.Source := Source_File;
Error_Context_Rec.Line_No := 0;
Error_Context_Rec.Current_Line := E_Strings.Empty_String;
Flush_Echo_Messages;
--# accept Flow, 33, Success, "Consequence of earlier non-use";
end Set_Error_Context;
-----------------------------------------------------------------------------
procedure Error_Reset
--# global in out Error_Context_Rec;
--# out Potential_Invalid_Value;
--# derives Error_Context_Rec from * &
--# Potential_Invalid_Value from ;
is
begin
Error_Context_Rec.Severity := No_Error;
Potential_Invalid_Value := False;
end Error_Reset;
-----------------------------------------------------------------------------
procedure Get_Error_Severity (Severity : out Error_Level)
--# global in Error_Context_Rec;
--# derives Severity from Error_Context_Rec;
is
begin
Severity := Error_Context_Rec.Severity;
end Get_Error_Severity;
---------------------------------------------------------------------------
function Syntax_Or_Semantic_Error return Boolean
--# global in Total_Error_Count;
is
begin
return Total_Error_Count.Explicit_Error_Count (Syntax_Or_Semantic) /= 0;
end Syntax_Or_Semantic_Error;
---------------------------------------------------------------------------
function Possibly_Invalid_Values return Boolean
--# global in Potential_Invalid_Value;
is
begin
return Potential_Invalid_Value;
end Possibly_Invalid_Values;
---------------------------------------------------------------------------
function Generate_SLI return Boolean
--# global in CommandLineData.Content;
--# in Stop_SLI;
is
begin
return CommandLineData.Content.Generate_SLI and then not Stop_SLI;
end Generate_SLI;
-----------------------------------------------------------------------------
procedure Report_Success
(Position : in LexTokenManager.Token_Position;
Subprog_Str : in LexTokenManager.Lex_String;
Err_Num : in Error_Types.ErrNumRange)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Subprog_Str &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# Subprog_Str &
--# Total_Error_Count from *;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Inc_Message_Count (Err_Type => Error_Types.NoErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.NoErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Subprog_Str),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
-- In "Brief" mode we don't echo success messages, since an
-- IDE like GPS would interpret them as "errors", which they
-- aren't!
if not CommandLineData.Content.Brief then
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Report_Success;
---------------------------------------------------------------------------
procedure Hidden_Text
(Position : in LexTokenManager.Token_Position;
Unit_Str : in LexTokenManager.Lex_String;
Unit_Typ : in SP_Symbols.SP_Symbol)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Unit_Str,
--# Unit_Typ,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# Unit_Str,
--# Unit_Typ,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => 10,
Identifiers => Null_Justification_Identifiers,
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if WarningStatus.Is_Suppressed (The_Element => Hidden_Parts) then
Inc_Suppressed_Warning_Counter (Warning_Type => Hidden_Parts);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithoutPosition);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithoutPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => 10,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Unit_Str),
Name2 => SP_Symbol_To_Name (Sym => Unit_Typ),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end if;
end Hidden_Text;
---------------------------------------------------------------------------
procedure Hidden_Handler
(Position : in LexTokenManager.Token_Position;
Unit_Str : in LexTokenManager.Lex_String;
Unit_Typ : in SP_Symbols.SP_Symbol)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Unit_Str,
--# Unit_Typ,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# Unit_Str,
--# Unit_Typ,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => 9,
Identifiers => Null_Justification_Identifiers,
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if WarningStatus.Is_Suppressed (The_Element => Handler_Parts) then
Inc_Suppressed_Warning_Counter (Warning_Type => Handler_Parts);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithoutPosition);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithoutPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => 9,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Unit_Str),
Name2 => SP_Symbol_To_Name (Sym => Unit_Typ),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end if;
end Hidden_Handler;
---------------------------------------------------------------------------
procedure Representation_Clause (Position : in LexTokenManager.Token_Position)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => 2,
Identifiers => Null_Justification_Identifiers,
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if WarningStatus.Is_Suppressed (The_Element => Representation_Clauses) then
Inc_Suppressed_Warning_Counter (Warning_Type => Representation_Clauses);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithPosition);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => 2,
Reference => No_Reference,
Name1 => Error_Types.NoName,
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end if;
end Representation_Clause;
---------------------------------------------------------------------------
procedure A_Pragma (Pragma_Name : in LexTokenManager.Lex_String;
Position : in LexTokenManager.Token_Position)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Pragma_Name,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Pragma_Name,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Pragma_Name,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => 3,
Identifiers => Null_Justification_Identifiers,
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if WarningStatus.Pragma_Is_Suppressed (Pragma_Name => Pragma_Name) then
Inc_Suppressed_Warning_Counter (Warning_Type => Pragmas);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithPosition);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => 3,
Reference => No_Reference,
Name1 => Error_Types.NoName,
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end if;
end A_Pragma;
--------------------------------------------------------------------------
procedure Add_Cut_Point (At_Line : LexTokenManager.Line_Numbers)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# At_Line,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from At_Line,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
if WarningStatus.Is_Suppressed (The_Element => Default_Loop_Assertions) then
Inc_Suppressed_Warning_Counter (Warning_Type => Default_Loop_Assertions);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithoutPosition);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithoutPosition,
Pos => LexTokenManager.Token_Position'(Start_Line_No => At_Line,
Start_Pos => 0),
Scope => Dictionary.GlobalScope,
Error_Number => 402,
Reference => No_Reference,
Name1 => Error_Types.NoName,
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Add_Cut_Point;
--------------------------------------------------------------------------
procedure Semantic_Warning_With_Position
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Sym,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Sym,
--# WarningStatus.SuppressionList &
--# Potential_Invalid_Value from *,
--# CommandLineData.Content,
--# Err_Num,
--# Sym,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Err_Num,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
if Err_Num = 1 and then WarningStatus.Is_Suppressed (The_Element => With_Clauses) then
Inc_Suppressed_Warning_Counter (Warning_Type => With_Clauses);
elsif Err_Num = 4 and then WarningStatus.Is_Suppressed (The_Element => Declare_Annotations) then
Inc_Suppressed_Warning_Counter (Warning_Type => Declare_Annotations);
elsif Err_Num = 5 and then WarningStatus.Is_Suppressed (The_Element => Interrupt_Handlers) then
Inc_Suppressed_Warning_Counter (Warning_Type => Interrupt_Handlers);
elsif Err_Num = 7 and then WarningStatus.Is_Suppressed (The_Element => Ada2005_Reserved_Words) then
Inc_Suppressed_Warning_Counter (Warning_Type => Ada2005_Reserved_Words);
elsif Err_Num = 11 and then WarningStatus.Is_Suppressed (The_Element => Others_Clauses) then
Inc_Suppressed_Warning_Counter (Warning_Type => Others_Clauses);
elsif Err_Num = 12 and then WarningStatus.Is_Suppressed (The_Element => Unchecked_Conversion) then
Inc_Suppressed_Warning_Counter (Warning_Type => Unchecked_Conversion);
elsif Err_Num = 169 and then WarningStatus.Is_Suppressed (The_Element => Direct_Updates) then
Inc_Suppressed_Warning_Counter (Warning_Type => Direct_Updates);
elsif (Err_Num = 200 or Err_Num = 201) and then WarningStatus.Is_Suppressed (The_Element => Static_Expressions) then
Inc_Suppressed_Warning_Counter (Warning_Type => Static_Expressions);
elsif Err_Num = 302
and then not CommandLineData.Content.VCG
and then WarningStatus.Is_Suppressed (The_Element => Expression_Reordering) then
-- Suppress ambiguous ordering message if not
-- generating VCs for Overflow_Check
Inc_Suppressed_Warning_Counter (Warning_Type => Expression_Reordering);
elsif Err_Num = 309 and then WarningStatus.Is_Suppressed (The_Element => Type_Conversions) then
Inc_Suppressed_Warning_Counter (Warning_Type => Type_Conversions);
elsif Err_Num = 310 and then WarningStatus.Is_Suppressed (The_Element => Obsolescent_Features) then
Inc_Suppressed_Warning_Counter (Warning_Type => Obsolescent_Features);
elsif Err_Num = 320 and then WarningStatus.Is_Suppressed (The_Element => Proof_Function_Non_Boolean) then
Inc_Suppressed_Warning_Counter (Warning_Type => Proof_Function_Non_Boolean);
elsif Err_Num = 321 and then WarningStatus.Is_Suppressed (The_Element => Proof_Function_Implicit) then
Inc_Suppressed_Warning_Counter (Warning_Type => Proof_Function_Implicit);
elsif (Err_Num = 322 or Err_Num = 323) and then WarningStatus.Is_Suppressed (Proof_Function_Refinement) then
Inc_Suppressed_Warning_Counter (Warning_Type => Proof_Function_Refinement);
elsif Err_Num = 350 and then WarningStatus.Is_Suppressed (The_Element => Imported_Objects) then
Inc_Suppressed_Warning_Counter (Warning_Type => Imported_Objects);
elsif Err_Num = 392 and then WarningStatus.Is_Suppressed (The_Element => External_Variable_Assignment) then
Inc_Suppressed_Warning_Counter (Warning_Type => External_Variable_Assignment);
elsif Err_Num = 394 and then WarningStatus.Is_Suppressed (The_Element => Unuseable_Private_Types) then
Inc_Suppressed_Warning_Counter (Warning_Type => Unuseable_Private_Types);
-- following two separate warnings share the same supression key word
elsif Err_Num = 396
and then -- non-moded variable with address clause
WarningStatus.Is_Suppressed (The_Element => Unexpected_Address_Clauses) then
Inc_Suppressed_Warning_Counter (Warning_Type => Unexpected_Address_Clauses);
elsif Err_Num = 351
and then -- constant with address clause
WarningStatus.Is_Suppressed (The_Element => Unexpected_Address_Clauses) then
Inc_Suppressed_Warning_Counter (Warning_Type => Unexpected_Address_Clauses);
elsif Err_Num = 380 and then WarningStatus.Is_Suppressed (The_Element => Style_Check_Casing) then
Inc_Suppressed_Warning_Counter (Warning_Type => Style_Check_Casing);
else
if Err_Num = 399 then
--special case, although just a warning we want this to suppress flow analysis
Error_Context_Rec.Severity := Semantic_Errs;
end if;
Inc_Message_Count (Err_Type => Error_Types.WarningWithPosition);
File := Error_Context_Rec.Errs;
if Dictionary.Is_Null_Symbol (Sym) then
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
else
Potential_Invalid_Value := Potential_Invalid_Value
or else Err_Num = 392 -- Read of an external variable
or else Err_Num = 12; -- Use of an unchecked conversion
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithPosition,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
end if;
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Semantic_Warning_With_Position;
procedure Semantic_Warning_Without_Position
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Sym,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Sym,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# Err_Num,
--# WarningStatus.SuppressionList;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
if Err_Num = 400 and then WarningStatus.Is_Suppressed (The_Element => Unused_Variables) then
Inc_Suppressed_Warning_Counter (Warning_Type => Unused_Variables);
elsif Err_Num = 403 and then WarningStatus.Is_Suppressed (The_Element => Constant_Variables) then
Inc_Suppressed_Warning_Counter (Warning_Type => Constant_Variables);
elsif Err_Num = 405 and then WarningStatus.Is_Suppressed (The_Element => Real_RTCs) then
Inc_Suppressed_Warning_Counter (Warning_Type => Real_RTCs);
elsif Err_Num = 430 and then WarningStatus.Is_Suppressed (The_Element => SLI_Generation) then
Inc_Suppressed_Warning_Counter (Warning_Type => SLI_Generation);
elsif Err_Num = 431 and then WarningStatus.Is_Suppressed (The_Element => Main_Program_Precondition) then
Inc_Suppressed_Warning_Counter (Warning_Type => Main_Program_Precondition);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithoutPosition);
File := Error_Context_Rec.Errs;
if Dictionary.Is_Null_Symbol (Sym) then
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithoutPosition,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
else
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.WarningWithoutPosition,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
end if;
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Semantic_Warning_Without_Position;
function Is_Number_With_Position (Err_Num : in Natural) return Boolean is
begin
return Err_Num >= 1 and then Err_Num < 400;
end Is_Number_With_Position;
procedure Semantic_Warning
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList &
--# Potential_Invalid_Value,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList;
is
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => Err_Num,
Identifiers => Justification_Identifiers'(1 => Lex_Str_To_Justification_Identifier (Str => Id_Str),
others => Null_Justification_Identifier),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if Is_Number_With_Position (Err_Num => Err_Num) then
Semantic_Warning_With_Position
(Err_Num => Err_Num,
Position => Position,
Id_Str => Id_Str,
Sym => Dictionary.NullSymbol,
Scope => Dictionary.GlobalScope);
else
Semantic_Warning_Without_Position
(Err_Num => Err_Num,
Position => Position,
Id_Str => Id_Str,
Sym => Dictionary.NullSymbol,
Scope => Dictionary.GlobalScope);
end if;
end if;
end Semantic_Warning;
----------------------------------------------------------------------------------
procedure SLI_Generation_Warning (Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# Potential_Invalid_Value,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
begin
if Generate_SLI then
Stop_SLI := True;
Semantic_Warning (Err_Num => 430,
Position => Position,
Id_Str => Id_Str);
end if;
end SLI_Generation_Warning;
----------------------------------------------------------------------------------
procedure Semantic_Warning_Sym
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Sym,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Sym,
--# WarningStatus.SuppressionList &
--# Potential_Invalid_Value,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Sym,
--# WarningStatus.SuppressionList;
is
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Warning_Message,
Err_Num => Err_Num,
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Sym),
others => Null_Justification_Identifier),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
if Is_Number_With_Position (Err_Num => Err_Num) then
Semantic_Warning_With_Position
(Err_Num => Err_Num,
Position => Position,
Id_Str => LexTokenManager.Null_String,
Sym => Sym,
Scope => Scope);
else
Semantic_Warning_Without_Position
(Err_Num => Err_Num,
Position => Position,
Id_Str => LexTokenManager.Null_String,
Sym => Sym,
Scope => Scope);
end if;
end if;
end Semantic_Warning_Sym;
----------------------------------------------------------------------------------
procedure SLI_Generation_Warning_Sym
(Position : in LexTokenManager.Token_Position;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Stop_SLI,
--# Sym,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# WarningStatus.SuppressionList &
--# Potential_Invalid_Value,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Stop_SLI,
--# Sym,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
begin
if Generate_SLI then
Stop_SLI := True;
Semantic_Warning_Sym (Err_Num => 430,
Position => Position,
Sym => Sym,
Scope => Scope);
end if;
end SLI_Generation_Warning_Sym;
----------------------------------------------------------------------------------
-- Previously, LexErrors, SyntaxErrors and SyntaxRecovery didn't use
-- the error buffer mechanism and were written direct to the error
-- file. This meant that attempts to NOT store strings anywhere in the
-- error handler system were impossible. The three routines have been
-- altered below in an elegent bodge to use ErrorBuffer.Add.
-- The trick has been to build the error string as now but instead of storing
-- it, we convert it to a lex string, place it in parameter Name1 and then use
-- the ErrorBuffer.Add mechanism. This is not wasteful of LexTokenManager
-- storage space because these errors are fatal anyway.
--
-- The result is that all errors are added to the system via ErrorBuffer.Add
-- and remain in numeric form until PrintErrors or AppendErrors converst them.
procedure Lex_Error (Error_Message, Recovery_Message : in String;
Error_Item : in LexTokenManager.Lex_Value)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out LexTokenManager.State;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Error_Item,
--# Error_Message,
--# LexTokenManager.State,
--# Recovery_Message,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# LexTokenManager.State from *,
--# Error_Item,
--# Error_Message,
--# Recovery_Message &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
Error_Lex_String : LexTokenManager.Lex_String; --pna
begin
Error_Context_Rec.Severity := Fatal;
Error := Error_Types.StringError'(0, Error_Types.LexErr, Error_Item.Position, E_Strings.Empty_String);
Append_String (E_Str => Error,
Str => Error_Message);
Append_String (E_Str => Error,
Str => " - ");
Append_String (E_Str => Error,
Str => Recovery_Message);
Append_String (E_Str => Error,
Str => ".");
-- convert string to LexString so we can use ErrorBuffer.Add
LexTokenManager.Insert_Examiner_String (Str => Error.Message,
Lex_Str => Error_Lex_String);
Inc_Message_Count (Err_Type => Error_Types.LexErr);
ErrorBuffer.Add
(Err_File => Error_Context_Rec.Errs,
Err_Type => Error_Types.LexErr,
Pos => Error_Item.Position,
Scope => Dictionary.GlobalScope,
Error_Number => 0,
Reference => 0,
Name1 => Lex_String_To_Name (Str => Error_Lex_String),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Error_Item.Position,
Id_Str => Error_Lex_String);
end Lex_Error;
--------------------------------------------------------------------------
procedure Syntax_Error
(Error_Item : in LexTokenManager.Lex_Value;
Current_Sym, Entry_Symbol : in SP_Symbols.SP_Symbol;
No_Of_Terminals, No_Of_Non_Terminals : in SP_Expected_Symbols.SP_Ess_Sym_Range;
Terminal_List, Non_Terminal_List : in SP_Expected_Symbols.SP_Exp_Sym_List)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out LexTokenManager.State;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Current_Sym,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# Entry_Symbol,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Error_Item,
--# LexTokenManager.State,
--# Non_Terminal_List,
--# No_Of_Non_Terminals,
--# No_Of_Terminals,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Terminal_List,
--# WarningStatus.SuppressionList &
--# LexTokenManager.State from *,
--# Current_Sym,
--# Entry_Symbol,
--# Error_Item,
--# Non_Terminal_List,
--# No_Of_Non_Terminals,
--# No_Of_Terminals,
--# Terminal_List &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
Error_Lex_String : LexTokenManager.Lex_String; --pna
procedure Append_Sym_List
(Error : in out Error_Types.StringError;
No_In_List : in SP_Expected_Symbols.SP_Ess_Sym_Range;
List : in SP_Expected_Symbols.SP_Exp_Sym_List;
Last_Sep : in String)
--# derives Error from *,
--# Last_Sep,
--# List,
--# No_In_List;
is
begin
AppendSym (Error => Error,
Sym => List (1));
for I in SP_Expected_Symbols.SP_Ess_Sym_Range range 2 .. No_In_List - 1 loop
Append_String (E_Str => Error,
Str => ", ");
AppendSym (Error => Error,
Sym => List (I));
end loop;
if No_In_List > 1 then
Append_String (E_Str => Error,
Str => Last_Sep);
AppendSym (Error => Error,
Sym => List (No_In_List));
end if;
end Append_Sym_List;
procedure Append_Hint
--# global in Current_Sym;
--# in Entry_Symbol;
--# in Non_Terminal_List;
--# in No_Of_Non_Terminals;
--# in No_Of_Terminals;
--# in Terminal_List;
--# in out Error;
--# derives Error from *,
--# Current_Sym,
--# Entry_Symbol,
--# Non_Terminal_List,
--# No_Of_Non_Terminals,
--# No_Of_Terminals,
--# Terminal_List;
is
procedure Dump_State
--# derives ;
is
--# hide Dump_State;
begin
if CommandLineData.Content.Debug.Parser then
Debug.PrintMsg ("In ErrorHandler.Syntax_Error.Append_Hint we know:", True);
Debug.PrintInt ("The Number of Terminals is ", Integer (No_Of_Terminals));
Debug.PrintMsg ("The Terminal List is:", True);
for TLI in SP_Expected_Symbols.SP_Ess_Sym_Range range 1 .. No_Of_Terminals loop
Debug.PrintMsg (SP_Symbols.SP_Symbol'Image (Terminal_List (TLI)), False);
Debug.PrintMsg (" ", False);
end loop;
Debug.PrintMsg ("", True);
Debug.PrintInt ("The Number of Non-Terminals is ", Integer (No_Of_Non_Terminals));
Debug.PrintMsg ("The Non-Terminal List is:", True);
for NTLI in SP_Expected_Symbols.SP_Ess_Sym_Range range 1 .. No_Of_Non_Terminals loop
Debug.PrintMsg (SP_Symbols.SP_Symbol'Image (Non_Terminal_List (NTLI)), False);
Debug.PrintMsg (" ", False);
end loop;
Debug.PrintMsg ("", True);
Debug.PrintMsg ("The Entry Symbol:", False);
Debug.PrintMsg (SP_Symbols.SP_Symbol'Image (Entry_Symbol), True);
Debug.PrintMsg ("The Current Symbol:", False);
Debug.PrintMsg (SP_Symbols.SP_Symbol'Image (Current_Sym), True);
Debug.Print_Lex_Str (Msg => "The current lex token is:",
L => Error_Item.Token_Str);
end if;
end Dump_State;
begin
Dump_State;
---------------------------------------------------------------------
-- Hints for special cases
--
-- Here, we search for known special cases where we can give
-- a more informative error message than that generated by the parser
-- alone. In detecting these special cases, take great care to find
-- _exactly_ the case you're expecting, since issuing a hint which
-- is wrong is probably just as bad as not issuing the hint at all!
--
-- This is a bit of a kludge - the long-term solution is to
-- re-implement the parser generator to produce better errors in
-- general.
---------------------------------------------------------------------
if No_Of_Terminals = 0 and No_Of_Non_Terminals = 1 then
---------------------------------------------------------------------
-- Case 1 - A protected type definition where the user forgets to
-- put a Priority pragma. This is likely to be a common mistake for
-- beginner RavenSPARK users, so giving a more informative error here
-- is important.
---------------------------------------------------------------------
if (Non_Terminal_List (1) = SP_Symbols.protected_definition) and
(Current_Sym = SP_Symbols.RWprocedure or Current_Sym = SP_Symbols.RWentry or Current_Sym = SP_Symbols.RWfunction)
then
Append_String (E_Str => Error,
Str => " Pragma Priority or Interrupt_Priority is required here.");
---------------------------------------------------------------------
-- Case 2 - Nested procedure body has unexpected semicolon. Can be
-- legal if followed by a pragma Import, but definitely wrong if
-- followed by "is".
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.apragma) and
(Current_Sym = SP_Symbols.RWis) and
(Entry_Symbol = SP_Symbols.procedure_annotation) then
Append_String (E_Str => Error,
Str => " Unexpected semicolon on preceding procedure specification.");
---------------------------------------------------------------------
-- Case 11 - A comma has been used instead of a semicolon prior to
-- an "IN" in a moded global definition.
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.global_variable) and
(Current_Sym = SP_Symbols.RWin) and
(Entry_Symbol = SP_Symbols.comma) then
Append_String
(E_Str => Error,
Str => " A semicolon and not a comma should precede an ""IN"" in a moded global definition.");
---------------------------------------------------------------------
-- Case 15 - Empty parenthesis in a subprogram specification.
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.formal_part_rep) and
(Current_Sym = SP_Symbols.right_paren) and
(Entry_Symbol = SP_Symbols.left_paren) then
Append_String
(E_Str => Error,
Str => " A subprogram specification without parameters should not have parentheses.");
---------------------------------------------------------------------
-- Case 16 - Empty parenthesis in a subprogram call.
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.name_argument_list) and
(Current_Sym = SP_Symbols.right_paren) and
(Entry_Symbol = SP_Symbols.left_paren) then
Append_String (E_Str => Error,
Str => " A subprogram call without parameters should not have parentheses.");
---------------------------------------------------------------------
-- Case 18 - Formal parameter list starts with an FDL identifier
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.formal_part_rep) and
(Current_Sym = SP_Symbols.predefined_FDL_identifier) and
(Entry_Symbol = SP_Symbols.left_paren) then
Append_String (E_Str => Error,
Str => " This token is a predefined FDL identifier, ");
Append_String (E_Str => Error,
Str => "and therefore may not be used in this context.");
---------------------------------------------------------------------
-- Case 22 - Attempt to use unqualified array aggregate in annotation
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.annotation_expression) and
(Current_Sym = SP_Symbols.RWothers) and
(Entry_Symbol = SP_Symbols.left_paren) then
Append_String (E_Str => Error,
Str => " Aggregate expressions in annotations must always be qualified");
Append_String (E_Str => Error,
Str => " with a subtype mark.");
---------------------------------------------------------------------
-- Case 23 - "body" appears in package spec - almost certainly
-- owing to a mis-placed inherit annotation preceding package
-- body
---------------------------------------------------------------------
elsif (Non_Terminal_List (1) = SP_Symbols.dotted_simple_name) and
(Current_Sym = SP_Symbols.RWbody) and
(Entry_Symbol = SP_Symbols.RWpackage) then
Append_String (E_Str => Error,
Str => " Package body cannot follow inherit annotation.");
end if;
elsif No_Of_Terminals = 1 and No_Of_Non_Terminals = 0 then
---------------------------------------------------------------------
-- Case 3 - misplaced "is" following procedure or function annotation
---------------------------------------------------------------------
if Terminal_List (1) = SP_Symbols.RWinherit and
(Current_Sym = SP_Symbols.RWglobal or Current_Sym = SP_Symbols.RWderives) then
Append_String (E_Str => Error,
Str => " Subprogram annotation should precede reserved word ""IS"".");
---------------------------------------------------------------------
-- Case 4 - Expecting Identifier, but got a predefined FDL identifier
-- A common error for beginners!
---------------------------------------------------------------------
elsif Terminal_List (1) = SP_Symbols.identifier and Current_Sym = SP_Symbols.predefined_FDL_identifier then
Append_String (E_Str => Error,
Str => " This token is a predefined FDL identifier, ");
Append_String (E_Str => Error,
Str => "and therefore may not be used in this context.");
---------------------------------------------------------------------
-- Case 9 - "own" annotation in package body following "is"
---------------------------------------------------------------------
elsif Terminal_List (1) = SP_Symbols.RWinherit and Current_Sym = SP_Symbols.RWown then
Append_String (E_Str => Error,
Str => " Own annotation should precede reserved word ""IS"".");
---------------------------------------------------------------------
-- Case 14 - Incorrect name given in hide directive
---------------------------------------------------------------------
elsif Terminal_List (1) = SP_Symbols.semicolon and Entry_Symbol = SP_Symbols.hidden_part then
Append_String (E_Str => Error,
Str => " The name in a preceding ""hide"" directive is probably incorrect.");
end if;
elsif No_Of_Terminals = 0 and No_Of_Non_Terminals = 0 then
---------------------------------------------------------------------
-- Case 5 - Misplaced "is" _before_ a mandatory annotation
---------------------------------------------------------------------
if Current_Sym = SP_Symbols.annotation_start and Entry_Symbol = SP_Symbols.RWis then
Append_String (E_Str => Error,
Str => " For packages and subprograms, annotations must ");
Append_String (E_Str => Error,
Str => "precede ""IS"".");
---------------------------------------------------------------------
-- Case 6 - semicolon missing at end of annotation
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.annotation_end and Entry_Symbol = SP_Symbols.dotted_simple_name then
Append_String (E_Str => Error,
Str => " Annotations must end with a ;");
---------------------------------------------------------------------
-- Case 10 - unexpected semicolon at end of subprogram specification
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.RWis and Entry_Symbol = SP_Symbols.semicolon then
Append_String (E_Str => Error,
Str => " Unexpected semicolon on preceding subprogram specification.");
---------------------------------------------------------------------
-- Case 12 - reported message is "No complete DOTTED_SIMPLE_NAME can be followed by IDENTIFIER here,"
-- Rockwell-Collins raised candidate for improvement in relation to
-- imports in derives annotations but the possible occurance of the
-- syntax error is much wider than this so we have to be careful with
-- the wording of the eror message.
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.identifier and Entry_Symbol = SP_Symbols.dotted_simple_name then
Append_String (E_Str => Error,
Str => " A separator is missing between two successive names.");
---------------------------------------------------------------------
-- Case 17 - declaration of an object using an FDL identifier
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.predefined_FDL_identifier and
(Entry_Symbol = SP_Symbols.visible_part_rep or Entry_Symbol = SP_Symbols.initial_declarative_item_rep) then
Append_String (E_Str => Error,
Str => " This token is a predefined FDL identifier, ");
Append_String (E_Str => Error,
Str => "and therefore may not be used in this context.");
---------------------------------------------------------------------
-- Case 19 - Attempt to label a declaration
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.left_label_paren and
(Entry_Symbol = SP_Symbols.initial_declarative_item_rep or Entry_Symbol = SP_Symbols.RWis) then
Append_String (E_Str => Error,
Str => " Declarations may not be labelled.");
---------------------------------------------------------------------
-- Case 20 - Attempt to label a proof context
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.proof_context and Entry_Symbol = SP_Symbols.sequence_of_labels then
Append_String (E_Str => Error,
Str => " Annotations may not be labelled.");
---------------------------------------------------------------------
-- Case 21 - Attempt to use unqualified aggregate expression
---------------------------------------------------------------------
elsif Current_Sym = SP_Symbols.arrow and Entry_Symbol = SP_Symbols.simple_expression then
Append_String (E_Str => Error,
Str => " Aggregate expressions must be qualified with a");
Append_String (E_Str => Error,
Str => " subtype mark or must specify an unconstrained");
Append_String (E_Str => Error,
Str => " array with only an others choice. Named and");
Append_String (E_Str => Error,
Str => " positional association may not be mixed.");
---------------------------------------------------------------------
-- Cases 24 and 25 - type, subtype, or object following a later declarative item
---------------------------------------------------------------------
elsif Entry_Symbol = SP_Symbols.later_declarative_item_rep then
if (Current_Sym = SP_Symbols.RWsubtype or Current_Sym = SP_Symbols.RWtype) then
Append_String (E_Str => Error,
Str => " Types and subtypes must precede all later declarative items");
Append_String (E_Str => Error,
Str => " such as bodies, stubs or instantiations.");
elsif (Current_Sym = SP_Symbols.identifier) then
Append_String (E_Str => Error,
Str => " Object declarations must precede all later declarative items");
Append_String (E_Str => Error,
Str => " such as bodies, stubs or instantiations.");
end if;
end if;
elsif No_Of_Terminals = 4 and No_Of_Non_Terminals = 0 then
---------------------------------------------------------------------
-- Case 7 - missing ; on the end of an own variable annotation
---------------------------------------------------------------------
if Entry_Symbol = SP_Symbols.own_variable_list and
Current_Sym = SP_Symbols.annotation_end and
Terminal_List (1) = SP_Symbols.left_paren and
Terminal_List (2) = SP_Symbols.comma and
Terminal_List (3) = SP_Symbols.colon and
Terminal_List (4) = SP_Symbols.semicolon then
Append_String (E_Str => Error,
Str => " Own variable annotation must end with a ;");
end if;
elsif No_Of_Terminals = 2 and No_Of_Non_Terminals = 0 then
---------------------------------------------------------------------
-- Case 8 - missing ; on the end of an initializes annotation
---------------------------------------------------------------------
if Entry_Symbol = SP_Symbols.package_variable_list and
Current_Sym = SP_Symbols.annotation_end and
Terminal_List (1) = SP_Symbols.comma and
Terminal_List (2) = SP_Symbols.semicolon then
Append_String (E_Str => Error,
Str => " Initializes annotation must end with a ;");
end if;
---------------------------------------------------------------------
-- Case 13 - derives list applied to a function
-- From the SPARK.LLA grammar, The two expected terminal symbols
-- RWpre and RWreturn can only occur together in an annotation
-- as a function constraint so we should be safe to assume that we
-- are in an annotation associated with a function.
---------------------------------------------------------------------
if Entry_Symbol = SP_Symbols.annotation_start and
Current_Sym = SP_Symbols.RWderives and
Terminal_List (1) = SP_Symbols.RWpre and
Terminal_List (2) = SP_Symbols.RWreturn then
Append_String
(E_Str => Error,
Str => " A function never has a ""derives"" annotation." &
" It may have a global definition in which all the global variables are of mode in.");
end if;
end if;
end Append_Hint; -- Terminal_List not ref at the moment, but likely to be needed in future.
begin
Error_Context_Rec.Severity := Fatal;
Error :=
Error_Types.StringError'(0, Error_Types.SyntaxErr, Error_Item.Position, E_Strings.Empty_String);
if No_Of_Terminals /= 0 and No_Of_Non_Terminals = 0 then
Append_Sym_List (Error => Error,
No_In_List => No_Of_Terminals,
List => Terminal_List,
Last_Sep => " or ");
Append_String (E_Str => Error,
Str => " expected");
elsif No_Of_Terminals = 0 and No_Of_Non_Terminals = 1 then
Append_String (E_Str => Error,
Str => "No ");
Append_Sym_List (Error => Error,
No_In_List => No_Of_Non_Terminals,
List => Non_Terminal_List,
Last_Sep => " nor ");
Append_String (E_Str => Error,
Str => " can start with ");
AppendSym (Error => Error,
Sym => Current_Sym);
elsif No_Of_Terminals = 0 and No_Of_Non_Terminals > 1 then
Append_String (E_Str => Error,
Str => "Neither ");
Append_Sym_List (Error => Error,
No_In_List => No_Of_Non_Terminals,
List => Non_Terminal_List,
Last_Sep => " nor ");
Append_String (E_Str => Error,
Str => " can start with ");
AppendSym (Error => Error,
Sym => Current_Sym);
elsif No_Of_Terminals /= 0 and No_Of_Non_Terminals /= 0 then
Append_Sym_List (Error => Error,
No_In_List => No_Of_Terminals,
List => Terminal_List,
Last_Sep => ", ");
Append_String (E_Str => Error,
Str => " or start of ");
Append_Sym_List (Error => Error,
No_In_List => No_Of_Non_Terminals,
List => Non_Terminal_List,
Last_Sep => " or ");
Append_String (E_Str => Error,
Str => " expected");
else
if SP_Relations.SP_Terminal_Like (Entry_Symbol) then
AppendSym (Error => Error,
Sym => Entry_Symbol);
Append_String (E_Str => Error,
Str => " cannot be followed by ");
else
Append_String (E_Str => Error,
Str => "No complete ");
AppendSym (Error => Error,
Sym => Entry_Symbol);
Append_String (E_Str => Error,
Str => " can be followed by ");
end if;
AppendSym (Error => Error,
Sym => Current_Sym);
Append_String (E_Str => Error,
Str => " here");
end if;
Append_String (E_Str => Error,
Str => ".");
Append_Hint;
-- convert string to LExString so we can use ErrorBuffer.Add
LexTokenManager.Insert_Examiner_String (Str => Error.Message,
Lex_Str => Error_Lex_String);
Inc_Message_Count (Err_Type => Error_Types.SyntaxErr);
ErrorBuffer.Add
(Err_File => Error_Context_Rec.Errs,
Err_Type => Error_Types.SyntaxErr,
Pos => Error_Item.Position,
Scope => Dictionary.GlobalScope,
Error_Number => 0,
Reference => 0,
Name1 => Lex_String_To_Name (Str => Error_Lex_String),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Error_Item.Position,
Id_Str => Error_Lex_String);
end Syntax_Error;
---------------------------------------------------------------------------
procedure Syntax_Recovery
(Recovery_Posn : in LexTokenManager.Lex_Value;
Replacement_Sym : in SP_Symbols.SP_Symbol;
Next_Sym : in SP_Symbols.SP_Terminal;
No_Of_Syms : in Natural;
Sym_List : in Err_Sym_List)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out LexTokenManager.State;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer,
--# Potential_Invalid_Value,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Next_Sym,
--# No_Of_Syms,
--# Recovery_Posn,
--# Replacement_Sym,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym_List,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Next_Sym,
--# No_Of_Syms,
--# Recovery_Posn,
--# Replacement_Sym,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym_List,
--# WarningStatus.SuppressionList &
--# LexTokenManager.State from *,
--# Error_Context_Rec,
--# Next_Sym,
--# No_Of_Syms,
--# Recovery_Posn,
--# Replacement_Sym,
--# Sym_List &
--# Stop_SLI from *,
--# CommandLineData.Content,
--# Error_Context_Rec;
is
Error, Unused_Error : Error_Types.StringError;
Error_Lex_String : LexTokenManager.Lex_String;
Max_Index : Err_Sym_Range;
begin
if Error_Context_Rec.Recovery_Messages then
Error := Error_Types.StringError'(0, Error_Types.SyntaxRec, Recovery_Posn.Position, E_Strings.Empty_String);
Append_String (E_Str => Error,
Str => "The recovery action was to ");
if Replacement_Sym = SP_Symbols.SPDEFAULT then
Append_String (E_Str => Error,
Str => "delete ");
AppendSym (Error => Error,
Sym => Sym_List (1));
elsif Replacement_Sym in SP_Symbols.SP_Terminal then
if No_Of_Syms = 0 then
Append_String (E_Str => Error,
Str => "insert ");
else
Append_String (E_Str => Error,
Str => "replace ");
AppendSym (Error => Error,
Sym => Sym_List (1));
Append_String (E_Str => Error,
Str => " with ");
end if;
AppendSym (Error => Error,
Sym => Replacement_Sym);
else
if Next_Sym /= SP_Symbols.SPDEFAULT then
if Next_Sym = SP_Symbols.SPEND then
Append_String (E_Str => Error,
Str => "ignore all remaining tokens and ");
else
Append_String (E_Str => Error,
Str => "ignore all tokens up until ");
AppendSym (Error => Error,
Sym => Next_Sym);
Append_String (E_Str => Error,
Str => " and ");
end if;
end if;
if No_Of_Syms /= 0 then
Append_String (E_Str => Error,
Str => "replace ");
if No_Of_Syms > Natural (Err_Sym_List'Last) then
Max_Index := Err_Sym_List'Last - 1;
else
Max_Index := Err_Sym_Range (No_Of_Syms);
end if;
for Index in Err_Sym_Range range 1 .. Max_Index loop
AppendSym (Error => Error,
Sym => Sym_List (Index));
Append_String (E_Str => Error,
Str => " ");
end loop;
if No_Of_Syms > Natural (Err_Sym_List'Last) then
Append_String (E_Str => Error,
Str => " .. ");
AppendSym (Error => Error,
Sym => Sym_List (Err_Sym_List'Last));
end if;
Append_String (E_Str => Error,
Str => " by ");
else
Append_String (E_Str => Error,
Str => "insert ");
end if;
AppendSym (Error => Error,
Sym => Replacement_Sym);
end if;
Append_String (E_Str => Error,
Str => ".");
-- convert string to LexString so we can use ErrorBuffer.Add
LexTokenManager.Insert_Examiner_String (Str => Error.Message,
Lex_Str => Error_Lex_String);
Inc_Message_Count (Err_Type => Error_Types.SyntaxRec);
--# accept Flow, 10, Unused_Error, "Only used where we want to echo message to screen";
ErrorBuffer.Add
(Err_File => Error_Context_Rec.Errs,
Err_Type => Error_Types.SyntaxRec,
Pos => Recovery_Posn.Position,
Scope => Dictionary.GlobalScope,
Error_Number => 0,
Reference => 0,
Name1 => Lex_String_To_Name (Str => Error_Lex_String),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Unused_Error);
--# end accept;
-- note, no echo back to screen in this case
SLI_Generation_Warning (Position => Recovery_Posn.Position,
Id_Str => Error_Lex_String);
end if;
--# accept Flow, 33, Unused_Error, "Consequence of earlier deliberate non-use";
end Syntax_Recovery;
-------------------------------------------------------------------------
procedure Semantic_Note
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# WarningStatus.SuppressionList &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList &
--# Total_Error_Count from *,
--# WarningStatus.SuppressionList;
is
File : Error_IO.File_Type;
Error : Error_Types.StringError;
begin
if WarningStatus.Is_Suppressed (The_Element => Notes) then
Inc_Suppressed_Warning_Counter (Warning_Type => Notes);
else
Inc_Message_Count (Err_Type => Error_Types.Note);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.Note,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Semantic_Note;
--------------------------------------------------------------------------
procedure Dep_Semantic_Error
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str1 : in LexTokenManager.Lex_String;
Id_Str2 : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# Id_Str1,
--# Id_Str2,
--# LexTokenManager.State,
--# Position &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str1,
--# Id_Str2,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys &
--# Total_Error_Count from *;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Inc_Message_Count (Err_Type => Error_Types.DepSemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.DepSemanticErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Lex_String_To_Name (Str => Id_Str1),
Name2 => Lex_String_To_Name (Str => Id_Str2),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end Dep_Semantic_Error;
---------------------------------------------------------------------------
procedure Dep_Semantic_Error_Sym
(Err_Num : in Natural;
Position : in LexTokenManager.Token_Position;
Sym1 : in Dictionary.Symbol;
Sym2 : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State from *,
--# CommandLineData.Content,
--# ErrorBuffer.Buffer,
--# Err_Num,
--# Position,
--# Scope,
--# Sym1,
--# Sym2 &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Sym1,
--# Sym2 &
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Err_Num,
--# Position,
--# Scope,
--# Sym1,
--# Sym2 &
--# Total_Error_Count from *;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Inc_Message_Count (Err_Type => Error_Types.DepSemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.DepSemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Sym1),
Name2 => Symbol_To_Name (Sym => Sym2),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end Dep_Semantic_Error_Sym;
---------------------------------------------------------------------------
procedure Semantic_Error
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Error_Context_Rec.Severity := Semantic_Errs;
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Position,
Id_Str => Id_Str);
end Semantic_Error;
---------------------------------------------------------------------------
procedure Semantic_Error2
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str1 : in LexTokenManager.Lex_String;
Id_Str2 : in LexTokenManager.Lex_String)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str1,
--# Id_Str2,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Lex_String_To_Name (Str => Id_Str1),
Name2 => Lex_String_To_Name (Str => Id_Str2),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Position,
Id_Str => Id_Str1);
end Semantic_Error2;
---------------------------------------------------------------------------
procedure Semantic_Error_Sym
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Symbol_To_Name (Sym => Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning_Sym (Position => Position,
Sym => Sym,
Scope => Scope);
end Semantic_Error_Sym;
---------------------------------------------------------------------------
procedure Semantic_Error_Sym2
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Sym : in Dictionary.Symbol;
Sym2 : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# Sym2,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Symbol_To_Name (Sym => Sym),
Name2 => Symbol_To_Name (Sym => Sym2),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning_Sym (Position => Position,
Sym => Sym,
Scope => Scope);
end Semantic_Error_Sym2;
---------------------------------------------------------------------------
procedure Semantic_Error_Lex1_Sym1
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String;
Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Symbol_To_Name (Sym => Sym),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Position,
Id_Str => Id_Str);
end Semantic_Error_Lex1_Sym1;
---------------------------------------------------------------------------
procedure Semantic_Error_Lex1_Sym2
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Id_Str : in LexTokenManager.Lex_String;
Sym : in Dictionary.Symbol;
Sym2 : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# Id_Str,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# Sym2,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Lex_String_To_Name (Str => Id_Str),
Name2 => Symbol_To_Name (Sym => Sym),
Name3 => Symbol_To_Name (Sym => Sym2),
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning (Position => Position,
Id_Str => Id_Str);
end Semantic_Error_Lex1_Sym2;
---------------------------------------------------------------------------
procedure Semantic_Error_Sym3
(Err_Num : in Natural;
Reference : in Natural;
Position : in LexTokenManager.Token_Position;
Sym : in Dictionary.Symbol;
Sym2 : in Dictionary.Symbol;
Sym3 : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Stop_SLI;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Num,
--# LexTokenManager.State,
--# Position,
--# Reference,
--# Scope,
--# SPARK_IO.File_Sys,
--# Stop_SLI,
--# Sym,
--# Sym2,
--# Sym3,
--# WarningStatus.SuppressionList &
--# Stop_SLI from *,
--# CommandLineData.Content;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
Justifications.Set_Current_Unit_Has_Semantic_Errors (Which_Table => Error_Context_Rec.Justifications_Data_Table);
Error_Context_Rec.Severity := Semantic_Errs;
Inc_Message_Count (Err_Type => Error_Types.SemanticErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.SemanticErr,
Pos => Position,
Scope => Scope,
Error_Number => Err_Num,
Reference => Reference,
Name1 => Symbol_To_Name (Sym => Sym),
Name2 => Symbol_To_Name (Sym => Sym2),
Name3 => Symbol_To_Name (Sym => Sym3),
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
SLI_Generation_Warning_Sym (Position => Position,
Sym => Sym,
Scope => Scope);
end Semantic_Error_Sym3;
---------------------------------------------------------------------------
procedure Control_Flow_Error (Err_Type : in Control_Flow_Err_Type;
Position : in LexTokenManager.Token_Position)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Err_Type,
--# Position &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys &
--# Total_Error_Count from *;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
begin
-- Note, no justification check here, these are serious structural errors in the code
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondFlowErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.ControlFlowErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Control_Flow_Err_Type'Pos (Err_Type) + Error_Types.ControlFlowErrOffset,
Reference => No_Reference,
Name1 => Error_Types.NoName,
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end Control_Flow_Error;
-------------------------------------------------------------------------
procedure Data_Flow_Error
(Err_Type : in Data_Flow_Err_Type;
Position : in LexTokenManager.Token_Position;
Var_Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State from *,
--# CommandLineData.Content,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Var_Sym &
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Var_Sym;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
function Obtain_Error_Number (Err_Type : Data_Flow_Err_Type) return Natural is
Result : Natural;
begin
case Err_Type is
when Expn_Undefined | Stmt_Undefined | Invariant_Exp =>
Result := Data_Flow_Err_Type'Pos (Err_Type) + Error_Types.UncondFlowErrorOffset;
when Expn_May_Be_Undefined | Stmt_May_Be_Undefined =>
Result := Data_Flow_Err_Type'Pos (Err_Type) + Error_Types.CondFlowErrorOffset;
end case;
return Result;
end Obtain_Error_Number;
begin -- Data_Flow_Error
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => Obtain_Error_Number (Err_Type => Err_Type),
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Var_Sym),
others => Null_Justification_Identifier),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
File := Error_Context_Rec.Errs;
case Err_Type is
when Expn_Undefined | Stmt_Undefined | Invariant_Exp =>
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondFlowErr);
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.UncondFlowErr,
Pos => Position,
Scope => Scope,
Error_Number => Data_Flow_Err_Type'Pos (Err_Type) + Error_Types.UncondFlowErrorOffset,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Var_Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
when Expn_May_Be_Undefined | Stmt_May_Be_Undefined =>
Error_Context_Rec.Severity := Flow_Warning;
Inc_Message_Count (Err_Type => Error_Types.CondlFlowErr);
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.CondlFlowErr,
Pos => Position,
Scope => Scope,
Error_Number => Data_Flow_Err_Type'Pos (Err_Type) + Error_Types.CondFlowErrorOffset,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Var_Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
end case;
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Data_Flow_Error;
-------------------------------------------------------------------------
procedure Ineffective_Stmt
(Position : in LexTokenManager.Token_Position;
Var_Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State from *,
--# CommandLineData.Content,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Var_Sym &
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Position,
--# Var_Sym;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => 10,
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Var_Sym),
others => Null_Justification_Identifier),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondFlowErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.IneffectiveStat,
Pos => Position,
Scope => Scope,
Error_Number => 10,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Var_Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Ineffective_Stmt;
----------------------------------------------------------------------------
procedure Stability_Error
(Err_Type : in Stability_Err_Type;
Position : in LexTokenManager.Token_Position;
Stability_Index : in Index_Type)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Stability_Index &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# SPARK_IO.File_Sys,
--# Stability_Index &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => Stability_Err_Type'Pos (Err_Type) + Error_Types.StabilityErrOffset,
Identifiers => Null_Justification_Identifiers,
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondFlowErr);
File := Error_Context_Rec.Errs;
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.StabilityErr,
Pos => Position,
Scope => Dictionary.GlobalScope,
Error_Number => Stability_Err_Type'Pos (Err_Type) + Error_Types.StabilityErrOffset,
Reference => No_Reference,
Name1 => Error_Types.Names'(Name_Sort => Error_Types.StabilityIndex,
Name_Sym => Dictionary.NullSymbol,
Name_Str => LexTokenManager.Null_String,
Pos => Index_Type'Pos (Stability_Index)),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Stability_Error;
----------------------------------------------------------------------------
procedure Dependency_Error
(Err_Type : in Dependency_Err_Type;
Position : in LexTokenManager.Token_Position;
Import_Var_Sym : in Dictionary.Symbol;
Export_Var_Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State from *,
--# CommandLineData.Content,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# Export_Var_Sym,
--# Import_Var_Sym,
--# LexTokenManager.State,
--# Position,
--# Scope &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# Export_Var_Sym,
--# Import_Var_Sym,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys &
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# Err_Type,
--# Export_Var_Sym,
--# Import_Var_Sym,
--# LexTokenManager.State,
--# Position,
--# Scope &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Type,
--# Export_Var_Sym,
--# Import_Var_Sym,
--# LexTokenManager.State,
--# Position;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
case Err_Type is
when Not_Used | Ineff_Init | Ineff_Local_Init | Policy_Violation =>
-- Unconditional error cases
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => Dependency_Err_Type'Pos (Err_Type) + Error_Types.UncondDependencyErrorOffset,
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Export_Var_Sym),
2 => Symbol_To_Justification_Identifier (Sym => Import_Var_Sym)),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
File := Error_Context_Rec.Errs;
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondDependencyErr);
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.UncondDependencyErr,
Pos => Position,
Scope => Scope,
Error_Number => Dependency_Err_Type'Pos (Err_Type) + Error_Types.UncondDependencyErrorOffset,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Import_Var_Sym),
Name2 => Symbol_To_Name (Sym => Export_Var_Sym),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
when May_Be_Used | Uninitialised | Integrity_Violation | May_Be_Integrity_Violation =>
-- Conditional error cases
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => Dependency_Err_Type'Pos (Err_Type) + Error_Types.CondDependencyErrorOffset,
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Export_Var_Sym),
2 => Symbol_To_Justification_Identifier (Sym => Import_Var_Sym)),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
File := Error_Context_Rec.Errs;
Error_Context_Rec.Severity := Flow_Warning;
Inc_Message_Count (Err_Type => Error_Types.CondlDependencyErr);
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.CondlDependencyErr,
Pos => Position,
Scope => Scope,
Error_Number => Dependency_Err_Type'Pos (Err_Type) + Error_Types.CondDependencyErrorOffset,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Import_Var_Sym),
Name2 => Symbol_To_Name (Sym => Export_Var_Sym),
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end case;
end Dependency_Error;
--------------------------------------------------------------------------
procedure Usage_Error
(Err_Type : in Usage_Err_Type;
Position : in LexTokenManager.Token_Position;
Var_Sym : in Dictionary.Symbol;
Scope : in Dictionary.Scopes)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State from *,
--# CommandLineData.Content,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Echo_Accumulator,
--# Error_Context_Rec,
--# SPARK_IO.File_Sys from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# SPARK_IO.File_Sys,
--# Var_Sym &
--# ErrorBuffer.Buffer from *,
--# CommandLineData.Content,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Scope,
--# Var_Sym &
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Error_Context_Rec,
--# Err_Type,
--# LexTokenManager.State,
--# Position,
--# Var_Sym;
is
Error : Error_Types.StringError;
File : Error_IO.File_Type;
Error_Is_Justified : Boolean;
begin
Justifications.Check_Whether_Justified
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Position,
Kind => Flow_Message,
Err_Num => Usage_Err_Type'Pos (Err_Type) + Error_Types.UsageErrOffset,
Identifiers => Justification_Identifiers'(1 => Symbol_To_Justification_Identifier (Sym => Var_Sym),
others => Null_Justification_Identifier),
Match_Found => Error_Is_Justified);
if Error_Is_Justified then
Inc_Total_Justified_Warnings;
else
File := Error_Context_Rec.Errs;
Error_Context_Rec.Severity := Flow_Errs;
Inc_Message_Count (Err_Type => Error_Types.UncondDependencyErr);
ErrorBuffer.Add
(Err_File => File,
Err_Type => Error_Types.UsageErr,
Pos => Position,
Scope => Scope,
Error_Number => Usage_Err_Type'Pos (Err_Type) + Error_Types.UsageErrOffset,
Reference => No_Reference,
Name1 => Symbol_To_Name (Sym => Var_Sym),
Name2 => Error_Types.NoName,
Name3 => Error_Types.NoName,
Echo_Str => Error);
Error_Context_Rec.Errs := File;
EchoErrorEntry (SPARK_IO.Standard_Output, Error);
end if;
end Usage_Error;
-----------------------------------------------------------------------------
procedure Put_Error_Pointers (Listing : in SPARK_IO.File_Type;
Errors : in Error_Sets)
--# global in CommandLineData.Content;
--# in Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Errors,
--# Error_Context_Rec,
--# Listing;
is
Err_Pos : Natural;
Last_Err_Pos : Natural;
Curr_Pos : Natural;
Err_Num : Positive;
First_One : Boolean;
function Width_Of (Err_Count : Natural) return Positive is
Size : Positive;
begin
if Err_Count < 10 then
Size := 1;
elsif Err_Count < 100 then
Size := 2;
elsif Err_Count < 1000 then
Size := 3;
else
Size := 4;
end if;
return Size;
end Width_Of;
begin
Last_Err_Pos := 0;
Curr_Pos := 0;
First_One := True;
--# assert True; -- for RTC generation
for I in Error_Set_Positions range 1 .. Errors.Length loop
--# assert True; -- for RTC generation
if Error_Has_Position_Inline (Err_Type => Errors.Content (I).Error.ErrorType) then
if First_One then
Put_Spaces (File => Listing,
N => Source_Line_Indent);
First_One := False;
end if;
Err_Pos := Errors.Content (I).Error.Position.Start_Pos;
if Err_Pos = 0 then
Err_Pos := 1;
end if;
--# assert True; -- for RTC generation
if Err_Pos = Last_Err_Pos then
Put_Char (File => Listing,
Item => ',');
else
if Curr_Pos > Err_Pos then
New_Line (File => Listing,
Spacing => 1);
Move_To_Indent
(Source_File => Listing,
Line => Error_Context_Rec.Current_Line,
Indent => Source_Line_Indent,
Position => Err_Pos - 1);
elsif Curr_Pos = 0 then
Move_To_Indent
(Source_File => Listing,
Line => Error_Context_Rec.Current_Line,
Indent => 0,
Position => Err_Pos - 1);
else
Put_Spaces (File => Listing,
N => Err_Pos - Curr_Pos);
end if;
Curr_Pos := Err_Pos;
Put_Char (File => Listing,
Item => '^');
end if;
Err_Num := Errors.Content (I).Err_Num;
--# accept Flow, 41, "Mode-specific code";
if CommandLineData.Content.Plain_Output then -- Expect stable condition
Curr_Pos := Curr_Pos + 1;
else
Put_Integer (File => Listing,
Item => Err_Num,
Width => Width_Of (Err_Count => Err_Num),
Base => 10);
Curr_Pos := (Curr_Pos + Width_Of (Err_Count => Err_Num)) + 1;
end if;
--# end accept;
Last_Err_Pos := Err_Pos;
end if;
end loop;
--# assert True; -- for RTC generation
if not First_One then
New_Line (File => Listing,
Spacing => 1);
end if;
end Put_Error_Pointers;
procedure Put_Error_Messages
(Listing : in SPARK_IO.File_Type;
Errors : in Error_Sets;
Start_Pos : in Natural;
Accumulator : in out ErrorAccumulator.T)
--# global in CommandLineData.Content;
--# in out SPARK_IO.File_Sys;
--# derives Accumulator from *,
--# Errors,
--# Start_Pos &
--# SPARK_IO.File_Sys from *,
--# Accumulator,
--# CommandLineData.Content,
--# Errors,
--# Listing,
--# Start_Pos;
is
The_Error : Error_Struct;
New_Start : Natural;
Started_Active : Boolean;
Indent : Natural;
Line_Length : Natural;
Explanation : E_Strings.T;
begin
Indent := 11;
Line_Length := Error_Line_Length;
for I in Error_Set_Positions range 1 .. Errors.Length loop
The_Error := Errors.Content (I);
Started_Active := ErrorAccumulator.Is_Active (This => Accumulator);
if ErrorAccumulator.Is_Active (This => Accumulator) then
ErrorAccumulator.Add
(This => Accumulator,
Error => The_Error,
End_Pos => Line_Length,
Indent => Indent,
Listing => Listing);
end if;
if not ErrorAccumulator.Is_Active (This => Accumulator) then
-- put a trailing blank line after compound messages.
if Started_Active then
New_Line (File => Listing,
Spacing => 2);
end if;
Output_Error_Marker
(File => Listing,
Err_Type => The_Error.Error.ErrorType,
Message_Id => The_Error.Error.MessageId,
Err_Count => The_Error.Err_Num);
if ErrorAccumulator.Is_Error_Start (The_Error => The_Error.Error) then
-- Message is of akind that will be "accumulated" before printing. We don't want
-- the explanation to appear over and over again, only once at the end of the completed
-- message. So we extract explanation from message here and pass it into ErrorAccumulator
-- where it is stored and appended to the error mesage when a later Flush operation is
-- performed.
Split_String_At_Explanation (E_Str => The_Error.Error.Message,
Explanation => Explanation);
PrintLine
(Listing => Listing,
Start_Pos => Start_Pos,
End_Pos => Line_Length,
Indent => Indent,
Line => The_Error.Error.Message,
Add_New_Line => False,
New_Start => New_Start);
ErrorAccumulator.Start_Msg
(This => Accumulator,
Start_Error => The_Error,
Start_Indent => New_Start,
Explanation => Explanation,
Line_Length => Line_Length,
Indent => Indent); -- in rather than recalculate them in error accumulator
else
-- leave message text unchanged and display it
--# accept Flow, 10, New_Start, "Returned parameter not needed in this case";
PrintLine
(Listing => Listing,
Start_Pos => Start_Pos,
End_Pos => Line_Length,
Indent => Indent,
Line => The_Error.Error.Message,
Add_New_Line => False,
New_Start => New_Start);
--# end accept;
-- Terminate message
New_Line (File => Listing,
Spacing => 1);
end if;
end if;
end loop;
end Put_Error_Messages;
procedure Put_Error_Messages_XML
(Listing : in SPARK_IO.File_Type;
Errors : in Error_Sets;
Start_Pos : in Natural;
Accumulator : in out ErrorAccumulator.T)
--# global in out SPARK_IO.File_Sys;
--# in out XMLReport.State;
--# derives Accumulator,
--# XMLReport.State from *,
--# Accumulator,
--# Errors,
--# Start_Pos &
--# SPARK_IO.File_Sys from *,
--# Accumulator,
--# Errors,
--# Listing,
--# Start_Pos,
--# XMLReport.State;
is
The_Error : Error_Struct;
New_Start : Natural;
Started_Active : Boolean;
Indent : Natural;
Line_Length : Natural;
Explanation : E_Strings.T;
begin
Indent := 0;
Line_Length := XML_Error_Line_Length;
for I in Error_Set_Positions range 1 .. Errors.Length loop
The_Error := Errors.Content (I);
The_Error.Error.Message := SPARK_XML.Filter_String (Str => The_Error.Error.Message);
Started_Active := ErrorAccumulator.Is_Active (This => Accumulator);
if ErrorAccumulator.Is_Active (This => Accumulator) then
ErrorAccumulator.Add
(This => Accumulator,
Error => The_Error,
End_Pos => Line_Length,
Indent => Indent,
Listing => Listing);
end if;
if not ErrorAccumulator.Is_Active (This => Accumulator) then
if Started_Active then
XMLReport.End_Message (Report => Listing);
New_Line (File => Listing,
Spacing => 1);
end if;
XMLReport.Start_Message
(Class => Get_Error_Class (Err_Class => The_Error.Error.ErrorType),
Code => Convert_Message_Id (Message_Id => The_Error.Error.MessageId,
Err_Type => The_Error.Error.ErrorType),
Line => Integer (The_Error.Error.Position.Start_Line_No),
Offset => The_Error.Error.Position.Start_Pos,
Report => Listing);
if ErrorAccumulator.Is_Error_Start (The_Error => The_Error.Error) then
-- Message is of akind that will be "accumulated" before printing. We don't want
-- the explanation to appear over and over again, only once at the end of the completed
-- message. So we extract explanation from message here and pass it into ErrorAccumulator
-- where it is stored and appended to the error mesage when a later Flush operation is
-- performed.
Split_String_At_Explanation (E_Str => The_Error.Error.Message,
Explanation => Explanation);
PrintLine
(Listing => Listing,
Start_Pos => Start_Pos,
End_Pos => Line_Length,
Indent => Indent,
Line => The_Error.Error.Message,
Add_New_Line => False,
New_Start => New_Start);
ErrorAccumulator.Start_Msg
(This => Accumulator,
Start_Error => The_Error,
Start_Indent => New_Start,
Explanation => Explanation,
Line_Length => Line_Length,
Indent => Indent); -- in rather than recalculate them in error accumulator
else
-- leave message text unchanged and display it
--# accept Flow, 10, New_Start, "Returned parameter not needed in this case";
PrintLine
(Listing => Listing,
Start_Pos => Start_Pos,
End_Pos => Line_Length,
Indent => Indent,
Line => The_Error.Error.Message,
Add_New_Line => False,
New_Start => New_Start);
--# end accept;
-- Terminate message
XMLReport.End_Message (Report => Listing);
end if;
end if;
end loop;
end Put_Error_Messages_XML;
procedure PrintErrors (Listing : in SPARK_IO.File_Type;
Purpose : in Error_Types.ConversionRequestSource)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# derives Conversions.State,
--# Error_Context_Rec from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Listing,
--# Purpose,
--# SPARK_IO.File_Sys &
--# ErrorBuffer.Buffer from * &
--# SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Listing,
--# Purpose,
--# WarningStatus.SuppressionList;
is separate;
procedure AppendErrors (Report : in SPARK_IO.File_Type;
Purpose : in Error_Types.ConversionRequestSource)
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out XMLReport.State;
--# derives Conversions.State,
--# Error_Context_Rec,
--# XMLReport.State from CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Purpose,
--# Report,
--# SPARK_IO.File_Sys,
--# XMLReport.State &
--# SPARK_IO.File_Sys from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# Purpose,
--# Report,
--# WarningStatus.SuppressionList,
--# XMLReport.State;
is separate;
procedure Index_Manager_Error
(S : in String;
Source_File : in LexTokenManager.Lex_String;
Line_No : in Positive;
Col_No : in Positive;
Token_String : in E_Strings.T;
Is_Token_Filename : in Boolean;
Is_Fatal : in Boolean)
--# global in CommandLineData.Content;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Error_Context_Rec;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Error_Context_Rec,
--# Total_Error_Count from *,
--# Is_Fatal,
--# WarningStatus.SuppressionList &
--# SPARK_IO.File_Sys from *,
--# Col_No,
--# CommandLineData.Content,
--# Is_Fatal,
--# Is_Token_Filename,
--# LexTokenManager.State,
--# Line_No,
--# S,
--# Source_File,
--# Token_String,
--# WarningStatus.SuppressionList;
is
Str : E_Strings.T;
Tmp_Col_No : Positive;
begin
if not Is_Fatal and then WarningStatus.Is_Suppressed (The_Element => Index_Manager_Duplicates) then
Inc_Suppressed_Warning_Counter (Warning_Type => Index_Manager_Duplicates);
else
if Is_Fatal then
Inc_Message_Count (Err_Type => Error_Types.SyntaxErr);
else
Inc_Message_Count (Err_Type => Error_Types.WarningWithoutPosition);
end if;
-- Adjust column number to take account of lookahead
if Col_No > 1 then
Tmp_Col_No := Col_No - 1;
else
Tmp_Col_No := Col_No;
end if;
Str := LexTokenManager.Lex_String_To_String (Lex_Str => Source_File);
if E_Strings.Get_Length (E_Str => Str) > 0 then
if CommandLineData.Content.Plain_Output or else CommandLineData.Content.Brief then
Str := FileSystem.Just_File (Fn => Str,
Ext => True);
end if;
else
Str := E_Strings.Empty_String;
end if;
if CommandLineData.Content.Brief then
ScreenEcho.Put_ExaminerString (Str);
ScreenEcho.Put_Char (':');
ScreenEcho.Put_Integer (Line_No, 0, 10);
ScreenEcho.Put_Char (':');
ScreenEcho.Put_Integer (Tmp_Col_No, 0, 10);
ScreenEcho.Put_String (": ");
ScreenEcho.Put_String (S);
else
ScreenEcho.Put_String ("In index file ");
ScreenEcho.Put_ExaminerString (Str);
ScreenEcho.Put_String (" at line ");
ScreenEcho.Put_Integer (Line_No, 0, 10);
ScreenEcho.Put_String (" column ");
ScreenEcho.Put_Integer (Tmp_Col_No, 0, 10);
ScreenEcho.Put_String (": ");
ScreenEcho.Put_String (S);
end if;
if E_Strings.Get_Length (E_Str => Token_String) > 0 then
if Is_Token_Filename then
if CommandLineData.Content.Plain_Output then
Str := FileSystem.Just_File (Fn => Token_String,
Ext => True);
elsif CommandLineData.Content.Brief then
Str := FileSystem.Just_File (Fn => Token_String,
Ext => True);
else
Str := Token_String;
end if;
else
Str := Token_String;
end if;
ScreenEcho.Put_String (": ");
ScreenEcho.Put_ExaminerLine (Str);
else
ScreenEcho.New_Line (1);
end if;
end if;
end Index_Manager_Error;
-- exported operations concerned with error justification mechanism ------------------------------
procedure Start_Unit
--# global in out Error_Context_Rec;
--# derives Error_Context_Rec from *;
is
begin
Justifications.Start_Unit (Which_Table => Error_Context_Rec.Justifications_Data_Table);
end Start_Unit;
procedure End_Unit
--# global in CommandLineData.Content;
--# in Dictionary.Dict;
--# in LexTokenManager.State;
--# in WarningStatus.SuppressionList;
--# in out Conversions.State;
--# in out Echo_Accumulator;
--# in out ErrorBuffer.Buffer;
--# in out Error_Context_Rec;
--# in out Potential_Invalid_Value;
--# in out SPARK_IO.File_Sys;
--# in out Total_Error_Count;
--# derives Conversions.State,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# Potential_Invalid_Value,
--# SPARK_IO.File_Sys,
--# Total_Error_Count from *,
--# CommandLineData.Content,
--# Conversions.State,
--# Dictionary.Dict,
--# Echo_Accumulator,
--# ErrorBuffer.Buffer,
--# Error_Context_Rec,
--# LexTokenManager.State,
--# SPARK_IO.File_Sys,
--# WarningStatus.SuppressionList;
is
It : Justifications.Unmatched_Justification_Iterator;
begin
-- First report all justifications in the unit just being ended that have failed to match
-- But only if we aren't ignoring justifications
if CommandLineData.Content.Justification_Option /= CommandLineData.Ignore then
Justifications.First_Unmatched_Justification (It => It,
Which_Table => Error_Context_Rec.Justifications_Data_Table);
while not Justifications.Is_Null_Iterator (It => It) loop
Semantic_Warning
(Err_Num => 121,
Position => Justifications.Error_Position (It => It),
Id_Str => LexTokenManager.Null_String);
Justifications.Next_Unmatched_Justification (It => It,
Which_Table => Error_Context_Rec.Justifications_Data_Table);
end loop;
end if;
-- Then discard data for now-completed unit
Justifications.End_Unit (Which_Table => Error_Context_Rec.Justifications_Data_Table);
end End_Unit;
procedure Start_Justification
(Position : in LexTokenManager.Token_Position;
Line : in LexTokenManager.Line_Numbers;
Kind : in Justification_Kinds;
Err_Num : in Natural;
Identifiers : in Justification_Identifiers;
Applies_To_All : in Boolean;
Explanation : in E_Strings.T;
Maximum_Justifications_Reached : out Boolean)
--# global in out Error_Context_Rec;
--# derives Error_Context_Rec from *,
--# Applies_To_All,
--# Err_Num,
--# Explanation,
--# Identifiers,
--# Kind,
--# Line,
--# Position &
--# Maximum_Justifications_Reached from Error_Context_Rec;
is
begin
Justifications.Start_Justification
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Position => Position,
Line => Line,
Kind => Kind,
Err_Num => Err_Num,
Identifiers => Identifiers,
Applies_To_All => Applies_To_All,
Explanation => Explanation,
Maximum_Justifications_Reached => Maximum_Justifications_Reached);
end Start_Justification;
procedure End_Justification (Line : in LexTokenManager.Line_Numbers;
Unmatched_End : out Boolean)
--# global in out Error_Context_Rec;
--# derives Error_Context_Rec,
--# Unmatched_End from Error_Context_Rec,
--# Line;
is
begin
Justifications.End_Justification
(Which_Table => Error_Context_Rec.Justifications_Data_Table,
Line => Line,
Unmatched_End => Unmatched_End);
end End_Justification;
procedure Set_File_Open_Error
--# global out File_Open_Error;
--# derives File_Open_Error from ;
is
begin
File_Open_Error := True;
end Set_File_Open_Error;
function Get_Errors_Type return Exit_Code
--# global in File_Open_Error;
--# in Total_Error_Count;
is
Return_Value : Exit_Code := 0;
begin
if File_Open_Error then
Return_Value := 8;
elsif Total_Error_Count.Explicit_Error_Count (Syntax_Or_Semantic) /= 0 then
Return_Value := 3;
elsif Total_Error_Count.Explicit_Error_Count (Flow) /= 0 then
Return_Value := 2;
elsif Total_Error_Count.Explicit_Error_Count (Warning) /= 0 then
Return_Value := 1;
end if;
return Return_Value;
end Get_Errors_Type;
begin
Error_Context_Rec := Null_Error_Context;
Echo_Accumulator := ErrorAccumulator.Clear;
Total_Error_Count := Null_Total_Error_Counts;
end ErrorHandler;
|