logic_parser.opp.exp 70 KB
Newer Older
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
File "logic_parser.mly", line 287, characters 10-17:
Warning: the token highest is unused.
%{

  open Cil
  open Cil_types
  open Logic_ptree
  open Logic_utils

  let loc () = (symbol_start_pos (), symbol_end_pos ())
  let info x = { lexpr_node = x; lexpr_loc = loc () }
  let loc_info loc x = { lexpr_node = x; lexpr_loc = loc }
  let loc_start x = fst x.lexpr_loc
  let loc_end x = snd x.lexpr_loc

  (* Normalize p1 && (p2 && p3) into (p1 && p2) && p3 *)
  let rec pland p1 p2 =
    match p2.lexpr_node with
      | PLand (p3,p4) ->
        let loc = (loc_start p1, loc_end p3) in
        PLand(loc_info loc (pland p1 p3),p4)
      | _ -> PLand(p1,p2)

  let rec plor p1 p2 =
    match p2.lexpr_node with
      | PLor(p3,p4) ->
        let loc = (loc_start p1, loc_end p3) in
        PLor(loc_info loc (plor p1 p3),p4)
      | _ -> PLor(p1,p2)

  let clause_order i name1 name2 =
    raise
      (Not_well_formed
         ((rhs_start_pos i, rhs_end_pos i),
          "wrong order of clause in contract: "
          ^ name1 ^ " after " ^ name2 ^ "."))

  let missing i token next_token =
    raise
      (Not_well_formed
         ((rhs_start_pos i, rhs_end_pos i),
          Pretty_utils.sfprintf "expecting '%s' before %s" token next_token))

  type sense_of_relation = Unknown | Disequal | Less | Greater

  let check_empty (loc,msg) l =
    match l with
        [] -> ()
      | _ -> raise (Not_well_formed (loc,msg))

  let relation_sense rel sense =
    match rel, sense with
        Eq, _ -> sense, true
      | Neq, Unknown -> Disequal, true (* No chain of disequality for now*)
      | (Gt|Ge), (Unknown|Greater) -> Greater, true
      | (Lt|Le), (Unknown|Less) -> Less, true
      | _ -> sense, false

  let type_variables_stack = Stack.create ()

  let enter_type_variables_scope l =
    List.iter Logic_env.add_typename l;
    Stack.push l type_variables_stack

  let exit_type_variables_scope () =
    let l = Stack.pop type_variables_stack in
    List.iter Logic_env.remove_typename l

  let rt_type = ref false

  let set_rt_type () = rt_type:= true

  let reset_rt_type () = rt_type:=false

  let is_rt_type () = !rt_type

  let loc_decl d = { decl_node = d; decl_loc = loc () }

  let wrap_extended = List.map (fun (n,p) -> n,0, p)

  let concat_froms a1 a2 =
    let compare_pair (b1,_) (b2,_) = is_same_lexpr b1 b2 in
    (* NB: the following has an horrible complexity, but the order of 
       clauses in the input is preserved. *)
    let concat_one acc (_,f2 as p)  =
      try
        let (_,f1) = List.find (compare_pair p) acc
        in
        match (f1, f2) with
          | _,FromAny -> 
            (* the new fundeps does not give more information than the one
               which is already present. Just ignore it.
             *)
           acc
          | FromAny, _ ->
              (* the new fundeps is strictly more precise than the old one.
                 We replace the old dependency by the new one, but keep
                 the location at its old place in the list. This ensures
                 that we get the exact same clause if we try to 
                 link the original contract with its pretty-printed version. *)
              Extlib.replace compare_pair p acc
          | From _, From _ -> 
            (* we keep the two functional dependencies, 
               as they have to be proved separately. *)
            acc @ [p]
      with Not_found -> acc @ [p]
    in List.fold_left concat_one a1 a2

  let concat_allocation fa1 fa2 =
    match fa1,fa2 with
      | FreeAllocAny,_ -> fa2
      | _,FreeAllocAny -> fa1
      | FreeAlloc(f1,a1),FreeAlloc(f2,a2) -> FreeAlloc(f2@f1,a2@a1)
 
  (* a1 represents the assigns _after_ the current clause a2. *)
  let concat_assigns a1 a2 =
    match a1,a2 with
        WritesAny,a -> Writes (concat_froms [] a)
      | Writes [], [] -> a1
      | Writes [], _  | Writes _, [] ->
        raise (
          Not_well_formed (loc(),"Mixing \\nothing and a real location"))
      | Writes a1, a2 -> Writes (concat_froms a2 a1)

  let concat_loop_assigns_allocation annots bhvs2 a2 fa2=
    (* NB: this is supposed to merge assigns related to named behaviors, in 
       case of annotation like
       for a,b: assigns x,y;
       for b,c: assigns z,t;
       DO NOT CALL this function for loop assigns not attached to specific 
       behaviors. 
     *)
    assert (bhvs2 <> []);
    if fa2 == FreeAllocAny && a2 == WritesAny 
    then annots
    else 
    let split l1 l2 =
      let treat_one (only1,both,only2) x =
        if List.mem x l1 then
          (Extlib.filter_out (fun y -> x=y) only1,x::both,only2)
        else (only1,both,x::only2)
      in List.fold_left treat_one (l1,[],[]) l2
    in
    let treat_one ca (bhvs2,acc) =
      match ca,a2,fa2 with
          (AAssigns(bhvs1,a1)),(Writes a2),_ ->
            let (only1,both,only2) = split bhvs1 bhvs2 in
            (match both with
              | [] -> bhvs2, ca::acc
              | _ ->
                let common_annot = AAssigns(both,concat_assigns a1 a2) in
                let annots =
                  match only1 with
                    | [] -> common_annot :: acc
                    | _ -> AAssigns(only1,a1) :: common_annot :: acc
                in only2,annots)
        | (AAllocation(bhvs1,fa1)),_,(FreeAlloc _) ->
           let (only1,both,only2) = split bhvs1 bhvs2 in
            (match both with
              | [] -> bhvs2, ca::acc
              | _ ->
                let common_annot =
                  AAllocation(both,concat_allocation fa1 fa2)
                in
                let annots =
                  match only1 with
                    | [] -> common_annot :: acc
                    | _ -> AAllocation(only1,fa1) :: common_annot :: acc
                in only2,annots)
         | _,_,_ -> bhvs2,ca::acc
    in
    let (bhvs2, annots) = List.fold_right treat_one annots (bhvs2,[]) in
    match bhvs2 with
      | [] -> annots (* Already considered all cases. *)
      | _ -> 
	  let annots = if a2 <> WritesAny 
	    then AAssigns (bhvs2,a2) :: annots
            else annots
	  in  
	  if fa2 <> FreeAllocAny 
	    then AAllocation (bhvs2,fa2) :: annots
            else annots

  let obsolete name ~source ~now =
    Kernel.warning ~source
      "parsing obsolete ACSL construct '%s'. '%s' should be used instead."
      name now

  let check_registered kw =
    if Logic_utils.is_extension kw then kw else raise Parsing.Parse_error

  let escape =
    let regex1 = Str.regexp "\\(\\(\\\\\\\\\\)*[^\\]\\)\\(['\"]\\)" in
    let regex2 = Str.regexp "\\(\\\\\\\\\\)*\\\\$" in
    fun str -> 
      let str = Str.global_replace regex1 "\\1\\\\3" str in
      Str.global_replace regex2 "\\1\\\\" str

%}
%start annot
%start ext_spec
%start lexpr_eof
%start spec
%token WRITES
%token WITH
%token VOID
%token VARIANT
%token VALID_READ
%token VALID_RANGE
%token VALID_INDEX
%token VALID
%token UNSIGNED
%token UNION
%token UNALLOCATED
%token TYPEOF
%token TYPE
%token TRUE
%token TERMINATES
%token STRUCT
%token <bool*string> STRING_LITERAL
%token STATIC
%token SLICE
%token SIZEOF
%token SIGNED
%token SHORT
%token SEMICOLON
%token RSQUARE
%token RPAR
%token RETURNS
%token RESULT
%token REQUIRES
%token REGISTER
%token REAL
%token READS
%token RBRACE
%token PREDICATE
%token PRAGMA
%token OLD
%token OFFSET
%token NULL
%token NOTHING
%token NE
%token MODULE
%token MODEL
%token LPAR
%token LOOP
%token LONG
%token LOGIC
%token LEMMA
%token LE
%token LBRACE
%token LAMBDA
%token LABEL
%token INVARIANT
%token INTER
%token INTEGER
%token INT
%token INITIALIZED
%token INDUCTIVE
%token INCLUDE
%token IMPACT
%token IF
%token GT
%token GLOBAL
%token GHOST
%token GE
%token FUNCTION
%token FROM
%token FRESH
%token FREES
%token FREEABLE
%token FORALL
%token FOR
%token FLOAT
%token FALSE
%token EXT_LET
%token EXT_AT
%token EXITS
%token EXISTS
%token EQUAL
%token EQ
%token EOF
%token ENUM
%token ENSURES
%token EMPTY
%token ELSE
%token DYNAMIC
%token DOUBLE
%token DOTDOTDOT
%token DOTDOT
%token DOLLAR
%token DISJOINT
%token DECREASES
%token DANGLING
%token CUSTOM
%token CONTRACT
%token CONTINUES
%token <string> CONSTANT10
%token <Logic_ptree.constant> CONSTANT
%token COMPLETE
%token COMMA
%token COLONCOLON
%token COLON2
%token COLON
%token CHAR
%token CASE
%token BSUNION
%token BSTYPE
%token BREAKS
%token BOOLEAN
%token BOOL
%token BLOCK_LENGTH
%token BEHAVIORS
%token BEHAVIOR
%token BASE_ADDR
%token AXIOMATIC
%token AXIOM
%token AUTOMATIC
%token AT
%token ASSUMES
%token ASSIGNS
%token ASSERT
%token ALLOCATION
%token ALLOCATES
%token ALLOCABLE
%token <string> TYPENAME
%token SEPARATED
%token <string> IDENTIFIER
%token LET
%token QUESTION
%token IFF
%token IMPLIES
%token OR
%token HATHAT
%token AND
%token PIPE
%token BIFF
%token BIMPLIES
%token HAT
%token AMP
%token LT
%token LTLT
%token GTGT
%token PLUS
%token MINUS
%token VOLATILE
%token STAR
%token SLASH
%token PERCENT
%token CONST
%token TILDE
%token NOT
%token LTCOLON
%token COLONGT
%token LSQUARE
%token DOT
%token ARROW
%nonassoc lowest 
%right prec_named 
%nonassoc TYPENAME SEPARATED IDENTIFIER 
%nonassoc prec_lambda prec_forall prec_exists LET 
%right prec_question QUESTION 
%left IFF 
%right IMPLIES 
%left OR 
%left HATHAT 
%left AND 
%left PIPE 
%left BIFF 
%right BIMPLIES 
%left HAT 
%left AMP 
%nonassoc prec_no_rel 
%left prec_rel_list 
%left LT 
%left LTLT GTGT 
%left PLUS MINUS 
%left VOLATILE STAR SLASH PERCENT CONST 
%right prec_unary_op prec_cast TILDE NOT 
%nonassoc LTCOLON COLONGT 
%left LSQUARE DOT ARROW 
%right prec_par 
%nonassoc highest 
%type <Logic_ptree.annot> annot
%type <Logic_ptree.ext_spec> ext_spec
%type <Logic_ptree.lexpr> lexpr_eof
%type <Logic_ptree.spec * Cabs.cabsloc> spec
%%

