-
-
Save rightfold/889ba0307e5be0107057 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
ecmascript :: Parser String | |
ecmascript = lexeme $ char '{' *> ecmascript' 0 | |
where ecmascript' n = do | |
c <- anyChar | |
case c of | |
'{' -> ('{' :) <$> ecmascript' (succ n) | |
'}' -> if n == 0 | |
then return "" | |
else ('}' :) <$> ecmascript' (pred n) | |
_ -> (c :) <$> ecmascript' n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment