Created
June 19, 2017 14:57
-
-
Save BookOwl/304cf0195b008269da9e2b2522658ffb to your computer and use it in GitHub Desktop.
Parser Combinators.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="SUCESS %'val'" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><l>SUCESS</l><block var="val"/></list></block></block></script></block-definition><block-definition s="ERROR %'msg'" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><l>ERROR</l><block var="msg"/></list></block></block></script></block-definition><block-definition s="match %'x' with Sucess %'val' %'block1' Error %'msg' %'block2'" type="command" category="control"><header></header><code></code><inputs><input type="%l"></input><input type="%upvar"></input><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="x"/></block><l>SUCESS</l></block><script><block s="doSetVar"><l>val</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doRun"><block var="block1"/><list></list></block></script><script><block s="doSetVar"><l>msg</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doRun"><block var="block2"/><list></list></block></script></block></script></block-definition><block-definition s="match %'x' with Success %'val' %'if success' Error %'msg' %'if error'" type="reporter" category="control"><header></header><code></code><inputs><input type="%l"></input><input type="%upvar"></input><input type="%anyUE"></input><input type="%upvar"></input><input type="%anyUE"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><l>SUCESS</l><block s="reportListItem"><l>1</l><block var="x"/></block></block><script><block s="doSetVar"><l>val</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doReport"><block s="evaluate"><block var="if success"/><list><block s="reportListItem"><l>2</l><block var="x"/></block></list></block></block></script><script><block s="doSetVar"><l>msg</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doReport"><block s="evaluate"><block var="if error"/><list><block s="reportListItem"><l>2</l><block var="x"/></block></list></block></block></script></block></script></block-definition><block-definition s="parse char %'c'" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input></inputs><script><block s="doReport"><custom-block s="parse if %predRing label %txt"><block s="reifyPredicate"><autolambda><block s="reportEquals"><l></l><block var="c"/></block></autolambda><list></list></block><block var="c"/></custom-block></block></script></block-definition><block-definition s="letters %'a' to %'b' of %'string'" type="reporter" category="operators"><comment x="0" y="0" w="90" collapsed="true">Returns letters a to b of string including letter a but discluding letter b</comment><header></header><code></code><inputs><input type="%n"></input><input type="%n"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>string</l><l>a</l><l>b</l></list><l>return string.slice(a-1, b-1)</l></block><list><block var="string"/><block var="a"/><block var="b"/></list></block><comment w="90" collapsed="false">Implemented as a JS function for speed</comment></block></script></block-definition><block-definition s="all but first of %'string'" type="reporter" category="operators"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="letters %n to %n of %txt"><l>2</l><block s="reportSum"><block s="reportStringSize"><block var="string"/></block><l>1</l></block><block var="string"/></custom-block></block></script></block-definition><block-definition s="%'parser1' and then %'parser2'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>a</l><l>next input</l></list></block><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyScript"><script><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><custom-block s="run parser %obj with input %txt"><block var="parser1"/><block var="input"/></custom-block><l>parser1's result</l><script><block s="doSetVar"><l>a</l><custom-block s="run parser %obj with input %txt"><block var="parser2"/><block s="reportListItem"><l>2</l><block var="parser1's result"/></block></custom-block></block><block s="doSetVar"><l>next input</l><block s="reportListItem"><l>2</l><block var="parser1's result"/></block></block><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><block var="a"/><l>parser2's result</l><script><block s="doReport"><custom-block s="SUCESS %s"><block s="reportNewList"><list><block s="reportNewList"><list><block s="reportListItem"><l>1</l><block var="parser1's result"/></block><block s="reportListItem"><l>1</l><block var="parser2's result"/></block></list></block><block s="reportListItem"><l>2</l><block var="parser2's result"/></block></list></block></custom-block></block></script><l>msg2</l><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser1"/></custom-block><l> andThen </l><custom-block s="label of %obj"><block var="parser2"/></custom-block></list></block><block s="reportListItem"><l>2</l><block var="msg2"/></block><block s="reportListItem"><l>3</l><block var="msg2"/></block></list></block></custom-block></block></script></custom-block></script><l>msg1</l><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser1"/></custom-block><l> andThen </l><custom-block s="label of %obj"><block var="parser2"/></custom-block></list></block><block s="reportListItem"><l>2</l><block var="msg1"/></block><block s="reportListItem"><l>3</l><block var="msg1"/></block></list></block></custom-block></block></script></custom-block></script><list><l>input</l></list></block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser1"/></custom-block><l> andThen </l><custom-block s="label of %obj"><block var="parser2"/></custom-block></list></block></custom-block></block></script><scripts><script x="99.27273418181801" y="620.4242543333339"><block s="reportNewList"><list><block s="reportListItem"><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><block s="reportListItem"><l>1</l><block var="input"/></block></block><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><custom-block s="column # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></list></block></script></scripts></block-definition><block-definition s="run parser %'parser' with input %'input'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%txt"></input></inputs><script><block s="doIfElse"><block s="reportIsA"><block var="input"/><l><option>list</option></l></block><script><block s="doReport"><block s="evaluate"><block s="reportListItem"><l>2</l><block var="parser"/></block><list><block var="input"/></list></block></block></script><script><block s="doReport"><block s="evaluate"><block s="reportListItem"><l>2</l><block var="parser"/></block><list><custom-block s="create InputState from %txt"><block var="input"/></custom-block></list></block></block></script></block></script></block-definition><block-definition s="%'parser1' or %'parser2'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyScript"><script><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><custom-block s="run parser %obj with input %txt"><block var="parser1"/><block var="input"/></custom-block><l>parser1's result</l><script><block s="doReport"><custom-block s="SUCESS %s"><block var="parser1's result"/></custom-block></block></script><l>msg1</l><script><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><custom-block s="run parser %obj with input %txt"><block var="parser2"/><block var="input"/></custom-block><l>parser2's result</l><script><block s="doReport"><custom-block s="SUCESS %s"><block var="parser2's result"/></custom-block></block></script><l>msg2</l><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser1"/></custom-block><l> or </l><custom-block s="label of %obj"><block var="parser2"/></custom-block></list></block><block s="reportListItem"><l>2</l><block var="msg2"/></block><block s="reportListItem"><l>3</l><block var="msg2"/></block></list></block></custom-block></block></script></custom-block></script></custom-block></script><list><l>input</l></list></block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser1"/></custom-block><l> or </l><custom-block s="label of %obj"><block var="parser2"/></custom-block></list></block></custom-block></block></script></block-definition><block-definition s="reduce %'list' %'func'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%l"></input><input type="%repRing"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportListLength"><block var="list"/></block><l>1</l></block><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="list"/></block></block></script><script><block s="doReport"><block s="evaluate"><block var="func"/><list><custom-block s="reduce %l %repRing"><block s="reportCDR"><block var="list"/></block><block var="func"/></custom-block><block s="reportListItem"><l>1</l><block var="list"/></block></list></block></block></script></block></script></block-definition><block-definition s="choose any %'parsers'" type="reporter" category="other"><header></header><code></code><inputs><input type="%mult%obj"></input></inputs><script><block s="doReport"><custom-block s="reduce %l %repRing"><block var="parsers"/><block s="reifyReporter"><autolambda><custom-block s="%obj or %obj"><l/><l/></custom-block></autolambda><list></list></block></custom-block></block></script></block-definition><block-definition s="parse any char of %'string'" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="choose any %mult%obj"><custom-block s="map %repRing over %l"><block s="reifyReporter"><autolambda><custom-block s="parse char %s"><l></l></custom-block></autolambda><list></list></block><custom-block s="%txt $arrowRightOutline list"><block var="string"/></custom-block></custom-block></custom-block></block></script></block-definition><block-definition s="%'string' $arrowRightOutline list" type="reporter" category="operators"><header></header><code></code><inputs><input type="%txt">world</input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportStringSize"><block var="string"/></block><l>0</l></block><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script><script><block s="doReport"><block s="reportCONS"><block s="reportLetter"><l>1</l><block var="string"/></block><custom-block s="%txt $arrowRightOutline list"><custom-block s="all but first of %txt"><block var="string"/></custom-block></custom-block></block></block></script></block></script></block-definition><block-definition s="map %'func' over %'list'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportListLength"><block var="list"/></block><l>0</l></block><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script><script><block s="doReport"><block s="reportCONS"><block s="evaluate"><block var="func"/><list><block s="reportListItem"><l>1</l><block var="list"/></block></list></block><custom-block s="map %repRing over %l"><block var="func"/><block s="reportCDR"><block var="list"/></block></custom-block></block></block></script></block></script></block-definition><block-definition s="transform result %'result' with %'func'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input><input type="%repRing"></input></inputs><script><block s="doReport"><custom-block s="match %l with Success %upvar %anyUE Error %upvar %anyUE"><block var="result"/><l>val</l><custom-block s="SUCESS %s"><block s="evaluate"><block var="func"/><list><block var="val"/></list></block></custom-block><l>msg</l><custom-block s="ERROR %s"><block var="msg"/></custom-block></custom-block></block></script></block-definition><block-definition s="transform result of parser %'parser' with %'func'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%repRing"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyReporter"><autolambda><custom-block s="transform result %l with %repRing"><custom-block s="run parser %obj with input %txt"><block var="parser"/><block var="input"/></custom-block><block s="reifyReporter"><autolambda><block s="reportNewList"><list><block s="evaluate"><block var="func"/><list><block s="reportListItem"><l>1</l><block var="#1"/></block></list></block><block s="reportListItem"><l>2</l><block var="#1"/></block></list></block></autolambda><list><l>#1</l></list></block></custom-block></autolambda><list><l>input</l></list></block><custom-block s="label of %obj"><block var="parser"/></custom-block></custom-block></block></script></block-definition><block-definition s="identity parser %'x'" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyReporter"><autolambda><custom-block s="SUCESS %s"><block s="reportNewList"><list><block var="x"/><l></l></list></block></custom-block></autolambda><list></list></block><l>IDENTITIY</l></custom-block></block></script></block-definition><block-definition s="applyP %'parser1' %'parser2'" type="reporter" category="other"><comment x="0" y="0" w="90" collapsed="false">Takes a parser that returns a function F and a parser that returns a value E and returns a parser that returns F(E)</comment><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj and then %obj"><block var="parser1"/><block var="parser2"/></custom-block><block s="reifyReporter"><autolambda><block s="evaluate"><block s="reportListItem"><l>1</l><block var="#1"/></block><list><block s="reportListItem"><l>2</l><block var="#1"/></block></list></block></autolambda><list><l>#1</l></list></block></custom-block></block></script></block-definition><block-definition s="sequence %'parsers'" type="reporter" category="other"><header></header><code></code><inputs><input type="%mult%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>consP</l><l>b</l><l>c</l></list></block><block s="doSetVar"><l>consP</l><custom-block s="lift2 %repRing"><block s="reifyReporter"><autolambda><block s="reifyReporter"><autolambda><block s="reportCONS"><block var="first"/><block var="rest"/></block></autolambda><list><l>rest</l></list></block></autolambda><list><l>first</l></list></block></custom-block></block><block s="doIfElse"><block s="reportEquals"><block s="reportListLength"><block var="parsers"/></block><l>0</l></block><script><block s="doReport"><custom-block s="set label of %obj to %txt"><custom-block s="identity parser %s"><block s="reportNewList"><list></list></block></custom-block><l></l></custom-block></block></script><script><block s="doSetVar"><l>b</l><custom-block s="sequence %mult%obj"><block s="reportCDR"><block var="parsers"/></block></custom-block></block><block s="doReport"><custom-block s="set label of %obj to %txt"><block s="evaluate"><block s="evaluate"><block var="consP"/><list><block var="b"/></list></block><list><block s="reportListItem"><l>1</l><block var="parsers"/></block></list></block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block s="reportListItem"><l>1</l><block var="parsers"/></block></custom-block><custom-block s="label of %obj"><block var="b"/></custom-block></list></block></custom-block></block></script></block></script></block-definition><block-definition s="lift2 %'f'" type="reporter" category="other"><comment x="0" y="0" w="90" collapsed="false">Lifts a two parameter function into the world of parsers</comment><header></header><code></code><inputs><input type="%repRing"></input></inputs><script><block s="doReport"><block s="reifyReporter"><autolambda><block s="reifyReporter"><autolambda><custom-block s="applyP %obj %obj"><custom-block s="applyP %obj %obj"><custom-block s="identity parser %s"><block var="f"/></custom-block><block var="xp"/></custom-block><block var="yp"/></custom-block></autolambda><list><l>xp</l></list></block></autolambda><list><l>yp</l></list></block></block></script></block-definition><block-definition s="parse string %'str'" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="set label of %obj to %txt"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="sequence %mult%obj"><custom-block s="map %repRing over %l"><block s="reifyReporter"><autolambda><custom-block s="parse char %s"><l></l></custom-block></autolambda><list></list></block><custom-block s="%txt $arrowRightOutline list"><block var="str"/></custom-block></custom-block></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block><block var="str"/></custom-block></block></script></block-definition><block-definition s="%'parser' zero or more times" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyScript"><script><block s="doDeclareVariables"><list><l>res</l><l>rest</l></list></block><block s="doSetVar"><l>res</l><custom-block s="run parser %obj with input %txt"><block var="parser"/><block var="input"/></custom-block></block><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><block var="res"/><l>val</l><script><block s="doSetVar"><l>rest</l><custom-block s="run parser %obj with input %txt"><custom-block s="%obj zero or more times"><block var="parser"/></custom-block><block s="reportListItem"><l>2</l><block var="val"/></block></custom-block></block><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><block var="rest"/><l>res of rest</l><script><block s="doReport"><custom-block s="SUCESS %s"><block s="reportNewList"><list><block s="reportCONS"><block s="reportListItem"><l>1</l><block var="val"/></block><block s="reportListItem"><l>1</l><block var="res of rest"/></block></block><block s="reportListItem"><l>2</l><block var="res of rest"/></block></list></block></custom-block></block></script><l>msg</l><script></script></custom-block></script><l>msg</l><script><block s="doReport"><custom-block s="SUCESS %s"><block s="reportNewList"><list><block s="reportNewList"><list></list></block><block var="input"/></list></block></custom-block></block></script></custom-block></script><list><l>input</l></list></block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser"/></custom-block><l>*</l></list></block></custom-block></block></script></block-definition><block-definition s="%'parser' one or more times" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyScript"><script><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><custom-block s="run parser %obj with input %txt"><block var="parser"/><block var="input"/></custom-block><l>val</l><script><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><custom-block s="run parser %obj with input %txt"><custom-block s="%obj zero or more times"><block var="parser"/></custom-block><block s="reportListItem"><l>2</l><block var="val"/></block></custom-block><l>rest</l><script><block s="doReport"><custom-block s="SUCESS %s"><block s="reportNewList"><list><block s="reportCONS"><block s="reportListItem"><l>1</l><block var="val"/></block><block s="reportListItem"><l>1</l><block var="rest"/></block></block><block s="reportListItem"><l>2</l><block var="rest"/></block></list></block></custom-block></block></script><l>msg</l><script></script></custom-block></script><l>msg</l><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser"/></custom-block><l>+</l></list></block><block s="reportListItem"><l>2</l><block var="msg"/></block><block s="reportListItem"><l>3</l><block var="msg"/></block></list></block></custom-block></block></script></custom-block></script><list><l>input</l></list></block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser"/></custom-block><l>+</l></list></block></custom-block></block></script></block-definition><block-definition s="SOME %'v'" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><l>SOME</l><block var="v"/></list></block></block></script></block-definition><block-definition s="NONE" type="reporter" category="other"><header></header><code></code><inputs></inputs><script><block s="doReport"><block s="reportNewList"><list><l>NONE</l></list></block></block></script></block-definition><block-definition s="match %'x' with Some %'val' %'block1' None %'block2'" type="command" category="control"><header></header><code></code><inputs><input type="%l"></input><input type="%upvar"></input><input type="%cs"></input><input type="%cs"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="x"/></block><l>SOME</l></block><script><block s="doSetVar"><l>val</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doRun"><block var="block1"/><list></list></block></script><script><block s="doRun"><block var="block2"/><list></list></block></script></block></script></block-definition><block-definition s="match %'x' with Some %'val' %'block1' None %'block2'" type="reporter" category="control"><header></header><code></code><inputs><input type="%l"></input><input type="%upvar"></input><input type="%anyUE"></input><input type="%anyUE"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="x"/></block><l>SOME</l></block><script><block s="doSetVar"><l>val</l><block s="reportListItem"><l>2</l><block var="x"/></block></block><block s="doReport"><block s="evaluate"><block var="block1"/><list><block s="reportListItem"><l>2</l><block var="x"/></block></list></block></block></script><script><block s="doReport"><block s="evaluate"><block var="block2"/><list></list></block></block></script></block></script></block-definition><block-definition s="maybe %'parser'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>some</l><l>none</l></list></block><block s="doSetVar"><l>some</l><custom-block s="transform result of parser %obj with %repRing"><block var="parser"/><block s="reifyReporter"><autolambda><custom-block s="SOME %s"><l></l></custom-block></autolambda><list></list></block></custom-block></block><block s="doSetVar"><l>none</l><custom-block s="identity parser %s"><custom-block s="NONE"></custom-block></custom-block></block><block s="doReport"><custom-block s="set label of %obj to %txt"><custom-block s="%obj or %obj"><block var="some"/><block var="none"/></custom-block><block s="reportJoinWords"><list><custom-block s="label of %obj"><block var="parser"/></custom-block><l>?</l></list></block></custom-block></block></script></block-definition><block-definition s="%'p1' and then %'p2' and keep left" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj and then %obj"><block var="p1"/><block var="p2"/></custom-block><block s="reifyReporter"><autolambda><block s="reportListItem"><l>1</l><l/></block></autolambda><list></list></block></custom-block></block></script></block-definition><block-definition s="%'p1' and then %'p2' and keep right" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj and then %obj"><block var="p1"/><block var="p2"/></custom-block><block s="reifyReporter"><autolambda><block s="reportListItem"><l>2</l><l/></block></autolambda><list></list></block></custom-block></block></script></block-definition><block-definition s="%'p1' between %'p2' and %'p3'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doReport"><custom-block s="%obj and then %obj and keep right"><block var="p2"/><custom-block s="%obj and then %obj and keep left"><block var="p1"/><block var="p3"/></custom-block></custom-block></block></script></block-definition><block-definition s="list of %'p1' seperated by %'p2'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>sep then item</l></list></block><block s="doSetVar"><l>sep then item</l><custom-block s="%obj and then %obj and keep right"><block var="p2"/><block var="p1"/></custom-block></block><block s="doReport"><custom-block s="set label of %obj to %txt"><custom-block s="%obj or %obj"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj and then %obj"><block var="p1"/><custom-block s="%obj zero or more times"><block var="sep then item"/></custom-block></custom-block><block s="reifyReporter"><autolambda><block s="reportCONS"><block s="reportListItem"><l>1</l><block var="#1"/></block><block s="reportListItem"><l>2</l><block var="#1"/></block></block></autolambda><list><l>#1</l></list></block></custom-block><custom-block s="identity parser %s"><block s="reportNewList"><list></list></block></custom-block></custom-block><block s="reportJoinWords"><list><l>list of </l><custom-block s="label of %obj"><block var="p1"/></custom-block><l> seperated by </l><custom-block s="label of %obj"><block var="p2"/></custom-block></list></block></custom-block></block></script></block-definition><block-definition s="parser %'func' label %'label'" type="reporter" category="other"><header></header><code></code><inputs><input type="%repRing"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="label"/><block var="func"/></list></block></block></script></block-definition><block-definition s="label of %'parser'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="parser"/></block></block></script></block-definition><block-definition s="set label of %'parser' to %'text'" type="reporter" category="other"><header></header><code></code><inputs><input type="%obj"></input><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyReporter"><autolambda><custom-block s="match %l with Success %upvar %anyUE Error %upvar %anyUE"><custom-block s="run parser %obj with input %txt"><block var="parser"/><block var="input"/></custom-block><l>val</l><custom-block s="SUCESS %s"><block var="val"/></custom-block><l>msg</l><custom-block s="ERROR %s"><block s="reportNewList"><list><block var="text"/><block s="reportListItem"><l>2</l><block var="msg"/></block><block s="reportListItem"><l>3</l><block var="msg"/></block></list></block></custom-block></custom-block></autolambda><list><l>input</l></list></block><block var="text"/></custom-block></block></script></block-definition><block-definition s="show parse result %'res'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>error line</l><l>col</l><l>line</l><l>failurecaret</l></list></block><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><block var="res"/><l>val</l><script><block s="doReport"><block s="reportJoinWords"><list><l>Parsed </l><block s="reportListItem"><l>1</l><block var="val"/></block></list></block></block></script><l>msg</l><script><block s="doSetVar"><l>col</l><block s="reportListItem"><l>3</l><block s="reportListItem"><l>3</l><block var="msg"/></block></block></block><block s="doSetVar"><l>line</l><block s="reportListItem"><l>2</l><block s="reportListItem"><l>3</l><block var="msg"/></block></block></block><block s="doSetVar"><l>error line</l><block s="reportListItem"><l>1</l><block s="reportListItem"><l>3</l><block var="msg"/></block></block></block><block s="doSetVar"><l>failurecaret</l><block s="reportJoinWords"><list><custom-block s="replicate %txt %n times"><l>_</l><block s="reportDifference"><block var="col"/><l>1</l></block></custom-block><l>^ </l><block s="reportListItem"><l>2</l><block var="msg"/></block></list></block></block><block s="doReport"><block s="reportJoinWords"><list><l>Line </l><block var="line"/><l>, Col </l><block var="col"/><l>: Error parsing </l><block s="reportListItem"><l>1</l><block var="msg"/></block><custom-block s="multiline %code"><l>
</l></custom-block><block var="error line"/><l> </l><custom-block s="multiline %code"><l>
</l></custom-block><block var="failurecaret"/></list></block></block></script></custom-block></script></block-definition><block-definition s="multiline %'text'" type="reporter" category="operators"><header></header><code></code><inputs><input type="%code"></input></inputs><script><block s="doReport"><block var="text"/></block></script></block-definition><block-definition s="parse if %'predicate' label %'label'" type="reporter" category="other"><header></header><code></code><inputs><input type="%predRing"></input><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyScript"><script><block s="doDeclareVariables"><list><l>next char</l><l>next input</l><l>c</l></list></block><block s="doSetVar"><l>c</l><custom-block s="next char from %l"><block var="input"/></custom-block></block><block s="doSetVar"><l>next input</l><block s="reportListItem"><l>1</l><block var="c"/></block></block><block s="doSetVar"><l>next char</l><block s="reportListItem"><l>2</l><block var="c"/></block></block><custom-block s="match %l with Some %upvar %cs None %cs"><block var="next char"/><l>char</l><script><block s="doIfElse"><block s="evaluate"><block var="predicate"/><list><block var="char"/></list></block><script><block s="doReport"><custom-block s="SUCESS %s"><block s="reportNewList"><list><block var="char"/><block var="next input"/></list></block></custom-block></block></script><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block var="label"/><block s="reportJoinWords"><list><l>Unexpected </l><block var="char"/></list></block><block s="reportNewList"><list><block s="reportListItem"><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><block s="reportListItem"><l>1</l><block var="input"/></block></block><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><custom-block s="column # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></list></block></list></block></custom-block></block></script></block></script><script><block s="doReport"><custom-block s="ERROR %s"><block s="reportNewList"><list><block var="label"/><l>Unexpected end of input</l><block s="reportNewList"><list><block s="reportListItem"><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><block s="reportListItem"><l>1</l><block var="input"/></block></block><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block><custom-block s="column # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></list></block></list></block></custom-block></block></script></custom-block></script><list><l>input</l></list></block><block var="label"/></custom-block></block></script></block-definition><block-definition s="Position %'line' %'column'" type="reporter" category="other"><header></header><code></code><inputs><input type="%n">1</input><input type="%n">1</input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="line"/><block var="column"/></list></block></block></script></block-definition><block-definition s="line # of %'pos'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="pos"/></block></block></script></block-definition><block-definition s="column # of %'pos'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>2</l><block var="pos"/></block></block></script></block-definition><block-definition s="incr line %'pos'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><custom-block s="Position %n %n"><block s="reportSum"><custom-block s="line # of %l"><block var="pos"/></custom-block><l>1</l></block><l>1</l></custom-block></block></script></block-definition><block-definition s="incr column %'pos'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><custom-block s="Position %n %n"><custom-block s="line # of %l"><block var="pos"/></custom-block><block s="reportSum"><custom-block s="column # of %l"><block var="pos"/></custom-block><l>1</l></block></custom-block></block></script></block-definition><block-definition s="InputState lines %'lines' pos %'pos'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="lines"/><block var="pos"/></list></block></block></script></block-definition><block-definition s="create InputState from %'text'" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportStringSize"><block var="text"/></block><l>0</l></block><script><block s="doReport"><custom-block s="InputState lines %l pos %l"><block s="reportNewList"><list></list></block><custom-block s="Position %n %n"><l>1</l><l>1</l></custom-block></custom-block></block></script><script><block s="doReport"><custom-block s="InputState lines %l pos %l"><block s="reportTextSplit"><block var="text"/><l><option>line</option></l></block><custom-block s="Position %n %n"><l>1</l><l>1</l></custom-block></custom-block></block></script></block></script></block-definition><block-definition s="next char from %'input'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>line pos</l><l>col pos</l><l>lines</l><l>line</l></list></block><block s="doSetVar"><l>line pos</l><custom-block s="line # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></block><block s="doSetVar"><l>col pos</l><custom-block s="column # of %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></block><block s="doSetVar"><l>lines</l><block s="reportListItem"><l>1</l><block var="input"/></block></block><block s="doIfElse"><block s="reportGreaterThan"><block var="line pos"/><block s="reportListLength"><block var="lines"/></block></block><script><block s="doReport"><block s="reportNewList"><list><block var="input"/><custom-block s="NONE"></custom-block></list></block></block></script><script><block s="doSetVar"><l>line</l><block s="reportListItem"><block var="line pos"/><block var="lines"/></block></block><block s="doIfElse"><block s="reportGreaterThan"><block var="col pos"/><block s="reportStringSize"><block var="line"/></block></block><script><block s="doReport"><block s="reportNewList"><list><custom-block s="InputState lines %l pos %l"><block var="lines"/><custom-block s="incr line %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></custom-block><custom-block s="SOME %s"><block s="reportUnicodeAsLetter"><l>10</l></block></custom-block></list></block></block></script><script><block s="doReport"><block s="reportNewList"><list><custom-block s="InputState lines %l pos %l"><block var="lines"/><custom-block s="incr column %l"><block s="reportListItem"><l>2</l><block var="input"/></block></custom-block></custom-block><custom-block s="SOME %s"><block s="reportLetter"><block var="col pos"/><block var="line"/></block></custom-block></list></block></block></script></block></script></block></script><scripts><comment x="343.6363636363636" y="220.18181818181816" w="104.54545454545453" collapsed="false">unicode 10 = newline</comment></scripts></block-definition><block-definition s="read all chars from %'input'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>a</l><l>new input</l><l>read</l></list></block><block s="doSetVar"><l>a</l><custom-block s="next char from %l"><block var="input"/></custom-block></block><block s="doSetVar"><l>new input</l><block s="reportListItem"><l>1</l><block var="a"/></block></block><block s="doSetVar"><l>read</l><block s="reportListItem"><l>2</l><block var="a"/></block></block><custom-block s="match %l with Some %upvar %cs None %cs"><block var="read"/><l>val</l><script><block s="doReport"><block s="reportCONS"><block var="val"/><custom-block s="read all chars from %l"><block var="new input"/></custom-block></block></block></script><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script></custom-block></script></block-definition><block-definition s="replicate %'text' %'n' times" type="reporter" category="operators"><header></header><code></code><inputs><input type="%txt"></input><input type="%n"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block var="n"/><l>0</l></block><script><block s="doReport"><l></l></block></script><script><block s="doReport"><block s="reportJoinWords"><list><block var="text"/><custom-block s="replicate %txt %n times"><block var="text"/><block s="reportDifference"><block var="n"/><l>1</l></block></custom-block></list></block></block></script></block></script></block-definition><block-definition s="forward reference %'p' label %'t'" type="reporter" category="other"><header></header><code></code><inputs><input type="%anyUE"></input><input type="%txt"></input></inputs><script><block s="doReport"><custom-block s="parser %repRing label %txt"><block s="reifyReporter"><autolambda><custom-block s="run parser %obj with input %txt"><block s="evaluate"><block var="p"/><list></list></block><block var="#1"/></custom-block></autolambda><list><l>#1</l></list></block><block var="t"/></custom-block></block></script></block-definition><block-definition s="if %'pred' then %'x' else %'y'" type="reporter" category="control"><header></header><code></code><inputs><input type="%b"></input><input type="%anyUE"></input><input type="%anyUE"></input></inputs><script><block s="doIfElse"><block var="pred"/><script><block s="doReport"><block s="evaluate"><block var="x"/><list></list></block></block></script><script><block s="doReport"><block s="evaluate"><block var="y"/><list></list></block></block></script></block></script></block-definition><block-definition s="%'txt' to number" type="reporter" category="operators"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>t</l></list><l>return parseFloat(t, 10);</l></block><list><block var="txt"/></list></block></block></script></block-definition><block-definition s="parse number" type="reporter" category="other"><header></header><code></code><inputs></inputs><script><block s="doDeclareVariables"><list><l>parse digit</l><l>parse digit 1-9</l><l>parse digits</l><l>parse sign</l><l>parse int part</l><l>parse exponent</l><l>parse back part</l></list></block><block s="doSetVar"><l>parse digit</l><custom-block s="parse any char of %txt"><l>1234567890</l></custom-block></block><block s="doSetVar"><l>parse digit 1-9</l><custom-block s="parse any char of %txt"><l>123456789</l></custom-block></block><block s="doSetVar"><l>parse digits</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj one or more times"><block var="parse digit"/></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doSetVar"><l>parse sign</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="maybe %obj"><custom-block s="parse char %s"><l>-</l></custom-block></custom-block><block s="reifyReporter"><autolambda><custom-block s="match %l with Some %upvar %anyUE None %anyUE"><block var="#1"/><l>val</l><l>-</l><l></l></custom-block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doSetVar"><l>parse int part</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="sequence %mult%obj"><list><block var="parse sign"/><custom-block s="%obj or %obj"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj and then %obj"><block var="parse digit 1-9"/><custom-block s="%obj zero or more times"><block var="parse digit"/></custom-block></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block><custom-block s="parse char %s"><l>0</l></custom-block></custom-block></list></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doSetVar"><l>parse exponent</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="maybe %obj"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="sequence %mult%obj"><list><custom-block s="parse any char of %txt"><l>eE</l></custom-block><block var="parse sign"/><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj one or more times"><block var="parse digit"/></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></list></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></custom-block><block s="reifyReporter"><autolambda><custom-block s="match %l with Some %upvar %anyUE None %anyUE"><block var="#1"/><l>val</l><block var="val"/><l></l></custom-block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doSetVar"><l>parse back part</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="maybe %obj"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="sequence %mult%obj"><list><custom-block s="parse char %s"><l>.</l></custom-block><block var="parse digits"/><block var="parse exponent"/></list></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></custom-block><block s="reifyReporter"><autolambda><custom-block s="match %l with Some %upvar %anyUE None %anyUE"><block var="#1"/><l>val</l><block var="val"/><l></l></custom-block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doReport"><custom-block s="transform result of parser %obj with %repRing"><custom-block s="sequence %mult%obj"><list><block var="parse int part"/><block var="parse back part"/></list></custom-block><block s="reifyReporter"><autolambda><custom-block s="%txt to number"><block s="reportJoinWords"><block var="#1"/></block></custom-block></autolambda><list><l>#1</l></list></block></custom-block></block></script></block-definition><block-definition s="parse string" type="reporter" category="other"><header></header><code></code><inputs></inputs><script><block s="doDeclareVariables"><list><l>parse unescaped char</l><l>parse escaped char</l><l>parse many chars</l><l>parse quote</l></list></block><block s="doSetVar"><l>parse unescaped char</l><custom-block s="parse if %predRing label %txt"><block s="reifyPredicate"><autolambda><block s="reportAnd"><custom-block s="%s ≠ %s"><l></l><l>"</l></custom-block><custom-block s="%s ≠ %s"><l></l><l>\</l></custom-block></block></autolambda><list></list></block><l>char</l></custom-block></block><block s="doSetVar"><l>parse escaped char</l><custom-block s="choose any %mult%obj"><custom-block s="map %repRing over %l"><block s="reifyReporter"><autolambda><custom-block s="transform result of parser %obj with %repRing"><custom-block s="parse string %txt"><block s="reportListItem"><l>1</l><block var="#1"/></block></custom-block><block s="reifyReporter"><autolambda><block s="reportListItem"><l>2</l><block var="#1"/></block></autolambda><list></list></block></custom-block></autolambda><list><l>#1</l></list></block><block s="reportNewList"><list><block s="reportNewList"><list><l>\"</l><l>"</l></list></block><block s="reportNewList"><list><l>\\</l><l>\</l></list></block><block s="reportNewList"><list><l>\/</l><l>/</l></list></block><block s="reportNewList"><list><l>\b</l><block s="reportUnicodeAsLetter"><l>8</l></block></list></block><block s="reportNewList"><list><l>\n</l><block s="reportUnicodeAsLetter"><l>10</l></block></list></block><block s="reportNewList"><list><l>\r</l><block s="reportUnicodeAsLetter"><l>13</l></block></list></block><block s="reportNewList"><list><l>\f</l><block s="reportUnicodeAsLetter"><l>12</l></block></list></block><block s="reportNewList"><list><l>\t</l><block s="reportUnicodeAsLetter"><l>9</l></block></list></block></list></block></custom-block></custom-block></block><block s="doSetVar"><l>parse many chars</l><custom-block s="transform result of parser %obj with %repRing"><custom-block s="%obj zero or more times"><custom-block s="%obj or %obj"><block var="parse unescaped char"/><block var="parse escaped char"/></custom-block></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><block var="#1"/></block></autolambda><list><l>#1</l></list></block></custom-block></block><block s="doSetVar"><l>parse quote</l><custom-block s="parse char %s"><l>"</l></custom-block></block><block s="doReport"><custom-block s="%obj between %obj and %obj"><block var="parse many chars"/><block var="parse quote"/><block var="parse quote"/></custom-block></block></script></block-definition></blocks> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment