packages feed

alex 3.4.0.1 → 3.5.0.0

raw patch · 9 files changed

+77/−31 lines, 9 files

Files

CHANGELOG.md view
@@ -1,3 +1,16 @@+## Changes in 3.5.0.0++ * 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)).+ * Debugging lexer: print character in addition to its ASCII code+   ([PR #252](https://github.com/haskell/alex/pull/252)).+ * Tested with GHC 8.0 - 9.8.1.++_Andreas Abel, 2023-12-30_+ ## Changes in 3.4.0.1   * Address new `x-partial` warning of GHC 9.8.
alex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.10 name: alex-version: 3.4.0.1+version: 3.5.0.0 -- don't forget updating changelog.md! license: BSD3 license-file: LICENSE@@ -24,7 +24,7 @@ tested-with:         GHC == 9.8.1         GHC == 9.6.3-        GHC == 9.4.7+        GHC == 9.4.8         GHC == 9.2.8         GHC == 9.0.2         GHC == 8.10.7
data/AlexTemplate.hs view
@@ -155,7 +155,7 @@      Nothing -> (new_acc, input__)      Just (c, new_input) -> #ifdef ALEX_DEBUG-      trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $+      trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c ++ " " ++ (show . chr . fromIntegral) c) $ #endif       case fromIntegral c of { IBOX(ord_c) ->         let
data/AlexWrappers.hs view
@@ -360,13 +360,13 @@ alexSetStartCode :: Int -> Alex () alexSetStartCode sc = Alex $ \s -> Right (s{alex_scd=sc}, ()) -#if !defined(ALEX_MONAD_BYTESTRING) && defined(ALEX_MONAD_USER_STATE)+#if defined(ALEX_MONAD_USER_STATE) alexGetUserState :: Alex AlexUserState alexGetUserState = Alex $ \s@AlexState{alex_ust=ust} -> Right (s,ust)  alexSetUserState :: AlexUserState -> Alex () alexSetUserState ss = Alex $ \s -> Right (s{alex_ust=ss}, ())-#endif /* !defined(ALEX_MONAD_BYTESTRING) && defined(ALEX_MONAD_USER_STATE) */+#endif /* defined(ALEX_MONAD_USER_STATE) */  #ifdef ALEX_MONAD alexMonadScan = do
src/Main.hs view
@@ -53,19 +53,26 @@ -- `main' decodes the command line arguments and calls `alex'.  main:: IO ()-main =  do- args <- getArgs- case getOpt Permute argInfo args of+main = do+  args <- getArgs+  case getOpt Permute argInfo args of     (cli,_,[]) | DumpHelp `elem` cli -> do         prog <- getProgramName         bye (usageInfo (usageHeader prog) argInfo)     (cli,_,[]) | DumpVersion `elem` cli ->         bye copyright+    (cli,_,[]) | DumpNumericVersion `elem` cli ->+        bye projectVersion+    (cli,_,[]) | OptVerbose `elem` cli ->+        failure "Option '--verbose' not yet implemented"     (cli,[file],[]) ->         runAlex cli file-    (_,_,errors) -> do-        prog <- getProgramName-        die (concat errors ++ usageInfo (usageHeader prog) argInfo)+    (_,_,errors) ->+        failure $ concat errors+  where+    failure err = do+      prog <- getProgramName+      die (err ++ usageInfo (usageHeader prog) argInfo)  projectVersion :: String projectVersion = showVersion version@@ -399,6 +406,7 @@  import_debug :: String import_debug   = "#if __GLASGOW_HASKELL__ >= 503\n" +++                 "import Data.Char (chr)\n" ++                  "import System.IO\n" ++                  "import System.IO.Unsafe\n" ++                  "import Debug.Trace\n" ++@@ -462,8 +470,10 @@   | OptTabSize String   | OptTemplateDir FilePath   | OptLatin1+  | OptVerbose   | DumpHelp   | DumpVersion+  | DumpNumericVersion   deriving Eq  argInfo :: [OptDescr CLIFlags]@@ -482,10 +492,14 @@         "set tab size to be used in the generated lexer (default: 8)",    Option ['d'] ["debug"] (NoArg OptDebugParser)         "produce a debugging scanner",+   Option ['v'] ["verbose"] (NoArg OptVerbose)+        "be verbose (not yet implemented)",    Option ['?'] ["help"] (NoArg DumpHelp)         "display this help and exit",-   Option ['V','v'] ["version"] (NoArg DumpVersion)  -- ToDo: -v is deprecated!+   Option ['V'] ["version"] (NoArg DumpVersion)         "output version information and exit"+  ,Option [] ["numeric-version"] (NoArg DumpNumericVersion)+        "output the version number and exit"   ]  -- -----------------------------------------------------------------------------
src/Scan.hs view
@@ -471,7 +471,7 @@      Nothing -> (new_acc, input__)      Just (c, new_input) -> #ifdef ALEX_DEBUG-      trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $+      trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c ++ " " ++ (show . chr . fromIntegral) c) $ #endif       case fromIntegral c of { IBOX(ord_c) ->         let
tests/Makefile view
@@ -102,10 +102,13 @@ %.g.hs : %.x 	$(ALEX) $(TEST_ALEX_OPTS) -g $< -o $@ -CLEAN_FILES += *.n.hs *.g.hs *.info *.hi *.o *.bin *.exe+%.d.hs : %.x+	$(ALEX) $(TEST_ALEX_OPTS) --debug $< -o $@ -ALL_TEST_HS = $(shell echo $(TESTS) $(TEXT_TESTS) | sed -e 's/\([^\. ]*\)\.\(l\)\{0,1\}x/\1.n.hs \1.g.hs/g')+CLEAN_FILES += *.n.hs *.g.hs *.d.hs *.info *.hi *.o *.bin *.exe +ALL_TEST_HS = $(shell echo $(TESTS) $(TEXT_TESTS) | sed -e 's/\([^\. ]*\)\.\(l\)\{0,1\}x/\1.n.hs \1.g.hs \1.d.hs/g')+ ALL_TESTS = $(patsubst %.hs, %.run, $(ALL_TEST_HS))  %.run : %$(HS_PROG_EXT)@@ -128,4 +131,6 @@ # :set args --template=.. simple.x -o simple.n.hs  debug :-	@echo HC_OPTS=$(HC_OPTS)+	@echo ALEX      = $(ALEX)+	@echo HC_OPTS   = $(HC_OPTS)+	@echo ALL_TESTS = $(ALL_TESTS)
tests/monadUserState_typeclass_bytestring.x view
@@ -70,6 +70,11 @@   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 []
tests/tokens_monadUserState_bytestring.x view
@@ -28,30 +28,39 @@ 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