Created
June 12, 2013 06:48
-
-
Save mkscrg/5763306 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 OverloadedStrings #-} | |
module Main where | |
import Control.Applicative | |
import Data.Char | |
import Data.Attoparsec.Text | |
import Data.Text (Text) | |
main :: IO () | |
main = getArgs >>= print . parseOnly identifier . read . head | |
identifier :: Parser Text | |
identifier = "$" .*> (withBraces <|> withoutBraces) | |
where | |
withBraces = "{" .*> takeWhile1 (/= '}') <*. "}" | |
withoutBraces = takeWhile1 isAlphaNum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment