summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitryIvanov <>2016-09-30 05:26:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-09-30 05:26:00 (GMT)
commit228881bb6cc0e0aa0c75d6568714258f2c31743c (patch)
tree6e4e84dc9514eaa09ed7347a996d657ba01037ff
parent0295058127b7f2b4fede66590db12de4fe646691 (diff)
version 0.13.0.10.13.0.1
-rw-r--r--src/Yi/Lexer/common.hsinc87
-rw-r--r--yi-mode-haskell.cabal5
2 files changed, 91 insertions, 1 deletions
diff --git a/src/Yi/Lexer/common.hsinc b/src/Yi/Lexer/common.hsinc
new file mode 100644
index 0000000..bb00f31
--- /dev/null
+++ b/src/Yi/Lexer/common.hsinc
@@ -0,0 +1,87 @@
+-- -*- Haskell -*-
+
+-- The include file for alex-generated syntax highlighters. Because alex
+-- declares its own types, any wrapper must have the highlighter in scope...
+-- so it must be included. Doubleplusyuck.
+
+#define IBOX(n) (I# (n))
+
+#define GEQ_(x, y) (tagToEnum# (x >=# y))
+#define EQ_(x, y) (tagToEnum# (x ==# y))
+
+-- | Scan one token. Return (maybe) a token and a new state.
+alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput))
+alexScanToken (AlexState state lookedOfs pos, inp@(_prevCh,_bs,str)) =
+ let (scn,lookahead) = alexScanUser' state inp (stateToInit state)
+ lookedOfs' = max lookedOfs (posnOfs pos +~ Size lookahead) in
+ case scn of
+ AlexEOF -> Nothing
+ AlexError inp' -> Nothing
+ AlexSkip inp' len ->
+ let chunk = take (fromIntegral len) str
+ in alexScanToken (AlexState state lookedOfs' (moveStr pos chunk), inp')
+ AlexToken inp' len act ->
+ let (state', tokValue) = act chunk state
+ chunk = take (fromIntegral len) str
+ newPos = moveStr pos chunk
+ in Just (Tok tokValue (posnOfs newPos ~- posnOfs pos) pos, (AlexState state' lookedOfs' newPos, inp'))
+
+alexScan' input (I# (sc))
+ = alexScanUser' undefined input (I# (sc))
+
+alexScanUser' user input (I# (sc))
+ = case alex_scan_tkn' user input 0# input sc AlexNone of
+ (AlexNone, input', lookahead) ->
+ case alexGetByte input of
+ Nothing -> (AlexEOF, lookahead)
+ Just _ -> (AlexError input', lookahead)
+ (AlexLastSkip input'' len, _, lookahead) -> (AlexSkip input'' len, lookahead)
+ (AlexLastAcc k input'' len, _, lookahead) -> (AlexToken input'' len k, lookahead)
+
+
+-- Same as alex_scan_tkn, but also return the length of lookahead.
+alex_scan_tkn' user orig_input len input s last_acc =
+ input `seq` -- strict in the input
+ let new_acc = check_accs (alex_accept `quickIndex` IBOX(s)) in
+ new_acc `seq`
+ case alexGetByte input of
+ Nothing -> (new_acc, input, IBOX(len))
+ Just (c, new_input) ->
+ let base = alexIndexInt32OffAddr alex_base s
+ ord_c = case fromIntegral c of (I# x) -> x
+ offset = (base +# ord_c)
+ check = alexIndexInt16OffAddr alex_check offset
+
+ new_s = if GEQ_(offset, 0#) && EQ_(check, ord_c)
+ then alexIndexInt16OffAddr alex_table offset
+ else alexIndexInt16OffAddr alex_deflt s
+ new_len = if c < 0x80 || c >= 0xC0 then len +# 1# else len
+ in case new_s of
+ -1# -> (new_acc, input, IBOX(new_len))
+ -- on an error, we want to keep the input *before* the
+ -- character that failed, not after.
+ -- (but still, we looked after)
+ _ -> alex_scan_tkn' user orig_input new_len new_input new_s new_acc
+
+ where
+ check_accs (AlexAccNone) = last_acc
+ check_accs (AlexAcc a ) = AlexLastAcc a input IBOX(len)
+ check_accs (AlexAccSkip) = AlexLastSkip input IBOX(len)
+#ifndef NO_ALEX_CONTEXTS
+ check_accs (AlexAccPred a predx rest)
+ | predx user orig_input IBOX(len) input
+ = AlexLastAcc a input IBOX(len)
+ | otherwise
+ = check_accs rest
+ check_accs (AlexAccSkipPred predx rest)
+ | predx user orig_input IBOX(len) input
+ = AlexLastSkip input IBOX(len)
+ | otherwise
+ = check_accs rest
+#endif
+
+
+c = actionConst
+m = actionAndModify
+ms = actionStringAndModify
+cs = actionStringConst
diff --git a/yi-mode-haskell.cabal b/yi-mode-haskell.cabal
index a146bdc..6d4afa6 100644
--- a/yi-mode-haskell.cabal
+++ b/yi-mode-haskell.cabal
@@ -3,7 +3,7 @@
-- see: https://github.com/sol/hpack
name: yi-mode-haskell
-version: 0.13
+version: 0.13.0.1
synopsis: Yi editor haskell mode
category: Yi
homepage: https://github.com/yi-editor/yi#readme
@@ -13,6 +13,9 @@ license: GPL-2
build-type: Simple
cabal-version: >= 1.10
+extra-source-files:
+ src/Yi/Lexer/common.hsinc
+
source-repository head
type: git
location: https://github.com/yi-editor/yi