Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Haskell parser from Geany #2712

Merged
merged 2 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Units/parser-haskell.r/literate-haskell1.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
3 changes: 3 additions & 0 deletions Units/parser-haskell.r/literate-haskell1.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main input.lhs /^> main = do putStr "Enter a number: "$/;" f
fact input.lhs /^> fact 0 = 1$/;" f
fact input.lhs /^> fact n = n * fact (n-1)$/;" f
18 changes: 18 additions & 0 deletions Units/parser-haskell.r/literate-haskell1.d/input.lhs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
>Without space, this is just a comment

This literate program prompts the user for a number
and prints the factorial of that number:

> main :: IO ()

> main = do putStr "Enter a number: "
> l <- readLine
> putStr "n!= "
> print (fact (read l))

This is the factorial function.

> fact :: Integer -> Integer
> fact 0 = 1
> fact n = n * fact (n-1)

1 change: 1 addition & 0 deletions Units/parser-haskell.r/literate-haskell2.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
1 change: 1 addition & 0 deletions Units/parser-haskell.r/literate-haskell2.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main input.lhs /^main = print [ (n, product [1..n]) | n <- [1..20]]$/;" f
15 changes: 15 additions & 0 deletions Units/parser-haskell.r/literate-haskell2.d/input.lhs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\documentstyle{article}

\begin{document}

\section{Introduction}

This is a trivial program that prints the first 20 factorials.

\begin{code}
main :: IO ()
main = print [ (n, product [1..n]) | n <- [1..20]]
\end{code}

\end{document}

1 change: 1 addition & 0 deletions Units/parser-haskell.r/simple-haskell.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
10 changes: 10 additions & 0 deletions Units/parser-haskell.r/simple-haskell.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Cards input.hs /^module Cards where$/;" m
Int input.hs /^data Int = -2147483648 | -2147483647 | ... | -1 | 0 | 1 | 2 | ... | 2147483647$/;" t
Fd input.hs /^newtype Fd = Fd CInt$/;" t
Fd input.hs /^newtype Fd = Fd CInt$/;" c
Bool input.hs /^data Bool $/;" t
True input.hs /^ = True | False$/;" c
False input.hs /^ = True | False$/;" c
Name input.hs /^type Name = String$/;" t
getSpareBuffer input.hs /^getSpareBuffer Handle__{haCharBuffer=ref, $/;" f
add input.hs /^add x y = x + y$/;" f
33 changes: 33 additions & 0 deletions Units/parser-haskell.r/simple-haskell.d/input.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Cards where

data Int = -2147483648 | -2147483647 | ... | -1 | 0 | 1 | 2 | ... | 2147483647
newtype Fd = Fd CInt
data Bool
= True | False
type Name = String


getSpareBuffer :: Handle__ -> IO (BufferMode, CharBuffer)
getSpareBuffer Handle__{haCharBuffer=ref,
haBuffers=spare_ref,
haBufferMode=mode}
= do
case mode of
NoBuffering -> return (mode, error "no buffer!")
_ -> do
bufs <- readIORef spare_ref
buf <- readIORef ref
case bufs of
BufferListCons b rest -> do
writeIORef spare_ref rest
return ( mode, emptyBuffer b (bufSize buf) WriteBuffer)
BufferListNil -> do
new_buf <- newCharBuffer (bufSize buf) WriteBuffer
return (mode, new_buf)


{-|
This is a docstring
-}
add :: Integer -> Integer -> Integer
add x y = x + y
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following parsers have been added:
* Gdbinit script *optlib*
* Glade *libxml*
* Go
* Haskell
* Haxe
* Inko *optlib*
* JavaProperties
Expand Down
1 change: 0 additions & 1 deletion docs/other-projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ They have these additional language parsers:
* `DocBook <https://en.wikipedia.org/wiki/DocBook>`_
* `Ferite (c.c) <https://en.wikipedia.org/wiki/Ferite>`_
* `GLSL (c.c) <https://en.wikipedia.org/wiki/OpenGL_Shading_Language>`_
* `Haskell <https://en.wikipedia.org/wiki/Haskell_%28programming_language%29>`_
* `Vala (c.c) <https://en.wikipedia.org/wiki/Vala_%28programming_language%29>`_

.. include:: tracking.rst
Expand Down
2 changes: 2 additions & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
FyppParser, \
GdbinitParser, \
GoParser, \
HaskellParser, \
HaxeParser, \
HtmlParser, \
IniconfParser, \
Expand All @@ -98,6 +99,7 @@
KconfigParser, \
LdScriptParser, \
LispParser, \
LiterateHaskellParser, \
LuaParser, \
M4Parser, \
ManParser, \
Expand Down
Loading