Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what type of parser is bison?

what type of parser is bison. is it a LALR(1) or LR(1) ?

like image 975
user574183 Avatar asked Feb 03 '11 14:02

user574183


People also ask

What kind of parser is Bison?

Bison is a general-purpose parser generator that converts a grammar description (Bison Grammar Files) for an LALR(1) context-free grammar into a C program to parse that grammar. The Bison parser is a bottom-up parser.

Is Bison a LR parser?

Bison is a general-purpose parser generator that converts an annotated context-free grammar into an LALR(1) or GLR parser for that grammar. The generated parser is implemented as a C or C++ program with a parsing function that can be called from application programs.

What kind of parser does rust use?

It is a simple hand-written recursive-descent parser with variable (but small) lookahead.

How does Bison parser work?

Bison reads a specification in the BNF notation (a context-free language), warns about any parsing ambiguities, and generates a parser that reads sequences of tokens and decides whether the sequence conforms to the syntax specified by the grammar.


2 Answers

Short answer: both.

By default, it produces LALR(1) parsers.

With the explicit option %glr-parser, it'll produce an LR(1) parser.

like image 188
Linus Kleen Avatar answered Oct 02 '22 23:10

Linus Kleen


Yep, since version 2.5, Bison does support several types of LR parsers: LALR(1), canonical LR(1), and IELR(1). See the documentation about "lr.type", for instance here.

like image 36
akim Avatar answered Oct 02 '22 23:10

akim