From: Robert Feldt Date: 2004-03-05T05:51:08+09:00 Subject: Re: perl6 grammar rules in ruby Charles Comstock wrote: >> Is the importance the integration with the language or the fact that >> you can create parsers dynamically? I'm aiming for the latter with >> Ruby but the grammars can either be written in a string (in the >> Rockit grammar format) or constructed directly with the Grammar >> classes. I haven't checked out the Perl6 stuff but my impression is >> that the the original poster thinks the integration into the host >> language is the most important thing. Can someone clarify? >> >> /Robert >> >> >> >> > The advantage of the embedded system is you can call out to a grammar > inline from a builtin regex, something you can't really do in ruby at > the moment. Basically with the perl6 grammars you would be able to say > text =~ /__START____END__/ where ruby would be the grammar for > ruby with associated callbacks for each grammar node to say create an > AST. The fact it can be embedded in a regex gives the nice touch that > a) you can switch quickly back and forth between the grammar and lexer > level > b) it just makes it alot easier to use a grammar from within the > language. > Sounds useful and might mean people start using grammars more. I see your point. > It might help the discussion if a few more people take a look at how > the grammars are designed to work in perl6. If the functionality they > are trying is possible without extending the language then go for it, > but I am inclined to believe it is not possible without a seperate > regex engine at the moment. In addition the ability to inherit > grammars would probably be easier if it was embedded in the language, > but it is certainly possible to work around that constraint. > I guess the sensible first step is to use it with a new extension NRegexp for example. If it is very useful then making NRegexp the Regexp of Ruby proper can be discussed. I think it's the wrong order to start discussing incorporation in the language first. Grammar inheritance is useful (not sure in what sense it's used here though but I'll make my homework) but have nothing to do with the integration/embedding really, right? > The pertinent perl6 grammar references: > http://dev.perl.org/perl6/exegesis/E05.html > http://dev.perl.org/perl6/apocalypse/A05.html > I'll take a look some day but I find Perl so hard to read that I might not understand it... ;) /Robert