What are the different passes of a compiler?

Has anybody used Lex and Yacc to write compiler/interpreter of their own. Is there any popular language/script whose compiler source was generated using lex and yacc?

Toby Thain at Quora Visit the source

Was this solution helpful to you?

Other answers

Lots of tools/obscure compilers have been built with Lex and Yacc; that was the point. But your question is inappropriate.  People use Lex and Yacc to support building a *parser*.   One needs completely different tools to handle the rest of the compiler (semantic analysis, optimization, code generator) Such tools (attribute grammars, instruction-code generators such as Twig, transformations) are used pretty rarely; it seems that many compiler-builders don't know about, don't want, or can't build the infrastructure to support them, so the back end of compilers tends to be a lot more ad hoc/procedural.  That's too bad, because the back end is more complex and typically a lot larger than the parser part.  (See my essay http://www.semdesigns.com/products/DMS/LifeAfterParsing.html?Home=DMSToolkit for more detail; I've made this point often enough to not repeat it here).

Ira Baxter

I have used Lex & Yacc (actually flex and bison!) a few years ago to convert COBOL to C. This can be best termed as a 'translator', rather then a 'compiler' - but in essence, they are same. The lex file is 27kb and the yacc file is 82kb. Considering the fact that COBOL is a verbose language with many verbs & variations, IMHO using lex/yacc allowed completing the task comfortably.

Rajiv Bhagwat

PHP uses Lex and Yacc. See Zend/zend_language_scanner.l and Zend/zend_language_parser.y.

Seo Sanghyeon

I have used lex and yacc to make a parser and IMHO it is a pain in the ass for which you'd have to have a very good reason to get involved. If you want to write a parser quick in a hurry, I recommend LPEG: http://www.inf.puc-rio.br/~roberto/lpeg/

Michael Fox

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.