----------------------------------------------------------------------
-- |
-- Module      :  Text.TeX.Lexer
  Copyright    :   2015 - 2017   ,
                 2015 - 2016 Language Science Press .
-- License     :  GPL-3
--
-- Maintainer  :  
-- Stability   :  experimental
  Portability :   GHC
--
   for TeX and LaTeX documents .
----------------------------------------------------------------------

module Text.TeX.Lexer
  *  
    lexTeX
  , lexTeXIO
  ) where

import Text.TeX.Lexer.Token (Token)
import Text.TeX.Lexer.TokenParser
  (runLexer, runLexerIO, texLexer, defaultLexerState)

-- | Run TeX lexer on named input string and return a 'Token' list.
  This is a pure function that ignores IO - related TeX primitives
-- like @\\input@ or @\\year@.
  ( The resulting ' Token ' stream is restricted to '  ' and
  '  ' elements , i.e. no '  ' elements . ) Exit on failure .
lexTeX :: String -> String -> [Token]
lexTeX name input =
  either (error . show) id $
  runLexer texLexer defaultLexerState name input

-- | Run TeX lexer on named input string and return a 'Token' list,
  executing embedded IO - related TeX primitives like @\\input@ or @\\year@.
lexTeXIO :: String -> String -> IO [Token]
lexTeXIO name input =
  either (error . show) id `fmap`
  runLexerIO texLexer defaultLexerState name input

--------------------------------------------------------------------
 |
 Module      :  Text.TeX.Lexer
 License     :  GPL-3

 Maintainer  :  
 Stability   :  experimental

--------------------------------------------------------------------
 | Run TeX lexer on named input string and return a 'Token' list.
 like @\\input@ or @\\year@.
 | Run TeX lexer on named input string and return a 'Token' list,
  Copyright    :   2015 - 2017   ,
                 2015 - 2016 Language Science Press .
  Portability :   GHC
   for TeX and LaTeX documents .

module Text.TeX.Lexer
  *  
    lexTeX
  , lexTeXIO
  ) where

import Text.TeX.Lexer.Token (Token)
import Text.TeX.Lexer.TokenParser
  (runLexer, runLexerIO, texLexer, defaultLexerState)

  This is a pure function that ignores IO - related TeX primitives
  ( The resulting ' Token ' stream is restricted to '  ' and
  '  ' elements , i.e. no '  ' elements . ) Exit on failure .
lexTeX :: String -> String -> [Token]
lexTeX name input =
  either (error . show) id $
  runLexer texLexer defaultLexerState name input

  executing embedded IO - related TeX primitives like @\\input@ or @\\year@.
lexTeXIO :: String -> String -> IO [Token]
lexTeXIO name input =
  either (error . show) id `fmap`
  runLexerIO texLexer defaultLexerState name input
