parsers-0.12.11: Parsing combinators

Copyright | (c) Edward Kmett 2011-2012
License | BSD3
Maintainer | ekmett@gmail.com
Stability | provisional
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell2010

Text.Parser.Token.Style

Contents

- Comment and white space styles
  - Lenses
  - Common Comment Styles
- Identifier Styles
- Operator Styles

Description

A toolbox for specifying comment and identifier styles

This must be imported directly as it is not re-exported elsewhere

Synopsis

- data CommentStyle = CommentStyle {
  - _commentStart :: String
  - _commentEnd :: String
  - _commentLine :: String
  - _commentNesting :: Bool
  }
- commentStart :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle
- commentEnd :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle
- commentLine :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle
- commentNesting :: Functor f => (Bool -> f Bool) -> CommentStyle -> f CommentStyle
- emptyCommentStyle :: CommentStyle
- javaCommentStyle :: CommentStyle
- scalaCommentStyle :: CommentStyle
- haskellCommentStyle :: CommentStyle
- buildSomeSpaceParser :: CharParsing m => m () -> CommentStyle -> m ()
- emptyIdents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m
- haskellIdents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m
- haskell98Idents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m
- emptyOps :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m
- haskellOps :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m
- haskell98Ops :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m

# Comment and white space styles

data CommentStyle #

How to deal with comments.

Constructors

CommentStyle |
Fields _commentStart :: String String that starts a multiline comment _commentEnd :: String String that ends a multiline comment _commentLine :: String String that starts a single line comment _commentNesting :: Bool Can we nest multiline comments?

#### Instances

Instances details

Data CommentStyle # |
Instance details Defined in Text.Parser.Token.Style Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CommentStyle -> c CommentStyle # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CommentStyle # toConstr :: CommentStyle -> Constr # dataTypeOf :: CommentStyle -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CommentStyle) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CommentStyle) # gmapT :: (forall b. Data b => b -> b) -> CommentStyle -> CommentStyle # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CommentStyle -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CommentStyle -> r # gmapQ :: (forall d. Data d => d -> u) -> CommentStyle -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CommentStyle -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CommentStyle -> m CommentStyle # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStyle -> m CommentStyle # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStyle -> m CommentStyle #
Read CommentStyle # |
Instance details Defined in Text.Parser.Token.Style Methods readsPrec :: Int -> ReadS CommentStyle # readList :: ReadS [CommentStyle] # readPrec :: ReadPrec CommentStyle # readListPrec :: ReadPrec [CommentStyle] #
Show CommentStyle # |
Instance details Defined in Text.Parser.Token.Style Methods showsPrec :: Int -> CommentStyle -> ShowS # show :: CommentStyle -> String # showList :: [CommentStyle] -> ShowS #
Eq CommentStyle # |
Instance details Defined in Text.Parser.Token.Style Methods (==) :: CommentStyle -> CommentStyle -> Bool # (/=) :: CommentStyle -> CommentStyle -> Bool #
Ord CommentStyle # |
Instance details Defined in Text.Parser.Token.Style Methods compare :: CommentStyle -> CommentStyle -> Ordering # (<) :: CommentStyle -> CommentStyle -> Bool # (<=) :: CommentStyle -> CommentStyle -> Bool # (>) :: CommentStyle -> CommentStyle -> Bool # (>=) :: CommentStyle -> CommentStyle -> Bool # max :: CommentStyle -> CommentStyle -> CommentStyle # min :: CommentStyle -> CommentStyle -> CommentStyle #

## Lenses

commentStart :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle #

This is a lens that can edit the string that starts a multiline comment.

    commentStart :: Lens' CommentStyle String

commentEnd :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle #

This is a lens that can edit the string that ends a multiline comment.

    commentEnd :: Lens' CommentStyle String

commentLine :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle #

This is a lens that can edit the string that starts a single line comment.

    commentLine :: Lens' CommentStyle String

commentNesting :: Functor f => (Bool -> f Bool) -> CommentStyle -> f CommentStyle #

This is a lens that can edit whether we can nest multiline comments.

    commentNesting :: Lens' CommentStyle Bool

## Common Comment Styles

emptyCommentStyle :: CommentStyle #

No comments at all

javaCommentStyle :: CommentStyle #

Use java-style comments

scalaCommentStyle :: CommentStyle #

Use scala-style comments

haskellCommentStyle :: CommentStyle #

Use haskell-style comments

buildSomeSpaceParser :: CharParsing m => m () -> CommentStyle -> m () #

Use this to easily build the definition of whiteSpace for your MonadParser given a comment style and an underlying someWhiteSpace parser

# Identifier Styles

emptyIdents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple identifier style based on haskell with no reserve words

haskellIdents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple identifier style based on haskell with the reserved words from Haskell 98 and some common extensions.

haskell98Idents :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple identifier style based on haskell with only the reserved words from Haskell 98.

# Operator Styles

emptyOps :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple operator style based on haskell with no reserved operators

haskellOps :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple operator style based on haskell with the operators from Haskell 98.

haskell98Ops :: forall (m :: Type -> Type). TokenParsing m => IdentifierStyle m #

A simple operator style based on haskell with the operators from Haskell 98.