packages feed

alex-tools 0.5.0.2 → 0.6.1

raw patch · 2 files changed

Files

alex-tools.cabal view
@@ -1,7 +1,7 @@ name:                alex-tools-version:             0.5.0.2+version:             0.6.1 synopsis:            A set of functions for a common use case of Alex.-description:         This captures a common patter for using Alex.+description:         This captures a common pattern for using Alex. license:             ISC license-file:        LICENSE author:              Iavor S. Diatchki@@ -19,11 +19,11 @@ library   exposed-modules:     AlexTools, AlexToolsBin   other-extensions:    TemplateHaskell-  build-depends:       base >=4.7 && <4.17,+  build-depends:       base >=4.7 && <4.18,                        text >= 1.2.4 && < 2.1,                        bytestring >= 0.9 && <0.12,                        deepseq >=1.3 && <1.5,-                       template-haskell >=2.9.0 && <2.19+                       template-haskell >=2.9.0 && <2.20   hs-source-dirs:      src   ghc-options:         -Wall   default-language:    Haskell2010
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