Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created March 5, 2015 12:43
Show Gist options
  • Save rightfold/6eff86aaa402dc2a3c30 to your computer and use it in GitHub Desktop.
Save rightfold/6eff86aaa402dc2a3c30 to your computer and use it in GitHub Desktop.
def parseQuote = "%{" ~> Parser { input_ =>
var (input, brackets, text) = (input_, 1, "")
while (brackets > 0) {
val char = input.first
input = input.rest
if (char == '{') {
brackets += 1
} else if (char == '}') {
brackets -= 1
}
if (brackets > 0) {
text += char
}
}
Success(text, input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment