1-----------------------------------------------------------------------------
3-- Module : PureScript.Parser.Common
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15module PureScript.Parser.Common where
17import Control.Applicative
18import qualified Text.Parsec as P
19import qualified Text.Parsec.Token as PT
20import qualified Text.Parsec.Language as PL
22langDef = PL.haskellStyle
23 { PT.identStart = P.lower <|> P.char '_'
24 , PT.reservedNames = [ "case"
37tokenParser = PT.makeTokenParser langDef
38lexeme = PT.lexeme tokenParser
39identifier = PT.identifier tokenParser
40reserved = PT.reserved tokenParser
41operator = PT.operator tokenParser
42stringLiteral = PT.stringLiteral tokenParser
43natural = PT.natural tokenParser
44naturalOrFloat = PT.naturalOrFloat tokenParser
45whiteSpace = PT.whiteSpace tokenParser
46parens = PT.parens tokenParser
47braces = PT.braces tokenParser
48angles = PT.angles tokenParser
49brackets = PT.brackets tokenParser
50squares = PT.squares tokenParser
51semi = PT.semi tokenParser
52comma = PT.comma tokenParser
53colon = PT.colon tokenParser
54dot = PT.dot tokenParser
55semiSep = PT.semiSep tokenParser
56semiSep1 = PT.semiSep1 tokenParser
57commaSep = PT.commaSep tokenParser
58commaSep1 = PT.commaSep1 tokenParser
60properName :: P.Parsec String u String
61properName = lexeme $ P.try properName'
63 properName' = (:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name"
65augment :: P.Stream s m t => P.ParsecT s u m a -> P.ParsecT s u m b -> (a -> b -> a) -> P.ParsecT s u m a
66augment p q f = (flip $ maybe id $ flip f) <$> p <*> P.optionMaybe q
68fold :: P.Stream s m t => P.ParsecT s u m a -> P.ParsecT s u m b -> (a -> b -> a) -> P.ParsecT s u m a
69fold first more combine = do
72 return $ foldl combine a bs
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list