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
8
votes
2 answers

replace the $ in php variable declaration

I would like to extend the php syntax, in order to tell apart mutable and immutable variables. $a should be declared mutable (as in standard php) and #b should be declared immutable. I've read Hacking PHP syntax, and I couldn't figure out where can…
Uri Goren
  • 13,386
  • 6
  • 58
  • 110
8
votes
2 answers

LALR(1) or GLR on Windows - Alternatives to Bison++ / Flex++ that are current?

UPDATE: This question is out of date, but left for informational purposes. Original Question I have been using the same version of bison++ (1.21-8) and flex++ (2.3.8-7) since 2002. I'm not looking for an alternative to LALR(1) or GLR at this time,…
codenheim
  • 20,467
  • 1
  • 59
  • 80
8
votes
3 answers

Compiling and executing the Shakespeare Programming Language translator spl2c on Mac OS X 10.6 results in warnings/errors

I wanted to experiment with the Shakespeare programming language, so I downloaded it from here and executed the Makefile using cd spl-1.2.1 Make. The compilation of spl2c executes with a couple warnings: scanner.l:600: warning, rule cannot be…
Redwood
  • 66,744
  • 41
  • 126
  • 187
8
votes
6 answers

M4 "No such file or directory".Bison

This is my code in file skener.y %{ #include %} %token T_Int %% exp: T_Int { $$ = $1; } | exp exp '+' { $$ = $1 + $2; } | exp exp '-' { $$ = $1 - $2; } | exp exp '*' { $$ = $1 * $2; } | exp exp…
Bodo Hombah
  • 209
  • 1
  • 3
  • 9
8
votes
2 answers

How do I implement a two-pass scanner using Flex?

As a pet-project, I'd like to attempt to implement a basic language of my own design that can be used as a web-scripting language. It's trivial to run a C++ program as an Apache CGI, so the real work lies in how to parse an input file containing…
dmercer
  • 397
  • 5
  • 17
7
votes
2 answers

Bison java examples

Does anyone knows if there are some tutorials and/or examples of using GNU Bison with Java over the net. I've searched through the net. But i didn't manage to find anything. I have tried to implement an example but I could not compile it (since I…
TheHube
  • 752
  • 1
  • 10
  • 23
7
votes
5 answers

How to fix YACC shift/reduce conflicts from post-increment operator?

I'm writing a grammar in YACC (actually Bison), and I'm having a shift/reduce problem. It results from including the postfix increment and decrement operators. Here is a trimmed down version of the grammar: %token NUMBER ID INC DEC %left '+'…
Zifre
  • 26,504
  • 11
  • 85
  • 105
7
votes
5 answers

How do I use C++ in flex and bison?

I have a project for school where we need to use flex and bison. I want to use C++ so that I have access to STL and my own classes that I wrote. We were provided with the following Makefile: CC = gcc CFLAGS = -g OBJs = parse.tab.o symtab.o attr.o…
Tom
  • 21,468
  • 6
  • 39
  • 44
7
votes
2 answers

Bison/Flex declaration mess... how what should I include/declare where?

I'm using Bison and Flex to make a reentrant scanner/parser pair but can't wrap my head around where everything is to be included and declared. First of all, I'm using reentrant Flex so I need to pass the yyscan_t scanner type first to Bison by…
Emil Eriksson
  • 2,110
  • 1
  • 21
  • 31
7
votes
7 answers

Lexer/parser tools

Which lexer/parser generator is the best (easiest to use, fastest) for C or C++? I'm using flex and bison right now, but bison only handles LALR(1) grammars. The language I'm parsing doesn't really need unlimited lookahead, but unlimited lookahead…
Zifre
  • 26,504
  • 11
  • 85
  • 105
7
votes
4 answers

Bison error output

I'm using Bison and I've generated a quite complex grammar. The trouble is that my first test case is failing- but Bison will only say "syntax error". Is there any way to ask Bison to output the rule that failed to match and the token that is a…
Puppy
  • 144,682
  • 38
  • 256
  • 465
7
votes
2 answers

Bison: How to ignore a token if it doesn't fit into a rule

I'm writing a program that handles comments as well as a few other things. If a comment is in a specific place, then my program does something. Flex passes a token upon finding a comment, and Bison then looks to see if that token fits into a…
Casey Patton
  • 4,021
  • 9
  • 41
  • 54
7
votes
1 answer

Undefined reference to `yylex' in yyparse() while compiling using g++, bison and flex

I have a problem while compiling my code (undefined reference to 'yylex'). Let's start off with the snippet and I'll describe the details below: Flex: %{ #include extern int yylex(); %} %% "=" {return EQ;} "!=" {return NE;} "<" {return…
pidabrow
  • 966
  • 1
  • 21
  • 47
7
votes
2 answers

When is %destructor invoked in BISON?

When is %destructor invoked in BISON? I have the following bison code: %union{ char * sval; Variable * vval; } %token VARIABLE %token Literal %type Expression VARIABLE %type Literal %destructor { delete $$; }
Jakub M.
  • 32,471
  • 48
  • 110
  • 179
7
votes
1 answer

Flex / Lex Encoding Strings with Escaped Characters

I'll refer to this question for some of the background: Regular expression for a string literal in flex/lex The problem I am having is handling the input with escaped characters in my lexer and I think it may be an issue to do with the encoding of…
Dan
  • 33,953
  • 24
  • 61
  • 87