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

What kind of data structure should I provide to handle scopes in my compiler?

I am developing a "toy" compiler with flex and bisonc++ in ubuntu, which compile a C-like input language into optimized C++. In the input language contains a main functions (must have) and can have optionals functions outside the main, for…
Business Man
  • 81
  • 1
  • 6
0
votes
1 answer

Bison if statements - setting symbol table prior to parsing block statements

In my language I have the ability to declare a variable in the current symbol table scope and also create a if statement which will generate a new symbol table scope for its statements. stmts : stmt { $$ = new Block(); $$->addStatement($1); } …
Tom
  • 1,235
  • 9
  • 22
0
votes
1 answer

Why am i getting segmentation fault when passing a pointer as a function parameter?

I build an AST with bison with a pointer to a Node structure: typedef struct Node { enum node_type type; Stmt *left; struct Node *right; } Node; Then I print it in bison in this…
0
votes
1 answer

Bison/Flex C is having problems parsing second token

I'm doing an assignment, where I have to make Bison/Flex app that would append while/if case beginning at the end every case as a comment. I've managed to compile all the components together, but no matter what I do, it always throws an error after…
Ozzzim
  • 3
  • 2
0
votes
0 answers

flex/bison based compiler: parsing asm[assembly commands] inside C program

I'm new to flex and bison. I want to write a compiler that read C program and translate it to my processor commands that are similar to assembly. I downloaded a pre-written compiler that uses flex and bison. I should change the scanner.l and…
zahrak
  • 1
  • 2
0
votes
1 answer

Where is the shift/reduce conflict in this yacc grammar?

I'm writing a parser for a language called C-. I have to write the grammar so its not ambiguous and I can't use any %prec statements in Bison. I've corrected all but 1 shift/reduce conflict and I can't figure out where it is. Any ideas? My .output…
0
votes
1 answer

Bison shift/reduce conflict ambigous

when i try to use$ bison --output=calcy.c -d calc.y i get this msg: calc.y: conflicts: 2 shift/reduce and this is my code program:DEBUT corps FIN ; corps:liste_declaration liste_instruction ; liste_declaration: |…
Ahmed Laggoun
  • 85
  • 1
  • 11
0
votes
1 answer

How to resolve reduce reduce conflicts in bison?

Firstly, I have already referred to many similar questions here, but unable to resolve the conflicts. I have this piece in my .y file . . . obj : INT { $$ = objNew($1, INT_T); } | FLOAT { $$ = objNew($1, FLOAT_T); } | STR { $$ =…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
0
votes
1 answer

Bison - why this is producing syntax error for all inputs

I have written a simple grammer: expr: INT { $$ = intc($1); } | FLOAT { $$ = floatc($1); } | STR { $$ = strc($1); } | ID { $$ = id($1, false); } | ID '=' expr { $$ = operate('=', id($1, false), $3); } | VAR ID { $$ = id($2,…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
0
votes
0 answers

cannot convert 'char*' to 'float' in assignment flex/bison

i am making a programming language using bison/flex but i get errors i just found a simple programming language tutorial in dev.to then made some changes now im making a variable system or anything else. but i get a error how the variable should…
0
votes
0 answers

cant use string Val in union flex/bison

im trying to make a programming language like basic or else i used a tutorial to make a simple programming language but it only can do calculation like x + y , y - x , and more, but i added a token for a variables such as x = 5; but when i tried to…
0
votes
0 answers

YACC expression grammar wont execute

I am trying to generate intermediate code using the following grammar, but the output i am getting is as if my parser isn't evaluating the input based on this grammar. below is my lex.l file: %{ #include "y.tab.h" extern char…
0
votes
1 answer

match multiple patterns in bison

In lex/flex, one can match multiple patterns to a token using normal regex rules, but what is the equivalent on the yacc/bison side? In my code I have two possible grammars for a single task: IF expression THEN number IF expression GOTO number It…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
0
votes
1 answer

Troubles using Bison's recursive rules, and storing values using it (again)

For reference: this is basically a followup question of Troubles using Bison's recursive rules, and storing values using it. I am trying to make a flex+bison scanner and parser for Newick file format trees in order to do operations on them. The…
Lightsong
  • 312
  • 2
  • 8
0
votes
2 answers

Token with several types in Bison

I want to write a parser with Bison, and I am trying to parse a file in which a value for a parameter is an integer or string. In other words, I want to have a token with two types. For example, suppose I have the following…
fva
  • 33
  • 4