Skip to content

Instantly share code, notes, and snippets.

@BookOwl
Created June 19, 2017 14:57
Show Gist options
  • Save BookOwl/304cf0195b008269da9e2b2522658ffb to your computer and use it in GitHub Desktop.
Save BookOwl/304cf0195b008269da9e2b2522658ffb to your computer and use it in GitHub Desktop.
Parser Combinators.xml
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="SUCESS %&apos;val&apos;" 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 %&apos;msg&apos;" 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 %&apos;x&apos; with Sucess %&apos;val&apos; %&apos;block1&apos; Error %&apos;msg&apos; %&apos;block2&apos;" 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 %&apos;x&apos; with Success %&apos;val&apos; %&apos;if success&apos; Error %&apos;msg&apos; %&apos;if error&apos;" 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 %&apos;c&apos;" 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 %&apos;a&apos; to %&apos;b&apos; of %&apos;string&apos;" 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 %&apos;string&apos;" 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="%&apos;parser1&apos; and then %&apos;parser2&apos;" 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&apos;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&apos;s result"/></block></custom-block></block><block s="doSetVar"><l>next input</l><block s="reportListItem"><l>2</l><block var="parser1&apos;s result"/></block></block><custom-block s="match %l with Sucess %upvar %cs Error %upvar %cs"><block var="a"/><l>parser2&apos;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&apos;s result"/></block><block s="reportListItem"><l>1</l><block var="parser2&apos;s result"/></block></list></block><block s="reportListItem"><l>2</l><block var="parser2&apos;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 %&apos;parser&apos; with input %&apos;input&apos;" 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="%&apos;parser1&apos; or %&apos;parser2&apos;" 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&apos;s result</l><script><block s="doReport"><custom-block s="SUCESS %s"><block var="parser1&apos;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&apos;s result</l><script><block s="doReport"><custom-block s="SUCESS %s"><block var="parser2&apos;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 %&apos;list&apos; %&apos;func&apos;" 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 %&apos;parsers&apos;" 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 %&apos;string&apos;" 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="%&apos;string&apos; $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 %&apos;func&apos; over %&apos;list&apos;" 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 %&apos;result&apos; with %&apos;func&apos;" 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 %&apos;parser&apos; with %&apos;func&apos;" 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 %&apos;x&apos;" 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 %&apos;parser1&apos; %&apos;parser2&apos;" 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 %&apos;parsers&apos;" 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 %&apos;f&apos;" 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 %&apos;str&apos;" 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="%&apos;parser&apos; 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="%&apos;parser&apos; 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 %&apos;v&apos;" 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 %&apos;x&apos; with Some %&apos;val&apos; %&apos;block1&apos; None %&apos;block2&apos;" 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 %&apos;x&apos; with Some %&apos;val&apos; %&apos;block1&apos; None %&apos;block2&apos;" 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 %&apos;parser&apos;" 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="%&apos;p1&apos; and then %&apos;p2&apos; 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="%&apos;p1&apos; and then %&apos;p2&apos; 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="%&apos;p1&apos; between %&apos;p2&apos; and %&apos;p3&apos;" 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 %&apos;p1&apos; seperated by %&apos;p2&apos;" 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 %&apos;func&apos; label %&apos;label&apos;" 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 %&apos;parser&apos;" 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 %&apos;parser&apos; to %&apos;text&apos;" 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 %&apos;res&apos;" 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>&#xD;</l></custom-block><block var="error line"/><l> </l><custom-block s="multiline %code"><l>&#xD;</l></custom-block><block var="failurecaret"/></list></block></block></script></custom-block></script></block-definition><block-definition s="multiline %&apos;text&apos;" 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 %&apos;predicate&apos; label %&apos;label&apos;" 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 %&apos;line&apos; %&apos;column&apos;" 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 %&apos;pos&apos;" 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 %&apos;pos&apos;" 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 %&apos;pos&apos;" 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 %&apos;pos&apos;" 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 %&apos;lines&apos; pos %&apos;pos&apos;" 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 %&apos;text&apos;" 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 %&apos;input&apos;" 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 %&apos;input&apos;" 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 %&apos;text&apos; %&apos;n&apos; 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 %&apos;p&apos; label %&apos;t&apos;" 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 %&apos;pred&apos; then %&apos;x&apos; else %&apos;y&apos;" 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="%&apos;txt&apos; 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