Created
February 1, 2015 21:09
-
-
Save dmitry-vsl/4e1ac80f755f3499ab68 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
import Text.ParserCombinators.Parsec | |
empty = many (oneOf "\t\n\r ") | |
inBraces = between (char '(') (char ')') | |
commaList p = sepBy (between empty empty p) (char ',') | |
array p = between (char '[') (char ']') (commaList p) | |
identifier = many1 alphaNum | |
quoted quote = do | |
begin <- (char quote) | |
result <- (many (noneOf [quote])) | |
end <- (char quote) | |
return result | |
jsString = choice [(quoted '\''), (quoted '"')] | |
amdModuleHeader = do | |
string "define(" >> empty | |
modules <- array jsString | |
char ',' >> empty >> string "function(" | |
names <- commaList identifier | |
string "){" | |
return (modules, names) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment