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

Why Bison can reduce an "error" item to an empty rule

I have the following yacc grammar: 33 CompSt: "{" DefList StmtList "}" 34 | "{" error ";" DefList StmtList "}" ...... 52 DefList: Def DefList 53 | %empty 54 Def: Specifier DecList ";" 55 | Specifier error ";" 56 | Specifier…
0
votes
1 answer

Multiplication by juxtaposition in yacc

I'm trying to implement a grammar that allows multiplication by juxtaposition. This is for parsing polynomial inputs for a CAS. It works quite well, except few edge cases, as far as I'm aware of. There are two problems I have identified: Conflict…
Jay Lee
  • 1,684
  • 1
  • 15
  • 27
0
votes
0 answers

Why yyerror() being call twice?

I am new working with a compiler in C, but a I having error and I don't know where it comes from. I think there's no problem in my Lex part of the compiler. All gramatical rules are properly printed but I still get a syntax error printed twice: Why…
0
votes
0 answers

Is there a flexc++ / bisonc++ that generates c++ code under Windows? Where do i download them from

I want to use c++ to write a flex/bison parser, but the flex/bison I installed can only use and generate c code. I looked for a day yesterday and there are projects like flexc++ / bisonc++ in gitlab. But this corresponds to the linux system, I need…
qianqian
  • 25
  • 4
0
votes
1 answer

memory management in C parser generated by BNFC

I use BNFC to generate parser bnfc -m -c ./mylang.cf. Internally, BNFC makefile calls bison to generate C parser. Parser.c : mylang.y ${BISON} ${BISON_OPTS} mylang.y -o Parser.c I can successfully parse source code by calling the generated…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
0
votes
1 answer

Flex/Bison program gives Syntax Error message

I recently started learning using flex and bison together for a project I am doing. Program is about interval arithmetics. It takes 2 values with either open or closed brackets, then prints out the interval of array that is defined in the bison…
0
votes
1 answer

How to handle a newLine properly

I'm trying to make a language that ignores NewLines in my code anywhere so i declared in my lexer just [\n] without returning anything so it can be ignored this is working well and it is ignoring every newLine in the code but i wanted to implement…
Tony Tony
  • 33
  • 1
  • 3
0
votes
1 answer

Unable to find cause of 'syntax error' in Bison code

I'm trying to connect simple flex and bison code that would just recognize a character for now. Yet I'm facing this error. I've read through a lot of answers to figure out what is wrong but am lost. Any help would be highly appreciated as I'm just…
0
votes
1 answer

Solve shift-reduce conlict for optional newlines in C-style block statement

I want to create a grammar rule for a simplified version of a block statement in C, which matches a list of statements in braces with optional newlines at the beginning and end. Statements in this language are terminated by a newline character. The…
ashishshenoy
  • 95
  • 1
  • 5
0
votes
1 answer

Parsing a function call (e.g. `exp '(' exp ')'`) in Bison: results in shift/reduce errors (precedence issue)

I'm trying to parse a function call (currently just one argument, but I'll allow for several when I get it working). Suppose exp is defined as %left '+' %precedence CALL exp: exp '+' exp { ... } | exp '(' exp ')' %prec CALL { ... } | …
Doot
  • 555
  • 5
  • 15
0
votes
2 answers

What decides which production the parser tries?

I am trying to build a parser for a desk calculator and am using the following bison code for it. %union{ float f; char c; // int } %token NUM %token ID %type S E T F G %% C : S ';' | C S ';' ; S : ID…
0
votes
1 answer

Bison/Yacc: yyparse not declared in this scope

This question is similar to this one but for yyparse, not yylex. I've been battling with this for hours now! I'm wanting to call yyparse from a C program (actually a C++ one but I ended up using the old flex/bison rather than the newer ones for C++…
ale
  • 11,636
  • 27
  • 92
  • 149
0
votes
1 answer

How do I parse two kinds of numbers with Bison and C++?

I'm writing a calculator of flowsnake numbers and just stubbed a parser. The program is in C++, and I had to figure out a few details of Bison use with C++ by looking at the generated code. (The calc++ example uses Flex, but I'm not using Flex.) I'm…
Pierre Abbat
  • 485
  • 4
  • 10
0
votes
1 answer

converting a string to a simple one character value in C language

I'm writing a compiler with Flex and Bison using C langage and need to convert a character string to a one simple character . which functions should i use ? i can't find it . forexample : -string to integer we use : int i = atoi(yytext); -string to…
0
votes
1 answer

Flex Bison and Gnu Automake

I wrote a small text-filter based on flex-lexer and bison. A boolean expression is applied to the specified string(logvar). Boolean expression consists of strings and boolean operations. example: *intput*: logvar=aa bb cc dd ee aa &…
Max
  • 817
  • 1
  • 10
  • 29