GithubHelp home page GithubHelp logo

haskell-lexer's People

Contributors

andreasabel avatar erikd avatar tmcgilchrist avatar yav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

haskell-lexer's Issues

Parsing of line comment fails if there is no trailing LF (but rather EOF).

Compare

no LF

*CabalDocspec.Lexer> traverse_ print $ L.lexerPass0 "1 + 1 -- foo"
(IntLit,(Pos {char = 0, line = 1, column = 1},"1"))
(Whitespace,(Pos {char = 1, line = 1, column = 2}," "))
(Varsym,(Pos {char = 2, line = 1, column = 3},"+"))
(Whitespace,(Pos {char = 3, line = 1, column = 4}," "))
(IntLit,(Pos {char = 4, line = 1, column = 5},"1"))
(Whitespace,(Pos {char = 5, line = 1, column = 6}," "))
(Commentstart,(Pos {char = 6, line = 1, column = 7},"--"))
(ErrorToken,(Pos {char = 8, line = 1, column = 9}," foo"))
(GotEOF,(Pos {char = 12, line = 1, column = 13},""))

With LF

*CabalDocspec.Lexer> traverse_ print $ L.lexerPass0 "1 + 1 -- foo\n"
(IntLit,(Pos {char = 0, line = 1, column = 1},"1"))
(Whitespace,(Pos {char = 1, line = 1, column = 2}," "))
(Varsym,(Pos {char = 2, line = 1, column = 3},"+"))
(Whitespace,(Pos {char = 3, line = 1, column = 4}," "))
(IntLit,(Pos {char = 4, line = 1, column = 5},"1"))
(Whitespace,(Pos {char = 5, line = 1, column = 6}," "))
(Commentstart,(Pos {char = 6, line = 1, column = 7},"--"))
(Comment,(Pos {char = 8, line = 1, column = 9}," foo\n"))

Eliminate warnings

E.g. with GHC-9.2.1:

[5 of 6] Compiling Language.Haskell.Lexer.Lex ( Language/Haskell/Lexer/Lex.hs, dist/build/Language/Haskell/Lexer/Lex.o )

Language/Haskell/Lexer/Lex.hs:122:5: warning: [-Wname-shadowing]
    This binding for ‘c’ shadows the existing binding
      bound at Language/Haskell/Lexer/Lex.hs:19:8
    |
122 |     c | isAscii c -> 0
    |     ^

Language/Haskell/Lexer/Lex.hs:131:26: warning: [-Wname-shadowing]
    This binding for ‘is’ shadows the existing binding
      bound at Language/Haskell/Lexer/Lex.hs:131:8
    |
131 | start1 is = state1 (\ as is -> gotError as is) "" is
    |                          ^^

Language/Haskell/Lexer/Lex.hs:133:8: warning: [-Wunused-matches]
    Defined but not used: ‘err’
    |
133 | state1 err as [] = gotEOF as
    |        ^^^

There are gazillion of these warnings...

Support for Haskell2010

The package description says:

A fully compliant Haskell 98 lexer.

The differences between Haskell98 and Haskell2010 as listed here.

License is MIT not BSD

haskell-lexer.cabal claims the project is BSD3 but actually the License file is MIT.

Can you please either update the License tag or License file to be consistent, thanks!

Non-deterministic behavior?!

Steps to reproduce:

-- Test.hs
import Test.QuickCheck
import Language.Haskell.Lexer

lexer :: String -> [(Token, String)]
lexer = map (\(token, (_pos, s)) -> (token, s)) . lexerPass1

input :: String
input = show 23

prop :: Int -> Property
prop _ = lexer input === lexer input

main :: IO ()
main = quickCheckWith stdArgs { maxSuccess = 1000000 } prop
$ runhaskell Test.hs 
*** Failed! Falsifiable (after 105133 tests):                  
13
[(Open 1,""),(Conid,"23")] /= [(Open 1,""),(IntLit,"23")]
$ runhaskell --$ runhaskell --version
runghc 8.0.1

Note: This only happens when haskell-lexer is compiled (not interpreted).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.