Hello community, here is the log from the commit of package alex for openSUSE:Factory checked in at 2013-08-01 15:19:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/alex (Old) and /work/SRC/openSUSE:Factory/.alex.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "alex" Changes: -------- --- /work/SRC/openSUSE:Factory/alex/alex.changes 2013-01-08 16:23:37.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.alex.new/alex.changes 2013-08-01 15:20:01.000000000 +0200 @@ -1,0 +2,7 @@ +Tue May 7 14:03:17 UTC 2013 - [email protected] + +- update to 3.0.5 from upstream +* performance improvement with certain grammars ~30% +- part of Haskell Platform 2013.2 + +------------------------------------------------------------------- Old: ---- alex-3.0.2.tar.gz New: ---- alex-3.0.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ alex.spec ++++++ --- /var/tmp/diff_new_pack.H1gwoA/_old 2013-08-01 15:20:02.000000000 +0200 +++ /var/tmp/diff_new_pack.H1gwoA/_new 2013-08-01 15:20:02.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package alex # - +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2012 Peter Trommler [email protected] # # All modifications and additions to the file contributed by third parties @@ -16,25 +16,28 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + Name: alex -Version: 3.0.2 +Version: 3.0.5 Release: 0 Summary: Tool for generating lexical analysers in Haskell - -Group: Development/Languages/Other License: BSD-3-Clause +Group: Development/Languages/Other + BuildRoot: %{_tmppath}/%{name}-%{version}-build # BEGIN cabal2spec -URL: http://hackage.haskell.org/package/%{name} +Url: http://hackage.haskell.org/package/%{name} Source0: http://hackage.haskell.org/packages/archive/%{name}/%{version}/%{name}-%{version}.tar.gz ExclusiveArch: %{ix86} x86_64 %{ghc_arches} +BuildRequires: autoconf BuildRequires: ghc-Cabal-devel -BuildRequires: ghc-rpm-macros BuildRequires: ghc-QuickCheck-devel -BuildRequires: autoconf +BuildRequires: ghc-rpm-macros # END cabal2spec - %description Tool for generating lexical analysers in Haskell similar to lex @@ -42,14 +45,12 @@ %prep %setup -q - %build %ghc_bin_build cd doc test -f configure || autoreconf ./configure - %install %ghc_bin_install mkdir -p %{buildroot}/%{_mandir}/man1 @@ -62,5 +63,4 @@ %{_datadir}/%{name}-%{version} %{_mandir}/man1/* - %changelog ++++++ alex-3.0.2.tar.gz -> alex-3.0.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/README new/alex-3.0.5/README --- old/alex-3.0.2/README 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/README 2013-03-10 13:19:12.000000000 +0100 @@ -4,7 +4,7 @@ documentation, see the doc directory. http://www.haskell.org/alex/ - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/alex + http://hackage.haskell.org/package/alex Alex is built using Cabal. First install GHC, then: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/Setup.lhs new/alex-3.0.5/Setup.lhs --- old/alex-3.0.2/Setup.lhs 2012-05-10 11:01:10.000000000 +0200 +++ new/alex-3.0.5/Setup.lhs 2013-03-10 13:19:13.000000000 +0100 @@ -73,6 +73,7 @@ templates = [ ("AlexTemplate", []), ("AlexTemplate-ghc", ["-DALEX_GHC"]), + ("AlexTemplate-ghc-nopred",["-DALEX_GHC", "-DALEX_NOPRED"]), ("AlexTemplate-ghc-debug", ["-DALEX_GHC","-DALEX_DEBUG"]), ("AlexTemplate-debug", ["-DALEX_DEBUG"]) ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/TODO new/alex-3.0.5/TODO --- old/alex-3.0.2/TODO 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/TODO 2013-03-10 13:19:12.000000000 +0100 @@ -1,14 +1,12 @@ - Option for pure Haskell 98 output? - -- Extend to Unicode (32-bit Char) + - maybe Haskell 2010 at this point? + - how about an option to use Data.Array.Unboxed? - Put in {-# LINE #-} pragmas for token actions -- bug: we throw away the first character of code - - Prune states that aren't reachable? -- Issues a warning for tokens that can't be generated? +- Issue a warning for tokens that can't be generated? - Info file? - start codes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/alex.cabal new/alex-3.0.5/alex.cabal --- old/alex-3.0.2/alex.cabal 2012-05-10 11:01:10.000000000 +0200 +++ new/alex-3.0.5/alex.cabal 2013-03-10 13:19:13.000000000 +0100 @@ -1,5 +1,5 @@ name: alex -version: 3.0.2 +version: 3.0.5 license: BSD3 license-file: LICENSE copyright: (c) Chis Dornan, Simon Marlow @@ -9,8 +9,13 @@ stability: stable homepage: http://www.haskell.org/alex/ synopsis: Alex is a tool for generating lexical analysers in Haskell +description: Alex is a tool for generating lexical analysers in Haskell. + It takes a description of tokens based on regular + expressions and generates a Haskell module containing code + for scanning text efficiently. It is similar to the tool + lex or flex for C/C++. category: Development -cabal-version: >= 1.6 +cabal-version: >= 1.8 build-type: Custom extra-source-files: @@ -44,8 +49,7 @@ src/Scan.hs src/ghc_hooks.c templates/GenericTemplate.hs - templates/Makefile - templates/wrappers.hs + templates/wrappers.hs tests/Makefile tests/simple.x tests/tokens.x @@ -85,7 +89,6 @@ DFAMin DFS Info - Main Map NFA Output @@ -100,3 +103,8 @@ Data.Ranged.Boundaries Data.Ranged.RangedSet Data.Ranged.Ranges + +test-suite tests + type: exitcode-stdio-1.0 + main-is: test.hs + build-depends: process diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/dist/build/alex/alex-tmp/Parser.hs new/alex-3.0.5/dist/build/alex/alex-tmp/Parser.hs --- old/alex-3.0.2/dist/build/alex/alex-tmp/Parser.hs 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/dist/build/alex/alex-tmp/Parser.hs 2013-03-10 13:19:12.000000000 +0100 @@ -21,7 +21,7 @@ import qualified Data.Array as Happy_Data_Array import qualified GHC.Exts as Happy_GHC_Exts --- parser produced by Happy Version 1.18.7 +-- parser produced by Happy Version 1.18.9 newtype HappyAbsSyn = HappyAbsSyn HappyAny #if __GLASGOW_HASKELL__ >= 607 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/dist/build/alex/alex-tmp/Scan.hs new/alex-3.0.5/dist/build/alex/alex-tmp/Scan.hs --- old/alex-3.0.2/dist/build/alex/alex-tmp/Scan.hs 2012-05-10 11:01:10.000000000 +0200 +++ new/alex-3.0.5/dist/build/alex/alex-tmp/Scan.hs 2013-03-10 13:19:13.000000000 +0100 @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP,MagicHash #-} +{-# LANGUAGE CPP,MagicHash,BangPatterns #-} {-# LINE 13 "src/Scan.x" #-} {-# OPTIONS_GHC -w #-} @@ -241,10 +241,10 @@ #ifdef WORDS_BIGENDIAN narrow16Int# i where - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# + !i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) + !high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + !low = int2Word# (ord# (indexCharOffAddr# arr off')) + !off' = off *# 2# #else indexInt16OffAddr# arr off #endif @@ -341,12 +341,12 @@ let - (base) = alexIndexInt32OffAddr alex_base s - ((I# (ord_c))) = fromIntegral c - (offset) = (base +# ord_c) - (check) = alexIndexInt16OffAddr alex_check offset + (!(base)) = alexIndexInt32OffAddr alex_base s + (!((I# (ord_c)))) = fromIntegral c + (!(offset)) = (base +# ord_c) + (!(check)) = alexIndexInt16OffAddr alex_check offset - (new_s) = if (offset >=# 0#) && (check ==# ord_c) + (!(new_s)) = if (offset >=# 0#) && (check ==# ord_c) then alexIndexInt16OffAddr alex_table offset else alexIndexInt16OffAddr alex_deflt s in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/examples/Makefile new/alex-3.0.5/examples/Makefile --- old/alex-3.0.2/examples/Makefile 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/examples/Makefile 2013-03-10 13:19:12.000000000 +0100 @@ -1,31 +1,59 @@ -TOP = .. -include $(TOP)/mk/boilerplate.mk +ALEX=../dist/build/alex/alex +HC=ghc -Wall -fno-warn-unused-binds -fno-warn-missing-signatures -fno-warn-unused-matches -fno-warn-name-shadowing -fno-warn-unused-imports -PROGS = lit Tokens Tokens_posn Tokens_gscan words words_posn words_monad \ - tiny haskell +HAPPY=happy +HAPPY_OPTS=-agc -lit : lit.hs - $(HC) $(HC_OPTS) -o $@ $< +ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" +exeext=.exe +else +exeext= +endif -tiny : Tokens_posn.o tiny.o - $(HC) $(HC_OPTS) -o $@ Tokens_posn.o tiny.o +PROGS = lit Tokens Tokens_gscan words words_posn words_monad tiny haskell -Tokens_posn : Tokens_posn.hs - $(HC) $(HC_OPTS) -o $@ $< +ALEX_OPTS = --template=.. -g +# ALEX_OPTS = --template=.. -Tokens_gscan : Tokens_gscan.hs - $(HC) $(HC_OPTS) -o $@ $< +%.hs : %.x + $(ALEX) $(ALEX_OPTS) $< -o $@ -words : words.hs - $(HC) $(HC_OPTS) -o $@ $< +%.hs : %.y + $(HAPPY) $(HAPPY_OPTS) $< -o $@ -words_posn : words_posn.hs - $(HC) $(HC_OPTS) -o $@ $< +%.o : %.hs + $(HC) $(HC_OPTS) -c -o $@ $< -words_monad : words_monad.hs - $(HC) $(HC_OPTS) -o $@ $< +CLEAN_FILES += *.info *.hi *.o *.bin *.exe -haskell : haskell.hs - $(HC) $(HC_OPTS) -o $@ $< +all : $(addsuffix $(HS_PROG_EXT),$(PROGS)) + +tiny$(exeext) : tiny.hs Tokens_posn.hs + $(HC) $(HC_OPTS) -o $@ $^ + +lit$(exeext) : lit.hs + $(HC) $(HC_OPTS) -o $@ $^ + +Tokens$(exeext) : Tokens.hs + $(HC) $(HC_OPTS) -o $@ $^ + +Tokens_gscan$(exeext) : Tokens_gscan.hs + $(HC) $(HC_OPTS) -o $@ $^ + +words$(exeext) : words.hs + $(HC) $(HC_OPTS) -o $@ $^ + +words_posn$(exeext) : words_posn.hs + $(HC) $(HC_OPTS) -o $@ $^ + +words_monad$(exeext) : words_monad.hs + $(HC) $(HC_OPTS) -o $@ $^ + +haskell$(exeext) : haskell.hs + $(HC) $(HC_OPTS) -o $@ $^ + +.PHONY: clean +clean: + rm -f *.o *.hi *.bin $(addsuffix $(exeext),$(PROGS)) \ + $(addsuffix .hs,$(PROGS)) Tokens_posn.hs -include $(TOP)/mk/target.mk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/examples/Tokens.x new/alex-3.0.5/examples/Tokens.x --- old/alex-3.0.2/examples/Tokens.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/examples/Tokens.x 2013-03-10 13:19:12.000000000 +0100 @@ -1,5 +1,5 @@ { -module Tokens (Token(..), alexScanTokens) where +module Main where } %wrapper "basic" @@ -31,4 +31,8 @@ Int Int | Err deriving (Eq,Show) + +main = do + s <- getContents + print (alexScanTokens s) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/examples/haskell.x new/alex-3.0.5/examples/haskell.x --- old/alex-3.0.2/examples/haskell.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/examples/haskell.x 2013-03-10 13:19:12.000000000 +0100 @@ -11,6 +11,7 @@ { module Main (main) where +import Data.Char (chr) } %wrapper "monad" @@ -122,7 +123,7 @@ deriving Eq mkL :: LexemeClass -> AlexInput -> Int -> Alex Lexeme -mkL c (p,_,str) len = return (L p c (take len str)) +mkL c (p,_,_,str) len = return (L p c (take len str)) nested_comment :: AlexInput -> Int -> Alex Lexeme nested_comment _ _ = do @@ -130,26 +131,26 @@ go 1 input where go 0 input = do alexSetInput input; alexMonadScan go n input = do - case alexGetChar input of + case alexGetByte input of Nothing -> err input Just (c,input) -> do - case c of + case chr (fromIntegral c) of '-' -> do - case alexGetChar input of + case alexGetByte input of Nothing -> err input - Just ('\125',input) -> go (n-1) input - Just (c,input) -> go n input + Just (125,input) -> go (n-1) input + Just (c,input) -> go n input '\123' -> do - case alexGetChar input of + case alexGetByte input of Nothing -> err input - Just ('-',input) -> go (n+1) input + Just (c,input) | c == fromIntegral (ord '-') -> go (n+1) input Just (c,input) -> go n input c -> go n input err input = do alexSetInput input; lexError "error in nested comment" lexError s = do - (p,c,input) <- alexGetInput + (p,c,_,input) <- alexGetInput alexError (showPosn p ++ ": " ++ s ++ (if (not (null input)) then " before " ++ show (head input) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/examples/lit.x new/alex-3.0.5/examples/lit.x --- old/alex-3.0.2/examples/lit.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/examples/lit.x 2013-03-10 13:19:12.000000000 +0100 @@ -1,4 +1,5 @@ { +{-# LANGUAGE NPlusKPatterns #-} module Main (main) where } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/examples/words_monad.x new/alex-3.0.5/examples/words_monad.x --- old/alex-3.0.2/examples/words_monad.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/examples/words_monad.x 2013-03-10 13:19:12.000000000 +0100 @@ -11,11 +11,11 @@ [A-Za-z0-9\'\-]+ { word } { -word (_,_,input) len = return (take len input) +word (_,_,_,input) len = return (take len input) scanner str = runAlex str $ do - let loop i = do tok <- alexMonadScan; - if tok == "stopped." || tok == "error." + let loop i = do tok <- alexMonadScan + if tok == "stopped." || tok == "error." then return i else do let i' = i+1 in i' `seq` loop i' loop 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/src/AbsSyn.hs new/alex-3.0.5/src/AbsSyn.hs --- old/alex-3.0.2/src/AbsSyn.hs 2012-05-10 11:01:08.000000000 +0200 +++ new/alex-3.0.5/src/AbsSyn.hs 2013-03-10 13:19:12.000000000 +0100 @@ -17,7 +17,8 @@ DFA(..), State(..), SNum, StartCode, Accept(..), RightContext(..), showRCtx, encodeStartCodes, extractActions, - Target(..) + Target(..), + UsesPreds(..), usesPreds ) where import CharSet ( CharSet ) @@ -118,6 +119,25 @@ type StartCode = Int -- ----------------------------------------------------------------------------- +-- Predicates / contexts + +-- we can generate somewhat faster code in the case that +-- the lexer doesn't use predicates +data UsesPreds = UsesPreds | DoesntUsePreds + +usesPreds :: DFA s a -> UsesPreds +usesPreds dfa + | any acceptHasCtx [ acc | st <- Map.elems (dfa_states dfa) + , acc <- state_acc st ] + = UsesPreds + | otherwise + = DoesntUsePreds + where + acceptHasCtx Acc { accLeftCtx = Nothing + , accRightCtx = NoRightContext } = False + acceptHasCtx _ = True + +-- ----------------------------------------------------------------------------- -- Regular expressions -- `RExp' provides an abstract syntax for regular expressions. `Eps' will diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/src/Main.hs new/alex-3.0.5/src/Main.hs --- old/alex-3.0.2/src/Main.hs 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/src/Main.hs 2013-03-10 13:19:12.000000000 +0100 @@ -140,7 +140,6 @@ | otherwise = UTF8 template_dir <- templateDir getDataDir cli - let template_name = templateFile template_dir target cli -- open the output file; remove it if we encounter an error bracketOnError @@ -168,6 +167,7 @@ let dfa = scanner2dfa encoding scanner_final scs min_dfa = minimizeDFA dfa nm = scannerName scanner_final + usespreds = usesPreds min_dfa put_info "\nStart codes\n" @@ -188,6 +188,7 @@ hPutStr out_h (actions "") -- add the template + let template_name = templateFile template_dir target usespreds cli tmplt <- alexReadFile template_name hPutStr out_h tmplt @@ -256,9 +257,9 @@ [] -> def ds -> return (last ds) -templateFile :: FilePath -> Target -> [CLIFlags] -> FilePath -templateFile dir target cli - = dir ++ "/AlexTemplate" ++ maybe_ghc ++ maybe_debug +templateFile :: FilePath -> Target -> UsesPreds -> [CLIFlags] -> FilePath +templateFile dir target usespreds cli + = dir ++ "/AlexTemplate" ++ maybe_ghc ++ maybe_debug ++ maybe_nopred where maybe_ghc = case target of GhcTarget -> "-ghc" @@ -268,6 +269,12 @@ | OptDebugParser `elem` cli = "-debug" | otherwise = "" + maybe_nopred = + case usespreds of + DoesntUsePreds | not (null maybe_ghc) + && null maybe_debug -> "-nopred" + _ -> "" + wrapperFile :: FilePath -> [Directive] -> IO (Maybe FilePath) wrapperFile dir directives = case [ f | WrapperDirective f <- directives ] of diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/src/Output.hs new/alex-3.0.5/src/Output.hs --- old/alex-3.0.2/src/Output.hs 2012-05-10 11:01:08.000000000 +0200 +++ new/alex-3.0.5/src/Output.hs 2013-03-10 13:19:12.000000000 +0100 @@ -71,20 +71,21 @@ . str "]\n" outputAccs :: [Accept Code] -> ShowS - outputAccs accs - = brack (interleave_shows (char ',') (map (paren.outputAcc) accs)) - - outputAcc (Acc _ Nothing Nothing NoRightContext) + outputAccs [] + = str "AlexAccNone" + outputAccs (Acc _ Nothing Nothing NoRightContext : []) = str "AlexAccSkip" - outputAcc (Acc _ (Just act) Nothing NoRightContext) + outputAccs (Acc _ (Just act) Nothing NoRightContext : []) = str "AlexAcc " . paren (str act) - outputAcc (Acc _ Nothing lctx rctx) + outputAccs (Acc _ Nothing lctx rctx : rest) = str "AlexAccSkipPred " . space . paren (outputPred lctx rctx) - outputAcc (Acc _ (Just act) lctx rctx) + . paren (outputAccs rest) + outputAccs (Acc _ (Just act) lctx rctx : rest) = str "AlexAccPred " . space . paren (str act) . space . paren (outputPred lctx rctx) + . paren (outputAccs rest) outputPred (Just set) NoRightContext = outputLCtx set diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/templates/GenericTemplate.hs new/alex-3.0.5/templates/GenericTemplate.hs --- old/alex-3.0.2/templates/GenericTemplate.hs 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/templates/GenericTemplate.hs 2013-03-10 13:19:12.000000000 +0100 @@ -9,7 +9,6 @@ #ifdef ALEX_GHC #define ILIT(n) n# -#define FAST_INT_BINDING(n) (n) #define IBOX(n) (I# (n)) #define FAST_INT Int# #define LT(n,m) (n <# m) @@ -22,7 +21,6 @@ #define IF_GHC(x) (x) #else #define ILIT(n) (n) -#define FAST_INT_BINDING(n) (n) #define IBOX(n) (n) #define FAST_INT Int #define LT(n,m) (n < m) @@ -74,14 +72,14 @@ ALEX_IF_BIGENDIAN narrow32Int# i where - !i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#` + i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#` (b2 `uncheckedShiftL#` 16#) `or#` (b1 `uncheckedShiftL#` 8#) `or#` b0) - !b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#))) - !b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#))) - !b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - !b0 = int2Word# (ord# (indexCharOffAddr# arr off')) - !off' = off *# 4# + b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#))) + b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#))) + b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + b0 = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 4# ALEX_ELSE indexInt32OffAddr# arr off ALEX_ENDIF @@ -154,37 +152,42 @@ 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) $ #endif - let - FAST_INT_BINDING(base) = alexIndexInt32OffAddr alex_base s - FAST_INT_BINDING(IBOX(ord_c)) = fromIntegral c - FAST_INT_BINDING(offset) = PLUS(base,ord_c) - FAST_INT_BINDING(check) = alexIndexInt16OffAddr alex_check offset + case fromIntegral c of { IBOX(ord_c) -> + let + base = alexIndexInt32OffAddr alex_base s + offset = PLUS(base,ord_c) + check = alexIndexInt16OffAddr alex_check offset - FAST_INT_BINDING(new_s) = if GTE(offset,ILIT(0)) && EQ(check,ord_c) + new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c) then alexIndexInt16OffAddr alex_table offset else alexIndexInt16OffAddr alex_deflt s in - case new_s of + case new_s of ILIT(-1) -> (new_acc, input) -- on an error, we want to keep the input *before* the -- character that failed, not after. _ -> alex_scan_tkn user orig_input (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len) -- note that the length is increased ONLY if this is the 1st byte in a char encoding) new_input new_s new_acc - + } where - check_accs [] = last_acc - check_accs (AlexAcc a : _) = AlexLastAcc a input IBOX(len) - check_accs (AlexAccSkip : _) = AlexLastSkip input IBOX(len) - check_accs (AlexAccPred a predx : rest) + check_accs (AlexAccNone) = last_acc + check_accs (AlexAcc a ) = AlexLastAcc a input IBOX(len) + check_accs (AlexAccSkip) = AlexLastSkip input IBOX(len) +#ifndef ALEX_NOPRED + check_accs (AlexAccPred a predx rest) | predx user orig_input IBOX(len) input = AlexLastAcc a input IBOX(len) - check_accs (AlexAccSkipPred predx : rest) + | otherwise + = check_accs rest + check_accs (AlexAccSkipPred predx rest) | predx user orig_input IBOX(len) input = AlexLastSkip input IBOX(len) - check_accs (_ : rest) = check_accs rest + | otherwise + = check_accs rest +#endif data AlexLastAcc a = AlexNone @@ -197,10 +200,12 @@ fmap f (AlexLastSkip x y) = AlexLastSkip x y data AlexAcc a user - = AlexAcc a + = AlexAccNone + | AlexAcc a | AlexAccSkip - | AlexAccPred a (AlexAccPred user) - | AlexAccSkipPred (AlexAccPred user) +#ifndef ALEX_NOPRED + | AlexAccPred a (AlexAccPred user) (AlexAcc a user) + | AlexAccSkipPred (AlexAccPred user) (AlexAcc a user) type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool @@ -226,6 +231,7 @@ -- TODO: there's no need to find the longest -- match when checking the right context, just -- the first match will do. +#endif -- used by wrappers iUnbox IBOX(i) = i diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/templates/Makefile new/alex-3.0.5/templates/Makefile --- old/alex-3.0.2/templates/Makefile 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/templates/Makefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,67 +0,0 @@ -TOP = .. -include $(TOP)/mk/boilerplate.mk - -TEMPLATES = \ - AlexTemplate \ - AlexTemplate-ghc \ - AlexTemplate-ghc-debug \ - AlexTemplate-debug \ - AlexWrapper-basic \ - AlexWrapper-posn \ - AlexWrapper-monad \ - AlexWrapper-gscan - -GENERIC_TEMPLATE = GenericTemplate.hs -EXCLUDED_SRCS = $(GENERIC_TEMPLATE) wrappers.hs - -INSTALL_DATAS = $(TEMPLATES) - -all :: $(TEMPLATES) - -override datadir = $(libdir) - -ghc_411_at_least = $(shell expr "$(GhcMajVersion)" = 4 \& \ - "$(GhcMinVersion)" \>= 11 \| \ - "$(GhcMajVersion)" \> 4) - -ifeq "$(ghc_411_at_least)" "1" -CPP_IT = $(GHC) -E -cpp -o -else -CPP_IT = $(GHC) -E -cpp > -endif - -AlexTemplate.hspp : $(GENERIC_TEMPLATE) - $(CPP_IT) $@ $(GENERIC_TEMPLATE) - -AlexTemplate-ghc.hspp : $(GENERIC_TEMPLATE) - $(CPP_IT) $@ -DALEX_GHC $(GENERIC_TEMPLATE) - -AlexTemplate-ghc-debug.hspp : $(GENERIC_TEMPLATE) - $(CPP_IT) $@ -DALEX_GHC -DALEX_DEBUG $(GENERIC_TEMPLATE) - -AlexTemplate-debug.hspp : $(GENERIC_TEMPLATE) - $(CPP_IT) $@ -DALEX_DEBUG $(GENERIC_TEMPLATE) - -AlexTemplate-monad.hspp : $(GENERIC_TEMPLATE) - $(CPP_IT) $@ -DALEX_MONAD $(GENERIC_TEMPLATE) - -AlexWrapper-basic.hspp : wrappers.hs - $(CPP_IT) $@ -DALEX_BASIC $< - -AlexWrapper-posn.hspp : wrappers.hs - $(CPP_IT) $@ -DALEX_POSN $< - -AlexWrapper-monad.hspp : wrappers.hs - $(CPP_IT) $@ -DALEX_MONAD $< - -AlexWrapper-gscan.hspp : wrappers.hs - $(CPP_IT) $@ -DALEX_GSCAN $< - -# hack to turn cpp-style '# 27 "GenericTemplate.hs"' into -# '{-# LINE 27 "GenericTemplate.hs" #-}'. -% : %.hspp - perl -pe 's/^#\s+(\d+)\s+(\"[^\"]*\")/{-# LINE \1 \2 #-}/g;s/\$$(Id:.*)\$$/\1/g' < $< > $@ - -CLEAN_FILES += $(TEMPLATES) $(patsubst %, %.hspp, $(TEMPLATES)) - -include $(TOP)/mk/target.mk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/templates/wrappers.hs new/alex-3.0.5/templates/wrappers.hs --- old/alex-3.0.2/templates/wrappers.hs 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/templates/wrappers.hs 2013-03-10 13:19:12.000000000 +0100 @@ -325,23 +325,24 @@ #ifdef ALEX_BASIC type AlexInput = (Char,[Byte],String) - -alexInputPrevChar (c,_) = c +alexInputPrevChar :: AlexInput -> Char +alexInputPrevChar (c,_,_) = c -- alexScanTokens :: String -> [token] alexScanTokens str = go ('\n',[],str) - where go inp@(_,_bs,str) = + where go inp@(_,_bs,s) = case alexScan inp 0 of AlexEOF -> [] AlexError _ -> error "lexical error" AlexSkip inp' len -> go inp' - AlexToken inp' len act -> act (take len str) : go inp' + AlexToken inp' len act -> act (take len s) : go inp' alexGetByte :: AlexInput -> Maybe (Byte,AlexInput) alexGetByte (c,(b:bs),s) = Just (b,(c,bs,s)) alexGetByte (c,[],[]) = Nothing alexGetByte (_,[],(c:s)) = case utf8Encode c of (b:bs) -> Just (b, (c, bs, s)) + [] -> Nothing #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/test.hs new/alex-3.0.5/test.hs --- old/alex-3.0.2/test.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/alex-3.0.5/test.hs 2013-03-10 13:19:12.000000000 +0100 @@ -0,0 +1,5 @@ +import System.Cmd (system) +import System.Exit (exitWith) + +main = system "make -k -C tests clean all" >>= exitWith + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/tests/Makefile new/alex-3.0.5/tests/Makefile --- old/alex-3.0.2/tests/Makefile 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/tests/Makefile 2013-03-10 13:19:12.000000000 +0100 @@ -1,7 +1,8 @@ ALEX=../dist/build/alex/alex -HC=ghc -Wall -fno-warn-unused-binds -fno-warn-missing-signatures -fno-warn-unused-matches -fno-warn-name-shadowing -fno-warn-unused-imports +HC=ghc +HC_OPTS=-Wall -fno-warn-unused-binds -fno-warn-missing-signatures -fno-warn-unused-matches -fno-warn-name-shadowing -fno-warn-unused-imports -.PRECIOUS: .hs .o .exe .bin +.PRECIOUS: %.n.hs %.g.hs %.o %.exe %.bin ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" HS_PROG_EXT = .exe @@ -22,7 +23,7 @@ %.o : %.hs $(HC) $(HC_OPTS) -c -o $@ $< -CLEAN_FILES += *.n.hs *.g.hs *.info *.hi *.bin *.exe +CLEAN_FILES += *.n.hs *.g.hs *.info *.hi *.o *.bin *.exe ALL_TEST_HS = $(shell echo $(TESTS) | sed -e 's/\([^\. ]*\)\.\(l\)\{0,1\}x/\1.n.hs \1.g.hs/g') @@ -38,7 +39,7 @@ .PHONY: clean clean: - rm -f *.o *.hi *.bin + rm -f $(CLEAN_FILES) interact: ghci -cpp -i../src -i../dist/build/autogen -i../dist/build/alex/alex-tmp Main -fbreak-on-exception diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/tests/tokens.x new/alex-3.0.5/tests/tokens.x --- old/alex-3.0.2/tests/tokens.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/tests/tokens.x 2013-03-10 13:19:12.000000000 +0100 @@ -18,6 +18,9 @@ [\=\+\-\*\/\(\)] { \s -> Sym (head s) } $alpha [$alpha $digit \_ \']* { \s -> Var s } + -- a left-context pattern for testing + ^ \# ; + { -- Each right-hand side has type :: String -> Token diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/alex-3.0.2/tests/unicode.x new/alex-3.0.5/tests/unicode.x --- old/alex-3.0.2/tests/unicode.x 2012-05-10 11:01:09.000000000 +0200 +++ new/alex-3.0.5/tests/unicode.x 2013-03-10 13:19:12.000000000 +0100 @@ -14,23 +14,27 @@ tokens :- -<0> { - - "αω" { string } - [AΓ] { character } - . { other } +<0> { + "αω" { string } + [AΓ] { character } + . { other } } { +string :: AlexInput -> Int -> Alex String string (p,_,_,input) len = return "string!" +other :: AlexInput -> Int -> Alex String other (p,_,_,input) len = return (take len input) +character :: AlexInput -> Int -> Alex String character (p,_,_,input) len = return "PING!" +alexEOF :: Alex String alexEOF = return "stopped." +scanner :: String -> Either String [String] scanner str = runAlex str $ do let loop = do tok <- alexMonadScan if tok == "stopped." || tok == "error." @@ -39,6 +43,7 @@ return (tok:toks) loop +main :: IO () main = do let test1 = scanner str1 when (test1 /= out1) $ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
