jog@umvlsi.ecs.umass.edu (Ashwini ) (04/16/91)
Hi, This is another, I'm sure very obvious question to those who know. Whats the difference between yacc and Bison, I know "Bison generates C++ compatible code" is this the parser thats produced? Actually I've got very confused after reading a couple of books. Are'nt parser generators supposed to handle any language?.ie Can I write a program in Yacc to translate a simple English-like language to C++ code?(of course with me supplying the routines) Thanks ashwini jog@umvlsi.umass.edu
barmar@think.com (Barry Margolin) (04/18/91)
In article <1995@umvlsi.ecs.umass.edu> jog@umvlsi.ecs.umass.edu (Ashwini ) writes: >Whats the difference between yacc and Bison, I know "Bison generates C++ >compatible code" is this the parser thats produced? Yes, it's referring to the generated parser. I don't actually see any references to C++ in the Bison manual; however, it does generate ANSI C compatible code, and I strongly doubt it generates any code that depends on the few features of ANSI C that are not included in C++. > Actually I've got >very confused after reading a couple of books. Are'nt parser generators >supposed to handle any language? .ie Can I write a program in Yacc to >translate a simple English-like language to C++ code?(of course with >me supplying the routines) The parser that is generated handles the language it was designed to parse. For instance, you can use Yacc or Bison to write a Pascal compiler. The input to Yacc or Bison is a text file containing a mixture of grammar specifications and C or C++ source code that define the actions of the parser when a particular piece of the language is recognized. Yacc and Bison read this file and write a C source file. When this C file is compiled, the result is a parser that recognizes the grammar and performs the specified actions. Bison comes with a 90-page manual that includes introductory information on the concepts of parser generators. I suggest you read this for more details. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar