4 ms·
> automatically generates a compiler front-end For a very narrow definition of compiler frontend. The missing piece to make this super awesome would be generat
by jupp0r 4y ago
> automatically generates a compiler front-end
For a very narrow definition of compiler frontend. The missing piece to make this super awesome would be generating LLVM IR, which is where the semantics of the language would need to be understood (vs just the grammar).
- tgv 4y agoParser generator would be more apt.
- jzimmerman64 4y agoIt's not just a parser generator; it also generates the AST, traversals, lexer, and pretty-printer. And it can generate the AST for your IRs and target language, if you specify them in BNF as well. This is a pretty significant piece of a compiler, all told.
- tgv 4y agoGenerating the tree is trivial. The lexer is part of the parser. A pretty printer is not part of a compiler. The rest you have to do by hand. I know the name is a play on yacc (Yet Another Compiler Compiler), but it generates only a part of a compiler, the parser.
- jzimmerman64 4y ago> Generating the tree is trivial. If by "generating the tree" you mean generating definitions for the AST data structures, this is nontrivial enough that yacc does not do it. > The lexer is part of the parser. Again, yacc (a parser generator) does not include a lexer generator; that requires a second package such as lex. > A pretty printer is not part of a compiler. A pretty-printer for the IR or target language is an important part of a compiler, as one needs to render the output in a form that some other tool (e.g., an assembler) can accept. A pretty-printer for the source language also comes in handy. > The rest you have to do by hand. What you have to do by hand is to write a function from the source AST to the target AST (i.e., a compiler backend). langcc generates the whole frontend, not just the parser.