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
15
votes
1 answer

Shift/reduce conflicts in bison

I'm new to Bison and I'm having trouble with shift/reduce conflicts... I'm trying to load from file to array data[]: struct _data { char name[50]; char surname[50]; int year; } data[1000]; Here is part of my bison code: %token ID NUM NL…
Zrinka
  • 163
  • 1
  • 1
  • 7
15
votes
1 answer

Undefined reference to `_yyerror' when compiling with Flex and Bison

I'm trying to make a compiler for a mini Pascal-like language. I'm using Flex and Bison for this and I came up with this error. My Flex file: %{ #include "y.tab.h" #include #include #include void yyerror(char…
fanulis
  • 175
  • 1
  • 1
  • 9
15
votes
1 answer

Simple Flex/Bison C++

I already looked for my answer but I didn't get any quick response for a simple example. I want to compile a flex/bison scanner+parser using g++ just because I want to use C++ classes to create AST and similar things. Searching over internet I've…
Jack
  • 131,802
  • 30
  • 241
  • 343
15
votes
4 answers

Undefined reference to 'yylex()'

I'm trying to use flex and bison to create a simple scripting language. Right now, I'm just trying to get a calculator working. I can't get it to compile, though. When I run this makefile: OBJECTS = hug.tab.o hug.yy.o PROGRAM = hug.exe CPP =…
Micah
  • 183
  • 1
  • 2
  • 9
14
votes
4 answers

Why are multi-line comments in flex/bison so evasive?

I'm trying to parse C-style multi-line comments in my flex (.l) file: %s ML_COMMENT %% ... "/*" BEGIN(ML_COMMENT); "*/" BEGIN(INITIAL); [.\n]+ { } I'm not returning…
adelarge
  • 143
  • 1
  • 5
14
votes
5 answers

A notation for empty right-hand sides of rules

When writing a ("theoretical") grammar with a rule with an empty right-hand side, one always use a symbol such as ε (or 1) to make this emptiness explicit: A → ε | a A Such a grammar in Yacc and others would then look like a: | 'a' a or "worse" a:…
akim
  • 8,255
  • 3
  • 44
  • 60
13
votes
5 answers

Is there a Sublime Text Syntax for Flex and Bison?

I'm looking for a syntax in Sublime Text that highlights my Flex and Bison files (or lex/yacc) in a way that makes them readable... Sublime Text automatically chooses Lisp for Flex files, but that doesn't do the trick all that well. Any suggestions…
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
13
votes
5 answers

bison end of file

If I forget to put an empty line at the end of any of my files my program gets a syntax error. The problem is my grammar expects a newline to end the current line. Since a newline doesn't exist bison generates a syntax error because it does not…
user34537
13
votes
7 answers

Why does my Mac (OS X 10.7.3) have an old version (2.3) of Gnu Bison?

The version of GNU Bison on my mac is 2.3 but I know that Bison 2.5 was released long ago. The book Flex & Bison uses version 2.5. Should I upgrade to 2.5 myself? Is it necessary? What's the difference between 2.3 and 2.5?
Alick
  • 181
  • 1
  • 1
  • 6
12
votes
3 answers

How can I use flex & bison in Visual Studio 2010?

I've read http://msdn.microsoft.com/en-us/library/aa730877%28vs.80%29.aspx but this document was for VS 2005. I stuck on the part 'Importing a .rules File in Visual C++' in the document. It seems that VS 2010 does not support .rules file, instead,…
David Johns
  • 1,201
  • 5
  • 15
  • 34
12
votes
1 answer

Configuring Bison and Flex without global or static variable

i am working in a small language/IDE. And I need to know how to configure flex and bison to work together but without using any global or static variable. I need to pass to bison my AST pointer. I also need that bison pass my AST to flex as well.…
Bruno Lebtag
  • 420
  • 4
  • 18
11
votes
2 answers

REPL for interpreter using Flex/Bison

I've written an interpreter for a C-like language, using Flex and Bison for the scanner/parser. It's working fine when executing full program files. Now I'm trying implement a REPL in the interpreter for interactive use. I want it to work like the…
Jay Lieske
  • 4,788
  • 3
  • 30
  • 41
11
votes
2 answers

GCC says "syntax error before numeric constant" in generated header file from bison

When I compile my .y file with bison parser.y -d -t and then include the parser.tab.h file in my flex file, gcc says "error: syntax error before numeric constant." It's referencing line 32, which is the first line in the enum of yytokentype. enum…
Kizaru
  • 2,443
  • 3
  • 24
  • 39
11
votes
1 answer

Building Lisp/Scheme-like parse tree with flex/bison

I was trying to parse simple Lisp/scheme-like code E.g. (func a (b c d) ) and build a tree from it, I could do the parsing in C without using bison (i.e, using only flex to return tokens and building the tree with recursion). But, with bison…
Ani
  • 1,448
  • 1
  • 16
  • 38
11
votes
2 answers

Trying to build a C# grammar for bison/wisent

I've never done Bison or Wisent before. how can I get started? My real goal is to produce a working Wisent/Semantic grammar for C#, to allow C# to be edited in emacs with code-completion, and all the other CEDET goodies. (For those who don't know,…
Cheeso
  • 189,189
  • 101
  • 473
  • 713