News for hackers. Stuff that matters.
Re:Implementing a LLVM Micro C compiler in Haskell by andi999 on Friday June 04, 2021 @01:18PM (#27396054)
Why not go for the full C language. C was made to make compilers easy to build. Also it might expose/help to see difficulties in the chosen approach.
Re:Implementing a LLVM Micro C compiler in Haskell by ash_gti on Friday June 04, 2021 @01:32PM (#27396255)
They went with a subset of C, its enough to write a working executable. Generally for a introduction tutorial to something as complex as writing a compiler a subset like what they presented in the article is enough to show how all the pieces work together to produce a working compiler.
Re:Implementing a LLVM Micro C compiler in Haskell by mikepurvis on Friday June 04, 2021 @04:03PM (#27398471)
Yup, for the purposes of a demo like this, a simplified top-to-bottom "vertical slice" is of far more value than total feature coverage.
Re:Implementing a LLVM Micro C compiler in Haskell by pjmlp on Friday June 04, 2021 @03:28PM (#27398012)
Unless you are talking about something like "A Retargetable C Compiler: Design and Implementation", it is definitly not easy.

https://www.amazon.com/Retargetable-Compiler-Design-Implemen...

During the early 80's, the best home computers could get was Small-C.

https://en.wikipedia.org/wiki/Small-C

Re:Implementing a LLVM Micro C compiler in Haskell by randomifcpfan on Friday June 04, 2021 @09:27PM (#27401094)
Small-C was the best one with open source, but there were many others. This one was my favorite: https://www.bdsoft.com/resources/bdsc.html
Re:Implementing a LLVM Micro C compiler in Haskell by pjmlp on Saturday June 05, 2021 @01:00AM (#27402358)
What I got back in the day came in book form, it was also another flavour.

"A book on C"

https://link.springer.com/book/10.1007/978-1-349-10233-4

It uses a K&R C subset with bytecodes and a bytecode-> machine language translation.

I just never bothered to type it in though.

Re:Implementing a LLVM Micro C compiler in Haskell by reikonomusha on Friday June 04, 2021 @02:23PM (#27397069)
A conforming ISO C compiler seems extremely difficulty to build and I don’t think ease of writing a compiler is a part of the design these days.
Re:Implementing a LLVM Micro C compiler in Haskell by andi999 on Friday June 04, 2021 @02:29PM (#27397177)
They could stick to ANSI C.
Re:Implementing a LLVM Micro C compiler in Haskell by woodruffw on Friday June 04, 2021 @02:52PM (#27397518)
ANSI C and ISO C are the same thing, at least for the 1989/90 revision. It’s still not a particularly easy language to implement, at any stage.