Libraries / tools needed for creating parsers

I made a tokenizer in pure Fortran. It’s probably not very efficient, but it’s simple enough to be used to tokenize anything as it uses a single boolean function, so this is maybe the easiest part to address.

I’m also interested in having something like lark, where you write a lark grammar (which is in general way easier to write) and get a parser.

And I found Brad Richardson’s take on parsing generators a good start writing one.

I guess that this would require building a tree structure and then letting the user create a visiting structure, as lark does (the LFortran docs is also helpful here).

I have my own takes[1] on parsers, but they are not near as stable or generic enough - I’m currently trying to improve the expression parser (writing a Precedence Climbing based on this work), but I keep hitting all sorts of weird runtime errors [while working with class(*), which is a must if you want to deal with derived types], so it won’t be available so soon.

There are other algorithms around, like pratt and pika that may be easier to implement in Fortran.

4 Likes