yav / haskell-lexer Goto Github PK
View Code? Open in Web Editor NEWA fully compliant Haskell 98 lexer.
License: MIT License
A fully compliant Haskell 98 lexer.
License: MIT License
Compare
*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},""))
*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"))
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...
The package description says:
A fully compliant Haskell 98 lexer.
The differences between Haskell98 and Haskell2010 as listed here.
consider
type Foo = 'True
which breaks the lexer :(
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!
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).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.