on master help sign in
tidy up parser library documentation
bc92430martinbaker
docs/image/parserModules.png

Binary file not shown.

docs/image/parserModules.svg+62−62
@@ -318,7 +318,7 @@
318 inkscape:stockid="Arrow1Mend">
318 inkscape:stockid="Arrow1Mend">
319 <path
319 <path
320 transform="scale(0.4) rotate(180) translate(10,0)"
320 transform="scale(0.4) rotate(180) translate(10,0)"
321− style="fill-rule:evenodd;stroke:#0000ff;stroke-width:1pt;stroke-opacity:1;fill:#0000ff;fill-opacity:1"
321+ style="fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1;fill:#ff0000;fill-opacity:1"
322 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
322 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
323 id="path1001" />
323 id="path1001" />
324 </marker>
324 </marker>
@@ -334,7 +334,7 @@
334 <path
334 <path
335 id="path995"
335 id="path995"
336 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
336 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
337− style="fill-rule:evenodd;stroke:#0000ff;stroke-width:1pt;stroke-opacity:1;fill:#0000ff;fill-opacity:1"
337+ style="fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1;fill:#ff0000;fill-opacity:1"
338 transform="scale(0.4) rotate(180) translate(10,0)" />
338 transform="scale(0.4) rotate(180) translate(10,0)" />
339 </marker>
339 </marker>
340 <marker
340 <marker
@@ -348,7 +348,7 @@
348 inkscape:collect="always">
348 inkscape:collect="always">
349 <path
349 <path
350 transform="scale(0.4) rotate(180) translate(10,0)"
350 transform="scale(0.4) rotate(180) translate(10,0)"
351− style="fill-rule:evenodd;stroke:#0000ff;stroke-width:1pt;stroke-opacity:1;fill:#0000ff;fill-opacity:1"
351+ style="fill-rule:evenodd;stroke:#ff0000;stroke-width:1pt;stroke-opacity:1;fill:#ff0000;fill-opacity:1"
352 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
352 d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
353 id="path989" />
353 id="path989" />
354 </marker>
354 </marker>
@@ -436,13 +436,13 @@
436 inkscape:pageshadow="2"
436 inkscape:pageshadow="2"
437 inkscape:zoom="1"
437 inkscape:zoom="1"
438 inkscape:cx="368.33949"
438 inkscape:cx="368.33949"
439− inkscape:cy="617.07597"
439+ inkscape:cy="547.05121"
440 inkscape:document-units="mm"
440 inkscape:document-units="mm"
441 inkscape:current-layer="layer1"
441 inkscape:current-layer="layer1"
442 showgrid="false"
442 showgrid="false"
443 inkscape:window-width="1800"
443 inkscape:window-width="1800"
444 inkscape:window-height="1011"
444 inkscape:window-height="1011"
445− inkscape:window-x="0"
445+ inkscape:window-x="86"
446 inkscape:window-y="0"
446 inkscape:window-y="0"
447 inkscape:window-maximized="0"
447 inkscape:window-maximized="0"
448 inkscape:snap-nodes="false" />
448 inkscape:snap-nodes="false" />
@@ -585,11 +585,11 @@
585 id="text931"
585 id="text931"
586 y="218.41846"
586 y="218.41846"
587 x="36.512497"
587 x="36.512497"
588− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
588+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
589 xml:space="preserve"
589 xml:space="preserve"
590 inkscape:export-xdpi="61.120499"
590 inkscape:export-xdpi="61.120499"
591 inkscape:export-ydpi="61.120499"><tspan
591 inkscape:export-ydpi="61.120499"><tspan
592− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
592+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;"
593 y="218.41846"
593 y="218.41846"
594 x="36.512497"
594 x="36.512497"
595 id="tspan929"
595 id="tspan929"
@@ -615,11 +615,11 @@
615 height="6.3500061"
615 height="6.3500061"
616 width="43.656254"
616 width="43.656254"
617 id="rect937"
617 id="rect937"
618− style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
618+ style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
619 <rect
619 <rect
620 inkscape:export-ydpi="61.120499"
620 inkscape:export-ydpi="61.120499"
621 inkscape:export-xdpi="61.120499"
621 inkscape:export-xdpi="61.120499"
622− style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
622+ style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
623 id="rect939"
623 id="rect939"
624 width="42.862495"
624 width="42.862495"
625 height="6.8791728"
625 height="6.8791728"
@@ -650,7 +650,7 @@
650 inkscape:export-ydpi="61.120499"
650 inkscape:export-ydpi="61.120499"
651 inkscape:export-xdpi="61.120499"
651 inkscape:export-xdpi="61.120499"
652 xml:space="preserve"
652 xml:space="preserve"
653− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
653+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
654 x="23.220526"
654 x="23.220526"
655 y="251.01649"
655 y="251.01649"
656 id="text971"><tspan
656 id="text971"><tspan
@@ -658,9 +658,9 @@
658 id="tspan969"
658 id="tspan969"
659 x="23.220526"
659 x="23.220526"
660 y="251.01649"
660 y="251.01649"
661− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332">module Text.Lexer.Core</tspan></text>
661+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;">module Text.Lexer.Core</tspan></text>
662 <rect
662 <rect
663− style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
663+ style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
664 id="rect973"
664 id="rect973"
665 width="47.889587"
665 width="47.889587"
666 height="6.3500061"
666 height="6.3500061"
@@ -669,7 +669,7 @@
669 inkscape:export-xdpi="61.120499"
669 inkscape:export-xdpi="61.120499"
670 inkscape:export-ydpi="61.120499" />
670 inkscape:export-ydpi="61.120499" />
671 <path
671 <path
672− style="fill:none;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker991)"
672+ style="fill:none;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker991)"
673 d="m 48.369316,228.83873 0.04943,-6.71548"
673 d="m 48.369316,228.83873 0.04943,-6.71548"
674 id="path975"
674 id="path975"
675 inkscape:connector-curvature="0"
675 inkscape:connector-curvature="0"
@@ -680,11 +680,11 @@
680 id="text979"
680 id="text979"
681 y="241.96643"
681 y="241.96643"
682 x="23.283329"
682 x="23.283329"
683− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
683+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
684 xml:space="preserve"
684 xml:space="preserve"
685 inkscape:export-xdpi="61.120499"
685 inkscape:export-xdpi="61.120499"
686 inkscape:export-ydpi="61.120499"><tspan
686 inkscape:export-ydpi="61.120499"><tspan
687− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
687+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;"
688 y="241.96643"
688 y="241.96643"
689 x="23.283329"
689 x="23.283329"
690 id="tspan977"
690 id="tspan977"
@@ -697,12 +697,12 @@
697 height="6.2469702"
697 height="6.2469702"
698 width="43.853985"
698 width="43.853985"
699 id="rect981"
699 id="rect981"
700− style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
700+ style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
701 <text
701 <text
702 inkscape:export-ydpi="61.120499"
702 inkscape:export-ydpi="61.120499"
703 inkscape:export-xdpi="61.120499"
703 inkscape:export-xdpi="61.120499"
704 xml:space="preserve"
704 xml:space="preserve"
705− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
705+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
706 x="23.18244"
706 x="23.18244"
707 y="233.68523"
707 y="233.68523"
708 id="text985"><tspan
708 id="text985"><tspan
@@ -710,9 +710,9 @@
710 id="tspan983"
710 id="tspan983"
711 x="23.18244"
711 x="23.18244"
712 y="233.68523"
712 y="233.68523"
713− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332">module Text.Token</tspan></text>
713+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;">module Text.Token</tspan></text>
714 <rect
714 <rect
715− style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
715+ style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
716 id="rect987"
716 id="rect987"
717 width="39.011257"
717 width="39.011257"
718 height="5.9464455"
718 height="5.9464455"
@@ -727,9 +727,9 @@
727 inkscape:connector-curvature="0"
727 inkscape:connector-curvature="0"
728 id="path993"
728 id="path993"
729 d="M 62.998384,237.01083 62.846037,221.92147"
729 d="M 62.998384,237.01083 62.846037,221.92147"
730− style="fill:none;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker997)" />
730+ style="fill:#ff0000;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker997)" />
731 <path
731 <path
732− style="fill:none;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1003)"
732+ style="fill:#ff0000;stroke:#ff0000;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1003)"
733 d="M 67.336659,246.29272 67.083422,221.71969"
733 d="M 67.336659,246.29272 67.083422,221.71969"
734 id="path999"
734 id="path999"
735 inkscape:connector-curvature="0"
735 inkscape:connector-curvature="0"
@@ -758,9 +758,9 @@
758 id="text1019"
758 id="text1019"
759 y="218.94762"
759 y="218.94762"
760 x="96.837494"
760 x="96.837494"
761− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
761+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
762 xml:space="preserve"><tspan
762 xml:space="preserve"><tspan
763− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
763+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;"
764 y="218.94762"
764 y="218.94762"
765 x="96.837494"
765 x="96.837494"
766 id="tspan1017"
766 id="tspan1017"
@@ -932,22 +932,22 @@
932 sodipodi:nodetypes="cc" />
932 sodipodi:nodetypes="cc" />
933 <text
933 <text
934 id="text950"
934 id="text950"
935− y="99.410255"
935+ y="104.70191"
936− x="145.19345"
936+ x="22.426785"
937 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
937 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
938 xml:space="preserve"
938 xml:space="preserve"
939 inkscape:export-xdpi="61.120499"
939 inkscape:export-xdpi="61.120499"
940 inkscape:export-ydpi="61.120499"><tspan
940 inkscape:export-ydpi="61.120499"><tspan
941 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
941 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
942− y="99.410255"
942+ y="104.70191"
943− x="145.19345"
943+ x="22.426785"
944 id="tspan948"
944 id="tspan948"
945 sodipodi:role="line">module Core.Core</tspan></text>
945 sodipodi:role="line">module Core.Core</tspan></text>
946 <rect
946 <rect
947 inkscape:export-ydpi="61.120499"
947 inkscape:export-ydpi="61.120499"
948 inkscape:export-xdpi="61.120499"
948 inkscape:export-xdpi="61.120499"
949− y="94.912086"
949+ y="100.20374"
950− x="143.60594"
950+ x="20.839275"
951 height="9.7895899"
951 height="9.7895899"
952 width="47.889587"
952 width="47.889587"
953 id="rect952"
953 id="rect952"
@@ -957,57 +957,57 @@
957 inkscape:export-xdpi="61.120499"
957 inkscape:export-xdpi="61.120499"
958 xml:space="preserve"
958 xml:space="preserve"
959 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
959 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
960− x="145.72261"
960+ x="22.955944"
961− y="103.11442"
961+ y="108.40608"
962 id="text956"><tspan
962 id="text956"><tspan
963 sodipodi:role="line"
963 sodipodi:role="line"
964 id="tspan954"
964 id="tspan954"
965− x="145.72261"
965+ x="22.955944"
966− y="103.11442"
966+ y="108.40608"
967 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332">error messages</tspan></text>
967 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332">error messages</tspan></text>
968 <text
968 <text
969 inkscape:export-ydpi="61.120499"
969 inkscape:export-ydpi="61.120499"
970 inkscape:export-xdpi="61.120499"
970 inkscape:export-xdpi="61.120499"
971 xml:space="preserve"
971 xml:space="preserve"
972 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
972 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
973− x="83.81012"
973+ x="79.312202"
974− y="78.243584"
974+ y="92.266502"
975 id="text960"><tspan
975 id="text960"><tspan
976 sodipodi:role="line"
976 sodipodi:role="line"
977 id="tspan958"
977 id="tspan958"
978− x="83.81012"
978+ x="79.312202"
979− y="78.243584"
979+ y="92.266502"
980 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332">module Core.CompileExpr</tspan></text>
980 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332">module Core.CompileExpr</tspan></text>
981 <rect
981 <rect
982 style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
982 style="opacity:1;vector-effect:none;fill:none;fill-opacity:0.97596154;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
983 id="rect962"
983 id="rect962"
984 width="61.912495"
984 width="61.912495"
985 height="18.785419"
985 height="18.785419"
986− x="82.22261"
986+ x="77.724693"
987− y="73.745415"
987+ y="87.768333"
988 inkscape:export-xdpi="61.120499"
988 inkscape:export-xdpi="61.120499"
989 inkscape:export-ydpi="61.120499" />
989 inkscape:export-ydpi="61.120499" />
990 <text
990 <text
991 id="text966"
991 id="text966"
992− y="81.947746"
992+ y="95.970665"
993− x="84.339279"
993+ x="79.841362"
994 style="font-style:normal;font-weight:normal;font-size:3.52777767px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
994 style="font-style:normal;font-weight:normal;font-size:3.52777767px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
995 xml:space="preserve"
995 xml:space="preserve"
996 inkscape:export-xdpi="61.120499"
996 inkscape:export-xdpi="61.120499"
997 inkscape:export-ydpi="61.120499"><tspan
997 inkscape:export-ydpi="61.120499"><tspan
998 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
998 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
999− y="81.947746"
999+ y="95.970665"
1000− x="84.339279"
1000+ x="79.841362"
1001 sodipodi:role="line"
1001 sodipodi:role="line"
1002 id="tspan968">Representation of expressions ready</tspan><tspan
1002 id="tspan968">Representation of expressions ready</tspan><tspan
1003 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1003 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1004− y="86.357468"
1004+ y="100.38039"
1005− x="84.339279"
1005+ x="79.841362"
1006 sodipodi:role="line"
1006 sodipodi:role="line"
1007 id="tspan974">for compiling: CExp</tspan><tspan
1007 id="tspan974">for compiling: CExp</tspan><tspan
1008 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1008 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1009− y="90.767189"
1009+ y="104.79011"
1010− x="84.339279"
1010+ x="79.841362"
1011 sodipodi:role="line"
1011 sodipodi:role="line"
1012 id="tspan972">Type erased, explicit case trees</tspan></text>
1012 id="tspan972">Type erased, explicit case trees</tspan></text>
1013 <text
1013 <text
@@ -1047,22 +1047,22 @@
1047 sodipodi:role="line">command line options</tspan></text>
1047 sodipodi:role="line">command line options</tspan></text>
1048 <text
1048 <text
1049 id="text988"
1049 id="text988"
1050− y="106.82006"
1050+ y="89.886726"
1051− x="22.69136"
1051+ x="22.162193"
1052 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
1052 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
1053 xml:space="preserve"
1053 xml:space="preserve"
1054 inkscape:export-xdpi="61.120499"
1054 inkscape:export-xdpi="61.120499"
1055 inkscape:export-ydpi="61.120499"><tspan
1055 inkscape:export-ydpi="61.120499"><tspan
1056 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
1056 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#0000ff;stroke-width:0.26458332"
1057− y="106.82006"
1057+ y="89.886726"
1058− x="22.69136"
1058+ x="22.162193"
1059 id="tspan986"
1059 id="tspan986"
1060 sodipodi:role="line">module Idris.Error</tspan></text>
1060 sodipodi:role="line">module Idris.Error</tspan></text>
1061 <rect
1061 <rect
1062 inkscape:export-ydpi="61.120499"
1062 inkscape:export-ydpi="61.120499"
1063 inkscape:export-xdpi="61.120499"
1063 inkscape:export-xdpi="61.120499"
1064− y="102.32182"
1064+ y="85.388489"
1065− x="21.103861"
1065+ x="20.574694"
1066 height="9.5250101"
1066 height="9.5250101"
1067 width="37.835419"
1067 width="37.835419"
1068 id="rect990"
1068 id="rect990"
@@ -1072,17 +1072,17 @@
1072 inkscape:export-xdpi="61.120499"
1072 inkscape:export-xdpi="61.120499"
1073 xml:space="preserve"
1073 xml:space="preserve"
1074 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
1074 style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
1075− x="23.220528"
1075+ x="22.69136"
1076− y="110.52423"
1076+ y="93.590897"
1077 id="text994"><tspan
1077 id="text994"><tspan
1078 sodipodi:role="line"
1078 sodipodi:role="line"
1079 id="tspan992"
1079 id="tspan992"
1080− x="23.220528"
1080+ x="22.69136"
1081− y="110.52423"
1081+ y="93.590897"
1082 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332">perror</tspan></text>
1082 style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332">perror</tspan></text>
1083 <path
1083 <path
1084 style="fill:none;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1000)"
1084 style="fill:none;stroke:#0000ff;stroke-width:0.70555556;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker1000)"
1085− d="m 142.54761,98.087086 c -7.32197,0.078 -68.613479,2.584834 -83.608332,4.234734"
1085+ d="m 66.876776,99.410007 c -0.17822,-10.50534 -0.880145,-7.9985 -7.143748,-8.99444"
1086 id="path996"
1086 id="path996"
1087 inkscape:connector-curvature="0"
1087 inkscape:connector-curvature="0"
1088 inkscape:export-xdpi="61.120499"
1088 inkscape:export-xdpi="61.120499"
@@ -1105,7 +1105,7 @@
1105 inkscape:export-ydpi="61.120499" />
1105 inkscape:export-ydpi="61.120499" />
1106 <text
1106 <text
1107 xml:space="preserve"
1107 xml:space="preserve"
1108− style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:0.40000001;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
1108+ style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:0.40000001;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
1109 x="158.75"
1109 x="158.75"
1110 y="226.09137"
1110 y="226.09137"
1111 id="text1473"
1111 id="text1473"
@@ -1115,16 +1115,16 @@
1115 id="tspan1471"
1115 id="tspan1471"
1116 x="158.75"
1116 x="158.75"
1117 y="226.09137"
1117 y="226.09137"
1118− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332">'text' modules are</tspan><tspan
1118+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;">'text' modules are</tspan><tspan
1119 sodipodi:role="line"
1119 sodipodi:role="line"
1120 x="158.75"
1120 x="158.75"
1121 y="230.92491"
1121 y="230.92491"
1122− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1122+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;"
1123 id="tspan1475">also in Idris 1</tspan><tspan
1123 id="tspan1475">also in Idris 1</tspan><tspan
1124 sodipodi:role="line"
1124 sodipodi:role="line"
1125 x="158.75"
1125 x="158.75"
1126 y="235.75845"
1126 y="235.75845"
1127− style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.26458332"
1127+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.23333311px;line-height:0.40000001;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ff0000;stroke-width:0.26458332;"
1128 id="tspan1477">library.</tspan></text>
1128 id="tspan1477">library.</tspan></text>
1129 <path
1129 <path
1130 inkscape:connector-curvature="0"
1130 inkscape:connector-curvature="0"
docs/parserLibrary/introduction.rst+4−4
@@ -52,13 +52,13 @@ Idris 2 has at least 3 compilers:
52 PTerm (and eventually TT structure).
52 PTerm (and eventually TT structure).
53- REPL - compiles input from the command line.
53- REPL - compiles input from the command line.
54
54
55−The following diagram is my attempt to work out how the modules in Idris 2 fit together.
55+The following diagram is my first attempt to work out how some of the modules in
56+Idris 2 fit together (with a few of the dependencies between them shown). The
57+Idris 1 library is based on the modules at the bottom of the diagram (shown
58+in red).
56
59
57.. image:: ../image/parserModules.png
60.. image:: ../image/parserModules.png
58 :width: 460px
61 :width: 460px
59 :height: 496px
62 :height: 496px
60 :alt: diagram illustrating these stages of lexer and parser
63 :alt: diagram illustrating these stages of lexer and parser
61
64
62−
63−
64−
docs/parserLibrary/lexer.rst+5−6
@@ -26,8 +26,7 @@ In order to construct this list of tokens we need:
26- A way to recognise the tokens in the input string.
26- A way to recognise the tokens in the input string.
27- A way to construct these individual tokens.
27- A way to construct these individual tokens.
28
28
29−This is given by the TokenMap. This is a mapping from lexers to the tokens
29+This is given by the TokenMap which is a list of pairs containing this information:
30−they produce. This is a list of pairs:
31
30
32.. code-block:: idris
31.. code-block:: idris
33
32
@@ -108,7 +107,7 @@ If a recogniser does not consume input there is a danger of an infinite loop.
108To prevent this the recogniser is dependent on a boolean called 'consumes' which
107To prevent this the recogniser is dependent on a boolean called 'consumes' which
109is true if the recogniser is guaranteed to consume at least one character.
108is true if the recogniser is guaranteed to consume at least one character.
110
109
111−The constructors of Recognise allow us to ensure that, event though parts of
110+The constructors of Recognise allow us to ensure that, even though parts of
112the recogniser may not consume, overall the recogniser will consume.
111the recogniser may not consume, overall the recogniser will consume.
113
112
114Since 'Recognise True' is more common than 'Recognise False' it is convenient to
113Since 'Recognise True' is more common than 'Recognise False' it is convenient to
@@ -133,12 +132,12 @@ when the indent decreases.
133
132
134This topic needs to be more fully expanded here. Until someone does that, a
133This topic needs to be more fully expanded here. Until someone does that, a
135possible way to get more information is to see how it is done in Idris 2
134possible way to get more information is to see how it is done in Idris 2
136−_`here`: https://github.com/edwinb/Idris2/blob/master/src/Parser/Lexer.idr
135+: https://github.com/edwinb/Idris2/blob/master/src/Parser/Lexer.idr
137
136
138Simple Expression Example for Lexer
137Simple Expression Example for Lexer
139-----------------------------------
138-----------------------------------
140
139
141−On this page we will implement a lexer to lex a very simple expression as
140+On this page we will implement a lexer to 'lex' a very simple expression as
142a running example, on the next page, we will go on to implement a parser for it.
141a running example, on the next page, we will go on to implement a parser for it.
143
142
144First import the lexer and parser code:
143First import the lexer and parser code:
@@ -268,7 +267,7 @@ input string as parameters:
268 Int,
267 Int,
269 String)
268 String)
270
269
271−The lexer uses potentially infinite data structures. It has recursive arguments (codata type) so code is lazy. In the example the indexes have not been computed but we can
270+The lexer uses potentially infinite data structures. It has recursive arguments (codata type) so code is lazy. In the output above the indexes have not been computed but we can
272pick out the tokens:
271pick out the tokens:
273
272
274- (Number 1)
273- (Number 1)
docs/parserLibrary/parser.rst+92−68
@@ -12,14 +12,14 @@ To run our parser we call 'parse'. This requires a Grammar and the output from t
12
12
13If successful this returns 'Right' with a pair of
13If successful this returns 'Right' with a pair of
14
14
15−- the parse result
15+- the parse result.
16−- the unparsed tokens (the remaining input)
16+- the unparsed tokens (the remaining input).
17
17
18otherwise it returns 'Left' with the error message.
18otherwise it returns 'Left' with the error message.
19
19
20So we need to define the Grammar for our parser, this is done using the following
20So we need to define the Grammar for our parser, this is done using the following
21−'Grammar' data structure, this is a combinator structure similar in principle to the
21+'Grammar' data structure. This is a combinator structure, similar in principle to the
22−recogniser combinator for the lexer which was discussed on the previous page.
22+recogniser combinator for the lexer, which was discussed on the previous page.
23
23
24As with the Recogniser the Grammar type is dependent on a boolean 'consumes'
24As with the Recogniser the Grammar type is dependent on a boolean 'consumes'
25value which allows us to ensure that complicated Grammar structures will always
25value which allows us to ensure that complicated Grammar structures will always
@@ -71,28 +71,31 @@ Parser Example
71On the previous page we implemented a lexer to 'lex' a very simple expression, on
71On the previous page we implemented a lexer to 'lex' a very simple expression, on
72this page we will go on to implement a parser for this running example.
72this page we will go on to implement a parser for this running example.
73
73
74−Expressed in Backus–Naur form (BNF) the syntax we are aiming at is something
74+.. list-table::
75−like this:
76
75
76+ * - Expressed in Backus–Naur form (BNF) the syntax we are aiming at is something
77+ like this:
77−.. code-block:: idris
78+ - .. code-block:: idris
78
79
79− <expr> ::= <integer literal>
80+ <expr> ::= <integer literal>
80 | <expr>'+'<expr>
81 | <expr>'+'<expr>
81 | <expr>'-'<expr>
82 | <expr>'-'<expr>
82 | <expr>'*'<expr>
83 | <expr>'*'<expr>
83 | '('<expr>')'
84 | '('<expr>')'
84
85
85− <integer literal> ::= <digit>|<integer literal><digit>
86+ <integer literal> ::= <digit>|<integer literal><digit>
86
87
87−To start, here is a Grammar to parse an integer literal (that is, a sequence of
88+.. list-table::
88−numbers).
89
89
90−.. code-block:: idris
90+ * - To start, here is a Grammar to parse an integer literal (that is, a
91+ sequence of numbers).
91
92
93+ - .. code-block:: idris
94+
92− export
95+ export
93− intLiteral : Rule Integer
96+ intLiteral : Rule Integer
94− intLiteral
97+ intLiteral
95− = terminal (\x => case tok x of
98+ = terminal (\x => case tok x of
96 Number i => Just i
99 Number i => Just i
97 _ => Nothing)
100 _ => Nothing)
98
101
@@ -137,33 +140,41 @@ successful, this is because we are not specifically checking for end-of-file.
137 (Integer, List (TokenData ExpressionToken))
140 (Integer, List (TokenData ExpressionToken))
138 *parserEx>
141 *parserEx>
139
142
143+.. list-table::
144+
140−The 'intLiteral' function above uses the 'terminal' function to construct
145+ * - The 'intLiteral' function above uses the 'terminal' function to
146+ construct the grammar
147+ - .. code-block:: idris
148+
149+ ||| Succeeds if running the predicate on the
150+ ||| next token returns Just x, returning x.
151+ ||| Otherwise fails.
152+ export
153+ terminal : (tok -> Maybe a) -> Grammar tok True a
154+ terminal = Terminal
155+
141−the grammar, this is defined here
156+This is defined here
142: https://github.com/idris-lang/Idris-dev/blob/master/libs/contrib/Text/Parser/Core.idr
157: https://github.com/idris-lang/Idris-dev/blob/master/libs/contrib/Text/Parser/Core.idr
143Idris 2 uses a slightly different version which stores an error message like
158Idris 2 uses a slightly different version which stores an error message like
144"Expected integer literal" which can be output if the rule fails
159"Expected integer literal" which can be output if the rule fails
145: https://github.com/edwinb/Idris2/blob/master/src/Text/Parser/Core.idr
160: https://github.com/edwinb/Idris2/blob/master/src/Text/Parser/Core.idr
146
161
147−.. code-block:: idris
162+.. list-table::
148−
149− ||| Succeeds if running the predicate on the next token returns Just x,
150− ||| returning x. Otherwise fails.
151− export
152− terminal : (tok -> Maybe a) -> Grammar tok True a
153− terminal = Terminal
154
163
155−The 'terminal' function is also used to construct the other elements of the
164+ * - The 'terminal' function is also used to construct the other
156−grammar that we require, for instance, opening parenthesis:
165+ elements of the grammar that we require, for instance,
166+ opening parenthesis:
157
167
158−.. code-block:: idris
168+ - .. code-block:: idris
159
169
160− openParen : Rule Integer
170+ openParen : Rule Integer
161− openParen = terminal (\x => case tok x of
171+ openParen = terminal (\x => case tok x of
162 OParen => Just 0
172 OParen => Just 0
163 _ => Nothing)
173 _ => Nothing)
164
174
165Integer value is not really relevant for parenthesis so '0' is used as
175Integer value is not really relevant for parenthesis so '0' is used as
166a default value.
176a default value.
177+
167As before, we can test this out with a function like this:
178As before, we can test this out with a function like this:
168
179
169.. code-block:: idris
180.. code-block:: idris
@@ -236,42 +247,49 @@ token lists are not:
236 OParen]) : Either (ParseError (TokenData ExpressionToken))
247 OParen]) : Either (ParseError (TokenData ExpressionToken))
237 (Integer, List (TokenData ExpressionToken))
248 (Integer, List (TokenData ExpressionToken))
238
249
239−The closing parenthesis is constructed in the same way.
250+.. list-table::
240
251
252+ * - The closing parenthesis is constructed in the same way.
253+
241−.. code-block:: idris
254+ - .. code-block:: idris
242
255
243− closeParen : Rule Integer
256+ closeParen : Rule Integer
244− closeParen = terminal (\x => case tok x of
257+ closeParen = terminal (\x => case tok x of
245 CParen => Just 0
258 CParen => Just 0
246 _ => Nothing)
259 _ => Nothing)
247
260
248−Now we can generate a Grammar for an expression inside parenthesis like this.
261+.. list-table::
249
262
263+ * - Now we can generate a Grammar for an expression inside parenthesis like this.
264+
250−.. code-block:: idris
265+ - .. code-block:: idris
251
266
252− paren : Rule Integer -> Rule Integer
267+ paren : Rule Integer -> Rule Integer
253− paren exp = openParen *> exp <* closeParen
268+ paren exp = openParen *> exp <* closeParen
254
269
255The use of '*>' and '<*' instead of '<*>' is an easy way to use the integer
270The use of '*>' and '<*' instead of '<*>' is an easy way to use the integer
256value from the inner expression.
271value from the inner expression.
257
272
258−Now for the operations, in this case: '+', '-' and '*'.
273+.. list-table::
259−The syntax we require is that operators like '+' are infix operators, which
260−would require a definition like this:
261
274
262−.. code-block:: idris
275+ * - Now for the operations, in this case: '+', '-' and '*'.
276+ The syntax we require is that operators like '+' are infix operators, which
277+ would require a definition like this:
263
278
279+ - .. code-block:: idris
280+
264− expr = (add expr (op "+") expr)
281+ expr = (add expr (op "+") expr)
265
282
266This is a potentially infinite structure which is not total.
283This is a potentially infinite structure which is not total.
267−In order to work up to this gradually I will start with prefix operators (sometimes known as Polish notation)
284+In order to work up to this gradually I will start with prefix operators (sometimes known as Polish notation) then modify later for infix operators.
268−then modify later for infix operators.
269
285
270−So prefix operators would have this sort of form:
286+.. list-table::
271
287
272−.. code-block:: idris
288+ * - So prefix operators would have this sort of form:
273
289
290+ - .. code-block:: idris
291+
274− expr = (add (op "+") expr expr)
292+ expr = (add (op "+") expr expr)
275
293
276where 'op' is defined like this:
294where 'op' is defined like this:
277
295
@@ -284,19 +302,21 @@ where 'op' is defined like this:
284 (Operator s1) => if s==s1 then Just 0 else Nothing
302 (Operator s1) => if s==s1 then Just 0 else Nothing
285 _ => Nothing)
303 _ => Nothing)
286
304
287−and 'add' is defined like this:
305+.. list-table::
288
306
289−.. code-block:: idris
307+ * - and 'add' is defined like this:
290
308
291− addInt : Integer -> Integer -> Integer
309+ - .. code-block:: idris
292− addInt a b = a+b
293
310
311+ addInt : Integer -> Integer -> Integer
312+ addInt a b = a+b
313+
294− export
314+ export
295− add : Grammar tok c1 Integer ->
315+ add : Grammar tok c1 Integer ->
296− Grammar tok c2 Integer ->
316+ Grammar tok c2 Integer ->
297− Grammar tok c3 Integer ->
317+ Grammar tok c3 Integer ->
298− Grammar tok ((c1 || c2) || c3) Integer
318+ Grammar tok ((c1 || c2) || c3) Integer
299− add x y z = map addInt (x *> y) <*> z
319+ add x y z = map addInt (x *> y) <*> z
300
320
301Where:
321Where:
302
322
@@ -343,22 +363,26 @@ partial as it is a potentially infinite structure and so not total.
343 <|> (mult (op "*") expr expr)
363 <|> (mult (op "*") expr expr)
344 <|> intLiteral <|> (paren expr)
364 <|> intLiteral <|> (paren expr)
345
365
346−To make the testing easier we can use this function:
366+.. list-table::
347
367
348−.. code-block:: idris
368+ * - To make the testing easier we can use this function:
349
369
370+ - .. code-block:: idris
371+
350− partial
372+ partial
351− test : String -> Either (ParseError (TokenData ExpressionToken))
373+ test : String -> Either (ParseError (TokenData ExpressionToken))
352 (Integer, List (TokenData ExpressionToken))
374 (Integer, List (TokenData ExpressionToken))
353− test s = parse expr (fst (lex expressionTokens s))
375+ test s = parse expr (fst (lex expressionTokens s))
354
376
355−First test a valid (prefix) expression:
377+.. list-table::
356
378
379+ * - First test a valid (prefix) expression:
380+
357−.. code-block:: idris
381+ - .. code-block:: idris
358
382
359− *parserEx> test "+1*6(4)"
383+ *parserEx> test "+1*6(4)"
360− Right (25,
384+ Right (25,
361− []) : Either (ParseError (TokenData ExpressionToken))
385+ []) : Either (ParseError (TokenData ExpressionToken))
362 (Integer, List (TokenData ExpressionToken))
386 (Integer, List (TokenData ExpressionToken))
363
387
364Then an invalid syntax:
388Then an invalid syntax: