0
votes

I have been trying to figure out this same issue for almost 2 weeks now. At first it was shift-reduce errors now its reduce-reduce problems. I have tried doing it so many ways and now I have came to the point where I just need help. I've coded many languages and started almost 10 years ago and this is the first time i've ever actually posted for help.

I am trying to write a grammar class for Angel Script a popular scripting engine I got the BNF grammar from the parser class. You can find the language reference here http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html

And within my class for each rule I addded a comment of the BNF grammar I'm trying to copy. At the moment I don't actually use the keywords I define. I will go back and try and clean it up once I can get it working without conflicts. Here is my class http://pastebin.com/FydCTqmU

You should be able to just create a Dll and run that with the grammar explorer and you'll see all the errors. It seems like most of the errors all come from the same issue so I think maybe once I can get that fixed it will fix almost everything. I wrote an app to help me split up the grammar into more less specific sections but I think that led to me hitting more reduce-reduce problems.

I tried condensing my code to hopefully get passed the reduce-reduce errors but it seems to stay exactly the same but only looking way more cluttered. If anyone can help me get it right i'll be more then happy to send them a few hundred dollars via paypal. I'm at the point of just giving up its been over 2 weeks I've been on this. My email is [email protected].

I've gone from shift-reduce to reduce-reduce errors. It seems no matter what I do I end up with problems. I just cant wrap my head around it and I really need help. As I mentioned I'll be more then happy to pay someone for the help just email me. I plan on making a Visual Studio extension like babelua so people can write Angel Script Scripts using Visual Studio and also hopefully adding debugging support. It will be free because I think this will be a great addition. So if anyone can help in any way as long as its working in the end ill be more then happy to make sure they are rewarded. Thank you.

State S0 (Inadequate) Reduce-reduce conflicts on inputs: const identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto :: Shift items:

script' -> ·script EOF 
script -> ·script_0_list 
script_0_list -> ·script_0+ 
script_0+ -> ·script_0+ script_0 
script_0+ -> ·script_0 
script_0 -> ·import 
import -> ·import type import_0_opt identifier paramlist from string ; 
script_0 -> ·enum 
enum -> ·enum_0_opt enum identifier { identifier enum_1_opt enum_2_list } 
enum_0_opt -> ·shared 
script_0 -> ·typedef 
typedef -> ·typedef primtype identifier ; 
script_0 -> ·class 
class -> ·class_0_list class identifier class_1_opt { class_2_list } 
class_0_list -> ·class_0+ 
class_0+ -> ·class_0+ class_0 
class_0+ -> ·class_0 
class_0 -> ·shared 
class_0 -> ·abstract 
class_0 -> ·final 
script_0 -> ·mixin 
mixin -> ·mixin class 
script_0 -> ·interface 
interface -> ·interface_0_opt interface identifier interface_1_opt { interface_2_list } 
interface_0_opt -> ·shared 
script_0 -> ·funcdef 
funcdef -> ·funcdef type funcdef_0_opt identifier paramlist ; 
script_0 -> ·virtprop 
virtprop -> ·virtprop_0_opt type virtprop_1_opt identifier { virtprop_2_list } 
virtprop_0_opt -> ·private 
virtprop_0_opt -> ·protected 
script_0 -> ·func 
func -> ·func_0_opt func_1_opt identifier paramlist func_2_opt func_3_list statblock 
func_0_opt -> ·private 
func_0_opt -> ·protected 
func_0_opt -> ·shared 
script_0 -> ·var 
var -> ·var_0_opt type identifier var_1_opt var_2_list ; 
var_0_opt -> ·private 
var_0_opt -> ·protected 
script_0 -> ·namespace 
namespace -> ·namespace identifier { script } 
script_0 -> ·;

Reduce items:

script_0_list -> · [EOF]
enum_0_opt -> · [enum]
class_0_list -> · [class]
interface_0_opt -> · [interface]
virtprop_0_opt -> · [const identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]
func_0_opt -> · [const ~ identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]
var_0_opt -> · [const identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]

Transitions:

script->S1, script_0_list->S2, script_0+->S3, script_0->S4, import->S5, import->S6, enum->S7, enum_0_opt->S8, shared->S9, typedef->S10, typedef->S11, class->S12, class_0_list->S13, class_0+->S14, class_0->S15, abstract->S16, final->S17, mixin->S18, mixin->S19, interface->S20, interface_0_opt->S21, funcdef->S22, funcdef->S23, virtprop->S24, virtprop_0_opt->S25, private->S26, protected->S27, func->S28, func_0_opt->S29, var->S30, var_0_opt->S31, namespace->S32, namespace->S33, ;->S34
1

1 Answers

0
votes

A conflict means that your grammar is ambiguous, there are 2 or more ways to parse the same thing.

A reduce reduce conflict means that different nonterminals can apply to the same input. In you case I think it is because a number like "5" can be both int8, int16 etc.

Tip: GNU Bison uses a similar parsing algorithm to Irony, it's help pages are quite helpful when dealing with these kinds of errors.