0

I have been trying to figure out how to fix some shift reduce conflicts I have. I have looked around and found different topics on fixing it but it seems like no matter what I do I just can't seem to find a way to fix these issues.

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 addde a comment of the BNF grammar Im 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.

EDIT: Here is the main issue. That is the main script state, I know its broken up into a lot of different rules but I did that so I could try and fix the issue which I still havent had luck with.

EDIT: 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 a week I've been on this. My email is Anth0ny229@live.com.

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
  • What do you mean with *fix*? By default shift-reduce conflicts are automatically resolved in favor of the *shift*; which is nearly always the supposed behavior. – Willem Van Onsem Jun 08 '15 at 00:03
  • Well the issue is that when it actually comes to parsing it seems to be failing. But It looks like it may be because there are a lot of reduce-reduce problems as well. I have been at this for about a week now and I cant seem to wrap my head around it. Ive been programming for about 10 years now and this is the first time Ive actually ever had to ask for help. If someone can get it working Ill be donate a hundred or so through paypal. I guess it's just my understanding is not so complete but I can'tseem to figure it out for the life of me. – Anth0ny229 Jun 08 '15 at 00:24

0 Answers0