At this point I don't have any code in my rules, so it may be the issue
with x -> a+
Though like you, I don't know why it's giving me a problem.
I'll attach my tokens and grammar, and the file I'm trying to parse is
a Rose MDL file.
Thanks again for any help.
-----Original Message-----
From: Tim Newsham [mailto:new...@lava.net]
Sent: Monday, June 20, 2005 5:07 PM
To: Fitzhugh, Cary
Subject: Re: Question about Pyggy
> Sorry to bug you - I have a problem with Pyggy, and maybe you know where
> I can look to fix the error.
>
> In the generated files _gramtab.py in one of the actions, it says that
> the symnode has no attribute append().
>
> I'm assuming this means that kids[0] was not initialized before it
> reached this point. Any idea where to start looking to fix this error?
Hi, I recently started a mailing list for discussing issues:
http://groups-beta.google.com/group/pyggy
If the error is in a rule that you did not specify the code to
then it must have been a rule for a "*" or "+" closure. For
example the production:
x -> a+ ;
will expand to two productions:
a.posclos -> a : return [kids[0]] ;
a.posclos -> a.posclos a :
kids[0].append(kids[1])
return kids[0]
;
to build a list for the positive closure. In this case the
a.posclos should always be represented by a list with an append
method. If its not an error will occur, but I'm not sure how
this could occur.
If the code with the error is in some code that you have
written yourself then it sounds like there was a non-list
returned when you expected a list.
I cant give further advice without more information. I'd
start by running in a debugger and breaking when you get
to the exception and printing out some items (or adding
prints to the generated file to see what is going on).
If you could provide a copy of your grammar I can look into
it in more detail.
> Cary FitzHugh
Tim Newsham
http://www.lava.net/~newsham/
-------------------------------------------------------------------------------
parse.py
-------------------------------------------------------------------------------
import sys
import pyggy
# build the lexer and parser
l,ltab = pyggy.getlexer("mdlTokens.pyl", debug=0)
p,ptab = pyggy.getparser("mdlGrammar.pyg", debug=5)
p.setlexer(l)
l.setinput(sys.argv[1])
tree = []
cont = True
try:
tree = p.parse()
except pyggy.ParseError, e:
print e.str
print e.tok
pyggy.proctree(tree, ptab)
-------------------------------------------------------------------------------
mdlGrammar.pyg
-------------------------------------------------------------------------------
# These are the rules
# File is composed of objects
objectTree -> object+
;
# an object is a (object TheType then Attributes)
object -> OBJECT objectType attribute+ RPAREN
;
quotedString -> QUOTE
(STRING | INTEGER | REAL | COLON | TILDE
| POUND | LBRACKET | RBRACKET | DOLLAR | RBRACE | LBRACE
| LTHAN | GTHAN | EQUAL | PERCENT | SEMICOLON | BACKSLASH | DOT
| FWDSLASH | DASH | AMPERSAND | COMMA | LPAREN | RPAREN |
LOCATIONPAIR)*
QUOTE :
print "Quoted String: "
print kids
;
objectType -> (STRING quotedString?)?
;
designType -> DESIGN quotedString
;
list ->
LIST
STRING?
(object | list | LOCATIONPAIR)*
RPAREN
;
attribute ->
( STRING (
STRING
| INTEGER
| REAL
| quotedString
| BOOLEAN
| list
| LOCATIONPAIR
| value
| KEYVALPAIR
| object ))
| ( quotedString (
STRING
| quotedString
| INTEGER
))
;
value -> VALUE (
quotedString
| list
| object
| BOOLEAN
| INTEGER
| (STRING quotedString)
| valueText
)
RPAREN
;
valueText -> STRING EXT_TEXT*
;
-------------------------------------------------------------------------------
mdlTokens.pyl
-------------------------------------------------------------------------------
INITIAL :
"TRUE|FALSE" : return "BOOLEAN"
"\([0-9]+, *[0-9]+\)" : return
"LOCATIONPAIR"
"\(\"[A-Za-z/_]+\" [0-9]+\)" : return
"KEYVALPAIR"
"-?[0-9]*\.[0-9]+" : return "REAL"
"-?[0-9]+" : return "INTEGER"
"["']" : return "QUOTE"
":" : return "COLON"
"\(object" : return "OBJECT"
"\(value" : return "VALUE"
"\(list" : return "LIST"
"," : return "COMMA"
"~" : return "TILDE"
"#" : return "POUND"
"\[" : return "LBRACKET"
"\]" : return "RBRACKET"
"\$" : return "DOLLAR"
"\{" : return "LBRACE"
"\}" : return "RBRACE"
"<" : return "LTHAN"
">" : return "GTHAN"
"\|" : return "VERT_BAR"
"=" : return "EQUAL"
"\+" : return "PLUS"
"%" : return "PERCENT"
";" : return "SEMICOLON"
"\\" : return "BACKSLASH"
"/" : return "FWDSLASH"
"&" : return "AMPERSAND"
"\*" : return "STAR"
"!" : return "EXCL"
"\." : return "DOT"
"\(" : return "LPAREN"
"\)" : return "RPAREN"
"-" : return "DASH"
"//.*\n" : return
"\|.*\n" : return "EXT_TEXT"
"<$?[A-Za-z&*]+>" : return "SUFFIX"
"<$?[A-Za-z&*]+, $?[A-Za-z&*]+>" : return
"DOUBLESUFFIX"
"([@*+][A-ZA-Z0-9_/+\-]+)|([a-zA-Z_][A-ZA-Z0-9_/+\-]*)" : return
"STRING"
"[ \t\n\r\f\v]" : return
or
function_definition -> declaration_specifiers declarator
compound_statement ;
etc
Alex
Alex
Alex