alex-tools 0.5.0.2 → 0.6
raw patch · 2 files changed
+20/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ AlexTools: initialInputAt :: SourcePos -> Text -> Input
Files
- alex-tools.cabal +1/−1
- src/AlexTools.hs +19/−1
alex-tools.cabal view
@@ -1,5 +1,5 @@ name: alex-tools-version: 0.5.0.2+version: 0.6 synopsis: A set of functions for a common use case of Alex. description: This captures a common patter for using Alex. license: ISC
src/AlexTools.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TemplateHaskell, CPP, DeriveLift #-} module AlexTools ( -- * Lexer Basics- initialInput, Input(..), inputFile+ initialInput, initialInputAt, Input(..), inputFile , Lexeme(..) , SourcePos(..), startPos, beforeStartPos, prevPos , SourceRange(..)@@ -238,6 +238,24 @@ , inputPrevChar = '\n' -- end of the virtual previous line , inputText = str }++-- | Prepare the text for lexing, starting at a particular position.+-- This is useful when the document is not at the start of the file.+-- Since: 0.6+initialInputAt ::+ SourcePos {- ^ Starting poistion -} ->+ Text {- ^ The text to lex, not including any preceeding text -} ->+ Input+initialInputAt start str = Input+ { inputPos = start+ , inputPrev = start { sourceIndex = sourceIndex start - 1+ , sourceColumn = sourceColumn start - 1+ }+ , inputPrevChar = '\n' -- just something+ , inputText = str+ }++ startPos :: Text {- ^ Name of file/thing containing this -} -> SourcePos startPos file = SourcePos { sourceIndex = 0