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

Creating comments in Lex and Yacc

How does one make a comment in Lex and Yacc? So far I haven't tried Yacc, but in Lex I have tried /* comment */ and // comment, but neither of these compile. I am on a Mac, using the builtin Lex and Yacc compilers, (or maybe the X-Code ones, I don't…
jellies
  • 639
  • 1
  • 5
  • 17
9
votes
2 answers

Emacs modes for flex and bison, or removing auto indent for these modes?

Emacs has poor handling of auto-indentation in Flex and Bison. In fact, it seems to have no support for flex mode. So, how does an emacs user cope with these? I like VIm but I would prefer not to switch because I am much faster and more comfortable…
Kizaru
  • 2,443
  • 3
  • 24
  • 39
9
votes
6 answers

Strange problem with context free grammar

I begin with an otherwise well formed (and well working) grammar for a language. Variables, binary operators, function calls, lists, loops, conditionals, etc. To this grammar I'd like to add what I'm calling the object construct: object :…
Chris Tonkinson
  • 13,823
  • 14
  • 58
  • 90
9
votes
2 answers

Bison one or more occurrences in grammar file

My program that needs to be parsed should be of the form: program : [declaration]+ ; Which should mean: The program consists of one or more declarations. Declaration on its turn is of course defined in a similar way, and so…
voluminat0
  • 866
  • 2
  • 11
  • 21
9
votes
1 answer

LLVM JIT Parser writing with Bison / Antlr / Packrat / Elkhound /

In the LLVM tutorials there is instruction how to write simple JIT compiler. Unfortunatelly, lexer and parser in this tutorial is written manually. I was thinking, such solution is good for learning purposes but it is not suitable for writing…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
9
votes
3 answers

Is there a flex - bison parser for javascript?

Is there a parser available in the open ? Else, i'm planning to write one using the grammar rules in http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Thanks.
trinity
  • 10,394
  • 15
  • 49
  • 67
8
votes
1 answer

YAML parsing - lex or hand-rolled?

I am trying to write a simple YAML parser, I read the spec from yaml.org, before I start, I was wondering if it is better to write a hand-rolled parser, or use lex (flex/bison). I looked at the libyaml (C library) - doesn't seem to use…
Ani
  • 1,448
  • 1
  • 16
  • 38
8
votes
4 answers

Is it possible to have two or more Lex/Yacc parsers in the same application

I have an application where I already have a parser for one sort of grammar and I need to add a second different grammar for another purpose. Is it possible to have more than one? And if so how do you get another entry point? Thanks david allan…
David Allan Finch
  • 1,414
  • 8
  • 20
8
votes
3 answers

Parsing SPARQL queries

I need to test for a certain structural property of a couple million SPARQL queries, and for that I need the structure of the WHERE statement. I'm currently trying to use fyzz to do this, but unfortunately its documentation is not very useful.…
ailnlv
  • 1,779
  • 1
  • 15
  • 29
8
votes
3 answers

how to setup flex/bison rules for parsing a comma-delimited argument list

I would like to be able to parse a non-empty, one-or-many element, comma-delimited (and optionally parenthesized) list using flex/bison parse rules. some e.g. of parseable lists : 1 1,2 (1,2) (3) 3,4,5 (3,4,5,6) etc. I am using the following…
sriaudacity
  • 157
  • 1
  • 6
8
votes
1 answer

How can I debug my flex/bison grammar?

This is a very silly problem. There are no errors in the grammar rules afaik but its not giving the right output. I have been staring at it but the mistake is not visible to me. What tools are available to me to help me see what is going on in a…
afsara_ben
  • 542
  • 1
  • 11
  • 30
8
votes
2 answers

How can I eliminate the 'main' routine of the flex & bison so I can put the lexing and parsing process into a library?

I'm working on a parser that parses json string and I want to make it a library. The problem is that when I use ld to link the library I wrote, there's a error message: main.o: In function `main': main.c:(.text+0x0): multiple definition of…
mapcan
  • 81
  • 1
  • 2
8
votes
5 answers

How can I parse a C string (char *) with flex/bison?

In my programming project I want to parse command line attributes using flex/bison. My program is called like this: ./prog -a "(1, 2, 3)(4, 5)(6, 7, 8)" filename Is it possible to parse this string using flex/bison without writing it to a file and…
Philipp Riegger
  • 127
  • 1
  • 1
  • 6
8
votes
2 answers

Problems with reentrant Flex and Bison

I'm learning how to use reentrant Bison and Flex together. I already got a simple calculator working without the reentrant capability. However when I activated the reentrant feature and made the necessary modifications, I couldn't get this to work.…
Fabricio
  • 343
  • 1
  • 5
  • 11
8
votes
1 answer

freeing the string allocated in strdup() from flex/bison

I have flex code that copies a string lexeme using strdup(). %{ #include "json.tab.h" #define YY_DECL extern "C" int yylex() %} %option noyywrap %% [ \t\n]+ ; \"[a-zA-Z]+\" {yylval.sval = strdup(yytext); return STRING; } [0-9]+ {yylval.ival…
prosseek
  • 182,215
  • 215
  • 566
  • 871