Looking for simple C statements parser for Parsec, MegaParsec or Happy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Looking for simple C statements parser for Parsec, MegaParsec or Happy

Bulat Ziganshin-2
Hello all,

I  develop  a preprocessor transpiling subset of C statements into gcc
_asm statements. For this project, I will be happy to reuse existing C
statements parser written with any popular Haskell technology, or just
start  with  some  simple  C  subset parser  in order to avoid redoing
existing work.

Unfortunately,  so far I found grammars just for everything but C. And
while  I  can  start  with  Parsec grammars for Java/Go, it seems that
MegaParsec now is better choice?

I  can  quickly  develop  grammar for small C subset, but ready-to-use
grammar  for  larger  C  subset  will  allow me to completely skip the
development  of  C statement parser and focus on the meat of project -
asm code generation.  

Eventually,  it may turn into LLVM pass transpiling parts of C++ code,
but  for  quick  prototype, I prefer Haskell, especially if I can find
ready-to-use parser.

PS:   It  was  the  first  time  I ever asked at SO, but it turned out
to be offtopic there:
https://stackoverflow.com/questions/50949118/simple-c-grammar-for-haskell-parsec-megaparsec-or-happy 

--
Best regards,
 Bulat                          mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Looking for simple C statements parser for Parsec, MegaParsec or Happy

Andrew Butterfield-2
Hi Bulat,
 will the c-language package do ? Its parser seems to be based on Happy?


Regards, Andrew


On 20 Jun 2018, at 16:09, Bulat Ziganshin <[hidden email]> wrote:

Hello all,

I  develop  a preprocessor transpiling subset of C statements into gcc
_asm statements. For this project, I will be happy to reuse existing C
statements parser written with any popular Haskell technology, or just
start  with  some  simple  C  subset parser  in order to avoid redoing
existing work.

Unfortunately,  so far I found grammars just for everything but C. And
while  I  can  start  with  Parsec grammars for Java/Go, it seems that
MegaParsec now is better choice?

I  can  quickly  develop  grammar for small C subset, but ready-to-use
grammar  for  larger  C  subset  will  allow me to completely skip the
development  of  C statement parser and focus on the meat of project -
asm code generation.   

Eventually,  it may turn into LLVM pass transpiling parts of C++ code,
but  for  quick  prototype, I prefer Haskell, especially if I can find
ready-to-use parser.

PS:   It  was  the  first  time  I ever asked at SO, but it turned out
to be offtopic there:
https://stackoverflow.com/questions/50949118/simple-c-grammar-for-haskell-parsec-megaparsec-or-happy

--
Best regards,
Bulat                          [hidden email]

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

--------------------------------------------------------------------
Andrew Butterfield     Tel: +353-1-896-2517     Fax: +353-1-677-2204
Lero@TCD, Head of Foundations & Methods Research Group
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
                         http://www.scss.tcd.ie/Andrew.Butterfield/
--------------------------------------------------------------------


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Looking for simple C statements parser for Parsec, MegaParsec or Happy

Bulat Ziganshin-2
Re: [Haskell-cafe] Looking for simple C statements parser for Parsec, MegaParsec or Happy Hello Andrew,

Wednesday, June 20, 2018, 6:23:27 PM, you wrote:

yeah, thank you very much - it seems to do everything I need and 1000%
on  top  of  it, and AST looks  to be as simple as possible. It hardly
can  be  beaten  for  my  purposes, but I still wonder - is there were
combinators-based C parsers or noone ever bothered since we already had
this excellent library?




Hi Bulat,
 will the c-language package do ? Its parser seems to be based on Happy?

http://hackage.haskell.org/package/language-c-0.8.1/docs/Language-C-Parser.html

Regards, Andrew


On 20 Jun 2018, at 16:09, Bulat Ziganshin <
[hidden email]> wrote:

Hello all,

I  develop  a preprocessor transpiling subset of C statements into gcc
_asm statements. For this project, I will be happy to reuse existing C
statements parser written with any popular Haskell technology, or just
start  with  some  simple  C  subset parser  in order to avoid redoing
existing work.

Unfortunately,  so far I found grammars just for everything but C. And
while  I  can  start  with  Parsec grammars for Java/Go, it seems that
MegaParsec now is better choice?

I  can  quickly  develop  grammar for small C subset, but ready-to-use
grammar  for  larger  C  subset  will  allow me to completely skip the
development  of  C statement parser and focus on the meat of project -
asm code generation.   

Eventually,  it may turn into LLVM pass transpiling parts of C++ code,
but  for  quick  prototype, I prefer Haskell, especially if I can find
ready-to-use parser.

PS:   It  was  the  first  time  I ever asked at SO, but it turned out
to be offtopic there:
https://stackoverflow.com/questions/50949118/simple-c-grammar-for-haskell-parsec-megaparsec-or-happy 

-- 
Best regards,
Bulat                          
[hidden email]

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

--------------------------------------------------------------------
Andrew Butterfield     Tel: +353-1-896-2517     Fax: +353-1-677-2204
Lero@TCD, Head of Foundations & Methods Research Group
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
                         
http://www.scss.tcd.ie/Andrew.Butterfield/
--------------------------------------------------------------------




-- 
Best regards,
 Bulat                            
[hidden email]
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.