<html><head><title>Re: [Haskell-cafe] Looking for simple C statements parser for Parsec, MegaParsec or Happy</title>
<META http-equiv=Content-Type content="text/html; charset=koi8-r">
</head>
<body>
<span style=" font-family:'Courier New'; font-size: 18pt;">Hello Andrew,<br>
<br>
Wednesday, June 20, 2018, 6:23:27 PM, you wrote:<br>
<br>
yeah, thank you very much - it seems to do everything I need and 1000%<br>
on top of it, and AST looks to be as simple as possible. It hardly<br>
can be beaten for my purposes, but I still wonder - is there were<br>
combinators-based C parsers or noone ever bothered since we already had<br>
this excellent library?<br>
<br>
<br>
<br>
</span><table>
<tr>
<td width=2 bgcolor= #0000ff><br>
</td>
<td><span style=" font-family:'courier new'; font-size: 18pt;">Hi Bulat,<br>
will the c-language package do ? Its parser seems to be based on Happy?<br>
<br>
</span><a style=" font-family:'courier new'; font-size: 18pt;" href="http://hackage.haskell.org/package/language-c-0.8.1/docs/Language-C-Parser.html">http://hackage.haskell.org/package/language-c-0.8.1/docs/Language-C-Parser.html</a><br>
<br>
<span style=" font-family:'courier new'; font-size: 18pt;">Regards, Andrew<br>
<br>
<br>
On 20 Jun 2018, at 16:09, Bulat Ziganshin <</span><a style=" font-family:'courier new'; font-size: 18pt;" href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a><span style=" font-family:'courier new'; font-size: 18pt;">> wrote:<br>
<br>
Hello all,<br>
<br>
I develop a preprocessor transpiling subset of C statements into gcc<br>
_asm statements. For this project, I will be happy to reuse existing C<br>
statements parser written with any popular Haskell technology, or just<br>
start with some simple C subset parser in order to avoid redoing<br>
existing work.<br>
<br>
Unfortunately, so far I found grammars just for everything but C. And<br>
while I can start with Parsec grammars for Java/Go, it seems that<br>
MegaParsec now is better choice?<br>
<br>
I can quickly develop grammar for small C subset, but ready-to-use<br>
grammar for larger C subset will allow me to completely skip the<br>
development of C statement parser and focus on the meat of project -<br>
asm code generation. <br>
<br>
Eventually, it may turn into LLVM pass transpiling parts of C++ code,<br>
but for quick prototype, I prefer Haskell, especially if I can find<br>
ready-to-use parser.<br>
<br>
PS: It was the first time I ever asked at SO, but it turned out<br>
to be offtopic there:<br>
</span><a style=" font-family:'courier new'; font-size: 18pt;" href="https://stackoverflow.com/questions/50949118/simple-c-grammar-for-haskell-parsec-megaparsec-or-happy">https://stackoverflow.com/questions/50949118/simple-c-grammar-for-haskell-parsec-megaparsec-or-happy</a><span style=" font-family:'courier new'; font-size: 18pt;"> <br>
<br>
-- <br>
Best regards,<br>
Bulat </span><a style=" font-family:'courier new'; font-size: 18pt;" href="mailto:bulat.ziganshin@gmail.com">mailto:Bulat.Ziganshin@gmail.com</a><br>
<br>
<span style=" font-family:'courier new'; font-size: 18pt;">_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
</span><a style=" font-family:'courier new'; font-size: 18pt;" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<span style=" font-family:'courier new'; font-size: 18pt;">Only members subscribed via the mailman list are allowed to post.<br>
<br>
--------------------------------------------------------------------<br>
Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204<br>
Lero@TCD, Head of Foundations & Methods Research Group<br>
School of Computer Science and Statistics,<br>
Room G.39, O'Reilly Institute, Trinity College, University of Dublin<br>
</span><a style=" font-family:'courier new'; font-size: 18pt;" href="http://www.scss.tcd.ie/Andrew.Butterfield/">http://www.scss.tcd.ie/Andrew.Butterfield/</a><br>
<span style=" font-family:'courier new'; font-size: 18pt;">--------------------------------------------------------------------</td>
</tr>
</table>
<br><br>
<br>
<br>
<span style=" font-family:'arial'; color: #c0c0c0;"><i>-- <br>
Best regards,<br>
Bulat </i></span><a style=" font-family:'arial';" href="mailto:Bulat.Ziganshin@gmail.com">mailto:Bulat.Ziganshin@gmail.com</a></body></html>