From: "Luke A. Kanies" Date: 2003-12-12T05:54:12+09:00 Subject: Re: problems with racc: $end token On Fri, 12 Dec 2003, Jim Freeze wrote: > On Friday, 12 December 2003 at 3:55:31 +0900, Luke A. Kanies wrote: > > Hi Luke > > I took your code and repeated the $end problem. > I removed the problem by putting an optional return > after your define { } block. Um, wow, thank you! I ended up finally figuring out how to turn on debugging in racc (yep, a hack: I had to use -E and then edit the parser.rb file manually, setting @yydebug = true), and this enabled me to figure out, that, well, my grammer didn't do anything like I expected. So, I ended up basically rewriting the grammar itself. In doing so, I was finally able to avoid the $end error. In other words, it was definitely a grammar problem, and I probably would have caught it much sooner if I had figured out earlier how to turn debugging on. The silly thing is, I know there's an API for turning it on, but I haven't been able to extract it yet. The problem here is that I have used perl's Parse::Yapp, which behaves quite differently in many ways, and most especially in how it deals with syntax errors. It is totally my fault, because I was unconsciously expecting racc to behave a certain way, and when it didn't I got very confused. With the advent of debugging, I figured it out relatively quickly. As a side note, the grammar rules must set the value of 'return'. For some reason, racc does not use explicit mechanisms for returning data; instead you have to set the value of 'return' and it returns that for you. This also caused a bunch of problems for me. To summarize: There is debugging in racc, and using racc -E to embed the parser and then manually setting @yydebug = true can turn it on. I'm sure there's a better way. Also, you must set 'return' manually, although it can be any type of variable. Thanks for all your help, Jim. Luke -- Today I dialed a wrong number...The other person said, "Hello?" and I said, "Hello, could I speak to Joey?"... They said, "Uh...I don't think so...he's only 2 months old." I said, "I'll wait." -- Steven Wright