    -----------------------------------------------------------------------------
    -- |
    -- Module      : Language.JavaScript.LexerUtils
    -- Based on language-python version by Bernie Pope
    -- Copyright   : (c) 2009 Bernie Pope
    -- License     : BSD-style
    -- Stability   : experimental
    -- Portability : ghc
    --
    -- Various utilities to support the JavaScript lexer.
    -----------------------------------------------------------------------------

    module Language.JavaScript.Parser.LexerUtils
        ( StartCode
        , symbolToken
        , mkString
        , mkString'
        , commentToken
        , wsToken
        , regExToken
        , decimalToken
        , hexIntegerToken
        , octalToken
        , stringToken
        ) where

    import Language.JavaScript.Parser.Token as Token
    import Language.JavaScript.Parser.SrcLocation
    import Prelude hiding (span)

    -- Functions for building tokens

    type StartCode = Int

    symbolToken :: Monad m => (TokenPosn -> [CommentAnnotation] -> Token) -> TokenPosn -> Int -> String -> m Token
    symbolToken :: forall (m :: * -> *).
    Monad m =>
    (TokenPosn -> [CommentAnnotation] -> Token)
    -> TokenPosn -> Int -> String -> m Token
    symbolToken TokenPosn -> [CommentAnnotation] -> Token
    mkToken TokenPosn
    location Int
    _ String
    _ = Token -> m Token
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (TokenPosn -> [CommentAnnotation] -> Token
    mkToken TokenPosn
    location [])

    mkString :: (Monad m) => (TokenPosn -> String -> Token) -> TokenPosn -> Int -> String -> m Token
    mkString :: forall (m :: * -> *).
    Monad m =>
    (TokenPosn -> String -> Token)
    -> TokenPosn -> Int -> String -> m Token
    mkString TokenPosn -> String -> Token
    toToken TokenPosn
    loc Int
    len String
    str = Token -> m Token
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (TokenPosn -> String -> Token
    toToken TokenPosn
    loc (Int -> String -> String
    forall a. Int -> [a] -> [a]
    take Int
    len String
    str))

    mkString' :: (Monad m) => (TokenPosn -> String -> [CommentAnnotation] -> Token) -> TokenPosn -> Int -> String -> m Token
    mkString' :: forall (m :: * -> *).
    Monad m =>
    (TokenPosn -> String -> [CommentAnnotation] -> Token)
    -> TokenPosn -> Int -> String -> m Token
    mkString' TokenPosn -> String -> [CommentAnnotation] -> Token
    toToken TokenPosn
    loc Int
    len String
    str = Token -> m Token
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (TokenPosn -> String -> [CommentAnnotation] -> Token
    toToken TokenPosn
    loc (Int -> String -> String
    forall a. Int -> [a] -> [a]
    take Int
    len String
    str) [])

    decimalToken :: TokenPosn -> String -> Token
    decimalToken :: TokenPosn -> String -> Token
    decimalToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    DecimalToken TokenPosn
    loc String
    str []

    hexIntegerToken :: TokenPosn -> String -> Token
    hexIntegerToken :: TokenPosn -> String -> Token
    hexIntegerToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    HexIntegerToken TokenPosn
    loc String
    str []

    octalToken :: TokenPosn -> String -> Token
    octalToken :: TokenPosn -> String -> Token
    octalToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    OctalToken TokenPosn
    loc String
    str []

    regExToken :: TokenPosn -> String -> Token
    regExToken :: TokenPosn -> String -> Token
    regExToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    RegExToken TokenPosn
    loc String
    str []

    stringToken :: TokenPosn -> String -> Token
    stringToken :: TokenPosn -> String -> Token
    stringToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    StringToken TokenPosn
    loc String
    str []

    commentToken :: TokenPosn -> String -> Token
    commentToken :: TokenPosn -> String -> Token
    commentToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    CommentToken TokenPosn
    loc String
    str []

    wsToken :: TokenPosn -> String -> Token
    wsToken :: TokenPosn -> String -> Token
    wsToken TokenPosn
    loc String
    str = TokenPosn -> String -> [CommentAnnotation] -> Token
    WsToken TokenPosn
    loc String
    str []