Stefan J
2013-08-23 12:53:56 UTC
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 :
| 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
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 :
| 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 ply-hack+***@googlegroups.com.
To post to this group, send email to ply-***@googlegroups.com.
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.
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 ply-hack+***@googlegroups.com.
To post to this group, send email to ply-***@googlegroups.com.
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.