Questions tagged [yacc]

The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system.

The name is an acronym for "Yet Another Compiler Compiler." It generates a parser (the part of a compiler that tries to make syntactic sense of the source code) based on an analytic grammar written in a notation similar to BNF. Historically, Yacc has generated the code for the parser in the C programming language.

Yacc used to be available as the default parser generator on most Unix systems. It has since been supplanted as the default by more recent, largely compatible, programs such as Berkeley Yacc, GNU bison, MKS yacc and Abraxas pcyacc. An updated version of the original AT&T version is included as part of Sun's OpenSolaris project. Each offers slight improvements and additional features over the original yacc, but the concept has remained the same. Yacc has also been rewritten for other languages, including Ratfor, ML, Ada, Pascal, Java, Python and Common Lisp.

The parser generated by yacc requires a lexical analyzer. Lexical analyzer generators, such as Lex or Flex are widely available. The IEEE POSIX P1003.2 standard defines the functionality and requirements for both Lex and Yacc.

Some versions of AT&T Yacc have become open source. For example, source code (for different implementations) is available with the standard distributions of Plan 9 and OpenSolaris.

http://en.wikipedia.org/wiki/Yacc

Books

See also:

1902 questions
157
votes
5 answers

Advantages of Antlr (versus say, lex/yacc/bison)

I've used lex and yacc (more usually bison) in the past for various projects, usually translators (such as a subset of EDIF streamed into an EDA app). Additionally, I've had to support code based on lex/yacc grammars dating back decades. So I know…
Don Wakefield
  • 8,693
  • 3
  • 36
  • 54
141
votes
5 answers

What is the difference between Flex/Lex and Yacc/Bison?

What is the difference between Flex & Lex and Yacc & Bison. I searched the Internet wildly and I didn't find any solid answer. Can I install pure Lex and Yacc on Ubuntu, or I can install only flex and bison. I am confused. Is Lex or Yacc still…
Dumb Questioner
  • 2,147
  • 4
  • 20
  • 21
87
votes
1 answer

How exactly does R parse `->`, the right-assignment operator?

So this is kind of a trivial question, but it's bugging me that I can't answer it, and perhaps the answer will teach me some more details about how R works. The title says it all: how does R parse ->, the obscure right-side assignment function? My…
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
72
votes
1 answer

how to install Lex and Yacc in Ubuntu?

I am doing project in SENSE, for that i have to install Lex and Yacc. If you can help me how to install in Ubuntu. I very new to this area. So can you help me. Any website to study the basic of Lex and Yacc
66
votes
9 answers

How to compile LEX/YACC files on Windows?

I'm having Lex and YACC files to parse my files (.l file and .y file). How to compile those files and how to make equivalent .c file for them in windows platform?
Thorin Oakenshield
  • 14,232
  • 33
  • 106
  • 146
61
votes
8 answers

String input to flex lexer

I want to create a read-eval-print loop using flex/bison parser. Trouble is, the flex generated lexer wants input of type FILE* and i would like it to be char*. Is there anyway to do this? One suggestion has been to create a pipe, feed it the…
bjorns
  • 606
  • 1
  • 5
  • 8
53
votes
14 answers

Good tools for creating a C/C++ parser/analyzer

What are some good tools for getting a quick start for parsing and analyzing C/C++ code? In particular, I'm looking for open source tools that handle the C/C++ preprocessor and language. Preferably, these tools would use lex/yacc (or flex/bison)…
Matt Ball
  • 1,434
  • 2
  • 17
  • 24
38
votes
4 answers

Is there a good Emacs mode or method for lex/flex/yacc/bison files?

Editing lex or yacc files with Emacs is a nuisance: if I use C mode the indenting goes wrong, and if I don't use C mode I can't use indenting. Does anyone have a trick, a method, or an editing mode to get around it?
user181548
32
votes
4 answers

Integrating Bison/Flex/Yacc into XCode

Is there a simple way for integrating Bison/Flex/Yacc into XCode? I want to write my own language to be parsed, which interacts with my ObjC objects. But the tools will only take STDIN as input, and will only produce C code, instead of ObjC. …
AWF4vk
  • 5,810
  • 3
  • 37
  • 70
31
votes
5 answers

Yacc equivalent for Java

I'm working on a compiler design project in Java. Lexical analysis is done (using jflex) and I'm wondering which yacc-like tool would be best(most efficient, easiest to use, etc.) for doing syntactical analysis and why.
vuzun
  • 942
  • 2
  • 8
  • 15
30
votes
4 answers

Lex and Yacc in PHP

Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I…
Rik Heywood
  • 13,816
  • 9
  • 61
  • 81
28
votes
4 answers

"make: yacc: Command not found" after installing Bison

While running a makefile in gcc 4.1.2 (linux 5), I got the following error make: yacc: Command not found By googling, I came to know that this error can be rectified by installing Bison-GNU parser generator. But even after installing Bison, I get…
Blackforest
  • 1,009
  • 2
  • 11
  • 18
24
votes
2 answers

yylval and union

What is the purpose of union in the yacc file? Is it directly related to yylval in the flex file? If you don't use yylval, then you don't need to use union?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
23
votes
6 answers

Where can I find standard BNF or YACC grammar for C++ language?

I'm trying to work on a kind of code generator to help unit-testing an legacy C/C++ blended project. I don't find any kind of independent tool can generate stub code from declaration. So I decide to build one, it shouldn't be that hard. Please,…
Kevin Yu
  • 1,423
  • 4
  • 15
  • 19
23
votes
12 answers

Lex/Yacc for C#?

Actually, maybe not full-blown Lex/Yacc. I'm implementing a command-interpreter front-end to administer a webapp. I'm looking for something that'll take a grammar definition and turn it into a parser that directly invokes methods on my object.…
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
1
2 3
99 100