Created
September 28, 2014 18:45
-
-
Save agrafix/ab66da8c8329d00caf25 to your computer and use it in GitHub Desktop.
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
var samples = | |
[ ' do var <- readTVar' | |
, 'do foo' | |
, 'main = do let x = do { foo }' | |
, 'main = do let x = do foo' | |
, 'main = foo $ do ' | |
]; | |
for (var i in samples) { | |
var line = samples[i]; | |
if (line.search(/(\s*do\s+)/) !== -1) { | |
var lastDo = line.lastIndexOf("do"); | |
var rest = line.substring(lastDo+2); | |
if (rest.trim() === "") { | |
console.log("No match: " + line); | |
continue; | |
} | |
if (rest.indexOf("{") !== -1) { | |
lastDo = line.substring(0, lastDo).lastIndexOf("do"); | |
} | |
var ident = Array(lastDo+1+3).join(" "); | |
console.log(line); | |
console.log(ident + "^"); | |
console.log("--------------------------"); | |
} else { | |
console.log("No match: " + line); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment