Created
September 6, 2014 19:36
-
-
Save dckc/925b37dec1795aef8030 to your computer and use it in GitHub Desktop.
how's this for simple__quasiParser?
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
object simple__quasiParser: | |
object VALUE_HOLE: pass | |
object PATTERN_HOLE: pass | |
def valueHole(i): | |
(VALUE_HOLE, i) | |
def valueMaker(chunks): | |
object x: | |
def substitute(values): | |
def mk(chunk): | |
switch (chunk): | |
match (==VALUE_HOLE, i): | |
values[i] | |
match (==PATTERN_HOLE, i): | |
throw("cannot substitue pattern hole") | |
match _: | |
chunk | |
mkString([mk(chunk) for chunk in chunks]) | |
def mkString(ss): | |
def out := "" | |
for s in ss: | |
out += s | |
out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment