0

I wrote a little LR(1) parser generator in Java that given a context-free grammar in input (better put it's productions) and a input word prints whether 1) The Grammar is not LR(1) 2) The word is accepted by the grammar 3) The word is rejected by the grammar

So far I've tried with this grammar

S -> CC
C -> cC | d

and this

A -> BA | e
B -> aB | b

(note that e is the empty string)

For this grammars the parser works but I'm having difficulties finding Grammars (list of productions) that I know for sure generate a LR(1) language, for testing.
Plus I need a context-free grammar that is not LR(1) for testing point (1) of the program.

Do you have any examples you could give me?

Crysis85
  • 345
  • 3
  • 17
  • 1
    There are a number of examples in the bison manual. And another one in this tutorial: http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/4/ For non-LR-1 grammars, I'd search "shift/reduce conflict", since most of those have to do with grammars which are not LR(1). – rici Jun 30 '15 at 17:21
  • possible duplicate of [Examples of LL(1), LR(1), LR(0), LALR(1) grammars?](http://stackoverflow.com/questions/6480634/examples-of-ll1-lr1-lr0-lalr1-grammars) – templatetypedef Jul 03 '15 at 19:23

0 Answers0