I know it takes time to do but trimming down the source code to the minimum required to expose the problem might help you understand the problem (and its solution) and the rest of us to help you as quickly as possible. We could cut and paste the code into a file, run PLY on the file and hopefully duplicate the problem. Seeing the actual code and the error message would similarly help.
Anyway, I've annotated you pseudo code as to where the problem might be. Or you could decide to leave the conflict in your grammar and accept the default behaviour of PLY. BTW you might consider removing comments at the lexical stage. Saves your grammar having to account for comments almost everywhere. Regards, John On 23 Aug 2013, at 13:53, Stefan J <[email protected]> wrote: > Hi, > > I am currently redesign my old compiler written in python by the use of pyl. > The current code is attached. > > First I want to explain the goal: > > This compiler should create an AST which is used to translate a domain > specific language in to some kind of assembler. Actual there are two elements > given in the grammar: > 1.) a comment > 2.) global variable declaration > > The global variable declaration can contain a list of variables. It is also > allowed to write comments. A listing of the text can look like this: > """ > // comment 1 > > global { > // comment 2 > integer a; > integer a[2345]; > // comment 3 > } > """ > > I have some problems by defining the grammar rules. I give a short pseudo > listing: > > start : /** try removing this empty production, does it make the > conflict go away? Is it necessary or are you trying to allow for a source > file with neither comment or global at the beginning? **/ > | startElement > | start startElement > > startElement : comment > startElement : global { varList } > > varList : > | varListElement > | varList varListElement > > varListElement : comment > varListElement : type name ; > varListElement: type name [ number ] ; > > As you can see it is very simple. I did not understand the error (4 Shift / > Reduce Erros). Maybe you can help me. > > Thanks and have a nice weekend! > Stefan > > -- > You received this message because you are subscribed to the Google Groups > "ply-hack" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ply-hack/559b5ca0-7f7c-4bf5-9711-581add0d035d%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > <ALc2.py> -- You received this message because you are subscribed to the Google Groups "ply-hack" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ply-hack/E19FBB3F-B368-456D-B11C-0A5FDBD322E0%40jptechnical.co.uk. For more options, visit https://groups.google.com/groups/opt_out.
