From 2816d10be35cb7aecadc88dead4bd010b39a6f57 Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Sat, 21 Aug 2021 19:02:53 -0700 Subject: [PATCH] Export lexToken --- src/PureScript/CST/Lexer.purs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PureScript/CST/Lexer.purs b/src/PureScript/CST/Lexer.purs index 528a4b9..2084c6e 100644 --- a/src/PureScript/CST/Lexer.purs +++ b/src/PureScript/CST/Lexer.purs @@ -1,6 +1,7 @@ module PureScript.CST.Lexer ( lex , lexWithState + , lexToken ) where import Prelude @@ -9,6 +10,7 @@ import Control.Alt (class Alt, (<|>)) import Data.Array as Array import Data.Array.NonEmpty as NonEmptyArray import Data.Char as Char +import Data.Either (Either(..)) import Data.Foldable (fold, foldl, foldMap) import Data.Int (hexadecimal) import Data.Int as Int @@ -211,6 +213,14 @@ lexWithState = init <*> trailingComments <*> leadingComments +lexToken :: String -> Either LexError Token +lexToken = k >>> case _ of + LexSucc tok "" -> Right tok + LexSucc tok _ -> Left (\_ -> ExpectedEof tok) + LexFail err _ -> Left err + where + (Lex k) = token + bumpToken :: SourcePos -> Token -> SourcePos bumpToken pos@{ line, column } = case _ of TokLeftParen ->