Hacker News new | ask | show | jobs
by jzimmerman64 1360 days ago
It'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.
1 comments

Generating 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.
> 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.