Parser combinator lib vs. parser generator?

12 views
Skip to first unread message

Mark at Bytesizedworkbench

unread,
Jun 7, 2021, 11:22:58 PM6/7/21
to Nashville Functional Programmers
Hello, 

I recall that one meeting somebody presented about using ANTLR parser generator… I am exploring best ideas for handling the parsing of many different (sometimes only slightly different) structured file format inputs. 

It seems like getting to a common AST would be useful. I think that manually creating many parsers might not be as maintainable as using a parser generator but not sure what others experience has been. 


(Also comparing activity in FP/Slack to Google Groups) 

-- 

Mark Mynsted 

Mark Wutka

unread,
Jun 11, 2021, 10:31:59 AM6/11/21
to nashfp

Depending on how much common processing you do on the files, I might lean towards a parser combinator library. If you use a parser generator, you'll probably have a separate grammar file for each file format. It might be difficult making things overlap when you want them too (if two formats have a similar structure that you want to represent with the same AST), and maybe you'd have the reverse problem of conflicts, where some AST node has the same name but different structure in two grammars. I think with the parser combinator, you would be able to share common elements across different parsers and have better control over the AST you generate.

I should add a disclaimer that over the past decade when faced with needing a parser, I have more often coded something by hand or used a parser generator. The only time I remember using a combinator library was parsing the select queries when NashFP was doing the rdbms project.
  Mark

--
You received this message because you are subscribed to the Google Groups "Nashville Functional Programmers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nashfp+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nashfp/a0a305e2-0a17-4b9a-a513-b73e9d658294n%40googlegroups.com.

Mark Mynsted

unread,
Jun 16, 2021, 1:16:56 PM6/16/21
to nas...@googlegroups.com, Mark Wutka
Thank you.

I am just curious, what language did you select?

 I use Scala, but I think for future things, perhaps Haskell or maybe something else.

Mark Wutka wrote on 6/8/21 09:48:

Mark Wutka

unread,
Jun 16, 2021, 1:27:43 PM6/16/21
to nashfp
For the rdbms I used Scheme, I think it was Chicken Scheme. Parsec for Haskell does look nice though, I think that's what Jason used last year for the ICFP programming contest.

Reply all
Reply to author
Forward
0 new messages