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 is the order that bison matching the pattern?

Description I want to implement a syntax detector for json file with bison. I used Array: LB RB | LB Values RB | LB Values COMMA RB error { puts("extra comma, recovered"); }; to recognize syntax error like ["extra comma",], but…
0
votes
0 answers

how print a rule inside of a main rule?

I am making a translator with bison / flex, but I have a problem because when implementing the rules I cannot print in only one and I have not been able to send the text to print it in the main rule, this is the code of the rules is the…
0
votes
2 answers

Why my program in flex and bison isn't working? Calculator of sin and cos functions

I have this program but it doesn't work, who can help me? When I entry 2+3 and Enter, the .exe file suddenly closes. I have no idea of what's wrong but I need to solve this soon, hope you can help me. Here's lexico.l: /* Ejemplo para una pequeña…
megasaw
  • 13
  • 4
0
votes
0 answers

How to force bison to go to a certain line and parse from that line?

I am still working on my simple language parser and I was wondering whether you could 'force' bison to parse from a certain line. By that I mean if there was some code such as: int avar = 7 int bvar = 10 log avar log bvar I want bison to go and…
0
votes
1 answer

How to get yy::parser::token from yy::parser::symbol_type in Bison c++ variant?

For example, I return yy::parser::symbol_type in flex rule via: [a-zA-Z][a-zA-Z0-9_]* return yy::parser::make_ID(yytext); where ID is a token I defined in bison, it will generate the yy::parser::token structure. Now I want to do some unit test…
linrongbin
  • 2,967
  • 6
  • 31
  • 59
0
votes
1 answer

How to solve bison shift/reduce when implementing try-catch-finally grammar?

I'm trying to implement try-catch-finally expression in my toy language with Bison. One more thing is that, inspired by Scala grammar, item inside try-catch-finally is an expression, not a block statement. Here's the grammar.y: %code top { #include…
linrongbin
  • 2,967
  • 6
  • 31
  • 59
0
votes
0 answers

bison/yacc grammar '|' is not working well

I've tried to parse below text using bison. signed int c1; unsigned int c2; This is bison definition. I removed All of actions because it's pretty complicate to explain and not that necessary. %type simple_type // enum %type opt…
0
votes
1 answer

Bison %token-table alternatives in c++ parser?

I'm learning Bison in generating c++ parser. Since %token-table is obsolescent, is there any alternatives to get the name from token integer value in c++ parser?
linrongbin
  • 2,967
  • 6
  • 31
  • 59
0
votes
1 answer

How to solve Bison optional else expression shift/reduce error?

I'm trying to implement a toy language with grammar inspired by Scala. I used part of the Scala Syntax Specification: Expr1 : ‘if’ ‘(’ Expr ‘)’ {nl} Expr [[semi] ‘else’ Expr] | ... In this toy language, everything is an expression (if-else,…
linrongbin
  • 2,967
  • 6
  • 31
  • 59
0
votes
1 answer

bison error: rule given for Semi, which is a token?

my bison grammar met an error: parser.yy: %union { Ast *ast; char *str; int tok; } %token NEWLINE SEMICOLON %type Semi %% Semi: NEWLINE { $$ = new Ast($1); } | SEMICOLON { $$ = new Ast($1); } ; Statements: Statement …
linrongbin
  • 2,967
  • 6
  • 31
  • 59
0
votes
1 answer

request for member 'sval' in something not a structure or union

I am getting an error in my parser for a toy language I am making. Here is some of my parser code: %union { char* ; } %token INTEGER %token INTDEC FLODEC AS %token VARIABLE %token POINT LBRACKET RBRACKET %token SHOW ESC %left '+'…
0
votes
0 answers

How to read an arbitrary long sequence in lex/yacc with a fixed buffer limit?

I would like to parse / store the following sequence: Ann {* some arbitrary long sequence *} My buffer length (YYLMAX) is set to 8K. Given that the sequence can be arbitrary long, I try to do it this way: Search for the Ann token followed by {*.…
user4979733
  • 3,181
  • 4
  • 26
  • 41
0
votes
1 answer

Win flex-bison always returns 1 when inside Visual Studio 2015 but works when run manually

I installed Win flex-bison which integrates with VS. This allows the projects to contain .l and .y files. The problem is when I try to compile with VS I get 1>------ Build started: Project: pasms64, Configuration: Release Win32 ------ 1> Process…
Paul Baxter
  • 1,054
  • 12
  • 22
0
votes
1 answer

Precedence issue with Bison

OK, so I'm experimenting a bit with a parser for an... experimental language. The main idea is, this: this is a command this is [another] command should output this: push: command push: a push: is push: this push: command …
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
0
votes
3 answers

how to interpret "shift/reduce" conflicts in bison

I'm writing a small bison / flex calculator but I'm not able to understand and debug the verbose output This is the code which is causing the errors: %token NUM %token NAME %% input: '\n' | line '\n' ; line: expr …
Adi Mehrotra
  • 150
  • 1
  • 7
1 2 3
99
100