From: Nikolai Weibull Date: 2005-11-11T06:07:00+09:00 Subject: Re: RUBY GRAMMAR Phil Tomson wrote: > In article <20051109184727.GB9100@puritan.petwork>, > Nikolai Weibull wrote: > > puellula@gmail.com wrote: > > > I have to write this for a University Examination. The examination is > > > for Java Language. > > This is what I suspected. Shouldn=E2=80=99t you be solving this by > > yours= elf? Or perhaps ask your teacher, course assitants, or > > fellow students for help? See > > http://www.faqs.org/faqs/usenet/primer/part1/. If you must have > > answers to questions you should be figuring out for yourself but > > don=E2=80=99t want to and you could consider _paying_ someone to do > > your = work for you, then there=E2=80=99s always > > http://answers.google.com/answers/. > Well, this is a pretty tough exam question, so while in general I > would agree with you Nikolai, in this case I'd be willing to cut some > slack. Writing a grammar for a small subset of an existing language isn’t what I would call a “pretty tough exam question”. It’s what I would call the first step in a three-step laboration in creating a 1) grammar, lexer, and parser, 2) interpreter, 3) compiler/translator. I’ve assisted on an introductory course in programming languages that has this setup, and while the results haven’t always been great on the final written examination, 85-90% of the students have been able to hand in all three laborations and gotten a passing grade on them. Coming up with an idea for a language and a grammar isn’t easy, but that’s precisely why these things are on the syllabus. “We don’t do it because it’s easy, we do it because it’s hard.” Finally, people should certainly be able to ask questions and certainly on things relating to their homework. However, asking questions like “can you take my partial solution and rewrite/finish it so that it works” isn’t what I would call a valid question. An honest question like “I have this homework exercise that requires me to write a grammar for a small subset of Ruby and I was wondering if anyone has a suggestion on how to parse parameter lists. I have this partial solution that seems to be able to handle the simple cases but am having trouble with the more esoteric ones. Here’s what I’ve got and a beginning on the rest. Anyone have any suggestions? I’ve tried the following things, but it fails for this and this, and I don’t quite understand why.” I’d consider answering such a question, provided I had something to contribute. > And who knows, with an exam question like this maybe we can end up > with a new parser for Ruby. I hope the professor publishes the best > result ;-) I’m not going to hold my breath for this one. Ruby’s grammar is very complex and it’ll take a lot more skill than one acquires during a semester writing grammars/lexers/parsers to write a parser for it. I know I’d have a hard time writing one. nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}