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
23
votes
3 answers

Reforming the grammar to remove shift reduce conflict in if-then-else

How do I remove shift-reduce conflict for bison for the given grammar? selection-stmt -> if ( expression ) statement | if ( expression ) statement else statement A solution giving the modified grammar would be highly…
Aakash Anuj
  • 3,773
  • 7
  • 35
  • 47
22
votes
3 answers

Choice of Parser Generator

OK, I understand this question may sound quite opinion-based, however since I have several specific criteria of choice, I think it would make a nice fit for SO. So, here I am... I've worked with compiler/interpreter construction in the past quite a…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
22
votes
13 answers

How much time would it take to write a C++ compiler using flex/yacc?

How much time would it take to write a C++ compiler using lex/yacc? Where can I get started with it?
Madhu
  • 1,176
  • 1
  • 13
  • 18
20
votes
2 answers

CMake and Flex/Bison

I am converting my build system from configure/make to a cmake system The system has some autogenerated files, from bison/flex. The original makefile commands are: bison --defines=tokens.h --output=parser.cpp parser.y flex --outfile=scanner.cpp…
LordAro
  • 1,269
  • 3
  • 18
  • 35
20
votes
3 answers

Include struct in the %union def with Bison/Yacc

I am trying to include a struct as part of the union with Bison, but I get an error on the 'struct node args' in %union: parser.y:17: error: field ‘args’ has incomplete type The Code: struct node { char * val; struct node *…
Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165
18
votes
3 answers

How to do python-like indentation with flex/bison

I want my language to have two features that make Python such a nicely formatted language: One statement per line Blocks begin with another indentation level and go on until that's ended Can anyone give me a detailed hint on how to achieve that…
Lanbo
  • 15,118
  • 16
  • 70
  • 147
17
votes
1 answer

Lex/Flex - Scanning for the EOF character

Other people have had the following problem that I am having but I can't find anyone that has reported a solution.. getting Flex to spot the EOF (end of file). I need Flex to find EOF and return a token indicating that it has found it so it can…
ale
  • 11,636
  • 27
  • 92
  • 149
17
votes
2 answers

Lemon power or not?

For grammar parser, I used to "play" with Bison which have its pros/cons. Last week, I noticed on SqLite site that the engine is done with another grammar parser: Lemon Sounds great after reading the thin documentation. Do you have some feedback…
Stef
  • 3,691
  • 6
  • 43
  • 58
16
votes
4 answers

Bison latest version installed but not in use

$ brew install bison Warning: bison-3.0.2 already installed $ bison -V bison (GNU Bison) 2.3 How can I change the Bison version in use to 3.0.2? I'm on OS X 10.9.4. I've restarted my terminal after $brew install bison. UPDATE I'm really not sure if…
goldfrapp04
  • 2,326
  • 7
  • 34
  • 46
16
votes
6 answers

Flex/Bison IDE?

I'm looking for a good development environment in which to work on flex or bison or both. Are there any IDE's that have these capabilities and/or are suitable for this? (If not the next most general question is are there lexer/parser generators with…
machinaut
  • 495
  • 2
  • 4
  • 17
15
votes
2 answers

premature eof error in flex file

I have the following code and it gives an error" "hello.l",line 31: premature EOF" when I run the following command flex hello.l %{ #include #include "y.tab.h" %} %% ("hi"|"oi")"\n" {return HI; } ("tchau"|"bye")"\n" …
Waseem
  • 1,392
  • 5
  • 21
  • 30
15
votes
7 answers

C grammar in GCC source code

I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form.
Haruki
  • 674
  • 1
  • 9
  • 24
15
votes
3 answers

Bison: Optional tokens in a single rule

I'm using GNU Bison 2.4.2 to write a grammar for a new language I'm working on and I have a question. When I specify a rule, let's say: statement : T_CLASS T_IDENT '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } If I…
Simone Margaritelli
  • 4,584
  • 10
  • 45
  • 70
15
votes
2 answers

#error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"

I have been trying to follow the tutorial at http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/5/ (using flex, bison and llvm) but when typing the line g++ -o parser parser.cpp tokens.cpp main.cpp I get the following errors: In file…
user1361491
15
votes
4 answers

Why am I getting this error: "data definition has no type or storage class"?

#include #include struct NODE { char* name; int val; struct NODE* next; }; typedef struct NODE Node; Node *head, *tail; head = (Node*) malloc( sizeof( Node ) ); //line 21 And I compiling like this: cc -g -c -o…
Daivid
  • 627
  • 3
  • 12
  • 22