Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. {-# LANGUAGE NoMonomorphismRestriction #-}
  2.  
  3. import Text.ParserCombinators.Parsec
  4.  
  5. empty = many (oneOf "\t\n\r ")
  6.  
  7. inBraces = between (char '(') (char ')')
  8.  
  9. commaList p = sepBy (between empty empty p) (char ',')
  10.  
  11. array p = between (char '[') (char ']') (commaList p)
  12.  
  13. identifier = many1 alphaNum
  14.  
  15. quoted quote = do
  16. begin <- (char quote)
  17. result <- (many (noneOf [quote]))
  18. end <- (char quote)
  19. return result
  20.  
  21. jsString = choice [(quoted '\''), (quoted '"')]
  22.  
  23. amdModuleHeader = do
  24. string "define(" >> empty
  25. modules <- array jsString
  26. char ',' >> empty >> string "function("
  27. names <- commaList identifier
  28. string "){"
  29. return (modules, names)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement