Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/yi-editor/yi

  • Loading branch information...
commit 92bb2ae69e0d5aec58a35fe2abe4d86aa3e6c3d8 2 parents 8b2ce54 + 4d71e7a
@mgajda mgajda authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 yi/src/library/Yi/Lexer/Alex.hs
View
11 yi/src/library/Yi/Lexer/Alex.hs
@@ -20,7 +20,8 @@ module Yi.Lexer.Alex (
ASI,
(+~), (~-), Size(..),
Stroke,
- tokToSpan
+ tokToSpan,
+ alexGetByte
) where
import Yi.Syntax hiding (mkHighlighter)
@@ -29,6 +30,8 @@ import Prelude ()
import Yi.Region
import Data.Ord (comparing)
import Data.Ix
+import Data.Word (Word8)
+import Data.Char (ord)
type IndexedStr = [(Point, Char)]
type AlexInput = (Char, IndexedStr)
@@ -101,6 +104,12 @@ alexGetChar :: AlexInput -> Maybe (Char, AlexInput)
alexGetChar (_,[]) = Nothing
alexGetChar (_,(_,c):rest) = Just (c, (c,rest))
+first :: (a -> b) -> (a, c) -> (b, c)
+first f (a, c) = (f a, c)
+
+alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
+alexGetByte = fmap (first (fromIntegral . ord)) . alexGetChar
+
alexCollectChar :: AlexInput -> [Char]
alexCollectChar (_, []) = []
alexCollectChar (_, (_,c):rest) = c : (alexCollectChar (c,rest))
Please sign in to comment.
Something went wrong with that request. Please try again.