Questions tagged [bison]

Bison is the GNU parser generator. It generates LALR parsers, but can also generate GLR parsers for grammars that are not LALR. It has a mode of compatibility with its old predecessor Yacc (yet another compiler compiler).

Bison is the GNU parser generator. It generates LALR parsers, but can also generate GLR parsers for grammars that are not LALR. In POSIX mode, Bison is compatible with Yacc (yet another compiler compiler). flex, an automatic lexical analyser, is often used with Bison, to tokenise input data and provide Bison with tokens.

Websites:

See also:

2588 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
90
votes
4 answers

Writing a parser like Flex/Bison that is usable on 8-bit embedded systems

I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. If I were writing this to run on my Linux box, I could use flex/bison. Now that I restricted myself to an…
Johan
  • 3,072
  • 3
  • 27
  • 27
76
votes
2 answers

Problem calling std::max

I compiled my bison-generated files in Visual Studio and got these errors: ...\position.hh(83): error C2589: '(' : illegal token on right side of '::' ...\position.hh(83): error C2059: syntax error : '::' ...\position.hh(83): error C2589: '(' :…
Haiyang
  • 1,489
  • 4
  • 15
  • 19
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
54
votes
2 answers

How to solve Bison warning "... has no declared type"

Running Bison on this file: %{ #include int yylex(); void yyerror(const char*); %} %union { char name[100]; int val; } %token NUM ID %right '=' %left '+' '-' %left '*' %% exp : NUM {$$.val = $1.val;} …
Asaf R
  • 6,880
  • 9
  • 47
  • 69
48
votes
5 answers

How to install bison on mac OSX

I'm trying to install Thrift on my macbook. Otherwise I got an error: configure: error: Bison version 2.5 or higher must be installed on the system! So tried to install Bison on my OS, but I didn't find tutorial on internet. Does anyone who can…
S7_0
  • 1,165
  • 3
  • 19
  • 32
34
votes
3 answers

Trouble building gcc 4.6: undefined reference to `yylex'

I'm trying to build gcc 4.6, but I'm getting some linker errors that look like it means bison or flex isn't getting linked to. When the makefile issues this command: gcc -g -fkeep-inline-functions -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual…
Chris
  • 6,642
  • 7
  • 42
  • 55
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
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
27
votes
9 answers

unistd.h related difficulty when compiling bison & flex program under vc++

I'm using bison & flex (downloaded via cygwin) with vc++. When I compile the program I got an error: ...: fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory The corresponding code in the flex-generated file…
Haiyang
  • 1,489
  • 4
  • 15
  • 19
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
24
votes
8 answers

Writing compilers ... what's right and what's wrong?

Okay, in my quest to figure out the necessary stuff to write a compiler, I've reached a bit of a roadblock. It seems that every technology or tool that I find has some opposition somewhere. I use Bison and Flex right now but I'm getting the feeling…
user204416
23
votes
8 answers

How does flex support bison-location exactly?

I'm trying to use flex and bison to create a filter, because I want get certain grammar elements from a complex language. My plan is to use flex + bison to recognise the grammar, and dump out the location of elements of interest. (Then use a script…
Kevin Yu
  • 1,423
  • 4
  • 15
  • 19
1
2 3
99 100