enter_kw_c_mode:
| 
    {            ( enter_kw_c_mode () )}

exit_kw_c_mode:
| 
    {            ( exit_kw_c_mode () )}

enter_rt_type:
| 
    {            ( if is_rt_type () then enter_rt_type_mode () )}

exit_rt_type:
| 
    {            ( if is_rt_type () then exit_rt_type_mode () )}

begin_rt_type:
| 
    {            ( set_rt_type () )}

end_rt_type:
| 
    {            ( reset_rt_type () )}

lexpr_list:
| 
    {                ( [] )}
| _1 = ne_lexpr_list
    {                 ( _1 )}

ne_lexpr_list:
| _1 = lexpr
    {                           ( [_1] )}
| _1 = lexpr _2 = COMMA _3 = ne_lexpr_list
    {                            ( _1 :: _3 )}

lexpr_eof:
| _1 = full_lexpr _2 = EOF
    {                 ( _1 )}

lexpr_option:
| 
    {                ( None )}
| _1 = lexpr
    {                ( Some _1 )}

lexpr:
| _1 = lexpr _2 = IMPLIES _3 = lexpr
    {                      ( info (PLimplies (_1, _3)) )}
| _1 = lexpr _2 = IFF _3 = lexpr
    {                  ( info (PLiff (_1, _3)) )}
| _1 = lexpr _2 = OR _3 = lexpr
    {                     ( info (plor _1 _3) )}
| _1 = lexpr _2 = AND _3 = lexpr
    {                     ( info (pland _1 _3) )}
| _1 = lexpr _2 = HATHAT _3 = lexpr
    {                        ( info (PLxor (_1, _3)) )}
| _1 = lexpr _2 = AMP _3 = lexpr
    {                  ( info (PLbinop (_1, Bbw_and, _3)) )}
| _1 = lexpr _2 = PIPE _3 = lexpr
    {                   ( info (PLbinop (_1, Bbw_or, _3)) )}
| _1 = lexpr _2 = HAT _3 = lexpr
    {                  ( info (PLbinop (_1, Bbw_xor, _3)) )}
| _1 = lexpr _2 = BIMPLIES _3 = lexpr
    {                       ( info (PLbinop (info (PLunop (Ubw_not, _1)), Bbw_or, _3)) )}
| _1 = lexpr _2 = BIFF _3 = lexpr
    {                   ( info (PLbinop (info (PLunop (Ubw_not, _1)), Bbw_xor, _3)) )}
| _1 = lexpr _2 = QUESTION _3 = lexpr _4 = COLON2 _5 = lexpr %prec prec_question
    {    ( info (PLif (_1, _3, _5)) )}
| _1 = any_identifier _2 = COLON _3 = lexpr %prec prec_named
    {                                              ( info (PLnamed (_1, _3)) )}
| _1 = string _2 = COLON _3 = lexpr %prec prec_named
    {      ( let (iswide,str) = _1 in
        if iswide then begin 
           let l = loc () in
           raise (Not_well_formed(l, "Wide strings are not allowed as labels."))
         end;
        let str = escape str in
         info (PLnamed (str, _3))
       )}
| _1 = lexpr_rel %prec prec_rel_list
    {                                ( _1 )}

lexpr_rel:
| _1 = lexpr_end_rel %prec prec_no_rel
    {                                  ( _1 )}
| _1 = lexpr_inner _2 = rel_list %prec prec_rel_list
    {      ( let rel, rhs, _, oth_rel = _2 in
        let loc = loc_start _1, loc_end rhs in
        let relation = loc_info loc (PLrel(_1,rel,rhs)) in
        match oth_rel with
            None -> relation
          | Some oth_relation -> info (pland relation oth_relation)
      )}

lexpr_binder:
| _1 = LET _2 = bounded_var _3 = EQUAL _4 = lexpr _5 = SEMICOLON _6 = lexpr %prec LET
    {                                                        (info (PLlet(_2,_4,_6)))}
| _1 = FORALL _2 = binders _3 = SEMICOLON _4 = lexpr %prec prec_forall
    {      ( info (PLforall (_2, _4)) )}
| _1 = EXISTS _2 = binders _3 = SEMICOLON _4 = lexpr %prec prec_exists
    {      ( info (PLexists (_2, _4)) )}
| _1 = LAMBDA _2 = binders _3 = SEMICOLON _4 = lexpr %prec prec_lambda
    {      ( info (PLlambda (_2,_4)) )}

lexpr_end_rel:
| _1 = lexpr_inner %prec prec_no_rel
    {                                ( _1 )}
| _1 = lexpr_binder
    {               ( _1 )}
| _1 = NOT _2 = lexpr_binder
    {                   ( info (PLnot _2) )}

rel_list:
| _1 = relation _2 = lexpr_end_rel %prec prec_rel_list
    {  ( _1, _2, fst(relation_sense _1 Unknown), None )}
| _1 = relation _2 = lexpr_inner _3 = rel_list %prec prec_rel_list
    {  (
    let next_rel, rhs, sense, oth_rel = _3 in
    let (sense, correct) = relation_sense _1 sense
    in
    if correct then
      let loc = loc_start _2, loc_end rhs in
      let my_rel = loc_info loc (PLrel(_2,next_rel,rhs)) in
      let oth_rel = match oth_rel with
          None -> my_rel
        | Some rel ->
	    let loc = loc_start _2, loc_end rel in
	    loc_info loc (pland my_rel rel)
      in
      _1,_2,sense,Some oth_rel
    else begin
      let loc = Parsing.rhs_start_pos 1, Parsing.rhs_end_pos 3 in
      raise (Not_well_formed(loc,"Inconsistent relation chain."));
    end
  )}

relation:
| _1 = LT
    {        ( Lt )}
| _1 = GT
    {        ( Gt )}
| _1 = LE
    {        ( Le )}
| _1 = GE
    {        ( Ge )}
| _1 = EQ
    {        ( Eq )}
| _1 = NE
    {        ( Neq )}
| _1 = EQUAL
    {        (
      let l = loc () in
      raise
        (Not_well_formed(l,
                         "Assignment operators not allowed in annotations."))
    )}

lexpr_inner:
| _1 = string
    {         (
      let (is_wide,content) = _1 in
      let cst = if is_wide then
        WStringConstant content
      else
        StringConstant content
      in
      info (PLconstant cst)
    )}
| _1 = NOT _2 = lexpr_inner
    {                  ( info (PLnot _2) )}
| _1 = TRUE
    {       ( info PLtrue )}
| _1 = FALSE
    {        ( info PLfalse )}
| _1 = VALID _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                    ( info (PLvalid (_2,_4)) )}
| _1 = VALID_READ _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                         ( info (PLvalid_read (_2,_4)) )}
| _1 = VALID_INDEX _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = COMMA _6 = lexpr _7 = RPAR
    {                                                      ( 
  let source = fst (loc ()) in
  obsolete ~source "\\valid_index(addr,idx)" ~now:"\\valid(addr+idx)";
  info (PLvalid (_2,info (PLbinop (_4, Badd, _6)))) )}
| _1 = VALID_RANGE _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = COMMA _6 = lexpr _7 = COMMA _8 = lexpr _9 = RPAR
    {                                                                  (
  let source = fst (loc ()) in
  obsolete "\\valid_range(addr,min,max)" 
    ~source ~now:"\\valid(addr+(min..max))";
  info (PLvalid 
          (_2,info (PLbinop (_4, Badd, (info (PLrange((Some _6),Some _8)))))))
)}
| _1 = INITIALIZED _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                          ( info (PLinitialized (_2,_4)) )}
| _1 = DANGLING _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                       ( info (PLdangling (_2,_4)) )}
| _1 = FRESH _2 = opt_label_2 _3 = LPAR _4 = lexpr _5 = COMMA _6 = lexpr _7 = RPAR
    {                                                ( info (PLfresh (_2,_4, _6)) )}
