-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
Looking at the code:
Lines 88 to 90 in e65958c
| type AlexInput = (Char, -- previous char | |
| [Byte], -- pending bytes on current char | |
| Data.Text.Text) -- current input string |
This can be replaced by:
type AlexInput = (Int, -- current offset
Data.Text.Text) -- input stringLines 98 to 105 in e65958c
| alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) | |
| alexGetByte (c,(b:bs),s) = Just (b,(c,bs,s)) | |
| alexGetByte (_,[],s) = case Data.Text.uncons s of | |
| Just (c, cs) -> | |
| case utf8Encode' c of | |
| (b, bs) -> Just (b, (c, bs, cs)) | |
| Nothing -> | |
| Nothing |
This can be replaced by:
alexGetByte :: AlexInput -> Maybe (Byte,AlexInput)
alexGetByte (cur, input) = case input of
Text arr off len
| cur < len = Just (unsafeIndex arr (off + curr) (cur + 1, input))
| otherwise = NothingThe only thing "complicated" is alexInputPrevChar, basically you go back from cur one byte at a time until you have seen two character boundaries and then do a character decode at that position.
Metadata
Metadata
Assignees
Labels
No labels