Skip to content

Commit

Permalink
Tests and CHANGELOG for #220
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Dec 30, 2023
1 parent ff5b1b8 commit a857c89
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Add option `--numeric-version`.
* Remove deprecated `-v` as alias for `--version`.
* Add `-v` as placeholder for a future `--verbose` option.
* Make `alex{G,S}etUserState` available with the `monadUserState-bytestring` wrapper
[Issue #220](https://github.com/haskell/alex/issues/220).

## Changes in 3.4.0.1

Expand Down
5 changes: 5 additions & 0 deletions tests/monadUserState_typeclass_bytestring.x
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ lex inp =
let
lexAll =
do
-- Andreas Abel, 2023-12-30, issue #220:
-- Test that alex{G,S}etUserState are in scope.
u <- alexGetUserState
alexSetUserState (u + 1)

res <- alexMonadScan
case res of
EOF -> return []
Expand Down
39 changes: 24 additions & 15 deletions tests/tokens_monadUserState_bytestring.x
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,39 @@ tokens :-
tok f (p,_,input,_) len = return (f p (B.take (fromIntegral len) input))
-- The token type:
data Token =
Let AlexPosn |
In AlexPosn |
Sym AlexPosn Char |
Var AlexPosn String |
Int AlexPosn Int |
Err AlexPosn |
EOF
deriving (Eq,Show)
data Token
= Let AlexPosn
| In AlexPosn
| Sym AlexPosn Char
| Var AlexPosn String
| Int AlexPosn Int
| Err AlexPosn
| EOF
deriving (Eq,Show)
alexEOF = return EOF
main = if test1 /= result1 then do print test1; exitFailure
else exitWith ExitSuccess
else exitWith ExitSuccess
type AlexUserState = ()
alexInitUserState = ()
scanner str = runAlex str $ do
let loop = do tk <- alexMonadScan
if tk == EOF
then return [tk]
else do toks <- loop
return (tk:toks)
let
loop = do
-- Andreas Abel, 2023-12-30, issue #220:
-- Test that alex{G,S}etUserState are in scope.
() <- alexGetUserState
alexSetUserState ()
tk <- alexMonadScan
if tk == EOF
then return [tk]
else do
toks <- loop
return (tk:toks)
loop
test1 = case scanner " let in 012334\n=+*foo bar__'" of
Expand Down

0 comments on commit a857c89

Please sign in to comment.