| _1 = BASE_ADDR _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                        ( info (PLbase_addr (_2,_4)) )}
| _1 = BLOCK_LENGTH _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                           ( info (PLblock_length (_2,_4)) )}
| _1 = OFFSET _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                     ( info (PLoffset (_2,_4)) )}
| _1 = ALLOCABLE _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                        ( info (PLallocable (_2,_4)) )}
| _1 = FREEABLE _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                       ( info (PLfreeable (_2,_4)) )}
| _1 = ALLOCATION _2 = opt_label_1 _3 = LPAR _4 = lexpr _5 = RPAR
    {                                          ( Format.eprintf "Warning: \\static not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = AUTOMATIC
    {            ( Format.eprintf "Warning: \\static not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = DYNAMIC
    {          ( Format.eprintf "Warning: \\dynamic not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = REGISTER
    {           ( Format.eprintf "Warning: \\register not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = STATIC
    {         ( Format.eprintf "Warning: \\static not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = UNALLOCATED
    {              ( Format.eprintf "Warning: \\unallocated not yet implemented." ;
	   (* TODO: *) raise Parse_error )}
| _1 = NULL
    {       ( info PLnull )}
| _1 = constant
    {           ( info (PLconstant _1) )}
| _1 = lexpr_inner _2 = PLUS _3 = lexpr_inner
    {                               ( info (PLbinop (_1, Badd, _3)) )}
| _1 = lexpr_inner _2 = MINUS _3 = lexpr_inner
    {                                ( info (PLbinop (_1, Bsub, _3)) )}
| _1 = lexpr_inner _2 = STAR _3 = lexpr_inner
    {                               ( info (PLbinop (_1, Bmul, _3)) )}
| _1 = lexpr_inner _2 = SLASH _3 = lexpr_inner
    {                                ( info (PLbinop (_1, Bdiv, _3)) )}
| _1 = lexpr_inner _2 = PERCENT _3 = lexpr_inner
    {                                  ( info (PLbinop (_1, Bmod, _3)) )}
| _1 = lexpr_inner _2 = ARROW _3 = identifier_or_typename
    {                                           ( info (PLarrow (_1, _3)) )}
| _1 = lexpr_inner _2 = DOT _3 = identifier_or_typename
    {                                         ( info (PLdot (_1, _3)) )}
| _1 = lexpr_inner _2 = LSQUARE _3 = range _4 = RSQUARE
    {                                    ( info (PLarrget (_1, _3)) )}
| _1 = lexpr_inner _2 = LSQUARE _3 = lexpr _4 = RSQUARE
    {                                    ( info (PLarrget (_1, _3)) )}
| _1 = MINUS _2 = lexpr_inner %prec prec_unary_op
    {                                        ( info (PLunop (Uminus, _2)) )}
| _1 = PLUS _2 = lexpr_inner %prec prec_unary_op
    {                                        ( _2 )}
| _1 = TILDE _2 = lexpr_inner
    {                    ( info (PLunop (Ubw_not, _2)) )}
| _1 = STAR _2 = lexpr_inner %prec prec_unary_op
    {                                        ( info (PLunop (Ustar, _2)) )}
| _1 = AMP _2 = lexpr_inner %prec prec_unary_op
    {                                        ( info (PLunop (Uamp, _2)) )}
| _1 = SIZEOF _2 = LPAR _3 = lexpr _4 = RPAR
    {                         ( info (PLsizeofE _3) )}
| _1 = SIZEOF _2 = LPAR _3 = logic_type _4 = RPAR
    {                              ( info (PLsizeof _3) )}
| _1 = OLD _2 = LPAR _3 = lexpr _4 = RPAR
    {                      ( info (PLold _3) )}
| _1 = AT _2 = LPAR _3 = lexpr _4 = COMMA _5 = label_name _6 = RPAR
    {                                      ( info (PLat (_3, _5)) )}
| _1 = RESULT
    {         ( info PLresult )}
| _1 = SEPARATED _2 = LPAR _3 = ne_lexpr_list _4 = RPAR
    {      ( info (PLseparated _3) )}
| _1 = identifier _2 = LPAR _3 = ne_lexpr_list _4 = RPAR
    {      ( info (PLapp (_1, [], _3)) )}
| _1 = identifier _2 = LBRACE _3 = ne_label_args _4 = RBRACE _5 = LPAR _6 = ne_lexpr_list _7 = RPAR
    {      ( info (PLapp (_1, _3, _6)) )}
| _1 = identifier _2 = LBRACE _3 = ne_label_args _4 = RBRACE
    {      ( info (PLapp (_1, _3, [])) )}
| _1 = identifier %prec IDENTIFIER
    {                              ( info (PLvar _1) )}
| _1 = lexpr_inner _2 = GTGT _3 = lexpr_inner
    {                               ( info (PLbinop (_1, Brshift, _3)))}
| _1 = lexpr_inner _2 = LTLT _3 = lexpr_inner
    {                               ( info (PLbinop (_1, Blshift, _3)))}
| _1 = LPAR _2 = lexpr _3 = RPAR %prec prec_par
    {                                 ( info _2.lexpr_node )}
| _1 = LPAR _2 = range _3 = RPAR
    {                  ( info _2.lexpr_node )}
| _1 = LPAR _2 = cast_logic_type _3 = RPAR _4 = lexpr_inner %prec prec_cast
    {      ( info (PLcast (_2, _4)) )}
| _1 = lexpr_inner _2 = LTCOLON _3 = lexpr_inner %prec prec_cast
    {      ( info (PLsubtype (_1, _3)) )}
| _1 = lexpr_inner _2 = COLONGT _3 = logic_type %prec prec_cast
    {      ( info (PLcoercion (_1, _3)) )}
| _1 = lexpr_inner _2 = COLONGT _3 = lexpr_inner %prec prec_cast
    {      ( info (PLcoercionE (_1, _3)) )}
| _1 = TYPEOF _2 = LPAR _3 = lexpr _4 = RPAR
    {                         ( info (PLtypeof _3) )}
| _1 = BSTYPE _2 = LPAR _3 = type_spec _4 = RPAR
    {                             ( info (PLtype _3) )}
| _1 = BSTYPE _2 = LPAR _3 = type_spec _4 = stars _5 = RPAR
    {                                   ( info (PLtype (_4 _3)) )}
| _1 = EMPTY
    {        ( info PLempty )}
| _1 = BSUNION _2 = LPAR _3 = lexpr_list _4 = RPAR
    {                               ( info (PLunion _3) )}
| _1 = INTER _2 = LPAR _3 = lexpr_list _4 = RPAR
    {                             ( info (PLinter _3) )}
| _1 = LBRACE _2 = lexpr _3 = RBRACE
    {      ( info (PLsingleton (_2)) )}
| _1 = LBRACE _2 = lexpr _3 = PIPE _4 = binders _5 = RBRACE
    {      (info (PLcomprehension (_2,_4,None)) )}
| _1 = LBRACE _2 = lexpr _3 = PIPE _4 = binders _5 = SEMICOLON _6 = lexpr _7 = RBRACE
    {      ( info (PLcomprehension (_2,_4,Some _6)) )}
| _1 = LBRACE _2 = field_init _3 = RBRACE
    {      ( info (PLinitField(_2)) )}
| _1 = LBRACE _2 = array_init _3 = RBRACE
    {      ( info (PLinitIndex(_2)) )}
| _1 = LBRACE _2 = lexpr _3 = WITH _4 = update _5 = RBRACE
    {      ( List.fold_left
	  (fun a (path,upd_val) -> info (PLupdate(a,path,upd_val))) _2 _4 )}

ne_label_args:
| _1 = identifier_or_typename
    {                         ( [ _1 ] )}
| _1 = identifier_or_typename _2 = COMMA _3 = ne_label_args
    {                                             ( _1 :: _3 )}

string:
| _1 = STRING_LITERAL
    {                 ( _1 )}
| _1 = string _2 = STRING_LITERAL
    {                        (
      let (is_wide,prefix) = _1 in
      let (is_wide2,suffix) = _2 in
      (is_wide || is_wide2, prefix ^ suffix)
    )}

range:
| _1 = lexpr_option _2 = DOTDOT _3 = lexpr_option
    {                                   ( info (PLrange(_1,_3)) )}

field_path_elt:
| _1 = DOT _2 = identifier_or_typename
    {                             ( _2 )}

field_init_elt:
| _1 = field_path_elt _2 = EQUAL _3 = lexpr
    {                             ( (_1, _3) )}

field_init:
| _1 = field_init_elt
    {                                  ( [_1] )}
| _1 = field_init_elt _2 = COMMA _3 = field_init
    {                                  ( _1::_3 )}

array_path_elt:
| _1 = LSQUARE _2 = lexpr _3 = RSQUARE
    {                             ( _2 )}
| _1 = LSQUARE _2 = range _3 = RSQUARE
    {                             ( _2 )}

array_init_elt:
| _1 = array_path_elt _2 = EQUAL _3 = lexpr
    {                             ( (_1, _3) )}

array_init:
| _1 = array_init_elt
    {                                  ( [_1] )}
| _1 = array_init_elt _2 = COMMA _3 = array_init
    {                                  ( _1::_3 )}

update:
| _1 = update_elt
    {                              ( [_1] )}
| _1 = update_elt _2 = COMMA _3 = update
    {                          ( _1::_3 )}

update_elt:
| _1 = path _2 = EQUAL _3 = lexpr
    {                                  ( _1, PLupdateTerm _3 )}
| _1 = path _2 = EQUAL _3 = LBRACE _4 = WITH _5 = update _6 = RBRACE
    {                                       ( _1, PLupdateCont _5 )}

path:
| _1 = path_elt
    {                ( [_1] )}
| _1 = path_elt _2 = path
    {                ( _1::_2 )}

path_elt:
| _1 = field_path_elt
    {                 ( PLpathField _1 )}
| _1 = array_path_elt
    {                 ( PLpathIndex _1 )}

binders:
| _1 = binders_reentrance
    {                     ( let (_lt, vars) = _1 in vars )}

binders_reentrance:
| _1 = decl_spec
    {            ( let (lt, var) = _1 in (lt, [var]) )}
| _1 = binders_reentrance _2 = COMMA _3 = decl_spec
    {    ( let _, vars = _1 in
      let (lt, var) = _3 in
        (lt, vars @ [ var ])
    )}
| _1 = binders_reentrance _2 = COMMA _3 = var_spec
    {    ( let last_type_spec, vars = _1 in
        (last_type_spec, vars @ [ let (modif, name) = _3 in (modif last_type_spec, name)])
    )}

decl_spec:
| _1 = type_spec _2 = var_spec
    {                     ( (_1, let (modif, name) = _2 in (modif _1, name))  )}

var_spec:
| _1 = var_spec_bis
    {                     ( let (outer, inner,name) = _1 in
                       ((fun x -> outer (inner x)), name))}
| _1 = stars _2 = var_spec_bis
    {  ( let (outer, inner, name) = _2 in
      ((fun x -> outer (inner (_1 x))), name) )}

constant:
| _1 = CONSTANT
    {             ( _1 )}
| _1 = CONSTANT10
    {             ( IntConstant _1 )}

constant_option:
| _1 = constant
    {            ( Some _1 )}
| 
    {              ( None )}

var_spec_bis:
| _1 = identifier
    {                 ( ((fun x -> x),(fun x -> x), _1) )}
| _1 = var_spec_bis _2 = LSQUARE _3 = constant_option _4 = RSQUARE
    {      ( let (outer, inner, name) = _1 in
          (outer, (fun x -> inner (LTarray (x,_3))), name)
      )}
| _1 = LPAR _2 = var_spec _3 = RPAR
    {                     ( let (modif, name) = _2 in (modif, (fun x -> x), name) )}
| _1 = var_spec_bis _2 = LPAR _3 = abs_param_type_list _4 = RPAR
    {      ( let (outer, inner,name) = _1 in
        let params = _3 in
        (outer, (fun x -> inner (LTarrow (params,x))), name)
      )}

abs_param_type_list:
| 
    {                 ( [ ] )}
| _1 = abs_param_list
    {                 ( _1 )}
| _1 = abs_param_list _2 = COMMA _3 = DOTDOTDOT
    {                                 (
    Format.eprintf "Warning: elipsis type is not yet implemented." ;
    (* TODO: *) raise Parse_error
  )}

abs_param_list:
| _1 = abs_param
    {            ( [ _1 ] )}
| _1 = abs_param_list _2 = COMMA _3 = abs_param
    {                                 ( _1 @ [ _3 ] )}

abs_param:
| _1 = logic_type
    {             ( _1 )}

id_as_typename:
| _1 = identifier
    {             ( LTnamed(_1, []) )}

ne_parameters:
| _1 = parameter
    {            ( [_1] )}
| _1 = parameter _2 = COMMA _3 = ne_parameters
    {                                ( _1 :: _3 )}

parameter:
| _1 = type_spec _2 = var_spec
    {                     ( let (modif, name) = _2 in (modif _1, name))}
| _1 = id_as_typename _2 = var_spec
    {                          ( let (modif, name) = _2 in (modif _1, name) )}

logic_type:
| _1 = type_spec _2 = abs_spec_option
    {                            ( _2 _1 )}

cv:
| _1 = CONST
    {        ( )}
| _1 = VOLATILE
    {           ( )}

type_spec_cv:
| _1 = type_spec
    {               ( _1 )}
| _1 = cv _2 = type_spec
    {                  ( _2 )}
| _1 = type_spec _2 = cv
    {                  ( _1 )}

cast_logic_type:
| _1 = type_spec_cv _2 = abs_spec_cv_option
    {                                   ( _2 _1 )}

logic_rt_type:
| _1 = id_as_typename
    {                 ( _1 )}
| _1 = begin_rt_type _2 = logic_type _3 = end_rt_type
    {                                       ( _2 )}

abs_spec_option:
|  %prec TYPENAME
    {                              ( fun t -> t )}
| _1 = abs_spec
    {           ( _1 )}

abs_spec_cv_option:
|  %prec TYPENAME
    {                              ( fun t -> t )}
| _1 = abs_spec_cv
    {              ( _1 )}

abs_spec:
| _1 = tabs
    {                          ( _1 )}
| _1 = stars %prec TYPENAME
    {                                         ( _1 )}
| _1 = stars _2 = tabs
    {                                         ( fun t -> _2 (_1 t) )}
| _1 = stars _2 = abs_spec_bis %prec TYPENAME
    {                                         ( fun t -> _2 (_1 t) )}
| _1 = stars _2 = abs_spec_bis _3 = tabs
    {                                         ( fun t -> _2 (_3 (_1 t)) )}
| _1 = abs_spec_bis _2 = tabs
    {                                         ( fun t -> _1 (_2 t) )}
| _1 = abs_spec_bis %prec TYPENAME
    {                                         ( _1 )}

abs_spec_cv:
| _1 = tabs
    {                               ( _1 )}
| _1 = stars_cv %prec TYPENAME
    {                                               ( _1 )}
| _1 = stars_cv _2 = tabs
    {                                               ( fun t -> _2 (_1 t) )}
| _1 = stars_cv _2 = abs_spec_bis_cv %prec TYPENAME
    {                                               ( fun t -> _2 (_1 t) )}
| _1 = stars_cv _2 = abs_spec_bis_cv _3 = tabs
    {                                               ( fun t -> _2 (_3 (_1 t)) )}
| _1 = abs_spec_bis_cv _2 = tabs
    {                                               ( fun t -> _1 (_2 t) )}
| _1 = abs_spec_bis_cv %prec TYPENAME
    {                                               ( _1 )}

abs_spec_bis:
| _1 = LPAR _2 = abs_spec _3 = RPAR
    {                     ( _2 )}
| _1 = abs_spec_bis _2 = LPAR _3 = abs_param_type_list _4 = RPAR
    {                                             ( fun t -> _1 (LTarrow(_3,t)) )}

abs_spec_bis_cv:
| _1 = LPAR _2 = abs_spec_cv _3 = RPAR
    {                        ( _2 )}
| _1 = abs_spec_bis_cv _2 = LPAR _3 = abs_param_type_list _4 = RPAR
    {                                                ( fun t -> _1 (LTarrow(_3,t)) )}

stars:
| _1 = STAR
    {                ( fun t -> LTpointer t )}
| _1 = stars _2 = STAR
    {                ( fun t -> _1 (LTpointer t) )}

stars_cv:
| _1 = STAR
    {                ( fun t -> LTpointer t )}
| _1 = STAR _2 = cv
    {                ( fun t -> LTpointer t )}
| _1 = stars_cv _2 = STAR
    {                   ( fun t -> _1 (LTpointer t) )}
| _1 = stars_cv _2 = STAR _3 = cv
    {                   ( fun t -> _1 (LTpointer t) )}

tabs:
| _1 = LSQUARE _2 = constant_option _3 = RSQUARE %prec TYPENAME
    {    (
      fun t -> LTarray (t,_2)
    )}
| _1 = LSQUARE _2 = constant_option _3 = RSQUARE _4 = tabs
    {    (
      fun t -> (LTarray (_4 t,_2))
    )}

type_spec:
| _1 = INTEGER
    {                 ( LTinteger )}
| _1 = REAL
    {                 ( LTreal )}
| _1 = BOOLEAN
    {                 ( LTnamed (Utf8_logic.boolean,[]) )}
| _1 = VOID
    {                 ( LTvoid )}
| _1 = BOOL
    {                 ( LTint IBool )}
| _1 = CHAR
    {                 ( LTint IChar )}
| _1 = SIGNED _2 = CHAR
    {                 ( LTint ISChar )}
| _1 = UNSIGNED _2 = CHAR
    {                 ( LTint IUChar )}
| _1 = INT
    {                 ( LTint IInt )}
| _1 = SIGNED _2 = INT
    {                 ( LTint IInt )}
| _1 = UNSIGNED _2 = INT
    {                 ( LTint IUInt )}
| _1 = UNSIGNED
    {                 ( LTint IUInt )}
| _1 = SHORT
    {                 ( LTint IShort )}
| _1 = SIGNED _2 = SHORT
    {                 ( LTint IShort )}
| _1 = UNSIGNED _2 = SHORT
    {                 ( LTint IUShort )}
| _1 = LONG
    {                 ( LTint ILong )}
| _1 = SIGNED _2 = LONG
    {                 ( LTint ILong )}
| _1 = UNSIGNED _2 = LONG
    {                 ( LTint IULong )}
| _1 = SIGNED _2 = LONG _3 = INT
    {                 ( LTint ILong )}
| _1 = LONG _2 = INT
    {                 ( LTint ILong )}
| _1 = UNSIGNED _2 = LONG _3 = INT
    {                    ( LTint IULong )}
| _1 = LONG _2 = LONG
    {                 ( LTint ILongLong )}
| _1 = SIGNED _2 = LONG _3 = LONG
    {                     ( LTint ILongLong )}
| _1 = UNSIGNED _2 = LONG _3 = LONG
    {                     ( LTint IULongLong )}
| _1 = LONG _2 = LONG _3 = INT
    {                    ( LTint ILongLong )}
| _1 = SIGNED _2 = LONG _3 = LONG _4 = INT
    {                        ( LTint ILongLong )}
| _1 = UNSIGNED _2 = LONG _3 = LONG _4 = INT
    {                         ( LTint IULongLong )}
| _1 = FLOAT
    {                    ( LTfloat FFloat )}
| _1 = DOUBLE
    {                    ( LTfloat FDouble )}
| _1 = LONG _2 = DOUBLE
    {                    ( LTfloat FLongDouble )}
| _1 = STRUCT _2 = exit_rt_type _3 = identifier_or_typename
    {                                             ( LTstruct _3 )}
| _1 = ENUM _2 = exit_rt_type _3 = identifier_or_typename
    {                                             ( LTenum _3 )}
| _1 = UNION _2 = exit_rt_type _3 = identifier_or_typename
    {                                              ( LTunion _3 )}
| _1 = TYPENAME
    {                    ( LTnamed (_1,[]) )}
| _1 = TYPENAME _2 = LT _3 = enter_rt_type _4 = ne_logic_type_list _5 = GT _6 = exit_rt_type
    {      ( LTnamed(_1,_4) )}

ne_logic_type_list:
| _1 = logic_type
    {                                      ( [_1] )}
| _1 = logic_type _2 = COMMA _3 = enter_rt_type _4 = ne_logic_type_list
    {                                                    ( _1 :: _4 )}

full_lexpr:
| _1 = enter_kw_c_mode _2 = lexpr _3 = exit_kw_c_mode
    {                                       ( _2 )}

full_identifier:
| _1 = enter_kw_c_mode _2 = identifier _3 = exit_kw_c_mode
    {                                            ( _2 )}

full_identifier_or_typename:
| _1 = enter_kw_c_mode _2 = identifier_or_typename _3 = exit_kw_c_mode
    {                                                        ( _2 )}

full_parameters:
| _1 = enter_kw_c_mode _2 = ne_parameters _3 = exit_kw_c_mode
    {                                               ( _2 )}

full_parameter:
| _1 = enter_kw_c_mode _2 = parameter _3 = exit_kw_c_mode
    {                                           ( _2 )}

full_zones:
| _1 = enter_kw_c_mode _2 = zones _3 = exit_kw_c_mode
    {                                        ( _2 )}

full_ne_lexpr_list:
| _1 = enter_kw_c_mode _2 = ne_lexpr_list _3 = exit_kw_c_mode
    {                                             ( _2 )}

full_logic_type:
| _1 = enter_kw_c_mode _2 = logic_type _3 = exit_kw_c_mode
    {                                            ( _2 )}

full_logic_rt_type:
| _1 = enter_kw_c_mode _2 = logic_rt_type _3 = exit_kw_c_mode
    {                                               ( _2 )}

full_assigns:
| _1 = enter_kw_c_mode _2 = assigns _3 = exit_kw_c_mode
    {                                         ( _2 )}

ext_spec:
| _1 = ext_global_clauses_opt _2 = ext_module_specs_opt _3 = ext_global_specs_opt _4 = EOF
    {                                                                        ( ("",_1,_2)::_3 )}

ext_global_clauses_opt:
| 
    {                       ( [] )}
| _1 = ext_global_clauses
    {                       ( _1 )}

ext_global_clauses:
| _1 = ext_global_clause
    {                                       ( [_1] )}
| _1 = ext_global_clause _2 = ext_global_clauses
    {                                       ( _1::_2 )}

ext_global_clause:
| _1 = decl
    {        ( Ext_decl (loc_decl _1) )}
| _1 = EXT_LET _2 = any_identifier _3 = EQUAL _4 = full_lexpr _5 = SEMICOLON
    {                                                    ( Ext_macro (_2, _4) )}
| _1 = INCLUDE _2 = string _3 = SEMICOLON
    {                           ( let b,s = _2 in Ext_include(b,s, loc()) )}

ext_global_specs_opt:
| 
    {                     ( [] )}
| _1 = ext_global_specs
    {                     ( _1 )}

ext_global_specs:
| _1 = ext_global_spec
    {                                   ( [_1] )}
| _1 = ext_global_spec _2 = ext_global_specs
    {                                   ( _1::_2 )}

ext_global_spec:
| _1 = ext_module_markup _2 = ext_global_clauses_opt _3 = ext_module_specs
    {    ( (_1,_2,_3) )}
| _1 = ext_module_markup
    {    ( (_1,[],[]) )}

ext_module_specs_opt:
| 
    {                    ( [] )}
| _1 = ext_module_specs
    {                    ( _1 )}

ext_module_specs:
| _1 = ext_module_spec
    {                                   ( [_1] )}
| _1 = ext_module_spec _2 = ext_module_specs
    {                                   ( _1::_2 )}

ext_module_spec:
| _1 = ext_function_markup _2 = ext_function_specs_opt
    {                                             ( (_1,_2) )}

ext_function_specs_opt:
| 
    {                      ( [] )}
| _1 = ext_function_specs
    {                      ( _1 )}

ext_function_specs:
| _1 = ext_at_loop_markup
    {                      ( [])}
| _1 = ext_at_stmt_markup
    {                      ( [])}
| _1 = ext_function_spec
    {                      ( [_1] )}
| _1 = ext_function_spec _2 = ext_function_specs
    {                                       ( _1::_2 )}

ext_function_spec:
| _1 = ext_global_clause
    {    ( Ext_glob _1 )}
| _1 = ext_at_loop_markup _2 = ext_stmt_loop_spec
    {    ( Ext_loop_spec(_1,_2,loc()) )}
| _1 = ext_at_stmt_markup _2 = ext_stmt_loop_spec
    {    ( Ext_stmt_spec(_1,_2,loc()) )}
| _1 = ext_contract_markup _2 = contract
    {    ( let s,pos = _2 in Ext_spec (s,pos) )}

ext_stmt_loop_spec:
| _1 = annotation
    {             ( _1 )}
| _1 = ext_contract_markup _2 = contract
    {                               ( let s, pos = _2 in Acode_annot (pos, AStmtSpec ([],s)) )}

ext_identifier_opt:
| 
    {                 ( "" )}
| _1 = ext_identifier
    {                 ( _1 )}

ext_identifier:
| _1 = any_identifier
    {                 ( _1 )}

ext_module_markup:
| _1 = MODULE _2 = ext_identifier _3 = COLON
    {                              ( _2 )}

ext_function_markup:
| _1 = FUNCTION _2 = ext_identifier _3 = COLON
    {                                ( _2, loc() )}

ext_contract_markup:
| _1 = CONTRACT _2 = ext_identifier_opt _3 = COLON
    {                                    ( _2 )}

ext_at_loop_markup:
| _1 = EXT_AT _2 = LOOP _3 = CONSTANT10 _4 = COLON
    {                               ( _3 )}

ext_at_stmt_markup:
| _1 = EXT_AT _2 = CONSTANT10 _3 = COLON
    {                              ( _2 )}
| _1 = EXT_AT _2 = any_identifier _3 = COLON
    {                              ( _2 )}

spec:
| _1 = contract _2 = EOF
    {               ( _1 )}

contract:
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = complete_or_disjoint
    {    ( let requires=_1 in
      let (allocation,assigns,post_cond,extended) = _4 in
      let behaviors = _5 in
      let (completes,disjoints) = _6 in
      let behaviors =
        if 
          requires <> [] || post_cond <> [] ||
	    allocation <> FreeAllocAny ||
            assigns <> WritesAny || extended <> [] 
        then
	  let allocation = 
	    if allocation <> FreeAllocAny then Some allocation else None
	  in
            (mk_behavior ~requires ~post_cond ~assigns ~allocation 
	       ~extended:(wrap_extended extended) ()) :: behaviors
        else behaviors
      in
        { spec_terminates = _2;
          spec_variant = _3;
          spec_behavior = behaviors;
          spec_complete_behaviors = completes;
          spec_disjoint_behaviors = disjoints;
        }, loc()
    )}
| _1 = requires _2 = ne_terminates _3 = REQUIRES
    {                                  ( clause_order 3 "requires" "terminates" )}
| _1 = requires _2 = terminates _3 = ne_decreases _4 = REQUIRES
    {      ( clause_order 4 "requires" "decreases" )}
| _1 = requires _2 = terminates _3 = ne_decreases _4 = TERMINATES
    {      ( clause_order 4 "terminates" "decreases" )}
| _1 = requires _2 = terminates _3 = decreases _4 = ne_simple_clauses _5 = REQUIRES
    {      ( clause_order 5 "requires" "post-condition or assigns" )}
| _1 = requires _2 = terminates _3 = decreases _4 = ne_simple_clauses _5 = TERMINATES
    {      ( clause_order 5 "terminates" "post-condition or assigns" )}
| _1 = requires _2 = terminates _3 = decreases _4 = ne_simple_clauses _5 = DECREASES
    {      ( clause_order 5 "decreases" "post-condition or assigns" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = ne_behaviors _6 = TERMINATES
    {      ( clause_order 6 "terminates" "behavior" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = ne_behaviors _6 = DECREASES
    {      ( clause_order 6 "decreases" "behavior" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = REQUIRES
    {      ( clause_order 7 "requires" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = TERMINATES
    {      ( clause_order 7 "terminates" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = DECREASES
    {      ( clause_order 7 "decreases" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = BEHAVIOR
    {      ( clause_order 7 "behavior" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = ASSIGNS
    {      ( clause_order 7 "assigns" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = ALLOCATES
    {      ( clause_order 7 "allocates" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = FREES
    {      ( clause_order 7 "frees" "complete or disjoint" )}
| _1 = requires _2 = terminates _3 = decreases _4 = simple_clauses _5 = behaviors _6 = ne_complete_or_disjoint _7 = post_cond_kind
    {      ( clause_order 7 "post-condition" "complete or disjoint" )}

clause_kw:
| _1 = REQUIRES
    {           ( "requires" )}
| _1 = ASSUMES
    {          ("assumes")}
| _1 = ASSIGNS
    {          ( "assigns" )}
| _1 = post_cond
    {            ( snd _1 )}
| _1 = DECREASES
    {            ( "decreases")}
| _1 = BEHAVIOR
    {           ( "behavior")}
| _1 = ALLOCATES
    {            ("allocates")}
| _1 = FREES
    {        ("frees")}
| _1 = COMPLETE
    {           ("complete")}
| _1 = DISJOINT
    {           ("disjoint")}
| _1 = IDENTIFIER
    {             ( _1 )}
| _1 = EOF
    {      ( "end of annotation" )}

requires:
| 
    {                ( [] )}
| _1 = ne_requires
    {              ( _1 )}

ne_requires:
| _1 = REQUIRES _2 = full_lexpr _3 = SEMICOLON _4 = requires
    {                                         ( _2::_4 )}
| _1 = REQUIRES _2 = full_lexpr _3 = clause_kw
    {                                ( missing 2 ";" _3)}

terminates:
| 
    {                             ( None )}
| _1 = ne_terminates
    {                ( Some _1 )}

ne_terminates:
| _1 = TERMINATES _2 = full_lexpr _3 = SEMICOLON
    {                                  ( _2 )}
| _1 = TERMINATES _2 = full_lexpr _3 = clause_kw
    {                                  ( missing 2 ";" _3 )}

decreases:
| 
    {                  ( None )}
| _1 = ne_decreases
    {               ( Some _1 )}

ne_decreases:
| _1 = DECREASES _2 = variant _3 = SEMICOLON
    {                              ( _2 )}
| _1 = DECREASES _2 = variant _3 = clause_kw
    {                              ( missing 2 ";" _3 )}

variant:
| _1 = full_lexpr _2 = FOR _3 = any_identifier
    {                                ( (_1, Some _3) )}
| _1 = full_lexpr
    {                                ( (_1, None) )}

simple_clauses:
| 
    {                ( FreeAllocAny,WritesAny,[],[] )}
| _1 = ne_simple_clauses
    {                    ( _1 )}

allocation:
| _1 = ALLOCATES _2 = full_zones
    {                       ( FreeAlloc([],_2) )}
| _1 = FREES _2 = full_zones
    {                   ( FreeAlloc(_2,[]) )}

ne_simple_clauses:
| _1 = post_cond_kind _2 = full_lexpr _3 = SEMICOLON _4 = simple_clauses
    {    ( let allocation,assigns,post_cond,extended = _4 in allocation,assigns,((_1,_2)::post_cond),extended )}
| _1 = allocation _2 = SEMICOLON _3 = simple_clauses
    {    ( let allocation,assigns,post_cond,extended = _3 in
      let a = concat_allocation allocation _1 in
      a,assigns,post_cond,extended
    )}
| _1 = ASSIGNS _2 = full_assigns _3 = SEMICOLON _4 = simple_clauses
    {    ( let allocation,assigns,post_cond,extended = _4 in
      let a = concat_assigns assigns _2
      in allocation,a,post_cond,extended
    )}
| _1 = grammar_extension _2 = SEMICOLON _3 = simple_clauses
    {    ( let allocation,assigns,post_cond,extended = _3 in
      allocation,assigns,post_cond,_1::extended
    )}
| _1 = post_cond_kind _2 = full_lexpr _3 = clause_kw
    {                                      ( missing 2 ";" _3 )}
| _1 = allocation _2 = clause_kw
    {                       ( missing 1 ";" _2 )}
| _1 = ASSIGNS _2 = full_assigns _3 = clause_kw
    {                                 ( missing 2 ";" _3 )}
| _1 = grammar_extension _2 = clause_kw
    {                              ( missing 1 ";" _2 )}

grammar_extension:
| _1 = grammar_extension_name _2 = full_zones
    {                                    ( _1,_2 )}

post_cond_kind:
| _1 = post_cond
    {            ( fst _1 )}

behaviors:
| 
    {                ( [] )}
| _1 = ne_behaviors
    {               ( _1 )}

ne_behaviors:
| _1 = BEHAVIOR _2 = behavior_name _3 = COLON _4 = behavior_body _5 = behaviors
    {      ( let (assumes,requires,(allocation,assigns,post_cond,extended)) = _4 in
	let behaviors = _5 in
	let allocation = Some allocation in
	let b =
	  Cil.mk_behavior 
            ~name:_2 ~assumes ~requires ~post_cond ~assigns ~allocation
            ~extended:(wrap_extended extended) ()
	in b::behaviors
      )}

behavior_body:
| _1 = assumes _2 = requires _3 = simple_clauses
    {                                  ( _1,_2,_3 )}
| _1 = assumes _2 = ne_requires _3 = ASSUMES
    {      ( clause_order 3 "assumes" "requires" )}
| _1 = assumes _2 = requires _3 = ne_simple_clauses _4 = ASSUMES
    {      ( clause_order 4 "assumes" "assigns or post-condition" )}
| _1 = assumes _2 = requires _3 = ne_simple_clauses _4 = REQUIRES
    {      ( clause_order 4 "requires" "assigns or post-condition" )}

assumes:
| 
    {                ( [] )}
| _1 = ASSUMES _2 = full_lexpr _3 = SEMICOLON _4 = assumes
    {                                       ( _2::_4 )}
| _1 = ASSUMES _2 = full_lexpr _3 = clause_kw
    {                               ( missing 2 ";" _3 )}

complete_or_disjoint:
| 
    {                ( [],[] )}
| _1 = ne_complete_or_disjoint
    {                          ( _1 )}

ne_complete_or_disjoint:
| _1 = COMPLETE _2 = BEHAVIORS _3 = behavior_name_list _4 = SEMICOLON _5 = complete_or_disjoint
    {      ( let complete,disjoint = _5 in _3::complete, disjoint )}
| _1 = DISJOINT _2 = BEHAVIORS _3 = behavior_name_list _4 = SEMICOLON _5 = complete_or_disjoint
    {      ( let complete,disjoint = _5 in complete,_3::disjoint )}
| _1 = COMPLETE _2 = BEHAVIORS _3 = ne_behavior_name_list _4 = clause_kw
    {                                                     ( missing 3 ";" _4 )}
| _1 = DISJOINT _2 = BEHAVIORS _3 = ne_behavior_name_list _4 = clause_kw
    {                                                     ( missing 3 ";" _4 )}

assigns:
| _1 = zones
    {        ( List.map (fun x -> (x,FromAny)) _1 )}
| _1 = ne_zones _2 = FROM _3 = zones
    {                      (List.map (fun x -> (x, From _3)) _1)}

zones:
| _1 = ne_zones
    {           ( _1 )}
| _1 = NOTHING
    {           ( [] )}

ne_zones:
| _1 = ne_lexpr_list
    {                ( _1 )}

annot:
| _1 = annotation _2 = EOF
    {                  ( _1 )}
| _1 = is_spec _2 = any _3 = EOF
    {                  ( Aspec )}
| _1 = decl_list _2 = EOF
    {                  ( Adecl (_1) )}
| _1 = CUSTOM _2 = any_identifier _3 = COLON _4 = custom_tree _5 = EOF
    {                                              ( Acustom(loc (),_2, _4) )}

custom_tree:
| _1 = TYPE _2 = type_spec
    {                  ( CustomType _2 )}
| _1 = LOGIC _2 = lexpr %prec prec_named
    {                                  ( CustomLexpr _2 )}
| _1 = any_identifier_non_logic %prec lowest
    {                                        ( CustomOther(_1,[]) )}
| _1 = any_identifier_non_logic _2 = LPAR _3 = custom_tree_list _4 = RPAR %prec lowest
    {                                                                   ( CustomOther(_1,_3) )}

custom_tree_list:
| _1 = custom_tree
    {                ( [_1] )}
| _1 = custom_tree _2 = COMMA _3 = custom_tree_list
    {                                      ( _1::_3 )}

annotation:
| _1 = loop_annotations
    {      ( let (b,v,p) = _1 in
	(* TODO: do better, do not lose the structure ! *)
	let l = b@v@p in
        Aloop_annot (loc (), l) )}
| _1 = FOR _2 = ne_behavior_name_list _3 = COLON _4 = contract
    {      ( let s, pos = _4 in Acode_annot (pos, AStmtSpec (_2,s)) )}
| _1 = code_annotation
    {                  ( Acode_annot (loc(),_1) )}
| _1 = code_annotation _2 = beg_code_annotation
    {      ( raise
          (Not_well_formed (loc(),
                            "Only one code annotation is allowed per comment"))
      )}
| _1 = full_identifier_or_typename
    {                              ( Aattribute_annot (loc (), _1) )}

loop_annotations:
| _1 = loop_annot_stack
    {    ( let (i,fa,a,b,v,p) = _1 in
      let invs = List.map (fun i -> AInvariant([],true,i)) i in
      let oth = match a with
        | WritesAny -> b
        | Writes _ -> 
            (* by definition all existing AAssigns are tied to at least
               one behavior. No need to merge against them. *)
            AAssigns ([],a)::b
      in
      let oth = match fa with
        | FreeAllocAny -> oth
        | _ -> AAllocation ([],fa)::oth
      in
	(invs@oth,v,p)
    )}

loop_annot_stack:
| _1 = loop_invariant _2 = loop_annot_opt
    {    ( let (i,fa,a,b,v,p) = _2 in (_1::i,fa,a,b,v,p) )}
| _1 = loop_effects _2 = loop_annot_opt
    {    ( let (i,fa,a,b,v,p) = _2 in (i,fa,concat_assigns a _1,b,v,p) )}
| _1 = loop_allocation _2 = loop_annot_opt
    {    ( let (i,fa,a,b,v,p) = _2 in (i,concat_allocation fa _1,a,b,v,p) )}
| _1 = FOR _2 = ne_behavior_name_list _3 = COLON _4 = loop_annot_stack
    {    ( let (i,fa,a,b,v,p) = _4 in
      let behav = _2 in
      let invs = List.map (fun i -> AInvariant(behav,true,i)) i in
      let oth = concat_loop_assigns_allocation b behav a fa in
      ([],FreeAllocAny,WritesAny,invs@oth,v,p)
    )}
| _1 = loop_variant _2 = loop_annot_opt
    {    ( let pos,loop_variant = _1 in
      let (i,fa,a,b,v,p) = _2 in
      check_empty
        (pos,"loop invariant is not allowed after loop variant.") i ;
      (match fa with
        | FreeAlloc(f,a) -> 
	    check_empty
              (pos,"loop frees is not allowed after loop variant.") f ;
	    check_empty
              (pos,"loop allocates is not allowed after loop variant.") a
        | FreeAllocAny -> ());
      (match a with
          WritesAny -> ()
        | Writes _ -> 
          raise 
            (Not_well_formed 
               (pos,"loop assigns is not allowed after loop variant.")));
      check_empty
        (pos,"loop behavior is not allowed after loop variant.") b ;
      check_empty
        (pos,"loop annotations can have at most one variant.") v ;
      (i,fa,a,b,AVariant loop_variant::v,p) )}
| _1 = loop_pragma _2 = loop_annot_opt
    {    ( let (i,fa,a,b,v,p) = _2 in (i,fa,a,b,v,APragma (Loop_pragma _1)::p) )}
| _1 = loop_grammar_extension _2 = loop_annot_opt
    {                                        (
    raise 
    (Not_well_formed 
       (loc(),"Grammar extension for loop annotations is not yet implemented"))
  )}

loop_annot_opt:
| 
    {    ( ([], FreeAllocAny, WritesAny, [], [], []) )}
| _1 = loop_annot_stack
    {    ( _1 )}

loop_effects:
| _1 = LOOP _2 = ASSIGNS _3 = full_assigns _4 = SEMICOLON
    {                                      ( _3 )}

loop_allocation:
| _1 = LOOP _2 = allocation _3 = SEMICOLON
    {                            ( _2 )}

loop_invariant:
| _1 = LOOP _2 = INVARIANT _3 = full_lexpr _4 = SEMICOLON
    {                                      ( _3 )}

loop_variant:
| _1 = LOOP _2 = VARIANT _3 = variant _4 = SEMICOLON
    {                                 ( loc(),_3 )}

loop_grammar_extension:
| _1 = LOOP _2 = grammar_extension _3 = SEMICOLON
    {                                   (
    raise (Not_well_formed (loc(),"Grammar extension for loop annotations is not yet implemented"))
  )}

loop_pragma:
| _1 = LOOP _2 = PRAGMA _3 = any_identifier _4 = full_ne_lexpr_list _5 = SEMICOLON
    {  ( if _3 = "UNROLL_LOOP" || _3 = "UNROLL" then
      (if _3 <> "UNROLL" then
	 Format.eprintf "Warning: use of deprecated keyword '%s'.\nShould use 'UNROLL' instead.@." _3;
       Unroll_specs _4)
    else if _3 = "WIDEN_VARIABLES" then
      Widen_variables _4
    else if _3 = "WIDEN_HINTS" then
      Widen_hints _4
    else raise (Not_well_formed (loc(),"Unknown loop pragma")) )}

beg_code_annotation:
| _1 = IMPACT
    {         ()}
| _1 = SLICE
    {        ()}
| _1 = FOR
    {      ()}
| _1 = ASSERT
    {         ()}
| _1 = INVARIANT
    {            ()}

code_annotation:
| _1 = slice_pragma
    {                   ( APragma (Slice_pragma _1) )}
| _1 = impact_pragma
    {                   ( APragma (Impact_pragma _1) )}
| _1 = FOR _2 = ne_behavior_name_list _3 = COLON _4 = ASSERT _5 = full_lexpr _6 = SEMICOLON
    {      ( AAssert (_2,_5) )}
| _1 = FOR _2 = ne_behavior_name_list _3 = COLON _4 = INVARIANT _5 = full_lexpr _6 = SEMICOLON
    {      ( AInvariant (_2,false,_5) )}
| _1 = ASSERT _2 = full_lexpr _3 = SEMICOLON
    {                                 ( AAssert ([],_2) )}
| _1 = INVARIANT _2 = full_lexpr _3 = SEMICOLON
    {                                 ( AInvariant ([],false,_2) )}

slice_pragma:
| _1 = SLICE _2 = PRAGMA _3 = any_identifier _4 = full_lexpr _5 = SEMICOLON
    {    ( if _3 = "expr" then SPexpr _4
      else raise (Not_well_formed (loc(), "Unknown slice pragma")) )}
| _1 = SLICE _2 = PRAGMA _3 = any_identifier _4 = SEMICOLON
    {    ( if _3 = "ctrl" then SPctrl
      else if _3 = "stmt" then SPstmt
      else raise (Not_well_formed (loc(), "Unknown slice pragma")) )}

impact_pragma:
| _1 = IMPACT _2 = PRAGMA _3 = any_identifier _4 = full_lexpr _5 = SEMICOLON
    {    ( if _3 = "expr" then IPexpr _4
      else raise (Not_well_formed (loc(), "Unknown impact pragma")) )}
| _1 = IMPACT _2 = PRAGMA _3 = any_identifier _4 = SEMICOLON
    {    ( if _3 = "stmt" then IPstmt
      else raise (Not_well_formed (loc(), "Unknown impact pragma")) )}

decl_list:
| _1 = decl
    {                  ( [loc_decl _1] )}
| _1 = decl _2 = decl_list
    {                  ( (loc_decl _1) :: _2 )}

decl:
| _1 = GLOBAL _2 = INVARIANT _3 = any_identifier _4 = COLON _5 = full_lexpr _6 = SEMICOLON
    {    ( LDinvariant (_3, _5) )}
| _1 = VOLATILE _2 = ne_zones _3 = volatile_opt _4 = SEMICOLON
    {                                           ( LDvolatile (_2, _3) )}
| _1 = type_annot
    {             (LDtype_annot _1)}
| _1 = model_annot
    {              (LDmodel_annot _1)}
| _1 = logic_def
    {             ( _1 )}
| _1 = deprecated_logic_decl
    {                        ( _1 )}

volatile_opt:
| 
    {              ( None, None )}
| _1 = READS _2 = any_identifier _3 = volatile_opt
    {              ( let read,write=_3 in
                  if read = None then
		    (Some _2),write
		  else
                    (Format.eprintf "Warning: read %s ignored@." _2; _3)
	      )}
| _1 = WRITES _2 = any_identifier _3 = volatile_opt
    {              ( let read,write=_3 in
                  if write = None then
		    read,(Some _2)
		  else
                    (Format.eprintf "Warning: write %s ignored@." _2; _3)
	      )}

type_annot:
| _1 = TYPE _2 = INVARIANT _3 = any_identifier _4 = LPAR _5 = full_parameter _6 = RPAR _7 = EQUAL _8 = full_lexpr _9 = SEMICOLON
    {  ( let typ,name = _5 in{ inv_name = _3; this_name = name; this_type = typ; inv = _8; } )}

opt_semicolon:
| 
    {                ( )}
| _1 = SEMICOLON
    {            ( )}

model_annot:
| _1 = MODEL _2 = type_spec _3 = LBRACE _4 = full_parameter _5 = opt_semicolon _6 = RBRACE _7 = SEMICOLON
    {  ( let typ,name = _4 in 
    { model_for_type = _2; model_name = name; model_type = typ; } 
  )}

poly_id_type:
| _1 = full_identifier
    {    ( enter_type_variables_scope []; (_1,[]) )}
| _1 = full_identifier _2 = LT _3 = ne_tvar_list _4 = GT
    {        ( enter_type_variables_scope _3; (_1,_3) )}

poly_id_type_add_typename:
| _1 = poly_id_type
    {               ( let (id,_) = _1 in Logic_env.add_typename id; _1 )}

poly_id:
| _1 = poly_id_type
    {               ( let (id,tvar) = _1 in (id,[],tvar) )}
| _1 = full_identifier _2 = LBRACE _3 = ne_label_list _4 = RBRACE
    {      ( enter_type_variables_scope []; (_1,_3,[]) )}
| _1 = full_identifier _2 = LBRACE _3 = ne_label_list _4 = RBRACE _5 = LT _6 = ne_tvar_list _7 = GT
    {      ( enter_type_variables_scope _6; _1,_3,_6 )}

opt_parameters:
| 
    {              ( [] )}
| _1 = parameters
    {             ( _1 )}

parameters:
| _1 = LPAR _2 = full_parameters _3 = RPAR
    {                            ( _2 )}

logic_def:
| _1 = LOGIC _2 = full_logic_rt_type _3 = poly_id _4 = opt_parameters _5 = EQUAL _6 = full_lexpr _7 = SEMICOLON
    {    ( let (id, labels, tvars) = _3 in
      exit_type_variables_scope ();
      LDlogic_def (id, labels, tvars, _2, _4, _6) )}
| _1 = PREDICATE _2 = poly_id _3 = opt_parameters _4 = EQUAL _5 = full_lexpr _6 = SEMICOLON
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      LDpredicate_def (id, labels, tvars, _3, _5) )}
| _1 = INDUCTIVE _2 = poly_id _3 = parameters _4 = LBRACE _5 = indcases _6 = RBRACE
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      LDinductive_def(id, labels, tvars, _3, _5) )}
| _1 = LEMMA _2 = poly_id _3 = COLON _4 = full_lexpr _5 = SEMICOLON
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      LDlemma (id, false, labels, tvars, _4) )}
| _1 = AXIOMATIC _2 = any_identifier _3 = LBRACE _4 = logic_decls _5 = RBRACE
    {    ( LDaxiomatic(_2,_4) )}
| _1 = TYPE _2 = poly_id_type_add_typename _3 = EQUAL _4 = typedef _5 = SEMICOLON
    {        ( let (id,tvars) = _2 in
          exit_type_variables_scope ();
          LDtype(id,tvars,Some _4)
        )}

deprecated_logic_decl:
| _1 = LOGIC _2 = full_logic_rt_type _3 = poly_id _4 = opt_parameters _5 = SEMICOLON
    {    ( let (id, labels, tvars) = _3 in
      let source = fst (loc ()) in
      exit_type_variables_scope ();
      obsolete  "logic declaration" ~source ~now:"an axiomatic block";
      LDlogic_reads (id, labels, tvars, _2, _4, None) )}
| _1 = PREDICATE _2 = poly_id _3 = opt_parameters _4 = SEMICOLON
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      let source = fst (loc ()) in
      obsolete "logic declaration" ~source ~now:"an axiomatic block";
      LDpredicate_reads (id, labels, tvars, _3, None) )}
| _1 = TYPE _2 = poly_id_type _3 = SEMICOLON
    {    ( let (id,tvars) = _2 in
      Logic_env.add_typename id;
      exit_type_variables_scope ();
      let source = fst (loc ()) in
      obsolete "logic type declaration" ~source ~now:"an axiomatic block";
      LDtype(id,tvars,None) 
    )}
| _1 = AXIOM _2 = poly_id _3 = COLON _4 = full_lexpr _5 = SEMICOLON
    {    ( let (id,_,_) = _2 in
      raise
	(Not_well_formed
	   (loc(),"Axiom " ^ id ^ " is declared outside of an axiomatic."))
    )}

logic_decls:
| 
    {    ( [] )}
| _1 = logic_decl_loc _2 = logic_decls
    {    ( _1::_2 )}

logic_decl:
| _1 = logic_def
    {             ( _1 )}
| _1 = LOGIC _2 = full_logic_rt_type _3 = poly_id _4 = opt_parameters _5 = reads_clause _6 = SEMICOLON
    {    ( let (id, labels, tvars) = _3 in
      exit_type_variables_scope ();
      LDlogic_reads (id, labels, tvars, _2, _4, _5) )}
| _1 = PREDICATE _2 = poly_id _3 = opt_parameters _4 = reads_clause _5 = SEMICOLON
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      LDpredicate_reads (id, labels, tvars, _3, _4) )}
| _1 = TYPE _2 = poly_id_type _3 = SEMICOLON
    {    ( let (id,tvars) = _2 in
      Logic_env.add_typename id;
      exit_type_variables_scope ();
      LDtype(id,tvars,None) )}
| _1 = AXIOM _2 = poly_id _3 = COLON _4 = full_lexpr _5 = SEMICOLON
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      LDlemma (id, true, labels, tvars, _4) )}

logic_decl_loc:
| _1 = logic_decl
    {             ( loc_decl _1 )}

reads_clause:
| 
    {                ( None )}
| _1 = READS _2 = zones
    {              ( Some _2 )}

typedef:
| _1 = ne_datacons_list
    {                   ( TDsum _1 )}
| _1 = full_logic_type
    {                  ( TDsyn _1 )}

datacons_list:
| 
    {                ( [] )}
| _1 = PIPE _2 = datacons _3 = datacons_list
    {                              ( _2 :: _3 )}

ne_datacons_list:
| _1 = datacons _2 = datacons_list
    {                         ( _1 :: _2 )}
| _1 = PIPE _2 = datacons _3 = datacons_list
    {                              ( _2 :: _3 )}

datacons:
| _1 = full_identifier
    {                  ( (_1,[]) )}
| _1 = full_identifier _2 = LPAR _3 = ne_type_list _4 = RPAR
    {                                         ( (_1,_3) )}

ne_type_list:
| _1 = full_logic_type
    {                  ( [_1] )}
| _1 = full_logic_type _2 = COMMA _3 = ne_type_list
    {                                     ( _1::_3 )}

indcases:
| 
    {    ( [] )}
| _1 = CASE _2 = poly_id _3 = COLON _4 = full_lexpr _5 = SEMICOLON _6 = indcases
    {    ( let (id,labels,tvars) = _2 in
      exit_type_variables_scope ();
      (id,labels,tvars,_4)::_6 )}

ne_tvar_list:
| _1 = full_identifier
    {                                     ( [_1] )}
| _1 = full_identifier _2 = COMMA _3 = ne_tvar_list
    {                                     ( _1 :: _3 )}

ne_label_list:
| _1 = label_name
    {                                 ( [_1] )}
| _1 = label_name _2 = COMMA _3 = ne_label_list
    {                                 ( _1 :: _3 )}

opt_label_1:
| _1 = opt_label_list
    {                 ( match _1 with 
		     | [] -> None
		     | l::[] -> Some l
		     | _ -> raise (Not_well_formed (loc(),"Only one label is allowed")) )}

opt_label_2:
| _1 = opt_label_list
    {                 ( match _1 with 
		     | [] -> None
		     | l1::l2::[] -> Some (l1,l2)
		     | _::[] -> raise (Not_well_formed (loc(),"One label is missing"))
		     | _ -> raise (Not_well_formed (loc(),"Only two labels are allowed")) )}

opt_label_list:
| 
    {                              ( [] )}
| _1 = LBRACE _2 = ne_label_list _3 = RBRACE
    {                              ( _2 )}

label_name:
| _1 = any_identifier
    {                 ( _1 )}

behavior_name_list:
| 
    {                        ( [] )}
| _1 = ne_behavior_name_list
    {                        ( _1 )}

ne_behavior_name_list:
| _1 = behavior_name
    {                                            ( [_1] )}
| _1 = behavior_name _2 = COMMA _3 = ne_behavior_name_list
    {                                            (_1 :: _3)}

behavior_name:
| _1 = any_identifier
    {                 ( _1 )}

any_identifier:
| _1 = identifier_or_typename
    {                         ( _1 )}
| _1 = keyword
    {          ( _1 )}

any_identifier_non_logic:
| _1 = identifier_or_typename
    {                         ( _1 )}
| _1 = non_logic_keyword
    {                    ( _1 )}

identifier_or_typename:
| _1 = IDENTIFIER
    {             ( _1 )}
| _1 = TYPENAME
    {           ( _1 )}

identifier:
| _1 = IDENTIFIER
    {             ( _1 )}

bounded_var:
| _1 = identifier
    {             ( _1 )}
| _1 = TYPENAME
    {    ( raise
	(Not_well_formed(loc (),
			 "Type names are not allowed as binding variable"))
    )}

c_keyword:
| _1 = CASE
    {       ( "case" )}
| _1 = CHAR
    {       ( "char" )}
| _1 = BOOLEAN
    {          ( "boolean" )}
| _1 = BOOL
    {       ( "_Bool" )}
| _1 = CONST
    {        ( "const" )}
| _1 = DOUBLE
    {         ( "double" )}
| _1 = ELSE
    {       ( "else" )}
| _1 = ENUM
    {       ( "enum" )}
| _1 = FLOAT
    {        ( "float" )}
| _1 = IF
    {     ( "if" )}
| _1 = INT
    {      ( "int" )}
| _1 = LONG
    {       ( "long" )}
| _1 = SHORT
    {        ( "short" )}
| _1 = SIGNED
    {         ( "signed" )}
| _1 = SIZEOF
    {         ( "sizeof" )}
| _1 = STATIC
    {         ( "static" )}
| _1 = STRUCT
    {         ( "struct" )}
| _1 = UNION
    {        ( "union" )}
| _1 = UNSIGNED
    {           ( "unsigned" )}
| _1 = VOID
    {       ( "void" )}

acsl_c_keyword:
| _1 = FOR
    {      ( "for" )}
| _1 = VOLATILE
    {           ( "volatile" )}

post_cond:
| _1 = ENSURES
    {          ( Normal, "normal" )}
| _1 = EXITS
    {          ( Exits, "exits" )}
| _1 = BREAKS
    {          ( Breaks, "breaks" )}
| _1 = CONTINUES
    {            ( Continues, "continues" )}
| _1 = RETURNS
    {          ( Returns, "returns" )}

is_acsl_spec:
| _1 = post_cond
    {             ( snd _1 )}
| _1 = ASSIGNS
    {             ( "assigns" )}
| _1 = ALLOCATES
    {             ( "allocates" )}
| _1 = FREES
    {             ( "frees" )}
| _1 = BEHAVIOR
    {             ( "behavior" )}
| _1 = REQUIRES
    {             ( "requires" )}
| _1 = TERMINATES
    {             ( "terminates" )}
| _1 = COMPLETE
    {             ( "complete" )}
| _1 = DECREASES
    {             ( "decreases" )}
| _1 = DISJOINT
    {             ( "disjoint" )}

is_acsl_decl_or_code_annot:
| _1 = ASSERT
    {            ( "assert" )}
| _1 = ASSUMES
    {            ( "assumes" )}
| _1 = GLOBAL
    {            ( "global" )}
| _1 = IMPACT
    {            ( "impact" )}
| _1 = INDUCTIVE
    {            ( "inductive" )}
| _1 = INVARIANT
    {            ( "invariant" )}
| _1 = LEMMA
    {            ( "lemma" )}
| _1 = LOOP
    {            ( "loop" )}
| _1 = PRAGMA
    {            ( "pragma" )}
| _1 = PREDICATE
    {            ( "predicate" )}
| _1 = SLICE
    {            ( "slice" )}
| _1 = TYPE
    {            ( "type" )}
| _1 = MODEL
    {            ( "model" )}
| _1 = AXIOM
    {            ( "axiom" )}
| _1 = VARIANT
    {            ( "variant" )}
| _1 = AXIOMATIC
    {            ( "axiomatic" )}

is_acsl_other:
| _1 = BEHAVIORS
    {            ( "behaviors" )}
| _1 = INTEGER
    {          ( "integer" )}
| _1 = LABEL
    {        ( "label" )}
| _1 = READS
    {        ( "reads" )}
| _1 = REAL
    {       ( "real" )}
| _1 = WRITES
    {         ( "writes" )}

is_ext_spec:
| _1 = CONTRACT
    {           ( "contract" )}
| _1 = FUNCTION
    {           ( "function" )}
| _1 = MODULE
    {           ( "module" )}
| _1 = INCLUDE
    {           ( "include" )}
| _1 = EXT_AT
    {           ( "at" )}
| _1 = EXT_LET
    {           ( "let" )}

keyword:
| _1 = LOGIC
    {            ( "logic" )}
| _1 = non_logic_keyword
    {                    ( _1 )}

non_logic_keyword:
| _1 = c_keyword
    {                 ( _1 )}
| _1 = acsl_c_keyword
    {                 ( _1 )}
| _1 = is_ext_spec
    {                 ( _1 )}
| _1 = is_acsl_spec
    {                 ( _1 )}
| _1 = is_acsl_decl_or_code_annot
    {                             ( _1 )}
| _1 = is_acsl_other
    {                 ( _1 )}
| _1 = CUSTOM
    {         ( "custom" )}

grammar_extension_name:
| _1 = full_identifier_or_typename
    {                              ( check_registered _1 )}
| _1 = is_acsl_other
    {                ( check_registered _1 )}
| _1 = c_keyword
    {                ( check_registered _1 )}

is_spec:
| _1 = is_acsl_spec
    {               ( () )}
| _1 = grammar_extension_name
    {                         ( () )}

bs_keyword:
| _1 = ALLOCABLE
    {            ( () )}
| _1 = ALLOCATION
    {             ( () )}
| _1 = AUTOMATIC
    {            ( () )}
| _1 = AT
    {     ( () )}
| _1 = BASE_ADDR
    {            ( () )}
| _1 = BLOCK_LENGTH
    {               ( () )}
| _1 = DYNAMIC
    {          ( () )}
| _1 = EMPTY
    {        ( () )}
| _1 = FALSE
    {        ( () )}
| _1 = FORALL
    {         ( () )}
| _1 = FREEABLE
    {           ( () )}
| _1 = FRESH
    {        ( () )}
| _1 = FROM
    {       ( () )}
| _1 = INTER
    {        ( () )}
| _1 = LAMBDA
    {         ( () )}
| _1 = LET
    {      ( () )}
| _1 = NOTHING
    {          ( () )}
| _1 = NULL
    {       ( () )}
| _1 = OLD
    {      ( () )}
| _1 = OFFSET
    {         ( () )}
| _1 = REGISTER
    {           ( () )}
| _1 = RESULT
    {         ( () )}
| _1 = SEPARATED
    {            ( () )}
| _1 = TRUE
    {       ( () )}
| _1 = BSTYPE
    {         ( () )}
| _1 = TYPEOF
    {         ( () )}
| _1 = BSUNION
    {          ( () )}
| _1 = UNALLOCATED
    {              ( () )}
| _1 = VALID
    {        ( () )}
| _1 = VALID_INDEX
    {              ( () )}
| _1 = VALID_RANGE
    {              ( () )}
| _1 = VALID_READ
    {             ( () )}
| _1 = INITIALIZED
    {              ( () )}
| _1 = DANGLING
    {           ( () )}
| _1 = WITH
    {       ( () )}

wildcard:
| _1 = any_identifier
    {                 ( () )}
| _1 = bs_keyword
    {             ( () )}
| _1 = AMP
    {      ( () )}
| _1 = AND
    {      ( () )}
| _1 = ARROW
    {        ( () )}
| _1 = BIFF
    {       ( () )}
| _1 = BIMPLIES
    {           ( () )}
| _1 = COLON
    {        ( () )}
| _1 = COLON2
    {         ( () )}
| _1 = COLONCOLON
    {             ( () )}
| _1 = COLONGT
    {          ( () )}
| _1 = COMMA
    {        ( () )}
| _1 = CONSTANT
    {           ( () )}
| _1 = CONSTANT10
    {             ( () )}
| _1 = DOLLAR
    {         ( () )}
| _1 = DOT
    {      ( () )}
| _1 = DOTDOT
    {         ( () )}
| _1 = DOTDOTDOT
    {            ( () )}
| _1 = EQ
    {     ( () )}
| _1 = EQUAL
    {        ( () )}
| _1 = EXISTS
    {         ( () )}
| _1 = GE
    {     ( () )}
| _1 = GHOST
    {        ( () )}
| _1 = GT
    {     ( () )}
| _1 = GTGT
    {       ( () )}
| _1 = HAT
    {      ( () )}
| _1 = HATHAT
    {         ( () )}
| _1 = IFF
    {      ( () )}
| _1 = IMPLIES
    {          ( () )}
| _1 = LBRACE
    {         ( () )}
| _1 = LE
    {     ( () )}
| _1 = LPAR
    {       ( () )}
| _1 = LSQUARE
    {          ( () )}
| _1 = LT
    {     ( () )}
| _1 = LTCOLON
    {          ( () )}
| _1 = LTLT
    {       ( () )}
| _1 = MINUS
    {        ( () )}
| _1 = NE
    {     ( () )}
| _1 = NOT
    {      ( () )}
| _1 = OR
    {     ( () )}
| _1 = PERCENT
    {          ( () )}
| _1 = PIPE
    {       ( () )}
| _1 = PLUS
    {       ( () )}
| _1 = QUESTION
    {           ( () )}
| _1 = RBRACE
    {         ( () )}
| _1 = RPAR
    {       ( () )}
| _1 = RSQUARE
    {          ( () )}
| _1 = SEMICOLON
    {            ( () )}
| _1 = SLASH
    {        ( () )}
| _1 = STAR
    {       ( () )}
| _1 = STRING_LITERAL
    {                 ( () )}
| _1 = TILDE
    {        ( () )}

any:
| _1 = wildcard
    {           ( () )}
| _1 = wildcard _2 = any
    {               ( () )}

%%


(*
Local Variables:
compile-command: "make -C ../../.."
End:
*)