~boringcactus/crowbar-lang-devel

1

Re: Send help

Cole Blakley <cblakley15@gmail.com>
Details
Message ID
<9CD52C46-2865-43A6-97C0-888D26FB66E7@gmail.com>
DKIM signature
missing
Download raw message
Hey, I read your blog sometimes and saw one of your posts ("Crowbar: Turns out, language development is hard").

I liked your ideas for Crowbar. I think that you might consider compiling the Crowbar language directly into LLVM IR. The compiler
I'm working on uses LLVM as a backend, and although the LLVM docs aren't great it hasn't been as hard as I thought to integrate
with my frontend.

For the interoperability with C, Clang has some tools for giving you access to the abstract syntax tree that Clang uses for
C, which could be used (I think) to parse C headers into something usable. I found this page ( https://clang.llvm.org/docs/Tooling.html <https://clang.llvm.org/docs/Tooling.html> ) a while ago and it seems informative. Although I've heard libclang
doesn't give full access to the AST (at least for complex C++ source files), so maybe https://github.com/foonathan/cppast <https://github.com/foonathan/cppast> could be an option?

I think it is possible to interoperate with C in the way I think you are describing in your blog posts. LLVM has support for
generating code that matches the C calling conventions, and if you use its tools to parse the C headers that need to
be included into a Crowbar program, you could do some kind of automatic binding process where you walk over the
Clang AST for each header and somehow hook each C declaration into the Crowbar code that references it.

Hope this is helpful. Sorry if you've already tried/know about this, just been working with LLVM a lot lately and thought I might share
since most of this kind of stuff has been hard for me to Google/find information on. I saw the other discussion thread on sr.ht after
I wrote this so sorry if I am retreading some of the same ground.

Your blog is pretty cool btw, nice to find a coding blog that has neat projects and not dumb VC stuff.

Re: Send help

Details
Message ID
<9e7f3e3d-a6dc-cc8e-23a4-0b623b8b3eb6@gmail.com>
In-Reply-To
<9CD52C46-2865-43A6-97C0-888D26FB66E7@gmail.com> (view parent)
DKIM signature
missing
Download raw message
On 2020-10-28 3:58 PM, Cole Blakley wrote:
> I think that you might consider compiling the Crowbar language directly into LLVM IR.

I thought about going with LLVM, but decided against it for two reasons:
1. It seemed complicated.
2. Everybody else is using it, and so it's too mainstream.

I've settled on using QBE <https://c9x.me/compile/> as my backend 
instead, which has its own comparison with LLVM: 
https://c9x.me/compile/doc/llvm.html

> Your blog is pretty cool btw, nice to find a coding blog that has neat projects and not dumb VC stuff.

Glad you like it!

-💤🌵
Reply to thread Export thread (mbox)