[cfe-dev] Advice for front-end design?

Joachim Durchholz via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 18 23:07:21 PDT 2015


Am 19.09.2015 um 01:34 schrieb Russell Wallace:

Thanks for the overview!

 > Doing something a bit different and still figuring all this out
 > myself, but thus far I've reached the following front-end-relevant
 > conclusions:
 >
 > http://llvm.org/docs/ProgrammersManual.html is a good starting point;
 > it discusses a number of useful facilities and guidelines.
 >
 > Read source files with MemoryBuffer::getFileOrSTDIN(Filename)

 > The clang way of reporting error messages is nice from the user's
 > perspective, and probably worth trying to pick up. Not sure how to do
 > that yet but
 > http://clang.llvm.org/doxygen/classclang_1_1SourceLocation.html
 > seems potentially relevant.

 > For how to run optimisation passes, ignore what the tutorial says
 > about that and look instead at opt.cpp

Thank you very much! That's a good list of things to try reading.

 > Write a recursive descent parser for your language by hand; in my
 > experience, other ways of doing parsers are not worth the added
 > complexity.

Heh. LR parsing seems to have fallen out of favor these days.

I'd like to unlock DSL coding for people who do not have deep 
understanding of parsing technology. Which means keeping it simple for 
DSL authors, so either operator precedence parsing (OPP) or GLR. Not an 
easy choice because OPP is hard to make powerful enough to be 
practically useful, whereas GLR is hard for doing grammar analysis and 
diagnosis.
I know how to be rigorous about the former and far too little about the 
latter, so I'll try the extended OPP route and hope for the best :-)

 > In my opinion, an automatic formatting tool is an essential
 > productivity tool nowadays. If the syntax of your language is at all
 > similar to the C family, consider forking clang-format.

Indent-based grammar.
That doesn't leave much room or need for automatic formatting support.

I'll admit that for me, editing a bracing-style language with 
reformatting support is somewhat more fluent than editing Python.
One of these days I should really sit down and scour the available 
keyboard shortcuts for structure navigation key combos.


Thanks for the feedback!
More feedback still welcome; I suppose for that kind of question, 
there's ample room for different approaches.

Regards,
Jo



More information about the cfe-dev mailing list