3 ms·
I've been reading mostly about lexers and parsers (antlr, yacc, bison, etc) that produce C code and would like to try different approaches like SML but haven't
by Kilimanjaro 15y ago
I've been reading mostly about lexers and parsers (antlr, yacc, bison, etc) that produce C code and would like to try different approaches like SML but haven't found any literature. Read also about LLVM but C++ is not my type. Haskell and GHC are cool but again C shows its ugly head.
So, I'd like to know if C is the only way or if there are new papers that I don't know of for implementing modern compilers before committing to C. I am just starting so there is a lot to read about different contexts and ideas.
(PS: Java is not an option)
- andrewflnr 15y agoPersonally, I've been using Python for prototyping. It has lots of lexing libraries, and from there I just do recursive descent. I figure I'll switch to C for a "real" implementation, partly because what I'm going for in my current project is as much database as programming language. I don't think you have to use C++ to target LLVM. I think you can output LLVM IR from anything and then just call LLVM from the shell to get an executable.
- deleted 15y ago[deleted]
- spacemanaki 15y agoAre you looking for an alternative to emitting C or to using C as the implementation language of the compiler? I'm not totally sure what you're after, and I'm a compiler noob, but I've been enjoying Appel's Modern Compiler Implementation in ML, which uses SML as the implementation language and emits RISC machine code or assembly (I think, I haven't actually gotten that far). I don't know how suitable it would be as a stepping stone to forking PHP, but it's something.
- Kilimanjaro 15y ago'Modern Compiler Implementation in ML' any online resource you can share?
- spacemanaki 15y agoIt's a book: http://www.cs.princeton.edu/~appel/modern/ml/ http://www.cs.princeton.edu/~appel/modern/ml/